var responselocation="";
var showCtoC="";
var showSMS="";
var curpaid="";
var curcountry="";
var calledCtoC="";
var curcontactno="";
var validprof="";


function loginsection(offerid,ispaid,country,tradetype,contactno,relkeyvals,relcatvals)
{
	var controls="";
	var ctoc="";
	var location="";
	var location1="";

	curcountry=country;
	curcontactno=contactno;

	calledCtoC=document.getElementById("ctocofferids").value;

	try
	{
		location1 = document.getElementById("responselocation").value;
		location = location1.split(",");
		responselocation=location[0];
		showCtoC=location[1];
		showSMS=location[2];
		if (ispaid=='1' || ispaid=='2' ||ispaid=='3' )
		{
			ispaid='1';
		}
		
	}
	catch(e)
	{
		
	}
	curpaid=ispaid;

	defaultcontrols(offerid,ispaid,country,tradetype,contactno);

	hideprevious(offerid);

	var maindivid="maindiv_"+offerid;
	document.getElementById(maindivid).style.backgroundColor = "aliceblue";
	document.getElementById("selecteddiv").value=offerid;
	var detailsdiv="group_"+offerid;

	try
	{
	document.getElementById(detailsdiv).style.display = "none" ;
	}
	catch(e)
	{
	}
	document.getElementById("reach_"+offerid).style.display = "none" ;

	assigncountries(1);

	//document.getElementById("Detailed_"+offerid).style.display = "" ;
	//document.getElementById("shortdetail_"+offerid).style.display = "none" ;
	document.getElementById("ids").value=offerid;
	document.getElementById("emailheader").style.fontWeight="bold";
	document.getElementById("blockid").value="1";

}

function progressBar()
{
	//alert(outvalues);	
	var tradetypes=tradetype1;
	var types= "";
	var multioffid= "";	
	matchcoval=outvalues.split(":");
	multioffid=matchcoval[1];	
	/*if(tradetypes==1)
	{
		types="Sell Offer";
	}
	else if(tradetypes==2)
	{
		types="Buy Offer";
	}
	else if(tradetypes==3)
	{
		types="Product";
	}
	else if(tradetypes==4)
	{
		types="Profile";
	}*/
	
	document.getElementById("sendinganimation").style.display = "block" ;
	//document.getElementById("reach_"+offerid1).style.display = "none" ;
	//alert("We have "+matchcoval[0]+" more offer(s) matching to this "+types+".<a title=\""+matchcoval[0]+"\" onclick=\"multiresponsesend('"+multioffid+"');\" href=\"javascript:void(0);\">Click here</a> to send a response to all the "+matchcoval[0]+" offer(s). Or <a title=\"Click here\" onclick=\"listingdet(relkeyvals1,relcatvals1,offerid1,tradetype1);\" href=\"javascript:void(0);\">Click here</a> to view the list of "+types+" and send individual responses.");		
	document.getElementById("sendinganimation").innerHTML="We have <a title=\"Click here\" onclick=\"listingdet(relkeyvals1,relcatvals1,user_uid,tradetype1);\" href=\"javascript:void(0);\">"+matchcoval[0]+" more valid offer(s)</a> matching your requirement. <br /><br /><input type=\"button\" name=\"update_now\" class=\"postmailstyle\" id=\"multi\" value=\"Send Email\" title=\"Click to Send Email\" onclick=\"multiresponsesend('"+multioffid+"');\"/>";
	if(matchcoval[0]!=0)
	{
		overlaydisp("b2boverlaydiv");
	}
}
var offerid1= "";
var ispaid1= "";
var country1= "";
var tradetype1= "";
var contactno1= "";
var relkeyvals1= "";
var relcatvals1= "";
var user_uid= "";
function loadcontrols(u_id,offerid,ispaid,country,tradetype,contactno,relkeyvals,relcatvals)
{
	var cntvals=0;
	offerid1= offerid;
	ispaid1= ispaid;
	country1= country;
	tradetype1= tradetype;
	contactno1= contactno;
	relkeyvals1= relkeyvals;
	relcatvals1= relcatvals;
	user_uid= u_id;
	
	for(var i=1;i<=10;i++)
	{
		if(document.getElementById('chkitem_'+i))
		{
			if(document.getElementById('chkitem_'+i).checked==true)
			{
				cntvals=cntvals+1;
				if(cntvals>=2)
				{
					break;
				}
			}
		}
	}
	if(cntvals>=2)
	{
		document.getElementById("overlayad").style.display =""; 
		document.getElementById('enquiryform').style.display ="";	
		document.getElementById('SelectType').focus();
		document.getElementById('SelectType').style.display='none';
		document.getElementById('SelectCountry').style.display='none';
		//document.getElementById("txtkeyword").focus();
		
		multiprofilebuild('enquiryform');
	}
	else
	{
		//Set_Cookie('respcookieval','1','','/','','');
		
		var B2Bcookie = Get_Cookie("respcookieval");
		
		if(document.getElementById("loginchk").value!=1 && B2Bcookie==null)
		{
			var testcontrols= "";
			var reachdividids= "reach1_" +offerid;
			testcontrols="<div id=\"loginfo\" class=\"sealogwrap\">";
			testcontrols+="<b class=\"seahd\">You need to register and verify your email id to contact this advertiser.</b>";
			testcontrols+="<div class=\"sealogbor\"><span class=\"row1\"><span class=\"logtxt\">Please register (it just takes 2 minutes) or login to respond. <a title=\"Why?\" onclick=\"javascript:displayhelpopen();\" href=\"javascript:void(0);\">Why?</a></span>";
			testcontrols+="<span class=\"logcontclose\"><a title=\"Close\" onclick=\"javascript:displayItemlogclose();hidecurrentdiv("+offerid+" );\" href=\"javascript:void(0);\"></a></span>";
			testcontrols+="<div id=\"helpcont\" class=\"memformnonact\">The suppliers can contact you easily only if you register and authenticate your email id. And 90% of the suppliers would like to deal only with registered buyers.<div class=\"helpclose\"><a title=\"Close\" onclick=\"javascript:displayhelpclose();\" href=\"javascript:void(0);\">Close</a></div></div>";
			testcontrols+="<div id=\"forget\" class=\"memformnonact\"><div class=\"forrow\">Sample Text</div><div style=\"text-align: center;\" class=\"forrow\"><input type=\"text\" class=\"saelabovr\" value=\"Enter your Email Id\" name=\"Email Id\"/></div>";
			testcontrols+="<div style=\"text-align: center;\" class=\"forrow\"><input type=\"button\" class=\"forsubmit\" value=\"Submit\" name=\"Register\"/></div>";
			testcontrols+="<div class=\"helpcloses\"><a title=\"Close\" onclick=\"javascript:displayItemforgetc();\" href=\"javascript:void(0);\">Close</a></div></div><div class=\"clr\"></div></span>";
			testcontrols+="<div class=\"sealoglt\"><span class=\"saelogltr1\"><b>New Users</b> (Not a Registered member yet?)</span>";
			testcontrols+="<div class=\"saebor\"><div class=\"saecols1\"><b>Your Name</b><input type=\"text\" class=\"saeinput\" value=\" Your Name*\" onkeypress=\"return callauthenticate(event,1);\" name=\"srname\" id=\"srname\" onfocus=\"input_onfocus1('srname',' Your Name*') \" onblur=\"input_onblur1('srname',' Your Name*');\"/></div>";		
			testcontrols+="<div class=\"saecols\"><b>Login Email</b><input type=\"text\" class=\"saeinput3\" value=\" Your Email Id*\" name=\"Email\" onkeypress=\"return callauthenticate(event,1);\" id=\"Email\" onfocus=\"input_onfocus1('Email',' Your Email Id*') \" onblur=\"input_onblur1('Email',' Your Email Id*');return ValidateIdentity();\"/></div>";
			//testcontrols+="<div class=\"saebor\"><div class=\"saecols1\"><b>Login Email</b><input type=\"text\" class=\"saeinput\" value=\" Your Email Id*\" onkeypress=\"return callauthenticate(event,1);\" name=\"Email\" id=\"Email\" onfocus=\"input_onfocus1('Email',' Your Email Id*') \" onblur=\"input_onblur1('Email',' Your Email Id*');\"/></div>";				
			//testcontrols+="<div class=\"saecols\"><b>Your Name</b><input type=\"text\" class=\"saeinput3\" value=\" Your Name*\" name=\"srname\" onkeypress=\"return callauthenticate(event,1);\"  id=\"srname\" onfocus=\"input_onfocus1('srname',' Your Name*') \" onblur=\"input_onblur1('srname',' Your Name*');\"/></div>";
			testcontrols+="<div class=\"saecols\"><b>Password</b><input type=\"password\" class=\"saeinput3\" value=\"\" name=\"srpass\" onkeypress=\"return callauthenticate(event,1);\"  id=\"srpass\"/></div><div class=\"clr\"></div></div>";
			//testcontrols+="<div class=\"saecols\"><b>Company Name</b><input type=\"text\" class=\"saeinput3\" value=\" Your Company Name*\" onkeypress=\"return callauthenticate(event,1);\" name=\"Company\" id=\"Company\" onfocus=\"input_onfocus1('Company',' Your Company Name*') \" onblur=\"input_onblur1('Company',' Your Company Name*');\"/></div><div class=\"clr\"></div></div>";
			testcontrols+="<div class=\"saebor1\"><div class=\"saecols1\"><b>Company Name</b><input type=\"text\" class=\"saeinput\" value=\" Your Company Name*\" onkeypress=\"return callauthenticate(event,1);\" name=\"Company\" id=\"Company\" onfocus=\"input_onfocus1('Company',' Your Company Name*') \" onblur=\"input_onblur1('Company',' Your Company Name*');\"/></div>";
			testcontrols+="<div class=\"saecols\"><b>Country</b><select class=\"saemenu\" name=\"SCountry\" id=\"SCountry\" onchange=\" FillCode1();\"></select></div>";
			testcontrols+="<div class=\"saecols\"><b>Phone Number</b><input type=\"text\" class=\"saeinput1\" value=\"Country\" name=\"CCode\" id=\"CCode\" onkeypress=\"return callauthenticate(event,1);\" onfocus=\"input_onfocus1('CCode','Country') \" onblur=\"input_onblur1('CCode','Country');\"/><input type=\"text\" onkeypress=\"return callauthenticate(event,1);\" class=\"saeinput4\" value=\"Area\" name=\"ACode\" id=\"ACode\" onfocus=\"input_onfocus1('ACode','Area') \" onblur=\"input_onblur1('ACode','Area');\"/><input type=\"text\" onkeypress=\"return callauthenticate(event,1);\" class=\"saeinput2\" maxlength=\"13\" value=\" Phone Number*\" name=\"Phone\" id=\"Phone\" onfocus=\"input_onfocus1('Phone',' Phone Number*') \" onblur=\"input_onblur1('Phone',' Phone Number*');\"/></div><div class=\"clr\"></div></div>";
			testcontrols+="<div class=\"saebor2\"><input type=\"button\" class=\"saesubmit\" value=\"Register and Proceed\" name=\"Register\" id=\"Register\" onclick=\"validatenewregandlogin(1);\"/></div></div>";
			testcontrols+="<div class=\"sealogrt\"><span class=\"saelogrtr1\">Existing Users</span><div class=\"saelogrtrow\"><span class=\"saelabellt\">Login Email:</span><span class=\"saelabelrt\"><input type=\"text\" class=\"saelabin\" value=\"\" name=\"logemail\" id=\"logemail\"/></span><div class=\"clr\"></div></div>";
			testcontrols+="<div class=\"saelogrtrow\"><span class=\"saelabellt\">Password:</span><span class=\"saelabelrt\"><input type=\"password\" class=\"saelabin\" value=\"\" name=\"Logpwd\" id=\"Logpwd\" onkeypress=\"return callauthenticate(event,2);\" /></span><div class=\"clr\"></div></div>";
			testcontrols+="<div class=\"saelogrtrow1\"><a title=\"Forgot Password\" href=\"http://www.sulekhab2b.com/network/forgetpwd.aspx\" target=\"blank\" onclick=\"javascript:displayItemforgetp();\" href=\"javascript:void(0);\">Forgot Password?</a></div>";
			testcontrols+="<div class=\"saelogrtrow2\"><input type=\"button\" class=\"saelogin\" value=\"Login\" name=\"Login\" onclick=\"validatenewregandlogin(2);\"/></div></div><div class=\"clr\"></div></div>";
			testcontrols+="</div>";
			newcontentdiv = document.getElementById(reachdividids);
			newcontentdiv.innerHTML=testcontrols;	
					
			hideprevious(offerid);
			document.getElementById("selecteddiv").value=offerid;
			document.getElementById("reach_"+offerid).style.display = "none" ;

			assigncountries(3);		
		}
		else
		{
			loginsection(offerid1,ispaid1,country1,tradetype1,contactno1,relkeyvals1,relcatvals1);
		}
	}
}
function callauthcate(e,ctrlid)
{
	var key;
    if(window.event)
        key = window.event.keyCode;     //IE
    else
        key = e.which;     //firefox
	
    if (key == 32)
    {
		document.getElementById(ctrlid).value="";
		alert("Please Avoid Space");		
		return false;				
    }
}
	
function callauthenticate(e,logval)
{
	var key;
    if(window.event)
        key = window.event.keyCode;     //IE
    else
        key = e.which;     //firefox
	
    if (key == 13)
    {
		validatenewregandlogin(logval);	
		return false;				
    }
}
	
	var newname= "";
	var newemail= "";
	var newcomp= "";
	var newcountry= "";
	var newpass= "";
	var newphone= "";
	
function validatenewregandlogin(logval)
{		
	if(logval == 1)
	{
		if (ValidateValuesSearchResult1(3)== "yes")
		{
			newname= document.getElementById("srname").value;
			newemail= document.getElementById("Email").value;
			newcomp= document.getElementById("Company").value;
			newcountry= document.getElementById("SCountry").value;
			newpass= document.getElementById("srpass").value;
			var arcode=document.getElementById("ACode").value;
			if(arcode!="" && arcode!=null && arcode!="Area")
			{				
				newphone= document.getElementById("CCode").value+"-"+document.getElementById("ACode").value+"-"+document.getElementById("Phone").value;
			}
			else
			{
				newphone= document.getElementById("CCode").value+"-"+document.getElementById("Phone").value;
			}

			SearchResult.buildprofile(newname,newemail,newcomp,newcountry,newpass,newphone,authval);		
		}
	}
	else 
	{		
		if(CheckForEmpty(document.getElementById("logemail").value,"Please Enter Email.")==false)
		{
			document.getElementById("logemail").focus();
			return false;
		}	
		if(document.getElementById("logemail").value=="Email Id")
		{
			alert("Please Enter Email");
			document.getElementById("logemail").focus();			
			return false;
		}		
		if(CheckForSplCharAndMaxLength(document.getElementById("logemail").value,4,200,"The Email Id cannot be less than 4 characters Or exceed 200 characters.","","")==false)
		{
			document.getElementById("logemail").focus();
			flag=1;
			return "no";
		}
		if(validateEmail(document.getElementById("logemail").value)==false)
		{
			alert('Please Enter Valid Email Id');
			document.getElementById("logemail").value='';
			document.getElementById("logemail").focus();
			return false;
		}		
		if(CheckForEmpty(document.getElementById("Logpwd").value,"Please Enter Password.")==false)
		{
			document.getElementById("Logpwd").focus();			
			return false;
		}
		if(document.getElementById("Logpwd").value=="Login Id")
		{
			alert("Please Enter Password");
			document.getElementById("Logpwd").focus();			
			return false;
		}
		else
		{
			var passvalue=document.getElementById("Logpwd").value;
			if(passvalue.indexOf(' ') != -1)
			{
				alert("Please Avoid Space");
				document.getElementById("Logpwd").value='';
				document.getElementById("Logpwd").focus();			
				return false;
			}
		}
		
		if(!ValidateVerified(2))
		{				
			return false;		
		}		
		//SearchResult.authenticuser(document.getElementById('logemail').value,document.getElementById('Logpwd').value,showalert);	
		return true;	
	}
}

function authval(response)
{	
	if(response.value!=0)
	{		
		document.getElementById("loginchk").value=1;
		document.getElementById("cookievalues").value=newname+","+newemail+","+newphone+","+newcountry+",,"+newcomp;
		
		Set_Cookie('respcookieval','1','','/','','');
		
		loginsection(offerid1,ispaid1,country1,tradetype1,contactno1,relkeyvals1,relcatvals1);
		document.getElementById('altmsg').style.display='block';	
	}
	else
	{
		alert('Invalid Profile');
	}	
}
function showalert(response)
{
	if(response.value!="0")
	{	
		setloginstatus();
		logvals=response.value.split('~');		
		document.getElementById("loginchk").value=1;		
		document.getElementById("cookievalues").value=logvals[0]+","+logvals[1]+","+logvals[4]+","+logvals[3]+",,"+logvals[2];
		loginsection(offerid1,ispaid1,country1,tradetype1,contactno1,relkeyvals1,relcatvals1);		
		return true;
	}
	else
	{
		alert('Invalid Email/Password');
		return false;	
	}
	
}
function defaultcontrols(offerid,ispaid,country,tradetype,contactno)
{
	var headerdiv= "";
	var subdiv= "";
	var controls= "";
	var reachdivid= "reach1_" +offerid;
	var testcontrols= "";
	var newcontentdiv= "";
	var paid=0;	
		
		testcontrols="<div class=\"mconfirm\" id=\"altmsg\">An activation mail has been sent to your email address. Kindly check your mail and activate your account before you proceed.</div><div class=\"viewcontform\" id=\"\"><div class=\"viewconthd\"><div class=\"vadvt\">Contact Advertiser:</div><div id=\"emailheader\" class=\"memcontemail memcontactiv\"><a href=\"javascript:void(0);\" onClick=\"javascript:displayItemssmail();fillcontrols("+tradetype+",1,"+offerid+");\">Send Email</a></div>";
		if ((showCtoC == ispaid || showCtoC == "2") && (calledCtoC.indexOf(offerid+"_"+tradetype) == "-1") && (checkReceiverCtoC(contactno)) )
		{
			testcontrols+="<div id=\"ctocheader\" class=\"memcontcall memcontnonactiv\"><a href=\"javascript:void(0);\" onClick=\"javascript:displayItemsscall();fillcontrols("+tradetype+",0,"+offerid+");\">Free Click to Call</a></div>";
		}
	
		if (country == "India")
		{
			if (checkReceiverSMS(contactno) )
			{
				if(showSMS == ispaid  || showSMS == "2"  )
				{
				 	testcontrols+="<div id=\"sendsmsheader\" class=\"memcontsms memcontnonactiv\"><a href=\"javascript:void(0);\" onClick=\"javascript:displayItemsssms();fillcontrols("+tradetype+",2,"+offerid+");\">Send Free SMS</a></div>";					
				}
			}			
		}		
		testcontrols+="<div id=\"tick\" name=\"tick\" style=\"display:none;\" class=\"sellconttick\"></div><div class=\"memcontclose\"><a href=\"javascript:void(0);\" onclick=\"hidecurrentdiv("+offerid+" );\" ></a></div></div>";
		testcontrols+="<div id=\"subdiv\"><div class=\"memcontbdmail memformact\">";
		testcontrols+="<input class=\"postmailinputlt\" name=\"srname\" maxlength=\"50\" value=\" Your Name*\" type=\"text\" id=\"srname\" onfocus=\"input_onfocus1('srname',' Your Name*')\" onblur=\"input_onblur1('srname',' Your Name*');\"/>";
		testcontrols+="<input class=\"postmailinputrt\" name=\"Email\"  value=\" Your Email Id*\" type=\"text\" id=\"Email\" onfocus=\"input_onfocus1('Email',' Your Email Id*') \" onblur=\"input_onblur1('Email',' Your Email Id*');\"/>";
		testcontrols+="<input class=\"postmailinputrt1\" name=\"Company\"  value=\" Your Company Name*\" type=\"text\" id=\"Company\" onfocus=\"input_onfocus1('Company',' Your Company Name*') \" onblur=\"input_onblur1('Company',' Your Company Name*');\"/>";
		testcontrols+="<input type=\"hidden\" id=\"SelCname\" name=\"SelCname\" value=\"0\" /><select id=\"SCountry\" name=\"SCountry\" class=\"postmailinputlt8\" onchange=\" FillCode1();\"></select>";
		testcontrols+="<input class=\"postmailinputlt1\" name=\"CCode\" value=\" Country*\" type=\"text\" id=\"CCode\" onfocus=\"input_onfocus1('CCode',' Country*') \" onblur=\"input_onblur1('CCode',' Country*');\"/><input class=\"postmailinputlt2\" name=\"ACode\" value=\"Area\" type=\"text\" id=\"ACode\" onfocus=\"input_onfocus1('ACode','Area') \" onblur=\"input_onblur1('ACode','Area');\"/><input class=\"postmailinputlt3\" name=\"Phone\" value=\" Phone Number*\" type=\"text\" id=\"Phone\" maxlength=\"13\" onfocus=\"input_onfocus1('Phone',' Phone Number*') \" onblur=\"input_onblur1('Phone',' Phone Number*');\"/>";
		testcontrols+="<input class=\"postmailinputrt1\" name=\"subject\" value=\" Subject*\" maxlength=\"50\" type=\"text\" id=\"subject\" onfocus=\"input_onfocus1('subject', ' Subject*') \" onblur=\"input_onblur1('subject', ' Subject*');\"/>";
		testcontrols+="<input type=\"hidden\" id=\"maxchars\" value=\"1500\" NAME=\"maxchars\" /><textarea class=\"postmailinputmid\" name=\"message1\" id=\"message1\" onkeydown=\"check_onkeydown('message1','details_charsCount');\" onkeyup=\"check_onkeyup('message1','details_charsCount',' Enter Your Message*');\"  onfocus=\"input_onfocus1('message1',' Enter Your Message*') \" 	onblur=\"input_onblur1('message1',' Enter Your Message*');\"> Enter Your Message*</textarea><span id=\"details_charsCount\" name=\"details_charsCount\" style=\"display: block; float:right;\">0/1500</span>";
		testcontrols+="<div class=\"postmailsub\"><input type=\"button\" name=\"update_now\" class=\"postmailstyle\" id=\"update_now\" value=\"Send\" title=\"Click to Send Email\" onclick=\"getvalues( 1 ,"+tradetype+","+offerid+");\"/></div>";
		testcontrols+="</div></div>";
		
		newcontentdiv = document.getElementById(reachdivid);
		newcontentdiv.innerHTML=testcontrols;		
	
}

function  check_onkeydown(controlName,displayControlName)
{
	TextArea_Keypress1(controlName,displayControlName);
}

function  check_onkeyup(controlName,displayControlName,defaultValue)
{
	TextArea_Keyup1(controlName,displayControlName,defaultValue);
}

function input_onfocus1(controlName,controlDefaultvalue)
{
	if (document.getElementById(controlName).value == controlDefaultvalue )
	{
		document.getElementById(controlName).value = "";
	}
}

function input_onblur1(controlName,controlDefaultvalue)
{
	if (document.getElementById(controlName).value== "")
	{
		document.getElementById(controlName).value = controlDefaultvalue;
	}
}

function TextArea_Keypress1(txtName,spnName)
{
	if (document.getElementById(txtName).value.length > parseInt(document.getElementById('maxchars').value))
		return false;
}
function TextArea_Keyup1(txtName,spnName)
{
	if (document.getElementById(txtName).value.length > parseInt(document.getElementById('maxchars').value))
	{
		document.getElementById(txtName).value = document.getElementById(txtName).value.substr(0, parseInt(document.getElementById('maxchars').value));
	}
	document.getElementById(spnName).innerHTML = (parseInt(document.getElementById(txtName).value.length))+"/1500";
}

function fillcontrols(tradetype,type,offerid)
{
	var controls= "";
	var testcontrols= "";
	var dothis = checkthis(type);
	if (dothis==5)
	{
	if(type==0)//Click to Call for Free
		{
			var divid = "ctocdetail" + "_" +offerid;
			document.getElementById("emailheader").style.fontWeight= "normal";
			if (showCtoC == curpaid || showCtoC == "2")
			{
			document.getElementById("ctocheader").style.fontWeight= "bold";
			}
			
			if (curcountry == "India")
			{
				if (checkReceiverSMS(curcontactno) )
				{
					if (showSMS == curpaid || showSMS == "2")
					{
					document.getElementById("sendsmsheader").style.fontWeight= "normal";
					}
				}
			}
			
			testcontrols="<div style=\"BEHAVIOR: url(/webservice.htc);\"  id=\"CtoCDiv\" class=\"memcontbdcall memformact\"><p>SulekhaB2B can call your phone now and connect you to this advertiser for free</p>";
			testcontrols+="<div class=\"postcalllt\" id=\""+divid+"\" name= \""+divid+"\"><input class=\"postmailinputlt\" name=\"srname\"  value=\" Your Name*\" type=\"text\" id=\"srname\" maxlength=\"50\" onfocus=\"input_onfocus1('srname',' Your Name*')\" onblur=\"input_onblur1('srname',' Your Name*');\"/><input class=\"postmailinputrt\" type=\"text\" name=\"Phone\" id=\"Phone\" value=\" Phone Number*\"  title=\"Enter number with Country code and Area code. No Special Characters.\" onfocus=\"input_onfocus1('Phone',' Phone Number*')\" onblur=\"input_onblur1('Phone',' Phone Number*');\"/></div><div class=\"postcallrt\"><input type=\"button\" value=\"click to call\" class=\"postmailstyle\" id=\"caller\" name=\"caller\" style=\"Cursor:pointer;\" title=\"click to call\" onclick=\"getvalues( 0 ,"+tradetype+","+offerid+");\"/></div>";
			testcontrols+="<div class=\"clr\"></div><div class=\"postcalltxt\">Enter number with Country code and Area code. No spaces/special characters.<br />E.g. US: 00173263XXXXX India: 9180233XXXXX (Landline) 9198840XXXXX (Mobile)</div></div>";
			testcontrols+="<div id=\"divfeedback\" valign=\"middle\" class=\"memcontform\" style=\"text-align:center;display:none;padding:20px;line-height:22px;\"></div>";
			
			document.getElementById("subdiv").innerHTML=testcontrols;
			assigncountries(0);
		}
		else if (type==1)//Send Email Response
		{
			testcontrols+="<div class=\"memcontbdmail memformact\">";
			testcontrols+="<input class=\"postmailinputlt\" name=\"srname\" maxlength=\"50\" value=\" Your Name*\" type=\"text\" id=\"srname\" onfocus=\"input_onfocus1('srname',' Your Name*')\" onblur=\"input_onblur1('srname',' Your Name*');\"/>";
			testcontrols+="<input class=\"postmailinputrt\" name=\"Email\"  value=\" Your Email Id*\" type=\"text\" id=\"Email\" onfocus=\"input_onfocus1('Email',' Your Email Id*') \" onblur=\"input_onblur1('Email',' Your Email Id*');\"/>";
			testcontrols+="<input class=\"postmailinputrt1\" name=\"Company\"  value=\" Your Company Name*\" type=\"text\" id=\"Company\" onfocus=\"input_onfocus1('Company',' Your Company Name*') \" onblur=\"input_onblur1('Company',' Your Company Name*');\"/>";
			testcontrols+="<input type=\"hidden\" id=\"SelCname\" name=\"SelCname\" value=\"0\" /><select id=\"SCountry\" name=\"SCountry\" class=\"postmailinputlt8\" onchange=\" FillCode1();\"></select>";
			testcontrols+="<input class=\"postmailinputlt1\" name=\"CCode\" value=\" Country*\" type=\"text\" id=\"CCode\" onfocus=\"input_onfocus1('CCode',' Country*') \" onblur=\"input_onblur1('CCode',' Country*');\"/><input class=\"postmailinputlt2\" name=\"ACode\" value=\"Area\" type=\"text\" id=\"ACode\" onfocus=\"input_onfocus1('ACode','Area') \" onblur=\"input_onblur1('ACode','Area');\"/><input class=\"postmailinputlt3\" name=\"Phone\" value=\" Phone Number*\" type=\"text\" id=\"Phone\" maxlength=\"13\" onfocus=\"input_onfocus1('Phone',' Phone Number*') \" onblur=\"input_onblur1('Phone',' Phone Number*');\"/>";
			testcontrols+="<input class=\"postmailinputrt1\" name=\"subject\" value=\" Subject*\" maxlength=\"50\" type=\"text\" id=\"subject\" onfocus=\"input_onfocus1('subject', ' Subject*') \" onblur=\"input_onblur1('subject', ' Subject*');\"/>";
			testcontrols+="<input type=\"hidden\" id=\"maxchars\" value=\"1500\" NAME=\"maxchars\" /><textarea class=\"postmailinputmid\" name=\"message1\" id=\"message1\" onkeydown=\"check_onkeydown('message1','details_charsCount');\" onkeyup=\"check_onkeyup('message1','details_charsCount',' Enter Your Message*');\"  onfocus=\"input_onfocus1('message1',' Enter Your Message*') \" 	onblur=\"input_onblur1('message1',' Enter Your Message*');\"> Enter Your Message*</textarea><span id=\"details_charsCount\" name=\"details_charsCount\" style=\"display:block;float:right;\">0/1500</span>";
			testcontrols+="<div class=\"postmailsub\"><input type=\"button\" name=\"update_now\" class=\"postmailstyle\" id=\"update_now\" value=\"Send\" title=\"Click to Send Email\" onclick=\"getvalues( 1 ,"+tradetype+","+offerid+");\"/></div>";
			testcontrols+="</div>";
			
			document.getElementById("emailheader").style.fontWeight="bold";
			if (showCtoC == curpaid || showCtoC == "2")
			{
				try
				{
					document.getElementById("ctocheader").style.fontWeight="normal";
				}
				catch(e)
				{
				}
			}
			
			if (curcountry == "India")
			{
				if (checkReceiverSMS(curcontactno))
				{
					if (showSMS == curpaid || showSMS == "2")
					{
					document.getElementById("sendsmsheader").style.fontWeight="normal";
					}
				}
			}
			document.getElementById("subdiv").innerHTML=testcontrols;
			assigncountries(1);
		}
		else if (type==2)//Send Free SMS 
		{
			if (curcountry == "India")
			{
				if (checkReceiverSMS(curcontactno))
				{
					if (showSMS == curpaid || showSMS == "2")
					{
					document.getElementById("sendsmsheader").style.fontWeight="bold";
					}
				}
			}
			if (showCtoC == curpaid || showCtoC == "2")
			{
				try
				{
					document.getElementById("ctocheader").style.fontWeight="normal";
				}
				catch(e)
				{
				}
			}
			document.getElementById("emailheader").style.fontWeight="normal";
						
			testcontrols+="<div class=\"memcontbdsms memformact\"><input class=\"postmailinputlt\" name=\"srname\" onfocus=\"input_onfocus1('srname',' Your Name*')\" maxlength=\"50\" onblur=\"input_onblur1('srname',' Your Name*');\" value=\" Your Name*\" type=\"text\" id=\"srname\"/>";
			testcontrols+="<input class=\"postmailinputrt\" name=\"Email\"  value=\" Your Email Id*\" type=\"text\" id=\"Email\" onfocus=\"input_onfocus1('Email',' Your Email Id*')\" onblur=\"input_onblur1('Email',' Your Email Id*');\"/>";
			testcontrols+="<input class=\"postmailinputrt1\" name=\"Phone\" onfocus=\"input_onfocus1('Phone',' Your Mobile number*') \" title=\"Enter number with Country code. No Special Characters.\"	onblur=\"input_onblur1('Phone',' Your Mobile number*');\" value=\" Your Mobile number*\" type=\"text\" id=\"Phone\"/>";
			testcontrols+="<input type=\"hidden\" id=\"maxchars\" value=\"100\" NAME=\"maxchars\" /><textarea maxlength=\"100\" class=\"postmailinputmid\" name=\"message1\" id=\"message1\" onkeydown=\"check_onkeydown('message1','details_charsCount');\" onkeyup=\"check_onkeyup('message1','details_charsCount',' Enter Your Message*');\"  onfocus=\"input_onfocus1('message1',' Enter Your Message*') \" 	onblur=\"input_onblur1('message1',' Enter Your Message*');\"> Enter Your Message*</textarea><span id=\"details_charsCount\" name=\"details_charsCount\" style=\"display:block;float:right;\">0/100</span>";
			testcontrols+="<div class=\"postmailsub\"><input type=\"button\" style=\"Cursor:pointer;\"  name=\"update_now\" class=\"postmailstyle\" id=\"update_now\" value=\"Send\" title=\"Click to Send Free SMS\" onclick=\"getvalues( 2 ,"+tradetype+","+offerid+");\"/></div>";
			testcontrols+="</div>";
			document.getElementById("subdiv").innerHTML=testcontrols;
			assigncountries(2);
		}
		return controls;
	}
		return "";
}

var senderEmailId ="";
var senderSubject ="";
var senderphoneno ="";
var senderMessage = "";
var senderCountry = "";
var senderObjective ="";
var senderName = "";

function getvalues(type,tradetype,offerid)
{	
	if (type==0)//ctoc
		{
			if (ValidateValuesSearchResult1(0)== "yes")
			{
				var cookievalues = document.getElementById("ctocofferids").value;
				if ( cookievalues !=null && cookievalues !="" && cookievalues.length > 0)
				{
					document.getElementById("ctocofferids").value=document.getElementById("ctocofferids").value+","+offerid+"_"+tradetype;
				}
				else
				{
					document.getElementById("ctocofferids").value=offerid+"_"+tradetype;
				}
				
				calledCtoC=document.getElementById("ctocofferids").value;
				senderName=document.getElementById("srname").value;
				senderphoneno =document.getElementById("Phone").value;
				if (checkSenderCtoC(senderphoneno))
				{
					InitiateCall(tradetype,offerid,senderphoneno,responselocation,senderName);
				}
				else
				{
					document.getElementById("Phone").select();
					return ;
				}
			}
		}
		else if (type==1)//email
		{			
			if ( ValidateValuesSearchResult1(1)== "yes")
			{
				senderName=document.getElementById("srname").value;
				senderEmailId=document.getElementById("Email").value;
				senderphoneno =document.getElementById("CCode").value +"-"+ document.getElementById("ACode").value +"-"+ document.getElementById("Phone").value;
				senderSubject =document.getElementById("subject").value;
				senderCountry=document.getElementById("SCountry").value;
				senderCompany=document.getElementById("Company").value;
				senderMessage=document.getElementById("message1").value;
				
				phnoval=document.getElementById("CCode").value + document.getElementById("ACode").value + document.getElementById("Phone").value;
													
				sendEmail(tradetype,offerid,senderName,senderEmailId,senderphoneno,senderSubject,senderCountry,senderCompany,senderMessage,responselocation);										
				countdet(relkeyvals1,relcatvals1,user_uid,tradetype1);					
			
				return ;								
			} 
		}
		else if (type==2)//sms
		{
		  if (ValidateValuesSearchResult1(2)=="yes")
		  {
				senderName=document.getElementById("srname").value;
				senderphoneno=document.getElementById("Phone").value;	
				senderEmailId=document.getElementById("Email").value;	
				senderMessage=document.getElementById("message1").value;	
				if (checkSenderSMS(senderphoneno))
				{
					sendSmsForm(tradetype,offerid,senderName,senderEmailId,senderphoneno,senderMessage,responselocation);
				}
				else
				{
					document.getElementById("Phone").select();
					return ;
				}
				
		  }
		}   
	}

function hideprevious(offerid)
{
	var newcontentdiv=document.getElementById("selecteddiv");
	var reachdivid="reach1_"+offerid;
	if (newcontentdiv.value!="0" && newcontentdiv.value!=offerid)
	{
		document.getElementById("maindiv_"+newcontentdiv.value).style.backgroundColor = "white";
		document.getElementById("reach1_"+newcontentdiv.value).innerHTML = "" ;
		document.getElementById("reach_"+newcontentdiv.value).style.display = "block" ;
		//document.getElementById("shortdetail_"+newcontentdiv.value).style.display = "" ;
		//document.getElementById("Detailed_"+newcontentdiv.value).style.display = "none" ;
	try
	{
	document.getElementById("group_"+newcontentdiv.value).style.display = "block" ;
	}
	catch(e)
	{
	}
	}
}


function hidecurrentdiv(offerid)
{
	document.getElementById("reach1_"+offerid).innerHTML = "" ;
	document.getElementById("reach_"+offerid).style.display = "block";
	document.getElementById("maindiv_"+offerid).style.backgroundColor = "white";
	//document.getElementById("shortdetail_"+offerid).style.display = "" ;
	//document.getElementById("Detailed_"+offerid).style.display = "none" ;
	try
	{
	document.getElementById("group_"+offerid).style.display = "block" ;
	}
	catch(e)
	{
	}
	enableDisableDivs(offerid,0);
	
}

function enableDisableDivs(curid,todo) 
{ 
		
	var styledisplay="";
		
	if (todo == 1)
		{
			styledisplay = "none";
		}
	else
		{
			styledisplay = "block";
		}
		
	
	var frmdiv=document.getElementsByTagName('div');

			for (var i = 0; i < frmdiv.length; i++) 
			{
						if (frmdiv.item(i).id.substring(0,6) == "reach_" ) 
						{
							if(frmdiv.item(i).id != "reach_" + curid )
								{
									frmdiv.item(i).style.display = styledisplay ;
								}
						}
			
			}

	
}

function checkthis(id)
{
	if (document.getElementById("blockid").value==id)
	{
		document.getElementById("blockid").value=id;
		return (4);
	}
	else
	{
		document.getElementById("blockid").value=id;
		return (5);
	}
	
}

function openwindow() 
{ 
	 var popupurl= "/html/ClicktoCallhelp.htm";
	 var helpwindow="";
	 helpwindow=window.open("/html/ClicktoCallhelp.htm","mywindow","height=500,width=620,status=no,toolbar=no,menubar=no,titlebar=0,location=no,left=50,top=50"); 
	 helpwindow.location= popupurl;
}

function openNoticewindow() 
{ 
	 var popupurl= "/html/ResponseNotice.htm";
	 var helpwindow="";
	 helpwindow=window.open("/html/ResponseNotice.htm","mywindow","height=585,width=650,status=no,toolbar=no,menubar=no,titlebar=0,location=no,left=50,top=50"); 
	 helpwindow.location= popupurl;
}


function assigncountries(type)
{
	var allvalues="";
	var userdetails="";
	try
	{
		userdetails = document.getElementById("cookievalues").value;
	}
	catch(e)
	{
		userdetails = "";
	}
	
	if( userdetails!= "" && userdetails!= null )
	{		
		allvalues = userdetails.split(",");		
		 if (type==0 || type==1 || type==2)
		 {			
			if(allvalues[2]!="")
			{
				if(type==1)
				{
					if(allvalues[2].indexOf("-")>-1)
					{
						var phval=allvalues[2].split("-");
						if(phval.length==2)
						{							
							document.getElementById("Phone").value=phval[2];
						}
						else
						{
							document.getElementById("ACode").value=phval[1];
							document.getElementById("Phone").value=phval[phval.length-1];
						}
						
					}
					else
					{
						document.getElementById("Phone").value=allvalues[2];
					}
				}
				if(type==2)
				{
					//document.getElementById("Phone").value=allvalues[2];
					if(allvalues[2].indexOf("-")>-1)
					{
						var phval=allvalues[2].split("-");
						if(phval.length==2)
						{							
							document.getElementById("Phone").value=phval[2];
						}
						else
						{							
							document.getElementById("Phone").value=phval[0] + phval[phval.length-1];
						}
						
					}
					else
					{
						document.getElementById("Phone").value=allvalues[2];
					}
				}
			}
		 }
		 
		 if (type==1 || type==2 ||type==0)
		 {
			if(allvalues[0]!="")
			{
				 document.getElementById("srname").value=allvalues[0];
			}
		 }
		 	
		 if (type==1 || type==2 )
		 {
			if(allvalues[1]!="")
			{	
				document.getElementById("Email").value=allvalues[1];
			}
		 }	
			
		if ( type==1 || type==3)
		 {
			try
			{
				if(allvalues[5]!=null && allvalues[5]!="")
				{	
					document.getElementById("Company").value=allvalues[5];
				}
				var getcountries = document.getElementById("ddlcname").value;	
				var setcountries = getcountries.split(",");
				document.getElementById("SCountry").options.length=0;	
				document.getElementById("SCountry").options[0] = new Option("Select Country*","0");
				
				var selectMenu = document.getElementById("SCountry");
				var TopCountry = document.createElement("optgroup");
				TopCountry.label = "Top Countries";

				var Other = document.createElement("optgroup");
				Other.label = "All Countries";
				
				for(var i=1;i<setcountries.length;i++)
				{
					ctryval = setcountries[i].split(";");					
					var ii= ctryval[0].length;
					if(ii>1)
					{
						var ctr = document.createElement("option");
						ctr.value = ctryval[1];
						ctr.appendChild(document.createTextNode(ctryval[1]));
						TopCountry.appendChild(ctr);
					}
					else
					{	
						var ctr1 = document.createElement("option");
						ctr1.value = ctryval[1];
						ctr1.appendChild(document.createTextNode(ctryval[1]));
						Other.appendChild(ctr1);
					}								
				}

				selectMenu.appendChild(TopCountry); 
				selectMenu.appendChild(Other); 	
				if (allvalues[3]!="")
				{
					document.getElementById('SCountry').value=allvalues[3];		
					FillCode1();				
				}
			}
			catch(e)
			{
			}
		}
	}	
}

function assignticks(previousids)
{
	if (previousids.indexOf(',')=="-1" && previousids!="")
	{
		try
		{
			document.getElementById("tick_" +previousids ).style.display = "inline" ;
		}
		catch(e)
		{
		}
		
		return;	
	}
	if (previousids!="")
	{
		var OfferId= previousids.split(",");
		for(var i=0;i<previousids.length;i++)
		{
			if (OfferId[i]!="" && OfferId[i]!=null)
			{
				try
				{
					document.getElementById("tick_" +OfferId[i] ).style.display = "inline" ;
				}
				catch(e)
				{
					
				}
			}
		}
	}	
}
function ValidateValuesSearchResult1(type)
{
	var flag=0;	
	if (type==0)
	{
		if(CheckForEmpty(document.getElementById("srname").value,"Please Enter Name.")==false)
		{
			document.getElementById("srname").focus();
			flag=1;
			return "no";
		}
		if(document.getElementById("srname").value==" Your Name*")
		{
			alert("Please Enter Your Name");
			document.getElementById("srname").focus();
			flag=1;
			return "no";
		}	
		if(CheckForSplCharAndMaxLength(document.getElementById("srname").value,4,50,"The Name cannot be less than 4 characters Or exceed 50 characters.","~!@#$%^&*()+;:|\/<>?[]{}-=0123456789","Please Avoid Special Character")==false)
		{
			document.getElementById("srname").focus();
			flag=1;
			return "no";
		}	
		if(document.getElementById("Phone").value==" Phone Number*")
		{
			alert("Please Enter Phone Number");
			document.getElementById("Phone").focus();
			flag=1;
			return "no";
		}		
	}	
	if(type==1 || type==3)
	{
		if(CheckForEmpty(document.getElementById("srname").value,"Please Enter Name.")==false)
		{
			document.getElementById("srname").focus();
			flag=1;
			return "no";
		}
		if(document.getElementById("srname").value==" Your Name*")
		{
			alert("Please Enter Your Name");
			document.getElementById("srname").focus();
			flag=1;
			return "no";
		}
		if(CheckForSplCharAndMaxLength(document.getElementById("srname").value,4,50,"The Name cannot be less than 4 characters Or exceed 50 characters.","~!@#$%^&*()+;:|\/<>?[]{}-=0123456789","Please Avoid Special Character")==false)
		{
			document.getElementById("srname").focus();
			flag=1;
			return "no";
		}	
		if(CheckForEmpty(document.getElementById("Email").value,"Please Enter Email.")==false)
		{
			document.getElementById("Email").focus();
			flag=1;
			return "no";
		}	
		if(document.getElementById("Email").value==" Your Email Id*")
		{
			alert("Please Enter Your Email");
			document.getElementById("Email").focus();
			flag=1;
			return "no";
		}			
		if(validateEmail(document.getElementById("Email").value)==false)
		{
			alert('Please Enter Valid Email Id');
			document.getElementById("Email").value='';
			document.getElementById("Email").focus();
			flag=1;
			return "no";
		}	
		if(CheckForSplCharAndMaxLength(document.getElementById("Email").value,4,200,"The Email Id cannot be less than 4 characters Or exceed 200 characters.","","")==false)
		{
			document.getElementById("Email").focus();
			flag=1;
			return "no";
		}
		if(type==3)
		{
			if(CheckForEmpty(document.getElementById("srpass").value,"Please Enter Password.")==false)
			{
				document.getElementById("srpass").focus();
				flag=1;
				return "no";
			}
			if(document.getElementById("srpass").value=="password")
			{
				alert("Please Enter Password");
				document.getElementById("srpass").focus();
				flag=1;
				return "no";
			}
			else
			{
				var passvalue=document.getElementById("srpass").value;
				if(passvalue.indexOf(' ') != -1)
				{
					alert("Please Avoid Space");
					document.getElementById("srpass").value='';
					document.getElementById("srpass").focus();			
					flag=1;
					return "no";
				}
			}
			if(CheckForSplCharAndMaxLength(document.getElementById("srpass").value,6,10,"Password cannot be less than 6 characters Or exceed 10 characters.","","")==false)
			{
				document.getElementById("srpass").focus();
				flag=1;
				return "no";
			}	
		}
		if(CheckForEmpty(document.getElementById("Company").value,"Please Enter Company Name.")==false)
		{
			document.getElementById("Company").focus();
			flag=1;
			return "no";
		}
		if(document.getElementById("Company").value==" Your Company Name*")
		{
			alert("Please Enter Company Name");
			document.getElementById("Company").focus();
			flag=1;
			return "no";
		}	
		if(CheckForSplCharAndMaxLength(document.getElementById("Company").value,4,50,"The Company Name cannot be less than 4 characters Or exceed 50 characters.","~!@#$%^&*()+;:|\/<>?[]{}=","Please Avoid Special Character")==false)
		{
			document.getElementById("Company").focus();
			flag=1;
			return "no";
		}	
		if(document.getElementById("SCountry").selectedIndex == 0)
		{
			alert("Please Select Country.");
			document.getElementById("SCountry").focus();
			flag=1;
			return "no";
		}			
		if(document.getElementById("CCode").value==" Country*")
		{
			alert("Please Enter CountryCode");
			document.getElementById("CCode").focus();
			flag=1;
			return "no";
		}		
		recACode=document.getElementById("ACode").value
		if(recACode!=null && recACode!="" && recACode!="Area")
		{
			if(CheckForEmpty(document.getElementById("ACode").value,"Please Enter AreaCode.")==false)
			{
				document.getElementById("ACode").focus();
				flag=1;
				return "no";
			}
			if(document.getElementById("ACode").value=="Area")
			{
				alert("Please Enter AreaCode");
				document.getElementById("ACode").focus();
				flag=1;
				return "no";
			}
			if(checkSenderNumberACode1(recACode))
			{				
				if ( (recACode.length <= 6) && (recACode.substring(0,3)!= "000" ))
				{					
					//return true;
				}
				else
				{
					alert("Invalid AreaCode!!!");
					document.getElementById("ACode").select();
					return "no";
				}
			}
			else
			{				
				return "no";	
			}
		}
		if(CheckForEmpty(document.getElementById("Phone").value,"Please Enter Phone Number.")==false)
		{
			document.getElementById("Phone").focus();
			flag=1;
			return "no";
		}
		if(document.getElementById("Phone").value==" Phone Number*")
		{
			alert("Please Enter Phone Number");
			document.getElementById("Phone").focus();
			flag=1;
			return "no";
		}
		recNumber=document.getElementById("Phone").value
		if(checkSenderNumber1(recNumber))
		{			
			if ( (recNumber.length >=5) && (recNumber.substring(0,3)!= "000" ) && (recNumber.length < 20))
			{
				//return true;
			}
			else
			{
				alert("Invalid Phone Number!!!");
				document.getElementById("Phone").select();
				return "no";
			}
		}
		else
		{			
			return "no";	
		}
		if(type!=3)
		{
			if(CheckForEmpty(document.getElementById("subject").value,"Please Enter Subject.")==false)
			{
				document.getElementById("subject").focus();
				flag=1;
				return "no";
			}
			if(document.getElementById("subject").value ==" Subject*")
			{
				alert("Please Enter subject.");
				document.getElementById("subject").focus();
				flag=1;
				return "no";	
			}	
		
			if(trim(document.getElementById("subject").value) =="")
			{
				alert("Please Enter a valid subject.");
				document.getElementById("subject").focus();
				flag=1;
				return "no";
			}	
			if(CheckForSplCharAndMaxLength(document.getElementById("subject").value,4,50,"The Subject cannot be less than 4 characters Or exceed 50 characters.","~!@#$%^&*()+;:|\/<>?[]{}-=","Please Avoid Special Character")==false)
			{
				document.getElementById("subject").focus();
				flag=1;
				return "no";
			}	
			if(CheckForEmpty(document.getElementById("message1").value,"Please Enter Message")==false)
			{
				flag=1;
				return "no";
			}
		
			if(document.getElementById("message1").value==" Enter Your Message*")
			{
				alert("Please Enter Your Message");
				document.getElementById("message1").focus();
				flag=1;
				return "no";
			}	
		}
		
	}	
	if(type==2)
	{
		if(CheckForEmpty(document.getElementById("srname").value,"Please Enter Name.")==false)
		{
			document.getElementById("srname").focus();
			flag=1;
			return "no";
		}
		if(document.getElementById("srname").value==" Your Name*")
		{
			alert("Please Enter Your Name");
			document.getElementById("srname").focus();
			flag=1;
			return "no";
		}	
		if(CheckForSplCharAndMaxLength(document.getElementById("srname").value,4,50,"The Name cannot be less than 4 characters Or exceed 50 characters.","~!@#$%^&*()+;:|\/<>?[]{}-=0123456789","Please Avoid Special Character")==false)
		{
			document.getElementById("srname").focus();
			flag=1;
			return "no";
		}
		if(CheckForEmpty(document.getElementById("Email").value,"Please Enter Email.")==false)
		{
			document.getElementById("Email").focus();
			flag=1;
			return "no";
		}	
		if(document.getElementById("Email").value==" Your Email Id*")
		{
			alert("Please Enter Email");
			document.getElementById("Email").focus();
			flag=1;
			return "no";
		}			
		if(validateEmail(document.getElementById("Email").value)==false)
		{
			alert('Please Enter Valid Email Id');
			document.getElementById("Email").value='';
			document.getElementById("Email").focus();
			flag=1;
			return "no";
		}
		if(CheckForSplCharAndMaxLength(document.getElementById("Email").value,4,200,"The Email Id cannot be less than 4 characters Or exceed 200 characters.","","")==false)
		{
			document.getElementById("Email").focus();
			flag=1;
			return "no";
		}
		if(CheckForEmpty(document.getElementById("Phone").value,"Please Enter Mobile Number.")==false)
		{
			document.getElementById("Phone").focus();
			flag=1;
			return "no";
		}
		if(document.getElementById("Phone").value==" Your Mobile number*")
		{
			alert("Please Enter Mobile Number");
			document.getElementById("Phone").focus();
			flag=1;
			return "no";
		}
		/*if(CheckForSplCharAndMaxLength(document.getElementById("Phone").value,10,12,"The Name cannot be less than 10 characters Or exceed 12 characters.","~!@#$%^&*()+;:|\/<>?[]{}-=","Please Avoid Special Character")==false)
		{
			document.getElementById("Phone").focus();
			flag=1;
			return "no";
		}*/
		if (!checkSenderSMS(document.getElementById("Phone").value))
		{
			document.getElementById("Phone").select();
			flag=1;
			return "no";
		}		
		if(CheckForEmpty(document.getElementById("message1").value,"Please Enter Message")==false)
		{
			flag=1;
			return "no";
		}	
		if(document.getElementById("message1").value==" Enter Your Message*")
		{
			alert("Please Enter Your Message");
			document.getElementById("message1").focus();
			flag=1;
			return "no";
		}	
	}		  
	return "yes";	
}

function FillCode1()
{
	var Country=document.getElementById("SCountry").value;	
	return(SearchResult.FillCountryCode(Country,BindValue1));		
}
function BindValue1(response)
{		
	document.getElementById("CCode").value=response.value;
	document.getElementById("CCode").disabled=true;	
}

function checkSenderNumberCCode1(str)
{
	var numericExpression = /^[0-9]+$/;
	if(str.match(numericExpression))
	   {
		  return true;
       }
       else
       {
			document.getElementById("CCode").select();
			alert("Invalid Country Code!!! No Space/Special character.");
			return false;    
       }	
}

function checkSenderNumberACode1(str)
{
	var numericExpression = /^[0-9]+$/;
	if(str.match(numericExpression))
	   {
		  return true;
       }
       else
       {
		  document.getElementById("ACode").select();
		  alert("Invalid Area Code!!! No Space/Special character.");
          return false;    
       }
	
}

function checkSenderNumber1(str)
{
	var numericExpression = /^[0-9]+$/;
	if(str.match(numericExpression))
	{
		return true;
    }
    else
    {
		document.getElementById("Phone").select();
		alert("Invalid Phone Number!!! No Space/Special character.");
        return false;    
    }
}
var _typesvals= "";
function ValidateVerified(typeval)
{			
	_typesvals=typeval;
	if(document.getElementById("logemail").value != '' && document.getElementById("logemail").value != 'Email Id')
	{			
		return(SearchResult.ValidateVerified(document.getElementById("logemail").value, updatePage2));		
	}
	else
	{	
		document.getElementById("logemail").select();
		document.getElementById("logemail").focus();
		return false;
	}			
}
function updatePage2(response)
{	
	if(response.value == 'Not Present')
	{					
		alert("Before logging in, kindly activate your account by clicking the link sent to your email ID.");
		document.getElementById("logemail").select();
		document.getElementById("logemail").focus();		
		return false;
	}	
	else
	{		
		if(_typesvals==1)
		{
			return(SearchResult.authenticuser(document.getElementById('logemail').value,document.getElementById('Logpwd').value,showalert1));	
		}
		else
		{
			return(SearchResult.authenticuser(document.getElementById('logemail').value,document.getElementById('Logpwd').value,showalert));	
		}	
	}
}

var outvalues="";
function countdet(keys,cat,idval,ttype)
{	
	var url="/MostPopularBoxFromLucene.aspx?keys="+keys;
		url+="&offerid="+idval;
		url+="&cats="+cat;
		url+="&ttype="+ttype;
	xmlhttp=null;

	if (window.XMLHttpRequest)
	{ xmlhttp=new XMLHttpRequest();	}

	else if (window.ActiveXObject)
	{	xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 	}

	if (xmlhttp!=null)
	{			
		xmlhttp.onreadystatechange = getresult11 ;
		xmlhttp.open("GET",url,true);		
		xmlhttp.send(null);				
		
	}
	else
	{   
		alert("Your browser does not support XMLHTTP.");   
	}	
}

function getresult11()
{
	// if xmlhttp shows "loaded"
	if (xmlhttp.readyState==4)
	{			
		outvalues=xmlhttp.responseText;		
		setTimeout("progressBar()",1000);
	}
}
function getresult111()
{
	// if xmlhttp shows "loaded"
	if (xmlhttp.readyState==4)
	{			
		outvalues=xmlhttp.responseText;			
	}
}
function listingdet(keys,cat,idval,ttype)
{	
	Set_Cookie('multirespkeys',keys,'','/','','');
	Set_Cookie('multirespcat',cat,'','/','','');
	Set_Cookie('multirespidval',idval,'','/','','');
	Set_Cookie('multirespttype',ttype,'','/','','');
	
	var url="/matching-offers.htm";	
	location.href = url;
}

/*function getresultval()
{	
	if (xmlhttp.readyState == 4)
	{
		outvalues=xmlhttp.responseText;
	}
}*/

function multiresponsesend(adrespid)
{		
	adresponseid=adrespid.split("~");
	var outresp= "";	
	for(abc=0;abc<adresponseid.length;abc++)
	{			
		if(adresponseid[abc]!='' && adresponseid[abc]!=null)
		{			
			outresp=sendMultiEmail(tradetype1,adresponseid[abc],senderName,senderEmailId,senderphoneno,senderSubject,senderCountry,senderCompany,senderMessage,18);		
		}
		if(outresp=="1")
		{
			alert('your email has been sent to all the matching valid offers');
			break;
		}	
		assignticks(adresponseid[abc]+"_"+tradetype1);	
	}
	alert('your email has been sent to all the matching valid offers');
	closeoverlay('b2boverlaydiv');
}

function sendMultiEmail(tradetype,offerid,name,emailId,phoneno,subject,country,company,message,responseLocation )
{			
		currentId = offerid;
		currentttype = tradetype;
		var host = window.location.hostname;
		var url="/testpaypal.aspx?tradetype="+tradetype ;
		url+="&offerid="+offerid;
		url+="&contacttype=email";
		url+="&name=" + name;
		url+="&mobileno=" + phoneno;
		url+="&message=" + message;
		url+="&emailaddress=" + emailId;
		url+="&country="+country;
		url+="&company="+company;
		url+="&subject="+subject;
		url+="&responselocation="+responseLocation;
		//url+="&sAdvMobileNo="+sAdvMobileNo;
		xmlhttp=null;

		if (window.XMLHttpRequest)
		{ xmlhttp=new XMLHttpRequest();	}
	
		else if (window.ActiveXObject)
		{	xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 	}

		if (xmlhttp!=null)
		{	//alert(url);		
			xmlhttp.onreadystatechange = getresult111;
			xmlhttp.open("GET",url,true);		
			xmlhttp.send(null);		
			
			if (outvalues == "maximum")
			{
				location.href = "/SendEmailsBlock.aspx";
				return 1;
			}		
			else
			{	
				return 0;
			}
			
		 }
	   else
	   {   alert("Your browser does not support XMLHTTP.");   }	
			
}

function multiprofilebuild(ovdivid)
{
	var B2Bcookie = Get_Cookie("respcookieval");			
	if(document.getElementById("loginchk").value!=1 && B2Bcookie==null)
	{				
		var testcontrols= "";
		var reachdividids= ovdivid;		
		testcontrols="<div id=\"loginfo\" class=\"sealogwrap\">";
		testcontrols+="<b class=\"seahd\">You need to register and verify your email id to contact this advertiser.</b>";
		testcontrols+="<div class=\"sealogbor\"><span class=\"row1\"><span class=\"logtxt\">Please register (it just takes 2 minutes) or login to respond. <a title=\"Why?\" onclick=\"javascript:displayhelpopen();\" href=\"javascript:void(0);\">Why?</a></span>";
		testcontrols+="<span class=\"logcontclose\"><a title=\"Close\" onclick=\"javascript:displayItemlogclose();document.getElementById('enquiryform').innerHTML='';closeoverlay('enquiryform');\" href=\"javascript:void(0);\"></a></span>";
		testcontrols+="<div id=\"helpcont\" class=\"memformnonact\">The suppliers can contact you easily only if you register and authenticate your email id. And 90% of the suppliers would like to deal only with registered buyers.<div class=\"helpclose\"><a title=\"Close\" onclick=\"javascript:displayhelpclose();\" href=\"javascript:void(0);\">Close</a></div></div>";
		testcontrols+="<div id=\"forget\" class=\"memformnonact\"><div class=\"forrow\">Sample Text</div><div style=\"text-align: center;\" class=\"forrow\"><input type=\"text\" class=\"saelabovr\" value=\"Enter your Email Id\" name=\"Email Id\"/></div>";
		testcontrols+="<div style=\"text-align: center;\" class=\"forrow\"><input type=\"button\" class=\"forsubmit\" value=\"Submit\" name=\"Register\"/></div>";
		testcontrols+="<div class=\"helpcloses\"><a title=\"Close\" onclick=\"javascript:displayItemforgetc();\" href=\"javascript:void(0);\">Close</a></div></div><div class=\"clr\"></div></span>";
		testcontrols+="<div class=\"sealoglt\"><span class=\"saelogltr1\"><b>New Users</b> (Not a Registered member yet?)</span>";
		testcontrols+="<div class=\"saebor\"><div class=\"saecols1\"><b>Your Name</b><input type=\"text\" class=\"saeinput\" value=\" Your Name*\" onkeypress=\"return callauthenticate1(event,1);\" name=\"srname\" id=\"srname\" onfocus=\"input_onfocus1('srname',' Your Name*') \" onblur=\"input_onblur1('srname',' Your Name*');\"/></div>";		
		testcontrols+="<div class=\"saecols\"><b>Login Email</b><input type=\"text\" class=\"saeinput3\" value=\" Your Email Id*\" name=\"Email\" onkeypress=\"return callauthenticate1(event,1);\" id=\"Email\" onfocus=\"input_onfocus1('Email',' Your Email Id*') \" onblur=\"input_onblur1('Email',' Your Email Id*');return ValidateIdentity();\"/></div>";
		//testcontrols+="<div class=\"saebor\"><div class=\"saecols1\"><b>Login Email</b><input type=\"text\" class=\"saeinput\" value=\" Your Email Id*\" onkeypress=\"return callauthenticate1(event,1);\" name=\"Email\" id=\"Email\" onfocus=\"input_onfocus1('Email',' Your Email Id*') \" onblur=\"input_onblur1('Email',' Your Email Id*');\"/></div>";				
		//testcontrols+="<div class=\"saecols\"><b>Your Name</b><input type=\"text\" class=\"saeinput3\" value=\" Your Name*\" name=\"srname\" onkeypress=\"return callauthenticate1(event,1);\"  id=\"srname\" onfocus=\"input_onfocus1('srname',' Your Name*') \" onblur=\"input_onblur1('srname',' Your Name*');\"/></div>";
		testcontrols+="<div class=\"saecols\"><b>Password</b><input type=\"password\" class=\"saeinput3\" value=\"\" name=\"srpass\" onkeypress=\"return callauthenticate1(event,1);\" id=\"srpass\"/></div><div class=\"clr\"></div></div>";
		//testcontrols+="<div class=\"saecols\"><b>Company Name</b><input type=\"text\" class=\"saeinput3\" value=\" Your Company Name*\" onkeypress=\"return callauthenticate1(event,1);\" name=\"Company\" id=\"Company\" onfocus=\"input_onfocus1('Company',' Your Company Name*') \" onblur=\"input_onblur1('Company',' Your Company Name*');\"/></div><div class=\"clr\"></div></div>";
		testcontrols+="<div class=\"saebor1\"><div class=\"saecols1\"><b>Company Name</b><input type=\"text\" class=\"saeinput\" value=\" Your Company Name*\" onkeypress=\"return callauthenticate1(event,1);\" name=\"Company\" id=\"Company\" onfocus=\"input_onfocus1('Company',' Your Company Name*') \" onblur=\"input_onblur1('Company',' Your Company Name*');\"/></div>";
		testcontrols+="<div class=\"saecols\"><b>Country</b><select class=\"saemenu\" name=\"SCountry\" id=\"SCountry\" onchange=\" FillCode1();\"></select></div>";
		testcontrols+="<div class=\"saecols\"><b>Phone Number</b><input type=\"text\" class=\"saeinput1\" value=\"Country\" name=\"CCode\" id=\"CCode\" onkeypress=\"return callauthenticate1(event,1);\" onfocus=\"input_onfocus1('CCode','Country') \" onblur=\"input_onblur1('CCode','Country');\"/><input type=\"text\" onkeypress=\"return callauthenticate1(event,1);\" class=\"saeinput4\" value=\"Area\" name=\"ACode\" id=\"ACode\" onfocus=\"input_onfocus1('ACode','Area') \" onblur=\"input_onblur1('ACode','Area');\"/><input type=\"text\" onkeypress=\"return callauthenticate1(event,1);\" class=\"saeinput2\" value=\" Phone Number*\" name=\"Phone\" maxlength=\"13\" id=\"Phone\" onfocus=\"input_onfocus1('Phone',' Phone Number*') \" onblur=\"input_onblur1('Phone',' Phone Number*');\"/></div><div class=\"clr\"></div></div>";
		testcontrols+="<div class=\"saebor2\"><input type=\"button\" class=\"saesubmit\" value=\"Register and Proceed\" name=\"Register\" id=\"Register\" onclick=\"validatenewregandlogin1(1);\"/></div></div>";
		testcontrols+="<div class=\"sealogrt\"><span class=\"saelogrtr1\">Existing Users</span><div class=\"saelogrtrow\"><span class=\"saelabellt\">Login Email:</span><span class=\"saelabelrt\"><input type=\"text\" class=\"saelabin\" value=\"\" name=\"logemail\" id=\"logemail\" /></span><div class=\"clr\"></div></div>";
		testcontrols+="<div class=\"saelogrtrow\"><span class=\"saelabellt\">Password:</span><span class=\"saelabelrt\"><input type=\"password\" class=\"saelabin\" value=\"\" name=\"Logpwd\" id=\"Logpwd\" onkeypress=\"return callauthenticate1(event,2);\"/></span><div class=\"clr\"></div></div>";
		testcontrols+="<div class=\"saelogrtrow1\"><a title=\"Forgot Password\" href=\"http://www.sulekhab2b.com/network/forgetpwd.aspx\" target=\"blank\" onclick=\"javascript:displayItemforgetp();\" href=\"javascript:void(0);\">Forgot Password?</a></div>";
		testcontrols+="<div class=\"saelogrtrow2\"><input type=\"button\" class=\"saelogin\" value=\"Login\" name=\"Login\" onclick=\"validatenewregandlogin1(2);\"/></div></div><div class=\"clr\"></div></div>";
		testcontrols+="</div>";
	
		newcontentdiv = document.getElementById(reachdividids);
		newcontentdiv.innerHTML=testcontrols;	
		
		assigncountries(3);	
	}
	else
	{
		defaultcontrols1();
	}

}

function callauthenticate1(e,logval)
{
	var key;
	if(window.event)
		key = window.event.keyCode;     //IE
	else
		key = e.which;     //firefox
	
	if (key == 13)
	{
		validatenewregandlogin1(logval);	
		return false;				
	}
}
	
	var newname1= "";
	var newemail1= "";
	var newcomp1= "";
	var newcountry1= "";
	var newpass1= "";
	var newphone1= "";
	
function validatenewregandlogin1(logval)
{		
	if(logval == 1)
	{
		if (ValidateValuesSearchResult1(3)== "yes")
		{
			newname1= document.getElementById("srname").value;
			newemail1= document.getElementById("Email").value;
			newcomp1= document.getElementById("Company").value;
			newcountry1= document.getElementById("SCountry").value;
			newpass1= document.getElementById("srpass").value;
			var arcode=document.getElementById("ACode").value;
			if(arcode!="" && arcode!=null && arcode!="Area")
			{				
				newphone1= document.getElementById("CCode").value+"-"+document.getElementById("ACode").value+"-"+document.getElementById("Phone").value;
			}
			else
			{
				newphone1= document.getElementById("CCode").value+"-"+document.getElementById("Phone").value;
			}
			
			SearchResult.buildprofile(newname1,newemail1,newcomp1,newcountry1,newpass1,newphone1,authval1);				
		}
	}
	else 
	{		
		if(CheckForEmpty(document.getElementById("logemail").value,"Please Enter Email.")==false)
		{
			document.getElementById("logemail").focus();
			return false;
		}		
		if(document.getElementById("logemail").value=="Email Id")
		{
			alert("Please Enter Email");
			document.getElementById("logemail").focus();			
			return false;
		}	
		if(CheckForSplCharAndMaxLength(document.getElementById("logemail").value,4,200,"The Email Id cannot be less than 4 characters Or exceed 200 characters.","","")==false)
		{
			document.getElementById("logemail").focus();
			flag=1;
			return "no";
		}
		if(validateEmail(document.getElementById("logemail").value)==false)
		{
			alert('Please Enter Valid Email Id');
			document.getElementById("logemail").value='';
			document.getElementById("logemail").focus();
			return false;
		}		
		if(CheckForEmpty(document.getElementById("Logpwd").value,"Please Enter Password.")==false)
		{
			document.getElementById("Logpwd").focus();	
			document.getElementById("Logpwd").value='';		
			return false;
		}
		if(document.getElementById("Logpwd").value=="Login Id")
		{
			alert("Please Enter Password");
			document.getElementById("Logpwd").focus();			
			return false;
		}	
		else
		{
			var passvalue=document.getElementById("Logpwd").value;
			if(passvalue.indexOf(' ') != -1)
			{
				alert("Please Avoid Space");
				document.getElementById("Logpwd").focus();	
				document.getElementById("Logpwd").value='';		
				return false;
			}
		}
		if(!ValidateVerified(1))
		{				
			return false;		
		}		
		//SearchResult.authenticuser(document.getElementById('logemail').value,document.getElementById('Logpwd').value,showalert);	
		return true;	
	}
}

function authval1(response)
{	
	if(response.value!=0)
	{		
		document.getElementById("loginchk").value=1;
		document.getElementById("cookievalues").value=newname+","+newemail+","+newphone+","+newcountry+",,"+newcomp;
		
		Set_Cookie('respcookieval','1','','/','','');
				
		defaultcontrols1();
		document.getElementById('altmsg').style.display='block';	
	}
	else
	{
		alert('Invalid Profile');
	}	
}
function showalert1(response)
{		
	if(response.value!="0")
	{				
		setloginstatus();
		logvals1=response.value.split('~');			
		document.getElementById("loginchk").value=1;		
		document.getElementById("cookievalues").value=logvals1[0]+","+logvals1[1]+","+logvals1[4]+","+logvals1[3]+",,"+logvals1[2];	
		//alert(document.getElementById("cookievalues").value);	
		defaultcontrols1();
		return true;
	}
	else
	{
		alert('Invalid Email/Password');
		return false;			
	}	
}

function defaultcontrols1()
{		
	var reachdivid= "enquiryform";
	var testcontrols1= "";
	var newcontentdiv1= "";
		
	testcontrols1="<div class=\"mconfirm\" id=\"altmsg\">An activation mail has been sent to your email address. Kindly check your mail and activate your account before you proceed.</div><div class=\"viewcontform\" id=\"\"><div class=\"viewconthd\"><div class=\"vadvt\">Contact Advertiser:</div><div id=\"emailheader\" class=\"memcontemail memcontactiv\"><a href=\"javascript:void(0);\" onClick=\"javascript:displayItemssmail();\">Send Email</a></div>";
	testcontrols1+="<div id=\"tick\" name=\"tick\" style=\"display:none;\" class=\"sellconttick\"></div><div class=\"memcontclose\"><a href=\"javascript:void(0);\" onclick=\"document.getElementById('enquiryform').innerHTML='';closeoverlay('enquiryform');\" ></a></div></div>";
	testcontrols1+="<div id=\"subdiv\"><div class=\"memcontbdmail memformact\">";
	testcontrols1+="<input class=\"postmailinputlt\" name=\"srname\" maxlength=\"50\" value=\" Your Name*\" type=\"text\" id=\"srname\" onfocus=\"input_onfocus1('srname',' Your Name*')\" onblur=\"input_onblur1('srname',' Your Name*');\"/>";
	testcontrols1+="<input class=\"postmailinputrt\" name=\"Email\"  value=\" Your Email Id*\" type=\"text\" id=\"Email\" onfocus=\"input_onfocus1('Email',' Your Email Id*') \" onblur=\"input_onblur1('Email',' Your Email Id*');\"/>";		
	testcontrols1+="<input class=\"postmailinputrt1\" name=\"Company\"  value=\" Your Company Name*\" type=\"text\" id=\"Company\" onfocus=\"input_onfocus1('Company',' Your Company Name*') \" onblur=\"input_onblur1('Company',' Your Company Name*');\"/>";
	testcontrols1+="<input type=\"hidden\" id=\"SelCname\" name=\"SelCname\" value=\"0\" /><select id=\"SCountry\" name=\"SCountry\" class=\"postmailinputlt8\" onchange=\" FillCode1();\"></select>";
	testcontrols1+="<input class=\"postmailinputlt1\" name=\"CCode\" value=\" Country*\" type=\"text\" id=\"CCode\" onfocus=\"input_onfocus1('CCode',' Country*') \" onblur=\"input_onblur1('CCode',' Country*');\"/><input class=\"postmailinputlt2\" name=\"ACode\" value=\"Area\" type=\"text\" id=\"ACode\" onfocus=\"input_onfocus1('ACode','Area') \" onblur=\"input_onblur1('ACode','Area');\"/><input class=\"postmailinputlt3\" name=\"Phone\" maxlength=\"13\" value=\" Phone Number*\" type=\"text\" id=\"Phone\" onfocus=\"input_onfocus1('Phone',' Phone Number*') \" onblur=\"input_onblur1('Phone',' Phone Number*');\"/>";
	testcontrols1+="<input class=\"postmailinputrt1\" name=\"subject\" value=\" Subject*\" maxlength=\"50\" type=\"text\" id=\"subject\" onfocus=\"input_onfocus1('subject', ' Subject*') \" onblur=\"input_onblur1('subject', ' Subject*');\"/>";
	testcontrols1+="<input type=\"hidden\" id=\"maxchars\" value=\"1500\" NAME=\"maxchars\" /><textarea class=\"postmailinputmid\" name=\"message1\" id=\"message1\" onkeydown=\"check_onkeydown('message1','details_charsCount');\" onkeyup=\"check_onkeyup('message1','details_charsCount',' Enter Your Message*');\"  onfocus=\"input_onfocus1('message1',' Enter Your Message*') \" 	onblur=\"input_onblur1('message1',' Enter Your Message*');\"> Enter Your Message*</textarea><span id=\"details_charsCount\" name=\"details_charsCount\" style=\"display:block;float:right;\">0/1500</span>";
	testcontrols1+="<div class=\"postmailsub\"><input type=\"button\" name=\"update_now\" class=\"postmailstyle\" id=\"update_now\" value=\"Send\" title=\"Click to Send Email\" onclick=\"validatemrcontrols();\"/></div>";
	testcontrols1+="</div></div>";		
	
	newcontentdiv1 = document.getElementById('enquiryform');
	newcontentdiv1.innerHTML=testcontrols1;	
	assigncountries(1);			
}

var senderEmailId1 ="";
var senderSubject1 ="";
var senderphoneno1 ="";
var senderMessage1 = "";
var senderCountry1 = "";
var senderCompany1 ="";
var senderName1 = "";

function validatemrcontrols()
{
	if( ValidateValuesSearchResult1(1)== "yes")
	{			
		senderName1=document.getElementById("srname").value;
		senderEmailId1=document.getElementById("Email").value;
		senderphoneno1 =document.getElementById("CCode").value +"-"+ document.getElementById("ACode").value +"-"+ document.getElementById("Phone").value;
		senderSubject1 =document.getElementById("subject").value;
		senderCountry1=document.getElementById("SCountry").value;
		senderCompany1=document.getElementById("Company").value;
		senderMessage1=document.getElementById("message1").value;	
		var responselocations="17";
		var tradetypes=document.getElementById("type").value;
		var alluids='';
		for(var i=1;i<=10;i++)
		{
			if(document.getElementById('chkitem_'+i))
			{
				if(document.getElementById('chkitem_'+i).checked==true)
				{
					alluids+=document.getElementById('chkitem_'+i).value+'~';
				}
			}
		}
		
		adresponseid=alluids.split("~");
		var outresp= "";	
		for(abc=0;abc<adresponseid.length;abc++)
		{	
			if(adresponseid[abc]!='' && adresponseid[abc]!=null)
			{
				outresp=sendMultiEmail(tradetypes,adresponseid[abc],senderName1,senderEmailId1,senderphoneno1,senderSubject1,senderCountry1,senderCompany1,senderMessage1,responselocations);		
			}
			if(outresp=="1")
			{
				alert('your email has been sent to all the matching valid offers');
				break;
			}
			assignticks(adresponseid[abc]+"_"+tradetypes);	
		}
		alert('your email has been sent to all the matching valid offers');
		closeoverlay('enquiryform');						
	}
	else
	{
		//alert('Please Enter Valid Details.');
	}
}

function displayItemssmail()
{
	document.getElementById("emailheader").className="memcontemail memcontactiv";
	if(document.getElementById("ctocheader"))
	{
		document.getElementById("ctocheader").className="memcontcall memcontnonactiv";
	}
	if(document.getElementById("sendsmsheader"))
	{
		document.getElementById("sendsmsheader").className="memcontsms memcontnonactiv";
	}
}

function displayItemsscall()
{
	document.getElementById("emailheader").className="memcontemail memcontnonactiv";
	if(document.getElementById("ctocheader"))
	{
		document.getElementById("ctocheader").className="memcontcall memcontactiv";
	}
	if(document.getElementById("sendsmsheader"))
	{
		document.getElementById("sendsmsheader").className="memcontsms memcontnonactiv";
	}
}

function displayItemsssms()
{
	document.getElementById("emailheader").className="memcontemail memcontnonactiv";
	if(document.getElementById("ctocheader"))
	{
		document.getElementById("ctocheader").className="memcontcall memcontnonactiv";
	}
	if(document.getElementById("sendsmsheader"))
	{
		document.getElementById("sendsmsheader").className="memcontsms memcontactiv";
	}	   
}
function displayItemspclose()
{
	document.getElementById("viewclose").className="memformnonact";
}

function displayItemsopen()
{
	document.getElementById("viewclose").className="viewcontform";
}
	
function displayItemlogopen()
{
	document.getElementById("loginfo").className="sealogwrap";
}

function displayItemlogclose()
{
	document.getElementById("loginfo").className="memformnonact";
}
		
function displayhelpopen()
{
	document.getElementById("helpcont").className="helpto";
}

function displayhelpclose()
{
	document.getElementById("helpcont").className="memformnonact";
}

function ValidateIdentity()
{				
	if(document.getElementById("Email").value != '' || document.getElementById("Email").value != ' Your Email Id*')
	{			
		return(SearchResult.ValidateIdentity(document.getElementById("Email").value, updatePage1)); 			
	}
	else
	{	
		return true;
	}			
}
function updatePage1(response)
{	
	if(response.value == 'Present')
	{					
		alert(document.getElementById("Email").value  + " is already in use. Please choose another email");		
		document.getElementById("logemail").value=document.getElementById("Email").value;			
		document.getElementById("logemail").select();
		document.getElementById("logemail").focus();
		document.getElementById("Email").value=" Your Email Id*";
		return false;
	}
	else if(response.value == 'NOT EXISTS')
	{		
		return true;
	}
	else
	{
		return true;
	}
}

function Get_Cookie(H)
{
	var I=document.cookie.split(";");  		
	var G="";
	var K="";
	var J="";
	var L=false;
	for(i=0;i<I.length;i++)
	{
		G=I[i].split("=");
		K=G[0].replace(/^\s+|\s+$/g,"");               
		if(K==H)
		{
			L=true;
			if(G.length>1)
			{
				J=unescape(G[1].replace(/^\s+|\s+$/g,""))
			}
			return J;
			break;
		}
		G=null;
		K="";
	}
	if(!L)
	{
		return null;
	}
}	 

function Set_Cookie(I,O,K,L,P,M)
{		
	var J=new Date();
	J.setTime(J.getTime());
	if(K)
	{
		K=K*1000*60*60*24;
	}

	var N=new Date(J.getTime()+(K));	
	document.cookie = I + "=" + ( O )+
	( ( K ) ? ";expires=" + N.toGMTString() : "" ) +
	( ( L ) ? ";path=" + L : "" ) +
	( ( P ) ? ";domain=" + P : "" ) +
	( ( M ) ? ";secure" : "" );	
}	 

function mulcondisp()
{	
	document.getElementById('multirespconttop').style.display='none' ;
	document.getElementById('multirespcontbottom').style.display='none' ;	
	var _curloc=document.getElementById('curlocationval').value;
	_curloc=_curloc.toLowerCase();
	if(_curloc=="<b>all</b>")
	{
		document.getElementById('chgcntry').style.display='none' ;
	}	
}