expires = new Date();
expires.setTime (expires.getTime() + 24 * 60 * 60 * 150 * 1000);
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 set()
{
var temp2 =document.dataform.Description.value;
var temp3 = temp2.replace(/\s/gi,"");
if(temp3.length == 0)
{
alert ("Kindly describe your requirement.");
document.dataform.Description.value='';
document.dataform.Description.focus();
return false;
}
if (document.dataform.S_name.value.length == 0)  {
alert ("Kindly enter your name.");
document.dataform.S_name.focus();
return false;
}
var temp =document.dataform.S_name.value;
var temp1 = temp.replace(/ /gi,"");
if(temp1.length == 0)
{
alert ("Kindly enter your name.");
document.dataform.S_name.value='';
document.dataform.S_name.focus();
return false;
}
if (document.dataform.S_email.value.length == 0) 
{
alert("Kindly enter your Email ID.");
document.dataform.S_email.focus();
return false;
}
if(document.dataform.S_email.value.indexOf(" ") >= 0)
{
alert("Please enter your email id without any space.");
document.dataform.S_email.focus();
return (false);
}
if ( (document.dataform.S_email.value.indexOf("@") == -1) || (document.dataform.S_email.value.indexOf(".") == -1) )
{
alert("Please enter a valid email id.");
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("Please enter a valid email id.");
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("Please enter a valid email id.");
document.dataform.S_email.focus();
return (false);
}
if (document.dataform.S_country.selectedIndex == "")  
{
alert ("Kindly select your country name.");
document.dataform.S_country.focus();
return false;
}
if(document.dataform.S_acode.value > ""  && document.dataform.S_acode.value != "Area Code"){
if (isNaN(document.dataform.S_acode.value)) {
alert ("Kindly enter valid area code number.");
document.dataform.S_acode.focus();
return false;
}
var temp =document.dataform.S_acode.value;
var temp1 = temp.replace(/ /gi,"");
if(temp1.length == 0)
{
alert ("Kindly enter valid area code number.");
document.dataform.S_acode.value='';
document.dataform.S_acode.focus();
return false;
}
}
if ((document.dataform.S_phone.value.length == 0 || document.dataform.S_phone.value == "Phone Number") && (document.dataform.S_mobile.value.length == 0 || document.dataform.S_mobile.value == "Mobile / Cell Phone Number"))
{
alert ("Kindly enter either telephone number or mobile number.");
document.dataform.S_phone.focus();
return false;
}
if(document.dataform.S_phone.value)
{
var val = document.dataform.S_phone.value;
val = val.replace(/\s/g, "");
if(val.length == 0)
{
alert ("Kindly enter valid phone number.");
document.dataform.S_phone.focus();
return false;
}
}
if ((document.dataform.S_phone.value.length > "") && (document.dataform.S_phone.value != "Phone Number"))
{
if(isNaN(document.dataform.S_phone.value))
{
alert ("Kindly enter valid phone number.");
document.dataform.S_phone.focus();
return false;
}
}
if(document.dataform.S_mobile.value)
{
var val = document.dataform.S_mobile.value;
val = val.replace(/\s/g, "");
if(val.length == 0)
{
alert ("Kindly enter valid mobile / cell phone number.");
document.dataform.S_mobile.focus();
return false;
}
}
if((document.dataform.S_mobile.value > "")  && (document.dataform.S_mobile.value != "Mobile / Cell Phone Number"))
{
if (isNaN(document.dataform.S_mobile.value))
{
alert ("Kindly enter valid mobile / cell phone number.");
document.dataform.S_mobile.focus();
return false;
}
}
var captcha_txt = document.getElementsByName("captcha_text");
var captcha_txt_len = captcha_txt.length;
if(captcha_txt_len == 1)
{
if (document.dataform.captcha_text.value.length == 0)  {
alert ("Kindly enter the code as appearing in the Image.");
document.dataform.captcha_text.focus();
return false;
}
}
if ( (document.dataform.S_acode.value == "Area Code"))
{
document.dataform.S_acode.value="";
} 
if ( (document.dataform.S_phone.value == "Phone Number"))
{
document.dataform.S_phone.value="";
} 
if ( (document.dataform.S_mobile.value == "Mobile / Cell Phone Number"))
{
document.dataform.S_mobile.value="";
} 
newCookie = document.dataform.S_name.value;
newCookie +="|"+document.dataform.S_email.value;
newCookie +="|"+document.dataform.S_organization.value;
newCookie +="|"+document.dataform.S_streetaddress.value;
newCookie +="|"+document.dataform.S_city.value;
newCookie +="|"+document.dataform.S_state.value;
newCookie +="|"+document.dataform.S_pin.value;
setCookie("newImeshID",newCookie);
return true;
}

function get()
{
var captcha_txt = document.getElementsByName("captcha_text");
var captcha_txt_len = captcha_txt.length;



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_organization.value.length == 0) document.dataform.S_organization.value=Values[2];
if (document.dataform.S_streetaddress.value.length == 0) document.dataform.S_streetaddress.value = Values[3];
if (document.dataform.S_city.value.length == 0) document.dataform.S_city.value = Values[4];
if (document.dataform.S_state.value.length == 0) document.dataform.S_state.value = Values[5];
if (document.dataform.S_pin.value.length == 0) document.dataform.S_pin.value = Values[6];
}
}
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) 
{ 
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 "";
}


 var is_input = document.URL.indexOf('?');
var pcode = '';
var pname = '';

if (is_input != -1)
{
addr_str = document.URL.substring(is_input+1, document.URL.length);
strarr = addr_str.split("&");
pname = unescape((strarr[0].split("="))[1]);
pname = pname.replace(/\+/g," ");
if(strarr[1])
{
pcode_name = unescape((strarr[1].split("="))[0]);
pcode_value = unescape((strarr[1].split("="))[1]);
}
else
{
pcode_name = '';
pcode_value = '';
}
}

/*----For Description Text Status----*/


var fieldlimiter={

defaultoutput: "<b>[int]</b> characters remaining in your input limit.", //default message that gets output to statusid element

uncheckedkeycodes: /(8)|(13)|(16)|(17)|(18)/, //keycodes that are not checked, even when limit has been reached. See http://www.javascriptkit.com/jsref/eventkeyboardmouse.shtml for avail keycodes

limitinput:function(e, config){
var e=window.event || e
var thefield=config.thefield
var keyunicode=e.charCode || e.keyCode
if (!this.uncheckedkeycodes.test(keyunicode)){
if (thefield.value.length>=config.maxlength){
if (e.preventDefault)
e.preventDefault()
return false
}
}
},

showlimit:function(config){
var thefield=config.thefield
var statusids=config.statusids
var charsleft=config.maxlength-thefield.value.length
if (charsleft<0) //if user has exceeded input limit (possible if cut and paste text into field)
thefield.value=thefield.value.substring(0, config.maxlength) //trim input
for (var i=0; i<statusids.length; i++){
var statusdiv=document.getElementById(statusids[i])
if (statusdiv) //if status DIV defined
statusdiv.innerHTML=this.defaultoutput.replace("[int]", Math.max(0, charsleft))
}
config.onkeypress.call(thefield, config.maxlength, thefield.value.length)
},

cleanup:function(config){
for (var prop in config){
config[prop]=null
}
},


addEvent:function(targetarr, functionref, tasktype){
if (targetarr.length>0){
var target=targetarr.shift()
if (target.addEventListener)
target.addEventListener(tasktype, functionref, false)
else if (target.attachEvent)
target.attachEvent('on'+tasktype, function(){return functionref.call(target, window.event)})
this.addEvent(targetarr, functionref, tasktype)
}
},

setup:function(config){
if (config.thefield){ //if form field exists
config.onkeypress=config.onkeypress || function(){}
config.thefield.value=config.thefield.value
this.showlimit(config)
this.addEvent([window], function(e){fieldlimiter.showlimit(config)}, "load")
this.addEvent([window], function(e){fieldlimiter.cleanup(config)}, "unload")
this.addEvent([config.thefield], function(e){return fieldlimiter.limitinput(e, config)}, "keypress")
this.addEvent([config.thefield], function(){fieldlimiter.showlimit(config)}, "keyup")
}
}

}

function style1()
 {
if (document.dataform.S_acode.value != 'Area Code')
{
 document.dataform.S_acode.className = 'field';
}
if(document.dataform.S_acode.value == '')
{
 document.dataform.S_acode.value = 'Area Code'
 document.dataform.S_acode.className = 'field1';
}

if (document.dataform.S_phone.value != 'Phone Number')
{
 document.dataform.S_phone.className = 'field';
}
if(document.dataform.S_phone.value == '')
{
 document.dataform.S_phone.value = 'Phone Number'
 document.dataform.S_phone.className = 'field1';
}

if (document.dataform.S_mobile.value != 'Mobile / Cell Phone Number')
{
 document.dataform.S_mobile.className = 'field';
}
if(document.dataform.S_mobile.value == '')
{
 document.dataform.S_mobile.value = 'Mobile / Cell Phone Number'
 document.dataform.S_mobile.className = 'field1';
}

 }

function assignPhoneCode(code)
{
document.dataform.S_ccode.value=code;
document.dataform.S_cmobile.value=code;
}

function AreaValue(FieldName)
{
if(FieldName.value == 'Area Code')
{
FieldName.value = '';
FieldName.className='field';
}
}
function AreaValue1(FieldName)
{
if(FieldName.value == '')
{
FieldName.value = 'Area Code';
FieldName.className='field1';
}
else
{
FieldName.className='field';
}
}

function PhoneValue(FieldName)
{
if(FieldName.value == 'Phone Number')
{
FieldName.value = '';
FieldName.className='field';
}
}
function PhoneValue1(FieldName)
{
if(FieldName.value == '')
{
FieldName.value = 'Phone Number';
FieldName.className='field1';
}
else
{
FieldName.className='field';
}
}

function CellValue(FieldName)
{
if(FieldName.value == 'Mobile / Cell Phone Number')
{
FieldName.value = '';
FieldName.className='field';
}
}
function CellValue1(FieldName)
{
if(FieldName.value == '')
{
FieldName.value = 'Mobile / Cell Phone Number';
FieldName.className='field1';
}
else
{
FieldName.className='field';
}
}
