function validReg()
{


  for(i=0;i<19;i++)
 {

  if (i!=3 &&  i!=10 && i!=11 && i!=13 && i!=16&& i!=17)
    {
  
     val=document.frmReg.elements[i].value
     if(val=="")
       {
	   	  
	  	alert("Please insert all required data");		
	    document.frmReg.elements[i].focus();		
	    document.frmReg.elements[i].select();
		
	    return false
	    }//if
	 
	 }//if
	 
	 
	 
 }//for
return true;

   }//fun
   

//-------------------------------------------------------------------//
function validSel(y)
{
	
		  x=y.selectedIndex;
		  if (x==0)
		  {
			alert("Please insert all required data");		
	        y.focus();	
			 return false;
	   
		  }
		   return true;
	 
}


//------------------------------------------------------------------//

 function validMail(y)
{

if(y.value.length>0)
{
	if (y.value.indexOf("@")== "-1" || y.value.indexOf(".")== "-1")
	{
	alert("Please enter a valid email.");
	y.focus();
	return (false);
	}
	
	
}

return true;

}
//-----------------------------------------------------------------//


function validEmptyGeneral(x)
{

if(x.value == "" || x.value == 0)
	{
	alert("Please insert all required data")
	x.select
	x.focus()
	return false;
	}
	
	return true;
}//whene call it  validateEmptyGeneral(formName.elementName)

//--------------------------------------------------------------------//


function validNum(y)
{
	

 val=y.value ;

if (val!="")

{
   
    str="0123456789 ";
    len=y.value.length;
	//alert(len)

   for(x=0;x<len;x++ )
      {
        if(str.indexOf(y.value.charAt(x))==-1)
        {
         alert("please Insert Number Only\n(don't include characters,space,'-','/')")
         y.focus();
		 y.select()
      
         return false;
       }//if
 
   }//for
   
 }//if
 
 
 return true;
 }

//--------------------------------------------------------------//

function validYear(x)
{
val=x.value ;
if (val!="")
{
  if(x.value.length!=4)
   {
     alert("Year must be 4 digits")
     x.focus();
     x.select();
     return false;
    }//if
 }//if
 return true;
 
 }//fun

//-----------------------------------------------------------------

function validChar(x)
{
	
str="0123456789"

val=x.value
len=val.length


for(i=0;i<len;i++)
  {
  ch=val.charAt(i)
  if(str.indexOf(ch)!=-1)
    {
	alert("Please enter a valid name")
	x.focus()
	x.select()
	return false
    }
  }

  return true
}

//-------------------------------------------------------------

function checkLogin(ID)
{


 if (ID==0)
   {
    alert("You Must Login First");
    return false
   }

return true

}

//===========================checkRad========================

function checkRad(obj)
{

//alert(obj);
len=obj.length;



if(len==null)
{
if(obj.checked)
{	


  if ( obj.value=="q" && frmQuote.quantity.value=="" )
     {
	 	alert("you must insert quantity")
		frmQuote.quantity.select();
		frmQuote.quantity.focus();
		return false;
	  }
	  
  if ( obj.value=="s" && frmQuote.sample.value=="" )
     {
	 	alert("you must insert representative sample");
		frmQuote.sample.select();
		frmQuote.sample.focus();
		return false;
	  }
  return true;
}
 
alert (" You Must Choose  First ")
return false
}

else
{

for(i=0;i<len;i++)
  {
  if(obj[i].checked)
  {
  
	
  if ( obj[i].value=="q" && frmQuote.quantity.value=="" )
     {
		alert("you must insert quantity");
		frmQuote.quantity.select();
		frmQuote.quantity.focus();
		return false;
	 }
	
   if ( obj[i].value=="s" && frmQuote.sample.value=="" )
    {
		alert("you must insert representative sample");
		frmQuote.sample.select();
		frmQuote.sample.focus();
		return false;
		
	}
  
    return true;
   }
  
  }//for
 
  alert ("You Must Choose  First ")
  return false
 }//else
  
}//function


//==================================================================
function checkRadCart(objRad,count)
{


for(i=1;i<count;i++) //len=session("counter")-deleted
  {
	
	if (objRad+i != null)
	 {
   //alert("not null") ;
   
   x=objRad+i;

alert("before check");
   
  if (checkRad(x))
  {
	  alert("check done")
	  return true;
  }
  
  //return false;
  /*if(obj+i.checked )
  {
	   x="frmCart.r1"
  	alert(frmCart.r1.value);
	return false;
 /* if ( obj+i.value=="q" && frmQuote.quantity.value=="" )
     {
		alert("you must insert quantity");
		frmQuote.quantity.select();
		frmQuote.quantity.focus();
		return false;
	 }
	
   if ( obj+i.value=="s" && frmQuote.sample.value=="" )
    {
		alert("you must insert representative sample");
		frmQuote.sample.select();
		frmQuote.sample.focus();
		return false;
		
	}*/
  
    //return true;
   //}
	  }//if obj
  
  }//for
 
  alert ("You Must Choose  First ")
  return false;

  
}//function

//==================================================================


function confirmPass()
{
	
	val=document.frmReg.password.value
	val2=document.frmReg.password2.value
	
	
	if (val!=val2)
	
	
	  {
		
		alert("password and Confirm Password must be identical")
		
	    document.frmReg.password2.focus()
	    document.frmReg.password2.select()
	    return false;
	  }
	  return true;
}


//-------------------------------------------------//


function validLen()
{

	
	len1=document.frmReg.username.value.length;
   len2=document.frmReg.password.value.length;
	
	
	if (len1<4 || len1>12  )
	{
		alert("username must be 4 to 12 characters");
		
	    document.frmReg.username.focus();
	    document.frmReg.username.select();
	    return false;
	}
	
	if (len2<4 || len1>12)
	{
		alert("password must be 4 to 12 characters");
		
	    document.frmReg.password.focus();
	    document.frmReg.password.select();
	    return false;
	}
	
	
	return true;
	
}

//--------------------------------------------------------

function otherValid()
{
	if (document.frmReg.city.value =="" && document.frmReg.city2.value=="")
   {
    alert("Please insert all required data")
    document.frmReg.city.focus()
    return false;
   }
   



if (document.frmReg.companyField.value =="" && document.frmReg.field2.value=="")
   {
    alert("Please insert all required data")
    document.frmReg.companyField.focus()
    return false;
   }

return true;
}
//----------------------------------------------------//


function validNumber()
{
 if (validNum(frmReg.phone1)&&validNum(frmReg.phone2)&&validNum(frmReg.mobile)&&validNum(frmReg.fax)&&validNum(frmReg.zipCode)&&validNum(frmReg.estYear)&&validNum(frmReg.empNo))
  {
  return true;
  }

  else
  {
  return false;
  }


}
///------------------OnBlur--OnFocus Functions---------------/////
function valOnBlur(ID,spanID,page,xID)
{
document.getElementById(spanID).innerHTML=""


if(document.getElementById(ID).value!=""&& document.getElementById(ID).value.length >3 &&document.getElementById(ID).value.indexOf(" ")==-1)
{
	
	if (ID=="username" )
	{
		
		if (page=="train")
		
		showHint(document.getElementById(ID).value,'../valid.asp','seeker','usr',xID)
		
		else
		
		showHint(document.getElementById(ID).value,'valid.asp','seeker','usr',xID)
			
    }
 
}
else
{
	 document.getElementById(spanID).innerHTML="Please enter a valid "+ID+""
}



}
///////////////////////////////////////////

function valOnFocus(spanID)
{
document.getElementById(spanID).innerHTML="4 to 12 characters (A-Z, a-z, 0-9, no spaces)" ;
}
///////////////////////////////////////

function onBlurPass()
{
    val=document.frmReg.password.value
	val2=document.frmReg.password2.value
	
	
	if (val!=val2)
	
	
	  {
		
		document.getElementById("pass2").innerHTML="password and Confirm Password must be identical"
	   
	  }
	  
	  else
	{
		document.getElementById("pass2").innerHTML=""
	}
	  
}
/////////////////////////////////////////////////

function onBlurEmail()
{
	
	
	if(document.frmReg.email.value.length>0)
     {
	if (document.frmReg.email.value.indexOf("@")== "-1" || document.frmReg.email.value.indexOf(".")== "-1")
	{
		document.getElementById("mail").innerHTML="Please enter a valid email."
	
	
	}
	
	  else
	{
		document.getElementById("mail").innerHTML=""
	}
    }

}



/////////////////////////////

function validSpChar(y)
{
	
	
	if(y.value.length>0)
  {
	if (y.value.indexOf("'")!= "-1" || y.value.indexOf(".")!= "-1" || y.value.indexOf(" ")!= "-1" )
	{
	alert("Please enter a valid "+y.name);
	y.focus();
	return (false);
	}
	
	
}

return true;
}


function disEnab(d,e)
{
	  
   d.disabled="true";     
   e.disabled=false;
   
  
   
}



//===================================
function checkd(y)
{
len=y.length
if(len==null)
{
if(y.checked)
  return true;
alert (" Choose  First ")
return false;
}
else
{
for(i=0;i<len;i++)
 {
  if(y[i].checked)
  {
 
if(confirm(" Are You Sure You Want To Delete "))
{ return true;}
else
{ return false;}

    
  }
  }
 
  alert (" Choose  First ")
  return false;
  
}
}
//=============================================
function ConfirmDel()
{
 	if(confirm(" Are You Sure You Want To Delete "))
   { return true;}
  else
   { return false;}
}
//==================================================
function srCheckEmpty()
{

  
   val=document.frmSearch.searchtxt.value
   if(val=="")
     {
	 alert("Please enter some keywords to search.")
	 document.frmSearch.searchtxt.focus()
	 document.frmSearch.searchtxt.select()
	 return false
	 }
  
 
   return true
}
////////////////////////////////////////////////////
function checkNumb()
{
len1=document.frmSearch.searchtxt.value.length;

 if (len1<3)
  {
     alert("Search text must be 3 characters at least.")
	 document.frmSearch.searchtxt.focus()
	 document.frmSearch.searchtxt.select()
	  return false
   }
   
 
   return true
}
///////////////////////////////////////////////////////
function validation()
{
if(srCheckEmpty()&&checkNumb())
{

  frmSearch.submit()
  return true;
 
 }
 else{

  return false;
  }
}


//===========================checkGender========================

function checkGender(obj)
{
len=obj.length
if(len==null)
{
if(obj.checked)
  return true;
alert (" You Must Choose Gender")
return false;
}
else
{
for(i=0;i<len;i++)
 {
  if(obj[i].checked)
  {
 
return true;

    
  }
  }
 
 alert (" You Must Choose Gender")
  return false;
  
}
}




//==================================================================



function PrintPage()
{
var gAutoPrint = true;
if (document.getElementById != null)

{
var html = '<HTML>\n<HEAD>\n';
html += '<link href=\"css/new-style.css\" rel=\"stylesheet\" type=\"text/css\">'
html += '\n</HE' + 'AD>\n<BODY>\n';
html += '<table width=\"575\"  border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align="\center\"><tr>';
html += '<td valign=\"middle\"><div align=\"left\"><a href=\"javascript:window.close();\">close window</a></div></td>'
//html += '<td valign=\"bottom\"><div align=\"right\"><img src=\"assets/logo.gif\" ></div></td></tr>'

html += '<tr><td colspan="\2\" ><hr width="\575\" align="\center\"></td></tr>'
html += '<tr><td align="\center\"  colspan="\2\">';
var printReadyElem = document.getElementById("PrintTD");
if (printReadyElem != null)
{
html += printReadyElem.innerHTML;
}
else
{
alert("Could not find the printReady section in the HTML");
return;
}
html += '</td></tr> <tr><td height="\20\" colspan="\2\"><br><br></td></tr><tr><td align="\center\"  colspan="\2\">';



html += 'Copyright &copy; 2008 A. Fakhry & Co All Rights Reserved.  Powered by   EGO solutions';
html += '</td></tr></table>\n';

html += '\n</BO' + 'DY>\n</HT' + 'ML>';
var printWin = window.open("","");
printWin.document.open();
printWin.document.write(html);
printWin.document.close();
if (gAutoPrint)
printWin.print();
}
else
{
alert("Sorry, the print ready feature is only available in modern browsers.");
}
}




//==================================================================


