// JavaScript Document
////////////////////////////////dynamic iframe function////////////////////////
function focusonfield()
{
document.all.pname.focus();
}
////////////////////////////////////////////////////////////////////////
////////////////////////////check yes and no choice and disable objects///////
function isSelected()
{
	if (document.check1.state.value==34)
	check1.otherstate.disabled=false
} 

/////////////////////////////////////////////////////

///////////////////////////////ismail function/////////////////
var pos;
var pos2;
function ismail(s)
{
 if(s == "")
 {
	alert("Please Enter a valid e-mail address");
	document.bookingfrm.mail.focus();
	return false;
	}
 pos = s.indexOf('@',1);
 if((pos == -1) || (pos == (s.length-1)))
 {
	alert("Please Enter a valid e-mail address");
	document.bookingfrm.mail.focus();
	return false;
 }
 pos2 = s.indexOf('.',1);
 if((pos2 == -1) || (pos2 == (s.length-1)))
 {
	alert("Please Enter a valid e-mail address");
	document.bookingfrm.mail.focus();
	return false;
 }
return true;
}
/////////////////////////////////////End/////////////////////////////////////

///////////////////////////////isempty function/////////////////////
var whitespace="\t\n\r";

function isEmpty(s)
{
  var i;

     if((s==null) || (s.length==0))
     	return true;

        for(i=0;i<s.length;i++)
          {
            var c=s.charAt(i);

            if(whitespace.indexOf(c)==-1)
            return false;
          }
     return true;
}
////////////////////////////////End/////////////////////////////////////

/////////////////////////////validatia fun including isempty function_booking Form/////////////////////
function validate()

{
//alert('koko');
	  if (isEmpty(document.all.pname.value))
         {
           alert("Name required !! ");
           document.all.pname.focus();
		   return false;
		  }
		   if (isEmpty(document.all.pid.value))
         {
           alert("User Name required !! ");
           document.all.pid.focus();
		   return false;
		  }
		   if (isEmpty(document.all.pass.value))
         {
           alert("Password required !! ");
           document.all.pass.focus();
		   return false;
		  }
		   if (isEmpty(document.all.pass2.value))
         {
           alert("plz,re-enter your password !! ");
           document.all.pass2.focus();
		   return false;
		  }
		  if(!(document.all.pass.value == document.all.pass2.value))
		  {
           alert("password didn`t match !! ");
           document.all.pass2.focus();
		   return false;
		  
		  }
		  
		   if (isEmpty(document.all.paddress1.value))
         {
           alert("Address required !! ");
           document.all.paddress1.focus();
		   return false;
		  }
		   if (isEmpty(document.all.pcity.value))
         {
           alert("city required !! ");
           document.all.pcity.focus();
		   return false;
		  }
		   if (isEmpty(document.all.pstate.value))
         {
           alert("State required !! ");
           document.all.pstate.focus();
		   return false;
		  }
		  /* if (isEmpty(document.all.pcountry.value))
         {
           alert("Country required !! ");
           document.all.pcountry.focus();
		   return false;
		  }*/
		   if (isEmpty(document.all.pzip.value))
         {
           alert("Postal code required !! ");
           document.all.pzip.focus();
		   return false;
		  }
		   if (isEmpty(document.all.name.value))
         {
           alert("recipiant name required !! ");
           document.all.name.focus();
		   return false;
		  }
		   if (isEmpty(document.all.address1.value))
         {
           alert("shipping address required !! ");
           document.all.address1.focus();
		   return false;
		  }
		   if (isEmpty(document.all.city.value))
         {
           alert("Shiiping city required !! ");
           document.all.city.focus();
		   return false;
		  }
		  /*if (isEmpty(document.form1.state.value))
         {
           alert("Shiiping State required !! ");
           document.form1.state.focus();
		   return false;
		  }*/
		  if (isEmpty(document.all.postalCode.value))
         {
           alert("Shiiping postal code required !! ");
           document.all.postalCode.focus();
		   return false;
		  }
		 /* if (isEmpty(document.all.countryName.value))
         {
           alert("Shiiping Country required !! ");
           document.all.countryName.focus();
		   return false;
		  }*/
		  if (isEmpty(document.all.contactPerson.value))
         {
           alert("Contact Person  required !! ");
           document.all.contactPerson.focus();
		   return false;
		  }
////////////////////////mail 1 /////////////////////////////////
var pos;
var pos2;
var s=document.all.pemail.value;
//var s2=document.all.pemail.value;
 if(s == "")
 {
	alert("Please Enter a valid Contact e-mail address");
	document.all.pemail.focus();
	return false;
 }
 pos = s.indexOf('@',1);
 if((pos == -1) || (pos == (s.length-1)))
 {
	alert("Please Enter a valid Contact e-mail address");
	document.all.pemail.focus();
	return false;
 }
 pos2 = s.indexOf('.',1);
 if((pos2 == -1) || (pos2 == (s.length-1)))
 {
	alert("Please Enter a valid Contact e-mail address");
	document.all.pemail.focus();
	return false;
 }
 if(s.charAt(s.length-1)=='@' || s.charAt(s.length-1)=='.')
 {
	alert("Please Enter a valid Contact e-mail address");
	document.all.pemail.focus();
	return false;
 
 }
 if(s.charAt(0)=='@' || s.charAt(0)=='.')
 {
	alert("Please Enter a valid Contact e-mail address");
	document.all.pemail.focus();
	return false;
 
 }
 if(isEmpty(s))
 {
	alert("a valid Contact e-mail address must not contain spaces");
	document.all.pemail.focus();
	return false;
 
 }
 /////////////// mail 2 ////////////////////////////
 
 var poss;
var poss2;
var s2=document.all.email.value;

 if(s2 == "")
 {
	alert("Please Enter a valid Shipping e-mail address");
	document.all.email.focus();
	return false;
 }
 pos = s.indexOf('@',1);
 if((poss == -1) || (poss == (s2.length-1)))
 {
	alert("Please Enter a valid Shipping e-mail address");
	document.all.email.focus();
	return false;
 }
 poss2 = s2.indexOf('.',1);
 if((poss2 == -1) || (poss2 == (s2.length-1)))
 {
	alert("Please Enter a valid Shipping e-mail address");
	document.all.email.focus();
	return false;
 }
 if(s.charAt(s2.length-1)=='@' || s2.charAt(s.length-1)=='.')
 {
	alert("Please Enter a valid Shipping e-mail address");
	document.all.email.focus();
	return false;
 
 }
 if(s2.charAt(0)=='@' || s2.charAt(0)=='.')
 {
	alert("Please Enter a valid Shipping e-mail address");
	document.all.email.focus();
	return false;
 
 }
if(isEmpty(s2))
 {
	alert("a valid Shipping e-mail address must not contain spaces");
	document.all.email.focus();
	return false;
 
 }

////////////////////////////////////////////////////
/*if (isEmpty(document.bookingfrm.orgin.value))
   {
     alert("Orgine required !! ");
     document.bookingfrm.orgin.focus();
     return false;
	}

if (isEmpty(document.bookingfrm.dest.value))
   {
	 alert("destintion required !! ");
	 document.bookingfrm.dest.focus();
	 return false;
    }

if (isEmpty(document.bookingfrm.comm.value))
   {
     alert("commodity required !! ");
	 document.bookingfrm.comm.focus();
	 return false;
   }
	   return true;

*/
return true;
}

//////////////////////////////////////End////////////////////////////////////////////////

///////////////////////validatia fun including isempty function_booking arabic Form/////////////////////


//function Validate() {
//	// Check for Empty fields
//	if (document.check1.pname.value == "" || document.check1.pid.value == "" || document.check1.pass.value == "" || document.check1.pass2.value == "" || document.check1.paddress1.value == ""
//	|| document.check1.pcity.value == "" || document.check1.pstate.value == "" || document.check1.pcountry.value == "" || document.check1.pzip.value == "" || document.check1.pemail.value == "" || document.check1.name.value == "" 
//	|| document.check1.address1.value == "" || document.check1.city.value == "" || document.check1.state.value == "" || document.check1.postalCode.value == "" || document.check1.countryName.value == "" || document.check1.email.value == "" || document.check1.contactPerson.value == "") 
//	{
//		alert ("You must complete all of the form");
//		return false;
//	}
	// Have we checked the checkbox?
//	if (document.check1.pstate.value == "Outside Egypt") 
//	{
//	 document.check1.potherstate.disabled=false
//	}
//	if (document.check1.state.value == "34") 
//	{
//	 document.check1.otherstate.disabled=false
//	}
//}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////




function check()
{

if (isEmpty(document.all.pCode.value))
         {
           alert("Product Code required !! ");
           document.all.pCode.focus();
		   return false;
		  }
if (isEmpty(document.all.pNameE.value))
         {
           alert("Product english name required !! ");
           document.all.pNameE.focus();
		   return false;
		  }
if (isEmpty(document.all.pnameA.value))
         {
           alert("Product arabic name required !! ");
           document.all.pnameA.focus();
		   return false;
		  }
if (isEmpty(document.all.pDelTime.value))
         {
           alert("Product English Delivery Date required !! ");
           document.all.pDelTime.focus();
		   return false;
		  }
if (isEmpty(document.all.pDelTimeA.value))
         {
           alert("Product arabic Delivery Date required !! ");
           document.all.pDelTimeA.focus();
		   return false;
		  }
if (isEmpty(document.all.pprice.value))
         {
           alert("Product english Price required !! ");
           document.all.pprice.focus();
		   return false;
		  }
if (isEmpty(document.all.ppriceA.value))
         {
           alert("Product arabic Price required !! ");
           document.all.ppriceA.focus();
		   return false;
		  }
if (isEmpty(document.all.psubCatCode.value))
         {
           alert("Product Sub-Category Code required !! ");
           document.all.psubCatCode.focus();
		   return false;
		  }
if (isEmpty(document.all.pQuantity.value))
         {
           alert("Product Quantity required !! ");
           document.all.pQuantity.focus();
		   return false;
		  }
		 
		return true;  
}
////////////////////////get url///////////////////
function getUrl(){
var x=document.getElementById("link");
//var check=window.location;
//alert(url);
window.open("tellFriend.jsp?check=home","","width=500,height=225,left=100");
}
////////////////////////////////////////////////////////