var URL_ROOT;
try{ URL_ROOT = String(document.getElementsByTagName('base').item(0).href).replace(/[^\/]*$/,'');}
catch(EE){ URL_ROOT='/';}
function createXmlObject(){
    var xmlobj = null;
    try{
        if (window.ActiveXObject){
            xmlobj = new ActiveXObject("Microsoft.XMLHTTP");
        }else{
            xmlobj = new XMLHttpRequest(); 
        }
		return xmlobj;
    }
    catch(e){
        alert("Your browser did not support Ajax");
        return false;
    }    
}
function getChecked(name){
/*	getChecked(name): return a comma seperated value (value1,value2,value3...)for all checkbox with same name
name	: name of the checkbox
need to create array of check box with same name like:
<input type=checkbox name='name' value=value1>
<input type=checkbox name='name' value=value2>
<input type=checkbox name='name' value=value3>
*/
	var o=document.getElementsByName(name);
	var i,s,v;
	for(i=0,s='';i < o.length; ++i){
		v=o.item(i);
		if(v.type == "checkbox"){
			if(v.checked) s += ',' + String(v.value);
		}
	}
	return s.substr(1);//remove leading ,
}
//////////////////////
function getIdValuesPair(name){
/*	getIdValuesPair(name): return a comma seperated (id1=value1,id2=value2...) for all input with same name
name	: name of input
need to create array of input with same name like:
<input type=text name='name' id='id1' value=value1>
<input type=text name='name' id='id2' value=value2>
<input type=text name='name' id='id3' value=value3>
*/
	var o=document.getElementsByName(name);
	var s='';
	for(i=0;i<o.length;++i){
		v=String(o.item(i).value);
		if(v != '') s += ',' + o.item(i).id + '=' + v;
	}
	return s.substr(1);
}
//////////////////////
function checkAll(name){
/*	checkAll(name):	mark as checked all checkbox with same name
name	: name of the checkbox
*/
	var o=document.getElementsByName(name);
	var i;
	for(i=0;i < o.length; o.item(i).checked=true, ++i);
}
////////////////////////
function setAll(name,state){
/*	setAll(name,state):	mark all checkbox with same name to the specified state
name	: name of the checkbox
state	: true/false status
*/
	var o=document.getElementsByName(name);
	var i;
	for(i=0;i < o.length; o.item(i).checked=state, ++i);
}

////////////////////////
function clearAll(name){
/*	clearAll(name):	uncheck all checkbox with same name
name	: name of the checkbox
*/
	var o=document.getElementsByName(name);
	var i;
	for(i=0;i < o.length; o.item(i).checked=false, ++i);
}
/////////////
////////////////////////
function resetAllName(name){
/*	resetAllName(name):	set name to empty string to exclude from submitting
name	: name of the checkbox
*/
	var o=document.getElementsByName(name);
	var i;
	for(i=0;i < o.length; o.item(i).name='', ++i);
}
/////////////
function urlgo(page,q){
/*	urlgo(page,q,[<name1,value1>[,..n]][,'-',<namex>[,...n]])
	tell browser to goto specified location
page:	page name to goto
q	:	query string
<name1,value1>:	append parameter name=value to query string q
namex	: chop this parameter from query string q
*/
	var c=arguments.length;
	var re=new RegExp;
	for(i = 2; (argv=String(arguments[i])) != '-' && i < c; ++i){
		re.compile("(?:\\&|^)" + argv + "=[^\\&]*(?=\\&|$)","ig");
		q=q.replace(re,"&");//append to url
		q += "&" + argv + "=" + String(arguments[++i]);
	}
	for(++i; i < c; ++i){ //ignore -, denote a start of chopping parameters)
		argv=String(arguments[i]);
		re.compile("(?:\\&|^)" + argv + "=[^\\&]*(?=\\&|$)","ig");
		q=q.replace(re,"&"); //chop from url
	}
	q=q.replace(/\&{2,}/ig,"&").replace(/(?:^\&|\&$)/ig,"");
	window.location.href=page + "?" + q;
}
///////////////
function urlchop(q){
/*	urlchop(q,[name][,...n])
	chop name from query string q
q	: original query string
name: chop this parameter from q
*/
	var c=arguments.length;
	var re=new RegExp;
	for(i=1; i < c; ++i){ //ignore -, denote a start of chopping parameters)
		argv=String(arguments[i]);
		re.compile("(?:\\&|^)" + argv + "=[^\\&]*(?=\\&|$)","ig");
		q=q.replace(re,"&"); //chop from url
	}
	return q.replace(/\&{2,}/ig,"&").replace(/(?:^\&|\&$)/ig,"");
}
////////////////
function urlformat(q){
/*	urlgo(q,[<name1,value1>[,..n]][,'-',<namex>[,...n]])
	append or chop specified parameters from query string
q				: original query string
<name1,value1>	: append parameter name1=value1 to query string q
namex			: chop this parameter from q
*/
	var c=arguments.length;
	var re=new RegExp;
	for(i = 1; (argv=String(arguments[i])) != '-' && i < c; ++i){
		re.compile("(?:\\&|^)" + argv + "=[^\\&]*(?=\\&|$)","ig");
		q=q.replace(re,"&");//append to url
		q += "&" + argv + "=" + String(arguments[++i]);
	}
	for(++i; i < c; ++i){ //ignore -, denote a start of chopping parameters)
		argv=String(arguments[i]);
		re.compile("(?:\\&|^)" + argv + "=[^\\&]*(?=\\&|$)","ig");
		q=q.replace(re,"&"); //chop from url
	}
	return q.replace(/\&{2,}/ig,"&").replace(/(?:^\&|\&$)/ig,"");
}
/*created by DungHM*/
function hideButton(){
//An button tren thanh cong cu voi doi so la id cua td chua nut	
	argLen = arguments.length;
	for(i=0;i<argLen;i++){
		arg = String(arguments[i]);
		with(parent.banner){
			document.getElementById(arg).style.display="none";
		}
	}
}
function showButton(){	
//Hien button tren thanh cong cu voi doi so la id cua td chua nut	
	argLen = arguments.length;
	for(i=0;i<argLen;i++){
		arg = String(arguments[i]);
		with(parent.banner){
			document.getElementById(arg).style.display="";
		}
	}
}
function oversort(id){
	document.getElementById(id).style.backgroundImage="url(../images/over.gif)";	
}
function outsort(id){
	document.getElementById(id).style.backgroundImage="url(../images/bg-product.gif)";	
}
function contextmenu(id){	
	document.getElementById(id).style.visibility = "visible";
}
function contextout(id){
	document.getElementById(id).style.visibility = "hidden";
}
function checknumber(val){
	if (isNaN(val)){
		alert("Day khong phai la mot so!");
		return false;
	}
	if (val == null || val ==""){
		alert("Ban khong duoc bo trong truong nay!");
		return false;
	}
	return true;
}
var __tested__ = false;
function storeCaret (textEl) {
	__tested__=true;
	if (textEl.createTextRange) {
		textEl.caretPos = document.selection.createRange().duplicate();
	}
}
function insertAtCaret (textEl, text) {
	if(!__tested__) return;
	if (textEl.createTextRange && textEl.caretPos) {
		var caretPos = textEl.caretPos;
		caretPos.text =
		caretPos.text.charAt(caretPos.text.length - 1) == ' ' ?	text + ' ' : text;
		textEl.focus();
	}
	else textEl.value = text;
}
function EnterToBr(){
	if(window.event.keyCode == 13 && ! window.event.shiftKey){
		insertAtCaret(window.event.srcElement,"<br>");
	}
}

//Gui cho nguoi than
function showpopup(url){
	if (url=="") return;
	var content = "<form id='sendform' action='sendto.php' method='post' onSubmit='return checkform(this);'>";
	content += "<table width='100%' style='font-size:11px' bgcolor='#EFEBDE'><tr><td colspan='2' class='boxTitle'><input type='hidden' name='url' value='"+url+"'>G&#7917;i cho b&#7841;n b&#232;</td></tr>";
	content += "<tr><td class='text'>Ng&#432;&#7901;i g&#7917;i:&nbsp;</td><td><input name='sendername' class='inputbox' type='text' style='font-size:11px;width:250px;' value=''></td></tr>";
	content += "<tr><td class='text'>Email ng&#432;&#7901;i g&#7917;i:&nbsp;</td><td><input class='inputbox' name='senderemail' type='text' style='font-size:11px;width:250px;'  value=''></td></tr>";
	content += "<tr><td class='text'>Ng&#432;&#7901;i nh&#7853;n:&nbsp;</td><td><input type='text' class='inputbox' name='receivername' style='font-size:11px;width:250px;'  value=''></td></tr>";
	content += "<tr><td class='text'>Email ng&#432;&#7901;i g&#7917;i:&nbsp;</td><td><input type='text' class='inputbox' name='receiveremail' style='font-size:11px;width:250px;'  value=''></td></tr>";
	content += "<tr><td class='text'>Ghi ch&#250;:&nbsp;</td><td><textarea style='overflow:auto' class='inputbox' name='sendernote' style='font-size:11px;width:250px;height:100px'></textarea></td></tr>";
	content += "<tr><td class='text' colspan='2' style='text-align:center'><input type='submit' value='G&#7917;i &#273;i' style='font-family:tahoma;font-size:11px;border:1px solid #000000'>&nbsp;<input type='button' value='B&#7887; qua' style='font-family:tahoma;font-size:11px;border:1px solid #000000' onClick=\"javascript:closebox('sendtofriend');\"></td></tr></table>";
	content += "</form>";
	if ($('sendtofriend')) document.body.removeChild($('sendtofriend'));
	oDiv = document.createElement('DIV');	
	oDiv.id="sendtofriend";
	oDiv.style.fontSize="11px";
	oDiv.style.border="1pt solid #0A2C6F";
	oDiv.style.padding="0px";
	oDiv.style.position="absolute";
	oDiv.style.textAlign="justify";
	oDiv.style.width="380px";
	oDiv.style.height="150px";
	oDiv.style.top="200px";
	oDiv.style.left="320px";
	oDiv.style.backgroundColor="#FFFFFF";
    oDiv.innerHTML = content;
	oSelect = document.getElementsByTagName("select");
	for(var i=0;i<oSelect.length;i++){
		oSelect[i].style.visibility="hidden";	
	}
	document.body.appendChild(oDiv);	
}

function showpicture(imgsrc){
	if (imgsrc=="") return;
	img = new Image();
	img.src = imgsrc;
	//alert(img.width);
	img.onclick = function (){
    closebox('picturebox');
  }
	img.title = 'Click chu&#7897;t l&#234;n &#7843;nh &#273;&#7875; &#273;&#243;ng';
  img.style.cursor = "pointer";
	if ($('picturebox')) document.body.removeChild($('picturebox'));
	if ($('banner_top')) $('banner_top').style.visibility="hidden";
	oDiv = document.createElement('DIV');
	oDiv.id = "picturebox";
	oDiv.style.zIndex = "1";
	//if (document.all){
    //oDiv.innerHTML = '<div style="display:block;padding:3px 3px 3px 3px;border-bottom:1px solid #7899bb;height:15px;width:'+img.width+'px;text-transform:uppercase;font-weight:bold;text-align:right;"><img src="images/close_box.gif" style="cursor:pointer;" onClick="javascript:closebox(\'picturebox\');" title="Click chu&#7897;t l&#234;n &#7843;nh &#273;&#7875; &#273;&#243;ng"/><div>';
  //}else{
    oDiv.innerHTML = '<div style="display:block;border-bottom:1px solid #7899bb;height:20px;width:'+(img.width)+'px;text-transform:uppercase;font-weight:bold;text-align:right;"><img src="images/close_box.gif" style="cursor:pointer;padding:3px 3px 3px 3px" onClick="javascript:closebox(\'picturebox\');" title="Click chu&#7897;t l&#234;n &#7843;nh &#273;&#7875; &#273;&#243;ng"/><div>';
  //}
	
	//oDiv.innerHTML += "<img src='"+imgsrc+"' style='cursor:pointer;display:block;' title='Click chu&#7897;t l&#234;n &#7843;nh &#273;&#7875; &#273;&#243;ng' onClick=\"javascript:closebox('picturebox');\">";
	oDiv.appendChild(img);
  oDiv.style.border="1px solid #7899bb";
	oDiv.style.padding="0px";
	oDiv.style.position="absolute";
	oDiv.style.width=img.width+"px"//"200px";
	oDiv.style.height=img.height+25+"px"//"10px";
	oDiv.style.top="200px";
	oDiv.style.bottom="200px";
	oDiv.style.left="400px";
	oDiv.style.backgroundColor="#FFFFFF";	
	document.body.appendChild(oDiv);
	oDiv.style.visibility ="hidden";
	fade(oDiv,"visible");
}

function closebox(id){
	oDiv = $(id);	
	if ($('banner_top')) $('banner_top').style.visibility="visible";
	document.body.removeChild(oDiv);	
	oSelect = document.getElementsByTagName("select");
	for(var i=0;i<oSelect.length;i++){
		oSelect[i].style.visibility="visible";	
	}
}

function fade(obj,type) {
	try{
    obj.style.filter="blendTrans(duration=2)";
    // Make sure the filter is not playing.
    if (obj.filters.blendTrans.status != 2) {
        obj.filters.blendTrans.apply();
        obj.style.visibility=type;
        obj.filters.blendTrans.play();
    }
	}catch(e){
		obj.style.visibility="visible";
	};
}

function checkform(oForm){
	var regex = /^(([\-\w]+)\.?)+@(([\-\w]+)\.?)+\.[a-zA-Z]{2,4}$/;
	var sender=oForm.senderemail.value;
	var receiver=oForm.receiveremail.value;
	for (var i=0;i<oForm.elements.length-2;i++){
		if (oForm.elements[i].value==""){
			alert("Ban khong duoc de trong truong nay");
			return false;
		}
	}
	if (!regex.test(sender) || !regex.test(receiver)){
		alert("Email khong dung dinh dang");
		return false
	}
	return true;
}	
function loadingbox(){
	this.loading = function (content,width,height){
		if (document.getElementById("loading")){
			document.body.removeChild(document.getElementById("loading"));
		}
		var div = document.createElement("DIV");
		div.setAttribute("id","loading");
		div.innerHTML = content;
		div.style.position = "absolute";
		div.style.left = "400px";
		div.style.bottom = "250px";
		div.style.width = width+"px";
		div.style.height = height+"px";
		div.style.textAlign = "center";
		div.style.verticalAlign = "middle";		
		div.style.padding = "0px";
		div.style.zIndex = 1;
		div.onclick = function (){
			document.body.removeChild(div);
		}
		document.body.appendChild(div);
	}
	this.draw = function (content,width,height){
		if (document.getElementById("loading")){
			document.body.removeChild(document.getElementById("loading"));
		}
		var div = document.createElement("DIV");
		div.setAttribute("id","loading");
		div.innerHTML = content;
		div.style.position = "absolute";
		div.style.left = "400px";
		div.style.bottom = "250px";
		div.style.width = width+"px";
		div.style.height = height+"px";
		div.style.textAlign = "center";
		div.style.verticalAlign = "middle";
		div.style.border = "2px solid #333333";
		div.style.fontColor = "#FFFF00";
		div.style.padding = "0px";
		div.style.zIndex = 1;
		div.style.backgroundColor = "#FFFFCC";
		div.onclick = function (){
			document.body.removeChild(div);
		}
		document.body.appendChild(div);
	}
	this.messagebox = function (content,width,height){
		if (document.getElementById("messagebox")){
			document.body.removeChild(document.getElementById("messagebox"));
		}
		var div = document.createElement("DIV");
		content = content + "<input type = 'button' value = '&nbsp;&nbsp;&nbsp;&#272;&oacute;ng&nbsp;&nbsp;&nbsp;' onClick = \"document.body.removeChild($('messagebox'));\" style='border:1px solid #CCCCCC;'><br/><a href='index.php' style='color:blue;'>http://www.dienthoaitrungtin.com</a><br/>";
		div.setAttribute("id","messagebox");
		div.innerHTML = content;
		div.style.position = "absolute";
		div.style.left = "310px";
		div.style.bottom = "100px";
		div.style.width = width+"px";
		div.style.height = height+"px";
		div.style.textAlign = "center";
		div.style.verticalAlign = "middle";
		div.style.border = "2px solid #333333";
		div.style.fontColor = "#FFFF00";
		div.style.padding = "2px 0px 0px 0px";
		div.style.zIndex = 1;
		div.style.backgroundColor = "#FFFFCC";
		//div.onclick = function (){
			//document.body.removeChild(div);
		//}
		document.body.appendChild(div);
	}
	this.clear = function (){
		var div = document.getElementById("loading");
		if (div){
			document.body.removeChild(div);
		}else{
			return;
		}
		
	}
}
function mediaPreview(url){
	window.open("trial.php?url="+url,null,"height=200,width=200,status=no,toolbar=no,menubar=no,location=no");
}

function checkEmail(form,input){
	var regex = /^(([\-\w]+)\.?)+@(([\-\w]+)\.?)+\.[a-zA-Z]{2,4}$/;
	if (!regex.test(input)){
		alert("Email khong dung dinh dang");
		return;
	}
	submitTextForm(form,'text','cust-process.php?act=resetpass');
	return true;
}

function vote(f){
	var v = '';
	for(i=0;i < f.elements.length;++i)
		if(f.elements[i].type == 'checkbox' || f.elements[i].type == 'radio'){
			if(f.elements[i].checked)
				v += '&' + f.elements[i].name + '=' + encodeURI(f.elements[i].value);
		}else{
			v += '&' + f.elements[i].name + '=' + encodeURI(f.elements[i].value);
		}
	v = v.substr(1);//exclude leading &
	var sParams = "status=no,scrollbars=yes,toolbar=no,menubar=no,resizable=yes,location=no,height=300,width=500,top=100,left=200";
	var wname = "pollwindow";
	var dest = "poll.php?"+v;
	window.open(dest,wname,sParams);
	return false;
}
function isEmpty(obj){
	var value = obj.value;
	if (value=="" || value == null){
		return false;
	}
	return true;
}
function isEmail(obj){
	var str = obj.value;
	var emailPattern = /^(([\-\w]+)\.?)+@(([\-\w]+)\.?)+\.[a-zA-Z]{2,4}$/;
	if (isEmpty(obj)){
		if (!emailPattern.test(str)){
			return false;
		}
	}	
	return true;
}
function showMenuNode(o){
	var u,v,w,i=0,j=0,k=0;
	v = o.nextSibling;
/*	if(u=v){
		w=u.previousSibling;
		while(w && i<20){
			w.nextSibling.style.display='none';
			w=w.previousSibling;
			++i;
		}
		w=u.nextSibling;
		while(w && i<20){
			w.nextSibling.style.display='none';
			w=w.nextSibling;
			++i;
		}
	}*/
	if(v.style.display=='list-item') v.style.display='none';
	else v.style.display  ='list-item';
	return false;
}
function posX(obj){
	var vX=0;
	if(obj.x)vX=obj.x;
	else if(obj.offsetParent)
		while(obj.offsetParent){
			vX+=obj.offsetLeft;
			obj=obj.offsetParent;
		}
	return vX;
}
function posY(obj){
	var vX=0;
	if(obj.y)vX=obj.y;
	else if(obj.offsetParent)
		while(obj.offsetParent){
			vX+=obj.offsetTop;
			obj=obj.offsetParent;
		}
	return vX;
}
function getCurrentTime(id){
  var d =  new Date();
  var wd = d.getDay();
  switch(wd){
    case 0: wd = 'Ch&#7911; Nh&#7853;t';break;
    case 1: wd = 'Th&#7913; hai';break;
    case 2: wd = 'Th&#7913; ba';break;
    case 3: wd = 'Th&#7913; t&#432;';break;
    case 4: wd = 'Th&#7913; n&#259;m';break;
    case 5: wd = 'Th&#7913; s&#225;u';break;
    case 6: wd = 'Th&#7913; b&#7843;y';break;
  } 
  var dat = d.getDate();
  var mon = d.getMonth()+1;
  var yer = d.getYear();
  var text = wd+',&nbsp;'+dat+'&nbsp;-&nbsp;'+mon+'&nbsp;-&nbsp;'+yer;
  document.getElementById(id).innerHTML = text;
}
function selectText(o){
  var val = o.value;
  if (val == 'Tim kiem...'){
    o.value = '';
  }  
  if ((val!='')&&(val!='Tim kiem...')){
    o.select();
  }  
}
function returnText(o){
  if (o.value=='') o.value = 'Tim kiem...';
}
function getImage(url,pars,target){
  var o =  new createXmlObject();
  url = url+'?'+pars;
  var info = new loadingbox();	
	info.loading("<img src = '"+ROOT+"images/loading.gif' style='padding:0px;'>",185,20);
  o.open('GET',url,true);
  o.onreadystatechange = function(){
    if (o.readyState == 4){
      if (o.status == 200){
        info.clear();      
        $(target).innerHTML = o.responseText; 
      }
    }    
  }	
  o.send(null);		
}
function updatePrice(url){  
  var o = null;
  o = new createXmlObject();
  document.getElementById('content').innerHTML ="";
  o.open('GET',url,true);
  o.onreadystatechange = function (){
    if (o.readyState == 4){
      if (o.status == 200){
        document.getElementById('content').innerHTML = o.responseText;
      }      
    }
    else document.getElementById('content').innerHTML = '&#272;ang c&#7853;p nh&#7853;t d&#7919; li&#7879;u m&#7899;i nh&#7845;t, vui l&#242;ng &#273;&#7907;i trong gi&#226;y l&#225;t...';
  }
  o.setRequestHeader('Cache-Control','no-cache');
  o.send(null);    
}
function showPrice(i){
  i = parseInt(i);
  var url = '';
  switch(i){
    case 2: url = 'stockprice1.php';break;
    default:url = 'stockprice.php'; 
  }
  window.open(URL_ROOT + url,'Banggia','width=1024,height=600,resizable=no,scrollbars=yes,location=yes"');
  return false;
}
function hitcounter(id1,id2){
  document.getElementById(id1).innerHTML = app.online;
  document.getElementById(id2).innerHTML = app.visit;
}
/*---end---*/
function bannerClick(id){
	o = new Image();
    o.src='bannerclick.php?BNid='+id+'&ref='+encodeURI(window.location.href);
}
function openWebLink(o){
	if(o.value != ""){
		if(typeof(o.options[o.selectedIndex].rel) == 'undefined' || o.options[o.selectedIndex].rel == '' || o.options[o.selectedIndex].rel == '_self')
			self.location.href=o.value;
		else
			window.open(o.value,o.options[o.selectedIndex].rel);
	}
}
function printpage(){
	window.print();
}

function closebox(id){
	oDiv=document.getElementById(id);
	document.getElementById('product_img_detail').removeChild(oDiv);	
	oSelect = document.getElementsByTagName("select");
	for(var i=0;i<oSelect.length;i++){
		oSelect[i].style.visibility="visible";	
	}
}

function showRealSize(evt,obj){
//	window.alert(obj.tagName + obj.src);
	oDiv = document.createElement('DIV');
	oDiv.id = "picturebox";
	oDiv.style.zIndex = "1";
	oDiv.innerHTML = '<div class="product_size_true"><strong style="cursor:pointer;padding:7px;font-size:14px;" onClick="closebox(\''+ oDiv.id +'\');" title="Click chu&#7897;t l&#234;n &#7843;nh &#273;&#7875; &#273;&#243;ng">X</strong><div>';
	oDiv.innerHTML += '<' + obj.tagName + ' src="' + obj.src + '" title="Click chu&#7897;t l&#234;n &#7843;nh &#273;&#7875; &#273;&#243;ng" onClick="closebox(\'' + oDiv.id + '\');"/>';
	//oDiv.style.border="1px solid #CCCCCC";
	//oDiv.style.top=posY(obj) + 'px';
	//oDiv.style.left=posX(obj) + 'px';
	//oDiv.style.backgroundColor="#FFFFFF";	
	//document.body.appendChild(oDiv);
	document.getElementById('product_img_detail').appendChild(oDiv);
	try{
		var i,n;
		n=oDiv.filters.length;
		//alert(parseInt(10*Math.random(1,n)));
		i = parseInt(n*Math.random());
		//for(i=0;i < n;++i){
		oDiv.style.visibility='hidden';
		oDiv.filters.item(i).Apply();
		oDiv.style.visibility='visible';
		oDiv.filters.item(i).Play();
		//}
	}catch(e){
		oDiv.style.visibility ="visible";
	}
}


function checkLinkForm(f){
//Reciprocal Link URL
	if(f.BNmybanner.value=="" || f.BNmybanner.value==null){
		window.alert(T_LINK_URL);
		f.BNmybanner.focus();
		return false;
	}	
//email
	var regex = /^(([\-\w]+)\.?)+@(([\-\w]+)\.?)+\.[a-zA-Z]{2,4}$/;
	if(f.BNemail.value=="" || f.BNemail.value==null){
		window.alert(T_EMAIL_REQUIRED);
		f.BNemail.focus();
		return false;
	}
	if (!regex.test(f.BNemail.value)){
		window.alert(T_EMAIL_TYPE);
		f.BNemail.focus();
		return false;
	}
//Site title / Your site URL / Reciprocal Link URL
	if(f.BNdesc.value=="" || f.BNdesc.value==null){
		if(f.BNname.value=="" || f.BNname.value==null){
			window.alert(T_TITLE_REQUIRED);
			f.BNname.focus();
			return false;
		}
		if(f.BNurl.value=="" || f.BNurl.value==null){
			window.alert(T_URL_REQUIRED);
			f.BNurl.focus();
			return false;
		}
	}

	f.CBname.value = f.CBid.options[f.CBid.selectedIndex].text;
	return esnc_aform(f);
}
/*
function getValue(o,id){
	obj = document.getElementById(id);
	obj.value = o.options[o.selectedIndex].text;
}
*/
function checkCommentForm(o){
//name
	if(o.CMname.value=="" || o.CMname.value==null){
		window.alert(T_NAME_REQUIRED);
		o.CMname.focus();
		return false;
	}
//email
	var regex = /^(([\-\w]+)\.?)+@(([\-\w]+)\.?)+\.[a-zA-Z]{2,4}$/;
	if(o.CMemail.value=="" || o.CMemail.value==null){
		window.alert(T_EMAIL_REQUIRED);
		o.CMemail.focus();
		return false;
	}
	if (!regex.test(o.CMemail.value)){
		window.alert(T_EMAIL_TYPE);
		o.CMemail.focus();
		return false;
	}
//duration
	if(o.CMduration.value=="" || o.CMduration.value==null){
		window.alert(T_DURATION_REQUIRED);
		o.CMduration.focus();
		return false;
	}
	return esnc_aform(f);
}
function toBookMark(v){
	window.location.href=String(window.location.href).replace(/#.*$/,'')+v;
}

function switchTab(o,type){
	for(var i=1;i<7;i++){
		var tab_active = document.getElementById('tab'+type+i);
		if(tab_active.id==o.id){
			tab_active.className = 'tab'+type+'_active';	
			document.getElementById('tab'+type+'_'+i).style.display = 'block';
		}else{
			tab_active.className = 'tab'+type;	
			document.getElementById('tab'+type+'_'+i).style.display = 'none';
		}
	}
}

function checkContactForm(f){	
//name
	if(f.ct_name.value=="" || f.ct_name.value==null){
		window.alert(T_NAME_REQUIRED);
		f.ct_name.focus();
		return false;
	}

	if (isNaN(f.ct_name.value)==false){
		window.alert(T_NAME_TYPE);
		f.ct_name.focus();
		return false;
	}
//email
	var regex = /^(([\-\w]+)\.?)+@(([\-\w]+)\.?)+\.[a-zA-Z]{2,4}$/;
	if(f.ct_email.value=="" || f.ct_email.value==null){
		window.alert(T_EMAIL_REQUIRED);
		f.ct_email.focus();
		return false;
	}	
	if (!regex.test(f.ct_email.value)){
		window.alert(T_EMAIL_TYPE);
		f.ct_email.focus();
		return false;
	}
//content
	//window.alert('==='+f.ct_content.value+'==');
	if(f.ct_content.value== null || f.ct_content.value==''){
		window.alert(T_CONTENT_REQUIRED);
		f.ct_content.focus();
		return false;
	}
	if(f.scode.value=="" || f.scode.value==null){
		window.alert("Number NULL");
		f.scode.focus();
		return false;
	}
return true;
}
function checkpostForm(f){
	var regex = /^(([\-\w]+)\.?)+@(([\-\w]+)\.?)+\.[a-zA-Z]{2,4}$/;
	if(f.ct_email.value=="" || f.ct_email.value==null){
		window.alert(T_EMAIL_REQUIRED);
		f.ct_email.focus();
		return false;
	}	
	if (!regex.test(f.ct_email.value)){
		window.alert(T_EMAIL_TYPE);
		f.ct_email.focus();
		return false;
	}
//content
	//window.alert('==='+f.ct_content.value+'==');
	if(f.ct_content.value== null || f.ct_content.value==''){
		window.alert(T_CONTENT_REQUIRED);
		f.ct_content.focus();
		return false;
	}
	if(f.scode.value=="" || f.scode.value==null){
		window.alert("Number NULL");
		f.scode.focus();
		return false;
	}
return true;	
}
function checkCustomerForm(f){	
var regex = /^(([\-\w]+)\.?)+@(([\-\w]+)\.?)+\.[a-zA-Z]{2,4}$/;
//card number
	if(f.ca_num1.value=="" || isNaN(f.ca_num1.value)){
		window.alert(T_CARD_NUMBER);
		f.ca_num1.focus();
		return false;
	}
	if(f.ca_num2.value=="" || isNaN(f.ca_num2.value)){
		window.alert(T_CARD_NUMBER);
		f.ca_num2.focus();
		return false;
	}
	if(f.ca_num3.value=="" || isNaN(f.ca_num4.value)){
		window.alert(T_CARD_NUMBER);
		f.ca_num3.focus();
		return false;
	}
	if(f.ca_num4.value=="" || isNaN(f.ca_num4.value)){
		window.alert(T_CARD_NUMBER);
		f.ca_num4.focus();
		return false;
	}
//card owner
	if(f.ca_expire.value=="" || f.ca_expire.value==null){
		window.alert('The field can not Empty');
		f.ca_expire.focus();
		return false;
	}
//card owner
	if(f.ca_holder.value=="" || f.ca_holder.value==null){
		window.alert('The field can not Empty');
		f.ca_holder.focus();
		return false;
	}
//firstname
	if(f.cs_firstname.value=="" || f.cs_firstname.value==null){
		window.alert(T_NAME_TYPE);
		f.cs_firstname.focus();
		return false;
	}
//lastname
	if(f.cs_lastname.value=="" || f.cs_lastname.value==null){
		window.alert(T_NAME_TYPE);
		f.cs_lastname.focus();
		return false;
	}
//email -1
	if (f.cs_email.value=="" || f.cs_email.value==null || !regex.test(f.cs_email.value)){
		window.alert(T_EMAIL_TYPE);
		f.cs_email.focus();
		return false;
	}
//phone
	if(f.cs_phone.value=="" || f.cs_phone.value==null){
		window.alert(T_PHONE_TYPE);
		f.cs_phone.focus();
		return false;
	}
	if(isNaN(f.cs_phone.value)){
		window.alert(T_PHONE_TYPE);
		f.cs_phone.focus();
		return false;
	}
//address
	if(f.cs_address.value=="" || f.cs_address.value==null){
		window.alert(T_ADDRESS_TYPE);
		f.cs_address.focus();
		return false;
	}
//zipcode
	if(f.cs_zipcode.value=="" || f.cs_zipcode.value==null){
		window.alert('Zipcode can not empty!');
		f.cs_zipcode.focus();
		return false;
	}
//code
	if(f.scode.value=="" || f.scode.value==null){
		window.alert(T_CODE_TYPE);
		f.scode.focus();
		return false;
	}
	return esnc_aform(f);
}