expires = new Date();
expires.setTime (expires.getTime() + 24 * 60 * 60 * 150 * 1000);



function set(){
if (document.dataform.S_name.value == "")
{
    alert ("يرجى ملء اسمك.");
	document.dataform.S_name.focus();
    return (false);
}
if (document.dataform.S_organization.value == "")
{
    alert ("يرجى ملء اسم الشركة أو المؤسسة.");
	document.dataform.S_organization.focus();
    return (false);
}
if (document.dataform.S_streetaddress.value == "")
{
    alert ("يرجى تعبئة في عنوانك.");
	document.dataform.S_streetaddress.focus();
    return (false);
}
if (document.dataform.S_city.value == "")
{
    alert ("يرجى تعبئة في مدينتك.");
	document.dataform.S_city.focus();
    return (false);
}
if (document.dataform.S_state.value == "")
{
    alert ("يرجى تعبئة في دولتكم.");
	document.dataform.S_state.focus();
    return (false);
}
if (document.dataform.S_pin.value == "")
{
    alert ("يرجى تعبئة الرقم السري الخاص بك.");
	document.dataform.S_pin.focus();
    return (false);
}
if (document.dataform.S_country.value == "")
{
    alert ("يرجى ملء في بلدكم.");
	document.dataform.S_country.focus();
    return (false);
}
if (document.dataform.S_phone.value == "")
{
    alert ("يرجى تعبئة في رقم الهاتف الخاص بك.");
	document.dataform.S_phone.focus();
    return (false);
}
if (document.dataform.S_email.value == "")
{
    alert ("يرجى ملء في الهوية البريد الإلكتروني");
	document.dataform.S_email.focus();
    return (false);
}
if(document.dataform.S_email.value.indexOf(" ") >= 0)
{
	alert("الرجاء كتابة البريد الالكتروني معرف دون استخدام أية مسافات بيضاء أو الفراغات..");
	document.dataform.S_email.focus();
	return (false);
}
if ( (document.dataform.S_email.value.indexOf("@") == -1) || (document.dataform.S_email.value.indexOf(".") == -1) )
{
	alert("الرجاء إدخال بريد إلكتروني صالح الهوية"); 
	document.dataform.S_email.focus();
	return (false);
}

BeforeAtRate = document.dataform.S_email.value.substring(0,document.dataform.S_email.value.indexOf("@"));
AfterAtRate = document.dataform.S_email.value.substring(document.dataform.S_email.value.indexOf("@")+1,document.dataform.S_email.value.length);
if (AfterAtRate.indexOf(".") == -1)
{
	alert("الرجاء إدخال بريد إلكتروني صالح الهوية"); 
	document.dataform.S_email.focus();
	return (false);
}
middle = AfterAtRate.substring(0, AfterAtRate.indexOf("."));
last = AfterAtRate.substring(AfterAtRate.indexOf(".") + 1,AfterAtRate.length);
if (BeforeAtRate.length == 0 || middle.length == 0 || last.length == 0)
{
	alert("الرجاء إدخال بريد إلكتروني صالح الهوية"); 
	document.dataform.S_email.focus();
	return (false);
}


var sizes = new Array;
sizes[0]=document.dataform.size01.checked;
sizes[1]=document.dataform.size02.checked;
sizes[2]=document.dataform.size03.checked;
sizes[3]=document.dataform.size04.checked;
sizes[4]=document.dataform.size05.checked;
sizes[5]=document.dataform.size06.checked;

if(sizes[0]==false && sizes[1]==false && sizes[2]==false && sizes[3]==false && sizes[4]==false && sizes[5]==false)
{
alert("الرجاء اختيار واحد على الأقل لحجم عينات مجانية");
document.dataform.size06.focus();
return false;
}

for(i=0;i<sizes.length;i++)
{
 	if(sizes[i] == true)
	{
		j=i+1;
		pth1 = "document.dataform.size0"+j;
		pth = "document.dataform.cap_color"+j;
		pth2 = "document.dataform.body_color"+j;
				
		if(sizes[i]!=false)
		{
			if(eval(pth).value=="")
			{
				alert("الرجاء إدخال لون غطاء من الكبسولة ، لعينات مجانية من حجم 0 كبسولات.  "+ i);
				eval(pth).focus();
				return false;
			}
			if(eval(pth2).value=="")
			{
				alert("الرجاء إدخال لون الجسم من الكبسولة ، لعينات مجانية من حجم 0 كبسولات.  "+i);
				eval(pth2).focus();
				return false;
			}
		}
		else
		{
			alert("Please select Free Sample Size0"+i);
			eval(pth1).focus();
			return false;
		}
	}

}
if (document.dataform.captcha_text.value.length == 0)  {
		alert ("Kindly enter security code as shown in image.");
		document.dataform.captcha_text.focus();
		return false;
	}

newCookie = document.dataform.S_name.value;
newCookie +="|"+document.dataform.S_email.value;
newCookie +="|"+document.dataform.S_phone.value;

newCookie +="|"+document.dataform.S_streetaddress.value;
newCookie +="|"+document.dataform.S_city.value;

newCookie +="|"+document.dataform.S_organization.value;
newCookie +="|"+document.dataform.S_state.value;
setCookie("newImeshID",newCookie);
return true;
}
var d = new Date();
	var epoch_time =(d.getTime()-d.getMilliseconds())/1000;
	var randomnumber=Math.floor(Math.random()*9999);
	var randomnumber1=Math.floor(Math.random()*9999);
	var ran_num=randomnumber+"."+epoch_time+"."+randomnumber1;
	var url="/cgi/get_captcha.cgi?cref="+ran_num+"&style=2";

function checknum(temp)
{
	str=temp.value;
	str1="";
	for(i=0;i<str.length;i++)
	{
		c=str.charAt(i);
		if(!(c=='0' || c=='1' || c=='2' || c=='3' || c=='4' || c=='5' || c=='6' || c=='7' || c=='8' || c=='9'))
		{
			alert("Please Enter Numbers Only");
			temp.value=str1;
			break;
		}
		str1+=c;
	}
}
function get(){
if( (cookie = getCookie("newImeshID")) > ""){
	Values = cookie.split("|");
	if (Values.length >= 7){
		if (document.dataform.S_name.value.length == 0) document.dataform.S_name.value = Values[0];
		if (document.dataform.S_email.value.length == 0)    document.dataform.S_email.value = Values[1];
		if (document.dataform.S_phone.value.length == 0)    document.dataform.S_phone.value=Values[2];
		if (document.dataform.S_fax.value.length == 0)      document.dataform.S_fax.value=Values[3];
		if (document.dataform.S_streetaddress.value.length == 0) document.dataform.S_streetaddress.value=Values[4];
		if (document.dataform.S_city.value.length == 0)  document.dataform.S_city.value=Values[5];
		if (document.dataform.S_pin.value.length == 0) document.dataform.S_pin.value = Values[6];
  if (document.dataform.S_organization.value.length == 0) document.dataform.S_organization.value = Values[7];
  if (document.dataform.S_state.value.length == 0) document.dataform.S_state.value = Values[8];

	}
}
return true;
}
function setCookie(name, value){
if (value.length > 0)
 document.cookie = name + "=" + escape(value)+ ";"+"expires=" + expires.toGMTString()+";"
}
function getCookie(Name) {
          var search = Name + "="
          if (document.cookie.length > 0) { // if there are any cookies
                    offset = document.cookie.indexOf(search) 
                    if (offset != -1) { // if cookie exists 
                              offset += search.length 
                              // set index of beginning of value
                              end = document.cookie.indexOf(";", offset) 
                              // set index of end of cookie value
                              if (end == -1) end = document.cookie.length
                              return unescape(document.cookie.substring(offset, end))
                    } 
          }
return "";
}