function CheckSearch()
{
	with (document.fs)
	{
		if (txtsearch.value=="")
		{
			alert("Please enter keyword!");
			txtsearch.focus();
			return false;
		}
	}
	return true;
}
function CheckLogin()
{
	with (document.fl)
	{
		if (username.value=="")
		{
			alert("Please enter username!");
			username.focus();
			return false;
		}
		if (password.value=="")
		{
			alert("Please enter password!");
			password.focus();
			return false;
		}
	}
	return true;
}

function CheckFormReg()
{
        with (document.registerform)
        {
                if (username.value==""||username.value.length < 3||username.value.length > 30)
                {
                        alert("Tên truy cập không hợp lệ");
                        username.focus();
                        return false;
                }
			   if (password.value==""||password.value.length < 6)
                {
                        alert("Mật khẩu không hợp lệ, phải tối thiểu 6 ký tự");
                        password.focus();
                        return false;
                }
                if (email.value=="")
                {
                        alert("Phải nhập vào email");
                        email.focus();
                        return false;
                }
                else
                {
                        if(email.value.indexOf("@")<0||email.value.indexOf(".")<0)
                        {
                                alert("Email không hợp lệ");
                                email.focus();
                                return false;
                        }

                }			
        }
        return true;
}

function CheckFormBuy()
{
        with (document.form1)
        {
                if (fullnamez.value=="")
                {
                        alert("Tên người nhận hàng cần phải có!");
                        fullname.focus();
                        return false;
                }
                if (emailz.value=="")
                {
                        alert("Phải nhập vào email người nhận");
                        email.focus();
                        return false;
                }
                else
                {
                        if(emailz.value.indexOf("@")<0||emailz.value.indexOf(".")<0)
                        {
                                alert("Email người nhận hàng không hợp lệ");
                                email.focus();
                                return false;
                        }

                }
				if (diachiz.value=="")
                {
                        alert("Phải có địa chỉ ngưòi nhận hàng!");
                        diachi.focus();
                        return false;
                }
				if (thanhphoz.value=="")
                {
                        alert("Phải nhập vào thành phố người nhận hàng!");
                        thanhpho.focus();
                        return false;
                }
        }
        return true;
}

function openImageNews(vLink, vHeight, vWidth)
{
	var sLink = (typeof(vLink.href)=='undefined') ? vLink : vLink.href;

	if (sLink=='')
	{
		return false;
	}

	winDef = 'status=no,resizable=no,scrollbars=no,toolbar=no,location=no,fullscreen=no,titlebar=yes,height='.concat(vHeight).concat(',').concat('width=').concat(vWidth).concat(',');
	winDef = winDef.concat('top=').concat((screen.height - vHeight)/2).concat(',');
	winDef = winDef.concat('left=').concat((screen.width - vWidth)/2);
	newwin = open('', '_blank', winDef);

	newwin.document.writeln('<title>Chi tiết hình ảnh!</title><body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">');
	newwin.document.writeln('<a href="" onClick="window.close(); return false;"><img src="', sLink, '" alt="', 'Dong lai', '" border=0></a>');
	newwin.document.writeln('</body>');

	if (typeof(vLink.href) != 'undefined')
	{
		return false;
	}
}
function sameto()
{	
	if(document.form1.samebuyerseller.checked)
	{
	document.form1.fullnamez.value =	document.form1.fullname.value;
	document.form1.emailz.value =	document.form1.email.value;
	document.form1.dienthoaiz.value =	document.form1.dienthoai.value;
	document.form1.faxz.value =	document.form1.fax.value;
	document.form1.diachiz.value =	document.form1.diachi.value;
	document.form1.thanhphoz.value =	document.form1.thanhpho.value;
	document.form1.quocgiaz.value =	document.form1.quocgia.value;

	//disable
	
	//document.form1.fullnamez.readonly =	true;
	//document.form1.emailz.disabled =	true;
	//document.form1.dienthoaiz.disabled =	true;
	//document.form1.faxz.disabled =	true;
	//document.form1.diachiz.disabled =	true;
	//document.form1.thanhphoz.disabled =	true;
	//document.form1.quocgiaz.disabled =	true;
	}
	else
	{
	document.form1.fullnamez.value =	'';
	document.form1.emailz.value =	'';
	document.form1.dienthoaiz.value =	'';
	document.form1.faxz.value =	'';
	document.form1.diachiz.value =	'';
	document.form1.thanhphoz.value =	'';
	document.form1.quocgiaz.value =	'';

	//disable
	
	//document.form1.fullnamez.disabled=false;
	//document.form1.emailz.disabled=false;
	//document.form1.dienthoaiz.disabled=false;
	//document.form1.faxz.enabledisabled=false;
	//document.form1.diachiz.enabledisabled=false;
	//document.form1.thanhphoz.enabledisabled=false;
	//document.form1.quocgiaz.enabledisabled=false;
	}
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

/*
var theoldcell = ""
function showhide(thecell)
{	
	if(theoldcell==thecell){			
		document.getElementById(thecell).style.display = 'none' ;
		document.getElementById(theoldcell).style.display = 'none' ;
		//eval('document.all.'+thecell).style.display = 'none'
		//eval('document.all.'+theoldcell).style.display = 'none'
		//theoldcell = ""
	}else{
		if(theoldcell != thecell)
		{
			if(theoldcell != "")
			{
				//alert(theoldcell) ;
				document.getElementById(theoldcell).style.display = 'none' ;
			}
			//eval('document.all.'+theoldcell).style.display = 'none'
			//eval('document.all.'+thecell).style.display = ''				
			document.getElementById(thecell).style.display = '' ;
			//alert(theoldcell + "-" + thecell) ;
			theoldcell = thecell ;
		}
	}
}
*/

function showhidebrothers(currentrow)
{
	currentelement = document.getElementById(currentrow) ;
	
	menulevel  = currentrow.charAt(4) ;
	menunumber = currentrow.split('menu' + menulevel)[1] ;
	
	//alert("currentmenu id : " + currentrow + "- menulevel : " + menulevel + "- menunumber : " + menunumber + "-" + currentrow.split('menu')[0] + "-" + currentrow.split('menu')[1] + "-" + currentrow.split('menu')[2]) ;

	if (currentelement.parentNode.rows)
	{
		//alert(currentelement.parentNode.rows) ;
		//alert(menunumber) ;
		x = '' ;
		for (i=0; i<currentelement.parentNode.rows.length; i++)
		{
			subelement = currentelement.parentNode.rows[i] ;
			if (subelement.id != "")
			{
				subnumber = "" ;
				ismenu    = subelement.id.substring(0, 4) ;
				subnumber = subelement.id.split('menu' + menulevel)[1] ;

				if (ismenu == "menu")
				{
					x = x + "-" + subnumber ;
					if (subnumber == menunumber)
					{
						if (subelement.style.display == "none")
							subelement.style.display = "" ;
						else
							subelement.style.display = "none" ;
					}
					else
					{
						subelement.style.display = "none" ;						
					}
				}
			}
		}
		//alert("XXX " + x) ;
	}

	//alert(currentelement.parentNode) ;
	//alert(currentelement.parentNode.rows.length) ;
}

	function mOvr(src) {
		if (!src.contains(event.fromElement)) {
		src.style.cursor = 'hand';
		src.bgcolor = '#000000';
		}
	}
	function mOut(src) {
		if (!src.contains(event.toElement)) {
		src.style.cursor = 'default';
		}
	}
	function mClk(src) {
		if(event.srcElement.tagName=='TD'){
		src.children.tags('A')[0].click();
		}
	}
