function GE(id)
{
	return document.getElementById(id);
}

function  isNumber(str)  
{   
    if(str.length==0) 
    return  false; 
    for(i =0;i<str.length;i++)
	{   
    if(str.charAt(i)< "0" || str.charAt(i)>"9") 
    return  false; 
    } 
   return  true; 
} 

function  isEnglish(str) 
{   
    if(str.length==0) 
    return  false; 
    for(i=0;i<str.length;i++)
    {   
     if(str.charCodeAt(i)>128) 
      return  false; 
    } 
    return  true; 
} 

function isMail(email) { 
 var pattern = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/; 
 if(pattern.test(email)) { 
  return true; 
 } 
 else { 
  return false; 
 } 
}

function getElementValue(str)
{
	return GE(str).value;
}

function CheckSearch()
{
   if (getElementValue("searchtype")=="pro_name")
   {
	   if(getElementValue("pro_id_name")=="" || getElementValue("pro_id_name")=="product name like 'nike',id like '200808'")
	   {   alert("Please enter a keyword for search");
		   GE("pro_id_name").focus();
		   return false;
		   }
	   else
	   { 
	       if(!isEnglish(getElementValue("pro_id_name")))
	       {
		       alert("Please input the information in English instead");
		       GE("pro_id_name").focus();
		       return false;	
		   }
		   else
		   {
			   return true;
		   }		   
	    } 	   
	}
	else
	{
		if(getElementValue("pro_id_name")=="" || getElementValue("pro_id_name")=="product name like 'nike',id like '200808'")
	   {   alert("Please enter a keyword for search");
		   GE("pro_id_name").focus();
		   return false;
		   }
	   else
	   { 
	       if(!isNumber(getElementValue("pro_id_name")))
	       {
		       alert("Please input the information in Integer instead");
		       GE("pro_id_name").focus();
		       return false;	
		   }
		   else
		   {
			   return true;
		   }		   
	    } 	   
		
		
	}
	
}

function CheckSearch1()
{
	  if(getElementValue("pro_detail")=="" || getElementValue("pro_detail")=="like 'male female size'")
	   {   alert("Please enter a keyword for search");
		   GE("pro_detail").focus();
		   return false;
		   }
	   else
	   { 
	       if(!isEnglish(getElementValue("pro_detail")))
	       {
		       alert("Please input the information in English instead");
		       GE("pro_detail").focus();
		       return false;	
		   }
		   else
		   {
			   return true;
		   }		   
	    } 	   
}
function CheckSearch2()
{
	  if(getElementValue("news_title")=="" || getElementValue("news_title")=="like 'shoes'")
	   {   alert("Please enter a keyword for search");
		   GE("news_title").focus();
		   return false;
		   }
	   else
	   { 
	       if(!isEnglish(getElementValue("news_title")))
	       {
		       alert("Please input the information in English instead");
		       GE("news_title").focus();
		       return false;	
		   }
		   else
		   {
			   return true;
		   }		   
	    } 	   
}
function CheckSearch2()
{
	  if(getElementValue("news_title")=="" || getElementValue("news_title")=="like 'shoes'")
	   {   alert("Please enter a keyword for search");
		   GE("news_title").focus();
		   return false;
		   }
	   else
	   { 
	       if(!isEnglish(getElementValue("news_title")))
	       {
		       alert("Please input the information in English instead");
		       GE("news_title").focus();
		       return false;	
		   }
		   else
		   {
			   return true;
		   }		   
	    } 	   
}

function viewLargerPic()
{
	if(GE("viewLargerPic").style.display=="none")
	{
		GE("viewLargerPic").style.display="block";
		GE("viewBTN").value="Close Original Picture";
	}
	else	
	{
		GE("viewLargerPic").style.display="none";
		GE("viewBTN").value="View Original Picture";
	}
}

function viewSimpleList()
{
	if(GE("viewsimplelist").style.display=="none")
	{
		GE("viewsimplelist").style.display="block";
		GE("viewdetailslist").style.display="none";		
	}	
}

function viewDetailsList()
{
	if(GE("viewdetailslist").style.display=="none")
	{
		GE("viewsimplelist").style.display="none";
		GE("viewdetailslist").style.display="block";				
	}			
}
	
function CheckEmailSave()
{
	  if(getElementValue("email_address")=="" || getElementValue("email_address")=="like 'loveit@hotmail.com'")
	   {   alert("Please enter a email address");
		   GE("email_address").focus();
		   return false;
		   }
	   else
	   { 
	       if(!isMail(getElementValue("email_address")))
	       {
		       alert("Please input the information in Email instead");
		       GE("email_address").focus();
		       return false;	
		   }
		   else
		   {  
		        if(getElementValue("email_username")=="" || getElementValue("email_username")=="like 'John'")
				{   alert("Please enter your name");
		            GE("email_username").focus();
		            return false;
		        }
	            else
				{
					return true;					
				}			   
		   }		   
	    } 	   
}