function Open(url,w,h){
	var nw=window.open(url,"","width="+w+",height="+h+",top=0,left=0,resizable=1,scrollbars=1,status=1");
	nw.focus();
}

function popSch(h){
		var fnm="TbRst3.aspx";
		location = "../Search/"+fnm+"#"+h;
}

function setCookie(c_name, value, expiredays) {
	var exdate = new Date();
	exdate.setDate(exdate.getDate() + expiredays);
	document.cookie = c_name + "=" + escape(value) +
    ((expiredays == null) ? ";path=/"+tlr_domain : ";expires=" + exdate.toGMTString()+";path=/"+tlr_domain);
}

function getCookie(c_name) {
	if (document.cookie.length > 0) {
		c_start = document.cookie.indexOf(c_name + "=");
		if (c_start != -1) {
			c_start = c_start + c_name.length + 1;
			c_end = document.cookie.indexOf(";", c_start);
			if (c_end == -1) c_end = document.cookie.length;
			return unescape(document.cookie.substring(c_start, c_end));
		}
	}
	return null;
}

function replaceAll(txt, replace, with_this) {
  return txt.replace(new RegExp(replace, 'g'),with_this);
}

function comma(num){
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num) || num=="") num = "0";
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
	num = num.substring(0,num.length-(4*i+3))+','+num.substring(num.length-(4*i+3));
	return (num);
}

function randomString() {
    var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
    var string_length = 8;
    var randomstring = '';
    for (var i=0; i<string_length; i++) {
	    var rnum = Math.floor(Math.random() * chars.length);
	    randomstring += chars.substring(rnum,rnum+1);
    }
    return randomstring;
}

function getOft(elm) {
	var t = elm.offsetTop;
	var p = elm.offsetParent;
	while(p){
		t += p.offsetTop;
		p = p.offsetParent;
	}
	return t;
}
function getOfl(elm) {
	var l = elm.offsetLeft;
	var p = elm.offsetParent;
	while(p) {
		l += p.offsetLeft;
		p = p.offsetParent;
	}
	return l;
}

function replaceT(obj,p){
    var newO=document.createElement('input');
    if(p){
        newO.setAttribute('type','password');
    }else{
        newO.setAttribute('type','text');
    }
    newO.setAttribute('id',obj.getAttribute('id')+"1");
    newO.setAttribute('name',obj.getAttribute('name')+"1");
    newO.style.color="#000000";
    obj.parentNode.replaceChild(newO,obj);
    setTimeout(function(){newO.focus()}, 10);
}

//Search Telno
function clrSchKw(){
    document.getElementById("schKw").value="";
}
function doSchKw(){
    var v=document.getElementById("schKw").value;
    if(v.length>3){
       var reg=v;
	    //var rx = new RegExp('^(0)\\d{9}');
	    var rx = new RegExp('^([0-9\/.-]{10,15})');
	    var mtc = rx.exec(reg);
	    if(mtc == null || reg != mtc[0]){
		  //location = "../Search/tbRstTg.aspx#msg:"+v;
		  return false;
	    }
	    location = "../Search/CarDet3.aspx?telno="+v;
    }
    return false;
}
function focusSchKw(wd){
    if(document.getElementById("schKw").value==wd){
        clrSchKw();
    }
}

function mail2F(cib){
    $.fancybox('../Serv/Mail2F.aspx?cib='+cib,{
	    'width'				: 500,
	    'height'			: 400,
	    'autoScale'			: false,
	    'transitionIn'		: 'none',
	    'transitionOut'		: 'none',
	    'type'				: 'iframe'
    });
}

function getFlashVersion(){
  try {
    try {
      var axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6');
      try { axo.AllowScriptAccess = 'always'; }
      catch(e) { return '6,0,0'; }
    } catch(e) {}
    return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g, ',').match(/^,?(.+),?$/)[1];
  } catch(e) {
    try {
      if(navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){
        return (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description.replace(/\D+/g, ",").match(/^,?(.+),?$/)[1];
      }
    } catch(e) {}
  }
  return '0,0,0';
}
