

function validate_formlogin(thisform)
{
	with (thisform)
	  {
			var formfields= new Array();
			formfields[0] = "username";
			formfields[1] = "password";

			var errors="";
			
		for (x in formfields)
				 {
	
					   if (document.getElementById(formfields[x]).value =="")
							   {
								   formfields[x]+="_lbl";
					//alert(document.getElementById(formfields[x]).value);			   
				document.getElementById(formfields[x]).style.visibility='visible';
								  errors="1";
								  
							   }
			
				  }
		  }
		  
		  
		  if(errors !="")
		  {
			  errors=null;
			  return false;
		  }
		  else
		  {
			  return true;
		  }
		 
 
}

/////////////////////////////////////////
//////////////////////////////////////////
//////////////////////////////////////////

////chat

function chatlogin(thisform)
{
	with (thisform)
	  {
			var formfields= new Array();
			formfields[0] = "name";

			var errors="";
			
		for (x in formfields)
				 {
	
					   if (document.getElementById(formfields[x]).value =="")
							   {
								   formfields[x]+="_lbl";
					//alert(document.getElementById(formfields[x]).value);			   
				document.getElementById(formfields[x]).style.visibility='visible';
								  errors="1";
								  
							   }
			
				  }
		  }
		  
		  
		  if(errors !="")
		  {
			  errors=null;
			  return false;
		  }
		  else
		  {
			  return true;
		  }
		 
 
}
///////////////////////////////////////////
/////////////////////////////////////////////
//career page validation


function validate_applay(thisform)
{
	with (thisform)
	  {
			var formfields= new Array();
			formfields[0] = "fullname";
			formfields[1] = "gender";
			formfields[2] = "martialStatus";
			formfields[3] = "militaryStatus";
			formfields[4] = "birthDate";
			formfields[5] = "country";			
			formfields[6] = "city";
			formfields[7] = "address";
			formfields[8] = "mobile";			
			formfields[9] = "phone";
			formfields[10] = "education";
			formfields[11] = "work";			
			
			var errors="";
			
		for (x in formfields)
				 {
	
  if (document.getElementById(formfields[x]).value =="")
							   {
								   formfields[x]+="_lbl";
					//alert(document.getElementById(formfields[x]).value);			   
				document.getElementById(formfields[x]).style.visibility='visible';
								  errors="1";
								  
							   }
			
				  }
		  }
		  
		  
		  if(errors !="")
		  {
			  //errors=null;
			  return false;
		  }
		  else
		  {
			  return true;
		  }
		 
 
}
/////////////////////////////////////////
//////////////////////////////////////////
//////////////////////////////////////////
///////////////////////////////////////////
/////////////////////////////////////////////
//contact us page validation
function contactus(thisform)
{
	with (thisform)
	  {
			var formfields= new Array();
			formfields[0] = "name";
			formfields[1] = "email";
			formfields[2] = "comment";
			var errors="";
			
		for (x in formfields)
				 {
	
					   if (document.getElementById(formfields[x]).value =="")
							   {
								   formfields[x]+="_lbl";
					//alert(document.getElementById(formfields[x]).value);			   
				document.getElementById(formfields[x]).style.visibility='visible';
								  errors="1";
								  
							   }
			
				  }
		  }
		  
		  
		  if(errors !="")
		  {
			  errors=null;
			  return false;
		  }
		  else
		  {
			  return true;
		  }
		 
 
}
/////////////////////////////////////////
//////////////////////////////////////////
//////////////////////////////////////////
///////////////////////////////////////////
/////////////////////////////////////////////
//cart us page validation

function addtoshopingcart(quntity,id,productname,sid)
{
	//q=quntity;
	 //itemquntity=document.getElementById(q).value;
	 var  itemid=id;
	 var  product=productname;
	 var  auth=sid;
	 var  itemname=document.getElementById("quntity_"+id).value;
	  
		if(itemname=="" || itemname==0 || itemname <"0")
			{
			   alert("add quntity please");
			}
		 else if(isNaN(itemname))
		 {
			  alert("add number please");
		 }
		else
			{
				insertcartajax(itemid,itemname,auth);
				//alert(quntity);
			}
	
}

////////////////////////////////////////////////////////////////////////////////
function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}


///////////////////
function insertcartajax(itemid,itemquntity,auth)
{ 
xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }

// continue only if the XMLHttpRequest object isn't busy
if (xmlHttp && (xmlHttp.readyState == 4 || xmlHttp.readyState == 0))
		  {
			var url="/pages/products/ajax.php";
url=url+"?action=insert&q="+itemquntity+"&sid="+Math.random()+"&auth="+auth+"&product="+itemid;
			xmlHttp.onreadystatechange=stateChangedinsert;
			xmlHttp.open("get",url,true);
			xmlHttp.send(null);
			//alert(url);
		 }
}

function stateChangedinsert() 
{ 
  if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
   { 
   
     // continue only if HTTP status is "OK"
       if(xmlHttp.status == 200)
             {
				 
					// read the response
					 response = xmlHttp.responseText;
							 // server error?
					if (response.indexOf("ERRNO") >= 0
						   || response.indexOf("error") >= 0
						   || response.length == 0)
					      {
			//document.getElementById("status").innerHTML="Couldn't add it. Try again Later";
			alert(xmlHttp.responseText);
					      }
				  // if everything went well, cancel edit mode
						else
						      {
							  
			
			//document.getElementById("status").innerHTML="add successfully";
			               //document.getElementById("status").innerHTML="";
							alert("added successfully .... تمت الاضافة بنجاح");
						
						      }
					  
             }
			  // stop only if HTTP status is not ok
      else
			{
			//document.getElementById("status").innerHTML="Error on server side.";
			alert("Error on server side.");
			return false;
			}
	 
	 } 
	else
	     {
//document.getElementById("status").innerHTML= "<img src='/js/loader.gif' align='center' />";
	     }
}



  ///////////////////////////////////////////
  /////////////////////////////////////////
  function validate_cart(thisform)
{
	with (thisform)
	  {
			var formfields= new Array();
			formfields[0] = "fullname";
			formfields[1] = "city";
			formfields[2] = "address";
			formfields[3] = "mobile";			
			formfields[4] = "phone";
			//formfields[5] = "comments";
		
			
			var errors="";
			
		for (x in formfields)
				 {
	
  if (document.getElementById(formfields[x]).value =="")
							   {
								   formfields[x]+="_lbl";
					//alert(document.getElementById(formfields[x]).value);			   
				document.getElementById(formfields[x]).style.visibility='visible';
								  errors="1";
								  
							   }
			
				  }
		  }
		  
		  
		  if(errors !="")
		  {
			  errors=null;
			  return false;
		  }
		  else
		  {
			  return true;
		  }
		 
 
}





