function includeJavaScript(jsFile){
      document.write('<script type="text/javascript" src="'
        + jsFile + '"></script>'); 
}

includeJavaScript('/js/dropdowncontent.js');


var localizedCountryData = new Array();localizedCountryData['AD'] = Array('Andorra', '376');localizedCountryData['AG'] = Array('Antigua + Barbuda', '1268');localizedCountryData['AR'] = Array('Argentina', '54');localizedCountryData['AW'] = Array('Aruba', '297');localizedCountryData['AU'] = Array('Australia', '61');localizedCountryData['AT'] = Array('Austria', '43');localizedCountryData['BE'] = Array('Belgium', '32');localizedCountryData['BM'] = Array('Bermuda', '1441');localizedCountryData['BO'] = Array('Bolivia', '591');localizedCountryData['BR'] = Array('Brazil', '55');localizedCountryData['BG'] = Array('Bulgaria', '359');localizedCountryData['CA'] = Array('Canada', '1');localizedCountryData['KY'] = Array('Cayman Islands', '1345');localizedCountryData['CL'] = Array('Chile', '56');localizedCountryData['CN'] = Array('China', '86');localizedCountryData['HR'] = Array('Croatia', '385');localizedCountryData['CY'] = Array('Cyprus', '357');localizedCountryData['CZ'] = Array('Czech Republic', '420');localizedCountryData['DK'] = Array('Denmark', '45');localizedCountryData['DM'] = Array('Dominica', '1767');localizedCountryData['DO'] = Array('Dominican Republic', '1806');localizedCountryData['EC'] = Array('Ecuador', '593');localizedCountryData['EG'] = Array('Egypt', '20');localizedCountryData['SV'] = Array('El Salvador', '503');localizedCountryData['EE'] = Array('Estonia', '372');localizedCountryData['FJ'] = Array('Fiji Islands', '679');localizedCountryData['FI'] = Array('Finland', '358');localizedCountryData['FR'] = Array('France', '33');localizedCountryData['GF'] = Array('French Guiana', '594');localizedCountryData['DE'] = Array('Germany', '49');localizedCountryData['GR'] = Array('Greece', '30');localizedCountryData['GD'] = Array('Grenada', '1473');localizedCountryData['GP'] = Array('Guadeloupe', '590');localizedCountryData['HK'] = Array('Hong Kong', '852');localizedCountryData['HU'] = Array('Hungary', '36');localizedCountryData['IS'] = Array('Iceland', '354');localizedCountryData['IN'] = Array('India', '91');localizedCountryData['ID'] = Array('Indonesia', '62');localizedCountryData['IE'] = Array('Ireland', '353');localizedCountryData['IL'] = Array('Israel', '972');localizedCountryData['IT'] = Array('Italy', '39');localizedCountryData['JM'] = Array('Jamaica', '1876');localizedCountryData['LV'] = Array('Latvia', '371');localizedCountryData['LI'] = Array('Liechtenstein', '423');localizedCountryData['LT'] = Array('Lithuania', '370');localizedCountryData['LU'] = Array('Luxembourg', '352');localizedCountryData['MY'] = Array('Malaysia', '60');localizedCountryData['MT'] = Array('Malta', '356');localizedCountryData['MQ'] = Array('Martinique', '596');localizedCountryData['MX'] = Array('Mexico', '52');localizedCountryData['MN'] = Array('Monaco', '377');localizedCountryData['MS'] = Array('Montserrat', '1664');localizedCountryData['NL'] = Array('Netherlands', '31');localizedCountryData['AN'] = Array('NetherlandsAntilles', '599');localizedCountryData['NZ'] = Array('New Zealand', '64');localizedCountryData['NO'] = Array('Norway', '47');localizedCountryData['PA'] = Array('Panama', '507');localizedCountryData['PY'] = Array('Paraguay', '595');localizedCountryData['PE'] = Array('Peru', '51');localizedCountryData['PH'] = Array('Philippines', '63');localizedCountryData['PL'] = Array('Poland', '48');localizedCountryData['PT'] = Array('Portugal', '351');localizedCountryData['RO'] = Array('Romania', '40');localizedCountryData['RU'] = Array('Russia &amp; Kazhakstan', '7');localizedCountryData['LC'] = Array('Saint Lucia', '1758');localizedCountryData['SG'] = Array('Singapore', '65');localizedCountryData['SK'] = Array('Slovakia', '421');localizedCountryData['SI'] = Array('Slovenia', '386');localizedCountryData['ZA'] = Array('South Africa', '27');localizedCountryData['KR'] = Array('South Korea', '82');localizedCountryData['ES'] = Array('Spain', '34');localizedCountryData['SR'] = Array('Suriname', '597');localizedCountryData['SE'] = Array('Sweden', '46');localizedCountryData['CH'] = Array('Switzerland', '41');localizedCountryData['TW'] = Array('Taiwan', '886');localizedCountryData['TH'] = Array('Thailand', '66');localizedCountryData['TT'] = Array('Trinidad &amp; Tobago', '1868');localizedCountryData['TR'] = Array('Turkey', '90');localizedCountryData['TC'] = Array('Turks and Caicos', '1649');localizedCountryData['UK'] = Array('United Kingdom', '44');localizedCountryData['US'] = Array('United States', '1');localizedCountryData['VE'] = Array('Venezuela', '58');localizedCountryData['VN'] = Array('Vietnam', '84');
localizedCountryData['RS'] = Array('Serbia', '381');

function smsInit() {
	var ph=document.getElementById('smscurrcountry');
	ph.value="US";

}
function smsswitchcountry(el, newc)
{
	var ph=document.getElementById('smscurrcountry');
	ph.value=newc.value;
	
	var flagObj =  document.getElementById('smsflag');
	flagObj.style.backgroundImage="url(/img/flags/"+newc.value+".png)";
	flagObj.style.backgroundRepeat="no-repeat";
	flagObj.style.textIndent="35px";
	var flagObjCountryName =  document.getElementById('smscname');
	flagObjCountryName.innerHTML=newc.text;
	
	
	var cObj =  document.getElementById('smscountry');
	cObj.style.display="none";

	var cObj =  document.getElementById('sms4');
	var country=localizedCountryData[newc.value];
	if (country[1] == '1')
		showUSCA(cObj);
	else
		showOthers(cObj,country[1]);
}

function showUSCA(cObj)
{
	cObj.style.display="none";
	var p1=document.getElementById('sms1');
	p1.style.display="block";
	var p2=document.getElementById('sms0');
	p2.style.display="none";
	var p1=document.getElementById('sms2');
	p1.style.display="block";
	var p2=document.getElementById('sms3');
	p2.style.display="block";

	var p3=document.getElementById('phone1');
	p3.maxLength=3;
	p3.style.width="30px";
	p3.value="";

	var p4=document.getElementById('phone2');
	p4.value="";
	
	var p5=document.getElementById('phone3');
	p5.value="";
}

function showOthers(cObj,cCode)
{
	cObj.innerHTML="+"+cCode;
	cObj.style.display="block";
	var p1=document.getElementById('sms1');
	p1.style.display="none";
	var p2=document.getElementById('sms0');
	p2.style.display="block";
	var p1=document.getElementById('sms2');
	p1.style.display="none";
	var p2=document.getElementById('sms3');
	p2.style.display="none";

	var p3=document.getElementById('phone1');
	p3.value="";

	var p4=document.getElementById('phone2');
	p4.value="";
	
	var p5=document.getElementById('phone3');
	p5.value="";


}
function smsshowcountrychange()
{
	var cObj =  document.getElementById('smscountry');
	cObj.style.display="block";
	var cObj =  document.getElementById('smsCountryList');
	cObj.style.display="block";
	return false;
}

function ajaxsms (pageurl, divId){
		var page_request = false
		var bustcacheparameter=""
		if (window.XMLHttpRequest) // if Mozilla, IE7, Safari etc
			page_request = new XMLHttpRequest()
		else if (window.ActiveXObject){ // if IE6 or below
			try {
			page_request = new ActiveXObject("Msxml2.XMLHTTP")
			} 
			catch (e){
				try{
				page_request = new ActiveXObject("Microsoft.XMLHTTP")
				}
				catch (e){}
			}
		}
		else
			return false
		document.getElementById(divId).innerHTML="<img src='/css/img/loading.gif'> &nbsp; Sending text message... ";
		page_request.onreadystatechange=function(){smsloadpage(page_request, divId)}
		bustcacheparameter=(pageurl.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
		page_request.open('GET', pageurl+bustcacheparameter, true)
		page_request.send(null)
	}

function 	smsloadpage (page_request, divId){
		if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)){
			document.getElementById(divId).innerHTML=page_request.responseText
		}
	}
	
function doSendSMS()
{

	grayOut(true);
	var tmp = document.getElementById("smscurrcountry");
	var linkId = document.getElementById("sms_link_id").value;
	
  	var country=localizedCountryData[tmp.value];
    
	var p1=document.getElementById('phone1');
	var p2=document.getElementById('phone2');
	var p3=document.getElementById('phone3');
	var p0=document.getElementById('phone0');
	var phnum="+"+country[1]+p0.value;
	
	if (country[1] == '1') {
		phnum="+"+country[1]+p1.value+p2.value+p3.value;
	} 
	
	var resdiv = document.getElementById('smsresultrame');
	var width        = window.innerWidth  ? window.innerWidth  : document.documentElement.clientWidth;
	var height       = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight;
	resdiv.style.left = (document.documentElement.scrollLeft+(width -resdiv.clientWidth )/4)+'px';
  	resdiv.style.top  = (document.documentElement.scrollTop +(height-resdiv.clientHeight)/2)+'px';
			
	resdiv.style.visibility="visible"
	resdiv.style.display="block";
	resdiv.style.zIndex = 101;
	var url="/common/sms/sendsms.jspf?linkid=" + linkId +"&p="+phnum+"&recaptcha_challenge_field="+
		document.getElementById("recaptcha_challenge_field").value+"&recaptcha_response_field="+
		document.getElementById("recaptcha_response_field").value;

	ajaxsms(url,"smsresult");

}

function showSMSResult2()
{
    grayOut(true);
	var resdiv = document.getElementById('smsresult2');
	resdiv.style.visibility="visible";
	resdiv.style.display="block";
	resdiv.style.zIndex = 101;
	
	return false;
}
function closeSMSResult2()
{
	var resdiv = document.getElementById('smsresult2');
	resdiv.style.visibility="hidden"
	resdiv.style.display="none";
	//grayOut(false);
	return false;
}

function closeSMSResult()
{
	var resdiv = document.getElementById('smsresultrame');
	resdiv.style.visibility="hidden"
	resdiv.style.display="none";
	//grayOut(false);
	return false;
}