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);
assigncountries(1);
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 reachdivid= "reach1_" +offerid;
	var newcontentdiv= "";
	var paid=0;
	
		
			controls="<table width=\"100%\" style=\"margin-top:5px;font-size:11px;background-color:#F6FAFB;border:1px solid #C1CAD1;padding:5px;\"  align=\"left\" cellspacing=\"0\"><tr align=\"left\" height=\"20px\" style=\"background-color:#E0EAF1;\"><td style=\"font-size:12px;border-bottom:1px solid #C1CAD1;\" width=\"30%\" colspan=\"2\"><b><font style=\"margin-left:4px;\">Contact Advertiser :</font></b></td><td style=\"horizontal-align:right;border-bottom:1px solid #C1CAD1;\"><span id=\"tick\" name=\"tick\" style=\"align:right;vertical-align:middle;display:none;margin-right:15px;margin-left:2px;\"><img border=\"0\" src=\"/images/emailtick.gif\" alt=\"You have responded to this Ad.\" width=\"16\" height=\"16\"/></span></td></tr><tr align=\"left\" style=\"horizontal-align:left;padding-left:5px;\" ><td style=\"horizontal-align:right;padding-top:5px;\" width=\"25%\"><div style=\"display:inline;\" id=\"emailheader\"><a onclick=\"fillcontrols("+tradetype+",1,"+offerid+");\" href=\"javascript:void(0);\" id=\"anchoremail\" title=\"send email response\"><img src=\"/images/email.gif\" style=\"margin-left:4px;\" height=\"13\" width=\"19\" border=\"0\" alt=\"send email response\" onclick=\"fillcontrols("+tradetype+",1,"+offerid+");\" />&#160;Send Email</a></div></td><td width=\"75%\" valign=\"top\" style=\"padding-top:5px;\">";
			if ((showCtoC == ispaid || showCtoC == "2") && (calledCtoC.indexOf(offerid+"_"+tradetype) == "-1" ) && ( checkReceiverCtoC(contactno) ) )
				 {
					controls+="<div style=\"display:inline;margin-left:10px;margin-right:20px;vertical-align:middle;\" id=\"ctocheader\" width=\"100%\" ><a onclick=\"fillcontrols("+tradetype+",0,"+offerid+");\"    href=\"javascript:void(0);\" id=\"anchorctoc\"  title=\"click to call for free\" style=\"cursor:hand;\"><img src=\"/images/CtoC.gif\" border=\"0\" alt=\"Click to call for free\" onclick=\"fillcontrols("+tradetype+",0,"+offerid+");\"/>&#160;Click to Call for Free</a></div>";
				 }
			
			if (country == "India")
			{
				if (checkReceiverSMS(contactno) )
				{
					if(showSMS == ispaid  || showSMS == "2")
				 		{
							controls+="<div style=\"display:inline;margin-left:10px;vertical-align:middle;\" id=\"sendsmsheader\"><a onclick=\"fillcontrols("+tradetype+",2,"+offerid+");\" href=\"javascript:void(0);\" id=\"sendsms\"  title=\"send free SMS\" style=\"cursor:hand;font-size:12px;margin-right:6px;\"><img src=\"/images/mPhone.gif\" border=\"0\" alt=\"Send free SMS\" onclick=\"fillcontrols("+tradetype+",2,"+offerid+");\"/>&#160;Send Free SMS</a></div>";
						}
				} 
			}
					
				
		controls+="</td></tr>";
		controls+="<tr align=\"center\"><td colspan=\"5\" width=\"100%\"><div align=\"center\" id=\"subdiv\" style=\"clear:both;\"><table width=\"99%\"  border=\"0\" style=\"margin-left:1px;background-color:white;border:1px solid #CAD5D9;margin-top:8px;\"><tr><td colspan=\"2\" align=\"left\" class=\"bktxt12\">&#160;<b>Send Email Response</b></td><td align=\"right\"></td></tr>";
		controls+="<tr align=\"center\"><td width=\"31%\"><input class=\"searchtxt\" style=\"width:95%\" name=\"srname\"  value=\" Your Name*\" type=\"text\" id=\"srname\" maxlength=\"50\" size=\"20\" onfocus=\"input_onfocus1('srname',' Your Name*')\" onblur=\"input_onblur1('srname',' Your Name*');\"/></td>";
		controls+="<td width=\"38%\"><input class=\"searchtxt\" style=\"width: 95%;\" name=\"Email\"  value=\" Your Email Id*\" type=\"text\" id=\"Email\" size=\"20\" onfocus=\"input_onfocus1('Email',' Your Email Id*') \" 	onblur=\"input_onblur1('Email',' Your Email Id*');\"/></td>";
		controls+="<td width=\"32%\"><input class=\"searchtxt\" style=\"width: 95%;\" name=\"Phone\" title=\"Enter number with Country code and Area code. No Special Characters.\" value=\" Phone Number*\" type=\"text\" id=\"Phone\" size=\"20\" onfocus=\"input_onfocus1('Phone',' Phone Number*') \" 	onblur=\"input_onblur1('Phone',' Phone Number*');\"/></td></tr>";
		controls+="<tr align=\"center\"><td width=\"31%\"><input class=\"searchtxt\" style=\"width: 95%;\" maxlength=\"50\" name=\"subject\" value=\" Subject*\" type=\"text\" id=\"subject\" size=\"20\" onfocus=\"input_onfocus1('subject', ' Subject*') \" 	onblur=\"input_onblur1('subject', ' Subject*');\"/></td>";
		controls+="<td width=\"38%\"><input type=\"hidden\" id=\"SelCname\" name=\"SelCname\" value=\"0\" /> <input type=\"hidden\" id=\"SelCountryIndex\" name=\"SelCountryIndex\" value=\"0\" /><select id=\"SCountry\" name=\"SCountry\" style=\"width: 97%;height:20px;\" class=\"searchtxt\"></select></td>";
		controls+="<td width=\"31%\"><select id=\"SObjective\" name=\"SObjective\" style=\"width:97%;height:20px;\" class=\"searchtxt\"><option value=\"0\">Select Objective*</option><option value=\"2\">I want to sell</option><option value=\"1\">I want to buy</option><option value=\"3\">I want to exp. busi. opp.</option></select></td></tr>";
		controls+="<tr align=\"center\"><td colspan=\"3\" ><input type=\"hidden\" id=\"maxchars\" value=\"1500\" NAME=\"maxchars\" /><textarea class=\"searchtxt\" name=\"message1\" id=\"message1\" rows=\"2\" style=\"width:98%;height:50px;\" cols=\"10\"  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></td></tr>";
		controls+="<tr align=\"center\" ><td align=\"left\" colspan=\"2\"><span style=\"font-size:10px;\">&#160;<b>*</b>&#160;-<i>All fields are Mandatory</span><div style=\"display:inline;margin-left:75px;\"><input type=\"button\" style=\"Cursor:pointer;\"  name=\"update_now\" class=\"mpbutbg\" id=\"update_now\" value=\"Send\" title=\"Click to Send Email\" onclick=\"getvalues( 1 ,"+tradetype+","+offerid+");\"/></div></td><td align=\"right\">-<span id=\"details_charsCount\" name=\"details_charsCount\" class=\"bktxt12\" style=\"font-size:12px;padding:10px;\">0/1500</span></td></tr>";
		controls+="</table></div></td></tr>";
		controls+="<tr align=\"center\"><td colspan=\"3\" style=\"horizontal-align:left;clear:both;\" >Please read this before you respond: <a onclick=\"openNoticewindow();\" href=\"javascript:void(0)\" title=\"Please read this before you respond\">Notice to SulekhaB2B Users</a></td></tr></table>"
		newcontentdiv = document.getElementById('container');
		newcontentdiv.innerHTML=controls;	
	
	
}

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 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";
					}
				}
			}
			
			controls="<div style=\"BEHAVIOR: url(/webservice.htc);\" id=\"CtoCDiv\"><table width=\"99%\" cellpadding=\"3\" border=\"0\" style=\"margin-left:1px;background-color:white;border:1px solid #CAD5D9;margin-top:8px;\" cellspacing=\"1\" ><tr><td align=\"left\" class=\"bktxt12\"><b>Click to Call for Free</b></td></tr><tr align=\"left\"><td class=\"txt11\">SulekhaB2B can call your phone now and connect you to this advertiser for free &#160;<img src=\"/images/questionmark.gif\" border=\"0\" style=\"Cursor:pointer;\" title=\"more details\" alt=\"more details\" onclick=\"openwindow();\"/></td></tr>"
			controls+="<tr><td align=\"left\"><div id=\""+divid+"\" name= \""+divid+"\"><input class=\"searchtxt\" style=\"width:35%\" name=\"srname\" maxlength=\"50\"  value=\" Your Name*\" type=\"text\" id=\"srname\" size=\"20\" onfocus=\"input_onfocus1('srname',' Your Name*')\" onblur=\"input_onblur1('srname',' Your Name*');\"/>&#160;&#160;<input type=\"text\" name=\"Phone\" id=\"Phone\" size=\"25\" 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*');\"/>&#160;&#160;&#160;<input type=\"button\" value=\"click to call\" class=\"mpbutbg\" id=\"caller\" name=\"caller\" style=\"Cursor:pointer;\" title=\"click to call\" onclick=\"getvalues( 0 ,"+tradetype+","+offerid+");\"/><br/>";
			controls+="</div></td></tr>";
			controls+="<tr align=\"left\"><td style=\"line-height:15px;color:#CC3416;\" class=\"txt11\">Enter number with Country code and Area code. No spaces/special characters. E.g. US: 00173263XXXXX   India: 9180233XXXXX (Landline)   9198840XXXXX (Mobile)</td></tr>"
			controls+="</table></div><div id=\"divfeedback\" style=\"margin:3px;background-color:aliceblue;border:1px solid #695525;line-height: 0.5cm;width:98%;height:140px;display:none;\" valign=\"middle\"></div>";
			
			document.getElementById("subdiv").innerHTML=controls;
			
			assigncountries(0);
			
		}
		else if (type==1)//Send Email Response
		{
			if (hideFlag ==1)
			{
				initialCall();
				return;
			}
			controls+="<div align=\"center\" id=\"subdiv\" ><table width=\"99%\" border=\"0\" style=\"margin-left:1px;background-color:white;border:1px solid #CAD5D9;margin-top:8px;\"><tr><td colspan=\"2\" align=\"left\" class=\"bktxt12\">&#160;<b>Send Email Response</b></td><td align=\"right\"></td></tr>";
			controls+="<tr align=\"center\"><td width=\"31%\"><input class=\"searchtxt\" style=\"width:95%\" name=\"srname\" maxlength=\"50\"  value=\" Your Name*\" type=\"text\" id=\"srname\" size=\"20\" onfocus=\"input_onfocus1('srname',' Your Name*')\" onblur=\"input_onblur1('srname',' Your Name*');\"/></td>";
			controls+="<td width=\"38%\"><input class=\"searchtxt\" style=\"width: 95%;\" name=\"Email\"  value=\" Your Email Id*\" type=\"text\" id=\"Email\" size=\"20\" onfocus=\"input_onfocus1('Email',' Your Email Id*') \" 	onblur=\"input_onblur1('Email',' Your Email Id*');\"/></td>";
			controls+="<td width=\"32%\"><input class=\"searchtxt\" style=\"width: 95%;\" name=\"Phone\" value=\" Phone Number*\" type=\"text\" id=\"Phone\" size=\"20\" title=\"Enter number with Country code and Area code. No Special Characters.\" onfocus=\"input_onfocus1('Phone',' Phone Number*') \" 	onblur=\"input_onblur1('Phone',' Phone Number*');\"/></td></tr>";
			controls+="<tr align=\"center\"><td width=\"31%\"><input class=\"searchtxt\" style=\"width: 95%;\" name=\"subject\" maxlength=\"50\" value=\" Subject*\" type=\"text\" id=\"subject\" size=\"20\" onfocus=\"input_onfocus1('subject', ' Subject*') \" 	onblur=\"input_onblur1('subject', ' Subject*');\"/></td>";
			controls+="<td width=\"38%\"><input type=\"hidden\" id=\"SelCname\" name=\"SelCname\" value=\"0\" /> <input type=\"hidden\" id=\"SelCountryIndex\" name=\"SelCountryIndex\" value=\"0\" /><select id=\"SCountry\" name=\"SCountry\" style=\"width: 97%;height:20px;\" class=\"searchtxt\"></select></td>";
			controls+="<td width=\"31%\"><select id=\"SObjective\" name=\"SObjective\" style=\"width:97%;height:20px;\" class=\"searchtxt\"><option value=\"0\">Select Objective*</option><option value=\"2\">I want to sell</option><option value=\"1\">I want to buy</option><option value=\"3\">I want to exp. busi. opp.</option></select></td></tr>";
			controls+="<tr align=\"center\"><td colspan=\"3\" ><input type=\"hidden\" id=\"maxchars\" value=\"1500\" NAME=\"maxchars\" /><textarea class=\"searchtxt\" name=\"message1\" id=\"message1\" rows=\"2\" style=\"width:98%;height:50px;\" cols=\"10\"  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></td></tr>";
			controls+="<tr align=\"center\" ><td align=\"left\" colspan=\"2\"><span style=\"font-size:10px;\">&#160;<b>*</b>&#160;-<i>All fields are Mandatory</span><div style=\"display:inline;margin-left:75px;\"><input type=\"button\" style=\"Cursor:pointer;\"  name=\"update_now\" class=\"mpbutbg\" id=\"update_now\" value=\"Send\" title=\"Click to Send Email\" onclick=\"getvalues( 1 ,"+tradetype+","+offerid+");\"/></div></td><td align=\"right\">-<span id=\"details_charsCount\" name=\"details_charsCount\" class=\"bktxt12\" style=\"font-size:12px;padding:10px;\">0/1500</span></td></tr>";
			controls+="</table></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=controls;
			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";
			
			controls+="<div align=\"center\"><table border=\"0\" style=\"width:99%;margin-left:1px;background-color:white;border:1px solid #CAD5D9;margin-top:8px;\"><tr align=\"left\"><td colspan=\"3\" class=\"bktxt12\">&#160;<b>Send Free SMS</b></td></tr><tr><td width=\"31%\"><input class=\"searchtxt\" style=\"width:95%;\" name=\"srname\" maxlength=\"50\" onfocus=\"input_onfocus1('srname',' Your Name*')\" onblur=\"input_onblur1('srname',' Your Name*');\" value=\" Your Name*\" type=\"text\" id=\"srname\" size=\"20\" /></td>";
			controls+="<td width=\"31%\"><input class=\"searchtxt\"  style=\"width:95%;\" name=\"Email\"  value=\" Your Email Id*\" type=\"text\" id=\"Email\" size=\"20\" onfocus=\"input_onfocus1('Email',' Your Email Id*')\" onblur=\"input_onblur1('Email',' Your Email Id*');\"/></td>";
			controls+="<td width=\"31%\"><input class=\"searchtxt\"  style=\"width:95%;\" 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\" size=\"20\" /></td></tr>";
			controls+="<tr><td colspan=\"3\"> <input type=\"hidden\" id=\"maxchars\" value=\"100\" NAME=\"maxchars\" /><textarea class=\"searchtxt\" name=\"message1\" id=\"message1\" rows=\"2\" style=\"width:98%;height:50px;\" cols=\"10\" 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></td></tr>";
			controls+="<tr><td align=\"left\" colspan=\"2\"><span style=\"font-size:10px;\">&#160;<b>*</b>&#160;-<i>All fields are Mandatory</span><div style=\"display:inline;margin-left:75px;\"><input type=\"button\" style=\"Cursor:pointer;\"  name=\"update_now\" class=\"mpbutbg\" id=\"update_now\" value=\"Send\" title=\"Click to Send Free SMS\" onclick=\"getvalues( 2 ,"+tradetype+","+offerid+");\"/></div></td><td align=\"right\">-<span id=\"details_charsCount\" name=\"details_charsCount\" class=\"bktxt12\" style=\"font-size:12px;padding:10px;\">0/100</span></td></tr>";
			document.getElementById("subdiv").innerHTML=controls;
			assigncountries(2);
		}
		return controls;
	}
		return "";
}

function getvalues(type,tradetype,offerid)
{
	var senderEmailId ="";
	var senderSubject ="";
	var senderphoneno ="";
	var senderMessage = "";
	var senderCountry = "";
	var senderObjective ="";
	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
				{
					//alert("being added");
					document.getElementById("ctocofferids").value=offerid+"_"+tradetype;
				}
				
				calledCtoC=document.getElementById("ctocofferids").value;
				senderName=document.getElementById("srname").value;
				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("Phone").value;
				senderSubject =document.getElementById("subject").value;
				senderCountry=document.getElementById("SCountry").value;
				senderObjective=document.getElementById("SObjective").value;
				senderMessage=document.getElementById("message1").value;
				
				if (checksenderEmail(senderphoneno,senderCountry))
				{
					document.getElementById("subdiv").style.display = "none" ;
					document.getElementById("sendinganimation").style.display = "block" ;
					document.getElementById("container").style.display = "none" ;
					sendEmail(tradetype,offerid,senderName,senderEmailId,senderphoneno,senderSubject,senderCountry,senderObjective,senderMessage,responselocation);	
				}
				else
				{
					//alert("Enter Number with International prefix, Country code, Area code and Phone Number. No Special Characters.\nAlways International prefix=00 ,E.g. for China -Country Code=86, Areacode=10, PhoneNo.=78454136. So Phone No: 00861078454136" );
					//document.getElementById("Phone").value="";
					//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 ;
				}
				//sendEmail(tradetype,offerid,senderName,senderEmailId,senderphoneno,senderSubject,senderCountry,senderObjective,senderMessage,responselocation);	
			} 
		}
		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))
				{
					sendSmsForm(tradetype,offerid,senderName,senderEmailId,senderphoneno,senderMessage,responselocation);
					window.location = "/searchmailresponse.aspx";
				}
				else
				{
					//alert("Enter Number with International prefix, Country code, Area code and Phone Number. No Special Characters.\nAlways International prefix=00 ,E.g. for China -Country Code=86, Areacode=10, PhoneNo.=78454136. So Phone No: 00861078454136");
					//document.getElementById("Phone").value="";
					//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]!="")
			{
					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
			{
				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");
				for(var i=1;i<setcountries.length;i++)
				{
					ctryval = setcountries[i].split(";");
					document.getElementById("SCountry").options[i] = new Option(ctryval[1],ctryval[1]);	
					if (allvalues!="")
					{			
						if (ctryval[1]==allvalues[3]) 
						{
							document.getElementById("SCountry").options[i].selected=true;				
						}
					}
				}
			}
		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==1 || type==2 ||type==0)
			{	
				if(CheckForEmpty(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 (type==1 || type==2 )
			{
								
				if(CheckForEmpty(document.getElementById("Email"),"Please Enter Email.",true,true)==false)
				{
					document.getElementById("Email").focus();
					flag=1;
					return "no";
				}
				
				if(CheckForSplCharAndMaxLength(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 (type==1 ||type==0 ||type==2 && flag==0)
			{
				if(document.getElementById("Phone").value==" Phone Number*")
				{
					alert("Please Enter Phone Number");
					document.getElementById("Phone").focus();
					flag=1;
					return "no";
				}
				
				/*if (type==2)
				{
					if(MobilePhoneValidation(document.getElementById("Phone").value)==false)
					{
						alert("Enter a Valid Mobile Number");
						document.getElementById("Phone").value='';
						document.getElementById("Phone").focus();	
						flag=1;
						return "no";	
					}
				}
				
				if(CheckGivenValue(document.getElementById("Phone"),"0123456789[](),+,-","Invalid Phone/Mobile Number")==false)
				{
					document.getElementById("Phone").value='';
					document.getElementById("Phone").focus();
					flag=1;
					return "no";
				}
				if (trim(getOnlyNumbers(document.getElementById("Phone").value)) =="")
				{
					alert('Invalid Phone/Mobile Number');
					document.getElementById("Phone").value='';
					document.getElementById("Phone").focus();
					flag=1;
					return "no";
				}*/
			}
			
			if(type==1 && flag==0)
			{
				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(document.getElementById("SCountry").selectedIndex == 0)
				{
					alert("Please Select Country.");
					document.getElementById("SCountry").focus();
					flag=1;
					return "no";
				}
				
				if(document.getElementById("SObjective").selectedIndex == 0)
				{
					alert("Please Select Response Objective.");
					document.getElementById("SObjective").focus();
					flag=1;
					return "no";	
				}
				
			}			
				
			if((type==1 || type==2) && flag==0)
			{
				if(CheckForEmpty(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";
	
}





