var responselocation="";
var showCtoC="";
var showSMS="";
var curpaid="";
var curcountry="";
var calledCtoC="";
var curcontactno="";
var hideFlag=0;

function initialCall()
{
	var offerid ="";
	var country ="";
	var tradetype ="";
	var ispaid ="";
	var location1="";
	var location="";
	var contactno="";
	hideFlag=0;
	try
	{
	location1 = document.getElementById("responselocation").value;
	location = location1.split(",");
	responselocation=location[0];
	showCtoC=location[1];
	showSMS=location[2];
	ispaid= location[3];
	tradetype=location[4];
	offerid=location[5];
	country=location[6];
	contactno=location[7];
	curcontactno=contactno;
	if (ispaid==1 || ispaid==2 ||ispaid==3 )
	{
		ispaid=1;
	}
	
	}
	catch(e)
	{
		
	}
	loadcontrols(offerid,ispaid,country,tradetype,contactno)
}

function loadcontrols(offerid,ispaid,country,tradetype,contactno)
{

var controls="";
var ctoc="";

curpaid=ispaid;
curcountry=country;
calledCtoC=document.getElementById("ctocofferids").value;
defaultcontrols(offerid,ispaid,country,tradetype,contactno);
document.getElementById("ids").value=offerid;
document.getElementById("emailheader").style.fontWeight="bold";
document.getElementById("blockid").value="1";
assignticks(offerid,tradetype); 
}

function defaultcontrols(offerid,ispaid,country,tradetype,contactno)
{
	var headerdiv= "";
	var subdiv= "";
	var controls= "";
	var testcontrols= "";
	var newcontentdiv= "";
	var paid=0;
		
		testcontrols="<div class=\"memcontform\"><div class=\"memconthd\"><div id=\"emailheader\" class=\"memcontemail memcontactiv\"><a href=\"javascript:void(0);\" onClick=\"javascript:displayItemssmail();fillcontrols("+tradetype+",1,"+offerid+");\">Send Email</a></div>";
		
		if (tradetype=="0")
		{
			if ((showCtoC == ispaid || showCtoC == "2") && (calledCtoC.indexOf(offerid+"_4")== "-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>";
				 }
		}
		else
		{
			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>";
		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=\"CCcode\" value=\" Country*\" type=\"text\" id=\"CCcode\" onfocus=\"input_onfocus1('CCcode',' Country*') \" onblur=\"input_onblur1('CCcode',' Country*');\"/><input class=\"postmailinputlt2\" name=\"ACcode\" value=\" Area*\" type=\"text\" id=\"ACcode\" onfocus=\"input_onfocus1('ACcode',' Area*') \" onblur=\"input_onblur1('ACcode',' Area*');\"/><input class=\"postmailinputlt3\" name=\"Phone\" value=\" Phone Number*\" type=\"text\" id=\"Phone\" 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:none;\">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('container');
		newcontentdiv.innerHTML=testcontrols;
		assigncountries(1);	
}

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 fillcontrols(tradetype,type,offerid)
{
	var controls= "";
	var testcontrols= "";
	var dothis = checkthis(type);
	if (dothis==5)
	{
	if(type==0)//Click to Call for Free
		{
			if (hideFlag ==1)
			{
				initialCall();
				return;
			}
			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>";
			document.getElementById("subdiv").innerHTML=testcontrols;
			assigncountries(0);
			
		}
		else if (type==1)//Send Email Response
		{
			if (hideFlag ==1)
			{
				initialCall();
				return;
			}
			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=\"CCcode\" value=\" Country*\" type=\"text\" id=\"CCcode\" onfocus=\"input_onfocus1('CCcode',' Country*') \" onblur=\"input_onblur1('CCcode',' Country*');\"/><input class=\"postmailinputlt2\" name=\"ACcode\" value=\" Area*\" type=\"text\" id=\"ACcode\" onfocus=\"input_onfocus1('ACcode',' Area*') \" onblur=\"input_onblur1('ACcode',' Area*');\"/><input class=\"postmailinputlt3\" name=\"Phone\" value=\" Phone Number*\" type=\"text\" id=\"Phone\" 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:none;\">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 (hideFlag ==1)
			{
				initialCall();
				return;
			}
			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 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:none;\">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 "";
}

function getvalues(type,tradetype,offerid)
{
	var senderEmailId ="";
	var senderSubject ="";
	var senderphoneno ="";
	var senderMessage = "";
	var senderCountry = "";
	var senderCompany ="";
	var senderName = "";
	
	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;
				//InitiateCall(tradetype,offerid,senderphoneno,responselocation,senderName);
				senderphoneno =document.getElementById("Phone").value;
				
				if (checkSenderCtoC(senderphoneno))
				{
					hideFlag=1;
					InitiateCall(tradetype,offerid,senderphoneno,responselocation,senderName);
				}
				else
				{
					//alert("Invalid Phone Number!!! No Space/Special character. E.g.: For China - International prefix(00), Country Code(86) , Area code(11) and phone number (2222222) - 0086112222222");
					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("CCcode").value + document.getElementById("ACcode").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;
			
				//sendEmail(tradetype,offerid,senderName,senderEmailId,senderphoneno,senderSubject,senderCountry,senderCompany,senderMessage,responselocation);	
				if (checksenderEmail(senderphoneno))
				{
					
					//alert(1456456);
sendEmail(tradetype,offerid,senderName,senderEmailId,senderphoneno,senderSubject,senderCountry,senderCompany,senderMessage,responselocation);	
					//alert('ok');
					try
					{
					document.getElementById("subdiv").style.display = "none" ;
					
					document.getElementById("sendinganimation").style.display = "block" ;
					document.getElementById("container").style.display = "none" ;
					}
					catch(e)
					{
					}
				}
				else
				{
					//alert("Invalid Phone Number!!! No Space/Special character. E.g.: For China - International prefix(00), Country Code(86) , Area code(11) and phone number (2222222) - 0086112222222");
					document.getElementById("Phone").select();
					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;
				/*document.getElementById("subdiv").style.display = "none" ;
				document.getElementById("sendinganimation").style.display = "block" ;
				document.getElementById("container").style.display = "none" ;	*/
				//sendSmsForm(tradetype,offerid,senderName,senderEmailId,senderphoneno,senderMessage,responselocation);
				if (checkSenderSMS(senderphoneno))
				{
					document.getElementById("subdiv").style.display = "none" ;
					document.getElementById("sendinganimation").style.display = "block" ;
					document.getElementById("container").style.display = "none" ;
					sendSmsForm(tradetype,offerid,senderName,senderEmailId,senderphoneno,senderMessage,responselocation);
					window.location = "/searchmailresponse.aspx";
				}
				else
				{
					//alert("Invalid Phone Number!!! No Space/Special character. E.g.: For China - International prefix(00), Country Code(86) , Area code(11) and phone number (2222222) - 0086112222222");
					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 = "aliceblue";
		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 = "aliceblue";
	//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("ACcode").value=phval[1];
							document.getElementById("Phone").value=phval[phval.length-1];
						}
						
					}
					else
					{
						document.getElementById("Phone").value=allvalues[2];
					}
				}
				if(type==0 || type==2)
				{
					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)
		 {
		 try
			{
				if(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(id, tratype)
{
	
	var curoid = id+"_"+tratype;
	var previousids= document.getElementById("previousids").value;	
	if (previousids.indexOf(',')=="-1" && previousids!="" && curoid==previousids)
	{
		try
		{
			document.getElementById("tick").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 && OfferId[i]==curoid )
			{
				try
				{
					document.getElementById("tick").style.display = "inline" ;
				}
				catch(e)
				{
					
				}
			}
		}
	}

	
}

function ValidateValuesSearchResult1(type)
{
	var flag=0;	
	if (type==0)
	{
		if(CheckEmpty(document.getElementById("srname"),"Please Enter Name.",true,true)==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(document.getElementById("Phone").value==" Phone*")
		{
			alert("Please Enter Phone Number");
			document.getElementById("Phone").focus();
			flag=1;
			return "no";
		}		
	}	
	if(type==1)
	{
		if(CheckEmpty(document.getElementById("srname"),"Please Enter Name.",true,true)==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(CheckEmpty(document.getElementById("Email"),"Please Enter Email.",true,true)==false)
		{
			document.getElementById("Email").focus();
			flag=1;
			return "no";
		}		
		if(CheckSplCharAndMaxLength(document.getElementById("Email"),4,200,"The Email Id cannot be less than 4 characters Or exceed 200 characters.",false,true,"","")==false)
		{
			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(CheckEmpty(document.getElementById("Company"),"Please Enter Company Name.",true,true)==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(document.getElementById("SCountry").selectedIndex == 0)
		{
			alert("Please Select Country.");
			document.getElementById("SCountry").focus();
			flag=1;
			return "no";
		}	
		if(document.getElementById("CCcode").value==" Country*")
		{
			alert("Please Enter CountryCode");
			document.getElementById("CCcode").focus();
			flag=1;
			return "no";
		}
		
		if(document.getElementById("ACcode").value==" Area*")
		{
			alert("Please Enter AreaCode");
			document.getElementById("ACcode").focus();
			flag=1;
			return "no";
		}
		recACode=document.getElementById("ACcode").value
		if(recACode!=null && recACode!="" && recACode!=" Area*")
		{
			if(checkSenderNumberACode1(recACode))
			{				
				if ( (recACode.length <= 6) && (recACode.substring(0,3)!= "000" ))
				{					
					//return true;
				}
				else
				{
					alert("Invalid AreaCode!!!");
					document.getElementById("ACcode").select();
					return "no";
				}
			}
			else
			{				
				return false;	
			}
		}
		
		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(CheckEmpty(document.getElementById("subject"),"Please Enter Subject.",true,true)==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(CheckEmpty(document.getElementById("message1"),"Please Enter Message",true,true)==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(CheckEmpty(document.getElementById("srname"),"Please Enter Name.",true,true)==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(CheckEmpty(document.getElementById("Email"),"Please Enter Email.",true,true)==false)
		{
			document.getElementById("Email").focus();
			flag=1;
			return "no";
		}		
		if(CheckSplCharAndMaxLength(document.getElementById("Email"),4,200,"The Email Id cannot be less than 4 characters Or exceed 200 characters.",false,true,"","")==false)
		{
			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(document.getElementById("Phone").value==" Your Mobile number*")
		{
			alert("Please Enter Mobile Number");
			document.getElementById("Phone").focus();
			flag=1;
			return "no";
		}
		if(CheckEmpty(document.getElementById("message1"),"Please Enter Message",true,true)==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 progressBar()
{
	//alert(" in progressBar ");
	//document.getElementById("sendinganimation").innerTEXT="Sending Response<SCRIPT type=\"text/javascript\">var bar1= createBar(250,13,'aliceblue',1,'grey','orange',50,10,1,'');alert('progress bar');</SCRIPT>";
}


function FillCode1()
{	
	var Country=document.getElementById("SCountry").value;	
	return(ViewOffer.FillCountryCode(Country,BindValue1));				
}
function BindValue1(response)
{		
	document.getElementById("CCcode").value=response.value;
	document.getElementById("CCcode").disabled=true;	
}

function checkSenderNumberACode1(str)
{
	var numericExpression = /^[0-9]+$/;
	if(str.match(numericExpression))
	   {
		  return true;
       }
       else
       {
		  document.getElementById("ACcode").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;    
       }
	
}
