// JavaScript Document
function open_nva(str){
	document.getElementById(str).className="nva_nva2";
}
function close_nva(str){
	document.getElementById(str).className="nva_nva";
}

function form_search()
{
	var key;
	key=document.soso.key.value;
	if(key=="")
	{
		window.alert("keyword is not empty");
		document.soso.key.focus();
		return false;
	}
	else
	{
		return true;
	}
}

function display(divID,num)
{
	var temp;
	for(var i=0;i<num;i++)
	{
		temp=document.getElementById(divID+"_"+i);
		if(temp.style.display=="")
		{
			temp.style.display="none";
		}
		else
		{
			temp.style.display="";
		}
	}
}
function displayP(divID)
{
	var temp;
	temp=document.getElementById(divID);
	if(temp.style.display=="")
	{
		temp.style.display="none";
	}
	else
	{
		temp.style.display="";
	}
}
function isEmail(str)
{  	
	if(str!="")
	{
		var reg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/;
		if (reg.test(str)) 
		{
			return false;
		}
		else
		{
			alert("E-MAIL Incorrect format");
			document.regForm.email.focus();
			return true;
		}
	}
	else
	{
		alert("E-MAIL is not empty");
		document.regForm.email.focus();
		return true;
	}

} 
function isEnglish(str,temp,len)
{  	
	var s=0;
	if(str=="")
	{
		window.alert (temp+" is not empty");
		return true;
	}
	else if(str.length < 6 || str.length > len)
	{
		window.alert (temp+" length is 6-"+len);
		return true;
	}
	else
	{
		for(i=0;i<str.length;i++)
		{
			var c=str.charAt(i);
			if((c>='A'&&c<='Z')||(c>='a'&&c<='z')||(c>='0'&&c<='9')||c=='_')
			{
				continue;
			}
			else
			{
				s++;
			}
		}
		if(s>0)
		{
			window.alert (temp+" is number and  Letters and _");
			return true;
		}
		else
		{
			return false;
		}
		
	}

} 
function checkInput(){
	
	var data4=document.regForm.data4.value;
	var data5=document.regForm.data5.value;
	var phone=document.regForm.phone.value;
	var email=document.regForm.email.value;
	var country_1=document.regForm.country_1.value;	
	var country_2=document.regForm.country_2.value;
	var username=document.regForm.username.value;
	var pass1=document.regForm.pass1.value;
	var pass2=document.regForm.pass2.value;
	
	
	
	if(data4==""){
		window.alert("First Name is not empty");
		document.regForm.data4.focus();
		return false;
	}
	
	if(data5== ""){
		window.alert("Last Name is not empty");
		document.regForm.data5.focus();
		return false;
	}
	if(phone== ""){
		window.alert("phone is not empty");
		document.regForm.phone.focus();
		return false;
	}
	if(isEmail(email))
	{
		document.regForm.email.focus();
		return false;
	}
	if(country_1== "1"&&country_2== ""){
		window.alert("country is not empty");
		document.regForm.country_1.focus();
		return false;
	}
	if(username== ""){
		window.alert("username is not empty");
		document.regForm.username.focus();
		return false;
	}
	
	if(isEnglish(pass1,"password",10))
	{
		document.regForm.pass1.focus();
		return false;
	}
	if(pass1!=pass2)
	{
		window.alert ("Two password the importation is inconsistent");
		document.regForm.pass1.focus();
		return false;
	}
	else
	{
		return true;
	}
}

function checkCart(){
	//isNaN
	var data2=document.cartForm.data2.value;
	if(data2==""){
		window.alert("number is not empty");
		document.cartForm.data2.focus();
		return false;
	}
	else if(isNaN(data2))
	{
		window.alert("Must be an integer ");
		document.cartForm.data2.focus();
		return false;
	}
	else
	{
		return true;
	}
}

