 //display_post_it();

function setlanguage() {
	var dayarray = new Array();
   	
	if (document.CallMeForm.language.value == "RU") {
		dayarray[0] = String.fromCharCode(1042,1086,1089); dayarray[1] = String.fromCharCode(1055,1086,1085); dayarray[2] = String.fromCharCode(1042,1090,1086); dayarray[3] = String.fromCharCode(1057,1088,1077); 
		dayarray[4] = String.fromCharCode(1063,1077,1090);	dayarray[5] = String.fromCharCode(1055,1103,1090); dayarray[6] = String.fromCharCode(1057,1091,1073);
		txt1 = "&#1053;&#1072;&#1078;&#1084;&#1080;&#1090;&#1077; &#1089;&#1102;&#1076;&#1072; &#1080; &#1084;&#1099; &#1042;&#1072;&#1084; &#1087;&#1086;&#1079;&#1074;&#1086;&#1085;&#1080;&#1084; -- &#1041;&#1045;&#1057;&#1055;&#1051;&#1040;&#1058;&#1053;&#1067;&#1049; &#1047;&#1042;&#1054;&#1053;&#1054;&#1050;";
		txt2 = "&#1055;&#1086;&#1078;&#1072;&#1083;&#1091;&#1081;&#1089;&#1090;&#1072; &#1091;&#1082;&#1072;&#1078;&#1080;&#1090;&#1077; &#1042;&#1072;&#1096; &#1085;&#1086;&#1084;&#1077;&#1088; &#1090;&#1077;&#1083;&#1077;&#1092;&#1086;&#1085;&#1072;!";
		txt3 = "&#1042;&#1072;&#1096;&#1072; &#1089;&#1090;&#1088;&#1072;&#1085;&#1072;";
		txt4 = "&#1042;&#1072;&#1096; &#1090;&#1077;&#1083;. &#1085;&#1086;&#1084;&#1077;&#1088;";
		txt5 = "&#1055;&#1086;&#1079;&#1074;&#1086;&#1085;&#1080;&#1090;&#1077; &#1084;&#1085;&#1077;";
		txt6 = "&#1053;&#1072;&#1096;&#1080; &#1095;&#1072;&#1089;&#1099; &#1088;&#1072;&#1073;&#1086;&#1090;&#1099;";
		txt7 = String.fromCharCode(45,32,1042,1099,1073,1086,1088,32,1089,1090,1088,1072,1085,1099,32,45);
		txt8 = "Your email";
		txt9 = "&#1042;&#1072;&#1096; &#1085;&#1072;&#1079;&#1074;&#1072;&#1085;&#1080;&#1077;";
		txtok1 = "&#1042;&#1072;&#1096; &#1079;&#1074;&#1086;&#1085;&#1086;&#1082; &#1089;&#1086;&#1077;&#1076;&#1080;&#1085;&#1105;&#1085;!";
		txtnok1 = "&#1042;&#1072;&#1096; &#1079;&#1074;&#1086;&#1085;&#1086;&#1082; &#1085;&#1077; &#1073;&#1099;&#1083; &#1089;&#1086;&#1077;&#1076;&#1080;&#1085;&#1105;&#1085;!";
		txtnok2 = "&#1057;&#1086;&#1086;&#1073;&#1097;&#1077;&#1085;&#1080;&#1077; &#1086;&#1073; &#1086;&#1096;&#1080;&#1073;&#1082;&#1077; &#1073;&#1099;&#1083;&#1086; &#1074;&#1099;&#1089;&#1083;&#1072;&#1085;&#1086; &#1089;&#1080;&#1089;&#1090;&#1077;&#1084;&#1085;&#1086;&#1084;&#1091; &#1072;&#1076;&#1084;&#1080;&#1085;&#1080;&#1090;&#1088;&#1072;&#1090;&#1086;&#1088;&#1091;";
		fb1 = String.fromCharCode(1064,1072,1075,32,49,58,32,1042,1099,1073,1080,1088,1077,1090,1077,32,1089,1090,1088,1072,1085,1091,32,1080,1079,32,1089,1087,1080,1089,1082,1072,46);
		fb2 = String.fromCharCode(1064,1072,1075,32,50,58,32,1047,1072,1087,1086,1083,1085,1080,1090,1077,32,1087,1086,1083,1077,32,1082,1086,1076,1072,32,1075,1086,1088,1086,1076,1072,32,1080,32,1090,1077,1083,1077,1092,1086,1085,1085,1086,1075,1086,32,1085,1086,1084,1077,1088,1072,32,1080,32,1085,1072,1078,1084,1080,1090,1077,32,1082,1085,1086,1087,1082,1091,32,67,97,108,108,77,69,33);
		fb3 = String.fromCharCode(1069,1090,1072,32,1092,1086,1088,1084,1072,32,1087,1086,1079,1074,1086,1083,1080,1090,32,1042,1072,1084,32,1087,1086,1079,1074,1086,1085,1080,1090,1100,32,1085,1072,1084,32,1072,1073,1089,1086,1083,1102,1090,1085,1086,32,1073,1077,1089,1087,1083,1072,1090,1085,1086,46,32,1042,1099,1073,1080,1088,1077,1090,1077,32,1089,1090,1088,1072,1085,1091,32,1080,1079,32,1089,1087,1080,1089,1082,1072,47,1079,1072,1087,1086,1083,1085,1080,1090,1077,32,1087,1086,1083,1077,32,1082,1086,1076,1072,32,1075,1086,1088,1086,1076,1072,32,1080,32,1090,1077,1083,1077,1092,1086,1085,1085,1086,1075,1086,32,1085,1086,1084,1077,1088,1072,32,1080,32,1085,1072,1078,1084,1080,1090,1077,32,1082,1085,1086,1087,1082,1091,32,67,97,108,108,77,69,33,32,46,32,1063,1077,1088,1077,1079,32,1085,1077,1089,1082,1086,1083,1100,1082,1086,32,1089,1077,1082,1091,1085,1076,32,1042,1072,1096,32,1090,1077,1083,1077,1092,1086,1085,32,1079,1072,1079,1074,1086,1085,1080,1090,32,1080,32,1042,1072,1089,32,1089,1086,1077,1076,1080,1085,1103,1090,32,1089,32,1085,1072,1096,1080,1084,32,1086,1092,1080,1089,1086,1084,46);
		fb4 = String.fromCharCode(1055,1086,1078,1072,1083,1091,1081,1089,1090,1072,44,32,1089,1085,1072,1095,1072,1083,1072,32,1074,1099,1073,1080,1088,1077,1090,1077,32,1089,1090,1088,1072,1085,1091,46);
		fb5 = String.fromCharCode(1047,1074,1086,1085,1082,1080,32,1089,32,1084,1086,1073,1080,1083,1100,1085,1099,1093,32,1090,1077,1083,1077,1092,1086,1085,1086,1074,32,1073,1083,1086,1082,1080,1088,1091,1102,1090,1089,1103,32,1087,1088,1080,32,1080,1089,1087,1086,1083,1100,1079,1086,1074,1072,1085,1080,1080,32,1082,1085,1086,1087,1082,1080,32,67,97,108,108,77,69,33,32,46,32,1055,1086,1078,1072,1083,1091,1081,1089,1090,1072,32,1080,1089,1087,1086,1083,1100,1079,1091,1081,1090,1077,32,1075,1086,1088,1086,1076,1089,1082,1086,1081,32,1090,1077,1083,1077,1092,1086,1085,1085,1099,1081,32,1085,1086,1084,1077,1088,46);
		fb6 ="CallME! TRIAL:<br>All calls are blocked as there is no prepaid credit in your account yet.";
		fb7 = String.fromCharCode(1042,1072,1096,32,1090,1077,1083,1077,1092,1086,1085,1085,1099,1081,32,1085,1086,1084,1077,1088,32,1076,1086,1083,1078,1077,1085,32,1089,1086,1076,1077,1088,1078,1072,1090,1100,32,1082,1072,1082,32,1084,1080,1085,1080,1084,1091,1084,32,57,32,1094,1080,1092,1088,40,1074,1082,1083,1102,1095,1072,1103,32,1082,1086,1076,32,1042,1072,1096,1077,1081,32,1089,1090,1088,1072,1085,1099,41,46);
		fb8 = String.fromCharCode(1042,1072,1096,32,1090,1077,1083,1077,1092,1086,1085,1085,1099,1081,32,1085,1086,1084,1077,1088,32,1076,1086,1083,1078,1077,1085,32,1089,1086,1076,1077,1088,1078,1072,1090,1100,32,1084,1072,1082,1089,1080,1084,1091,1084,32,49,52,32,1094,1080,1092,1088,40,1074,1082,1083,1102,1095,1072,1103,32,1082,1086,1076,32,1042,1072,1096,1077,1081,32,1089,1090,1088,1072,1085,1099,41,46);
		fb9 = String.fromCharCode(1053,1077,1074,1077,1088,1085,1099,1081,32,1090,1077,1083,1077,1092,1086,1085,1085,1099,1081,32,1085,1086,1084,1077,1088,32,1074,32,1057,1064,1040);
		fb10 = String.fromCharCode(32,1053,1072,1096,1077,32,1074,1088,1077,1084,1103,58,32);
		fb11 = String.fromCharCode(32,45,45,32,1042,1072,1096,1077,32,1074,1088,1077,1084,1103,58,32);
		fb12 = String.fromCharCode(1053,1072,1096,1072,32,1089,1083,1091,1078,1073,1072,32,1087,1086,1076,1076,1077,1088,1078,1082,1080,32,1088,1072,1073,1086,1090,1072,1077,1090,32);
		fb13 = String.fromCharCode(10,1042,32,1085,1072,1089,1090,1086,1103,1097,1080,1081,32,1084,1086,1084,1077,1085,1090,32,1084,1099,32,1085,1077,32,1084,1086,1078,1077,1084,32,1086,1090,1074,1077,1090,1080,1090,1100,32,1085,1072,32,1042,1072,1096,32,1079,1074,1086,1085,1086,1082,33);
		fb14 = String.fromCharCode(1057,1077,1075,1086,1076,1085,1103,32,1095,1072,1089,1099,32,1088,1072,1073,1086,1090,1099,32,1085,1072,1096,1077,1081,32,1089,1083,1091,1078,1073,1099,32,1087,1086,1076,1076,1077,1088,1078,1082,1080,32,1086,1090,32);
		fb15 = String.fromCharCode(32,1076,1086,32);
		fb16 = String.fromCharCode(10,1052,1099,32,1075,1086,1090,1086,1074,1099,32,1087,1086,1075,1086,1074,1086,1088,1080,1090,1100,32,1089,32,1042,1072,1084,1080,32,1089,1077,1081,1095,1072,1089,46);
	}
	if (document.CallMeForm.enable.value.charAt(50) == "1") { 
		txt4 = "Your phone number:";
		txt6 = "Our Business Hours";
		txt7 = "Select your country";
		txtok1 = "Your call has been activated!";
		txtnok1 = "Your call could not be activated!";
		txtnok2 = "A problem report has been sent automatically";
		fb1 = "Select your country from the list and fill in your area code and phone number (Your phone number can be registered in your LivePrices profile).";
		fb2 = "Click on 'CallME!' to call us for free.\nInformation below only indicates your interest and is not a commitment.";
		fb4 = "Please select your country first";
		fb5 = "Calls from mobile phones are blocked for this CallME! button. Please use your land line.";
		fb6 = "Leave out the 0 in front of your area code. Use the international number format.";
		fb7 = "Your phone number should have at least 9 digits (including your country code).";
		fb8 = "Your phone number should have maximum 14 digits (including your country code).";
		fb9 = "Not a valid US phone number";
		fb10 = " Our time: ";
		fb11 = " -- Your time: ";
		fb12 = "We are available to take your call on";
		fb13 = "\nWe can't take your call right now!";
		fb14 = "Today we are available to take your call from ";
		fb15 = " to ";
		fb16 = "\nWe are ready to take your call now.";
	}
}
	
function copylanguage()
{
	if (document.CallMeForm.language.value == "RU") {
		document.getElementById("intro1text").innerHTML = txt1;
		document.getElementById("intro2text").innerHTML = txt2;
		document.getElementById("countrylabel").innerHTML = txt3;
		document.getElementById("numberlabel").innerHTML = txt4;
		document.getElementById("buttonlabel").innerHTML = txt5;
		document.getElementById("businesshours").innerHTML = txt6;
		document.getElementById("emaillabel").innerHTML = txt8;
		document.getElementById("namelabel").innerHTML = txt9;
		if (document.CallMeForm.SelectCountry.options[0].value == "") {
			document.forms['CallMeForm'].SelectCountry.options[0].text = txt7;
		}
	}
}

function copylanguageok()
{
	if (document.CallMeForm.language.value == "RU") {
		document.getElementById("intro1text").innerHTML = txt1;
		if (document.CallMeForm.forward_call.value == 1) {
			document.getElementById("intro2text").innerHTML = txtok2;
		} else {
			document.getElementById("intro2text").innerHTML = txtok1;
		}
	}
}

function copylanguagenok()
{
	if (document.CallMeForm.language.value == "RU") {
		document.getElementById("intro1text").innerHTML = txt1;
		document.getElementById("intro2text").innerHTML = txtnok1;
		document.getElementById("feedbacktext").innerHTML = txtnok2;
	}
}

// canada
var canada_codes = "204,226,249,250,289,306,343,403,416,418,438,450,506,514,519,579,581,587,600,604,613,647,705,709,778,780,807,819,867,902,905";

var non_usa_codes = "264,268,242,246,441,284,345,767,809,849,473,671,876,664,787,869,758,784,670,868,649,340,684,829,939";
 
function display_button()
{
	if (document.CallMeForm.timeout.value != 1 ) {
		document.getElementById('ctcbutton').style.display = 'block';
		document.getElementById('buttonlabel').style.display = 'none';
	} else {
		document.getElementById('buttonlabel').innerHTML = fb28;
		timeout_countdown();
	} 
}

var time_left=30;
function timeout_countdown() {
	if(time_left>0) {
		time_left=time_left-1;
		document.getElementById('buttonlabel').innerHTML = fb28 + ' ' + fb29 + ' ' + time_left;
		setTimeout('timeout_countdown()', 1000);
	} else {
		url2 = 'callme_client_status.php?ip=' + document.CallMeForm.ip.value + '&f=' + document.CallMeForm.f.value; 
		new Ajax.Updater('buttoncheck', url2, {	evalScripts:true, 
			onSuccess : function(resp) { 
    				
			},
			onFailure : function(resp) { 
				alert('Oops, there has been an error.'); 
 			} 
		});
		setTimeout('check_client()', 3000); // we have to wait for client status to return
	}
}

function check_client() {
 	if (document.getElementById('buttoncheck').innerHTML == 'OK;CR') { // display button
		document.getElementById('ctcbutton').style.display = 'block';
		document.getElementById('buttonlabel').style.display = 'none';
	} else {
		time_left=30;
		timeout_countdown();
	}
}

function countrydropdown(state)
{
	if (state == "1") {
		document.getElementById('countrydropdown').style.display = 'inline';
		document.getElementById('number_non_us').style.display = 'none';
	}
	else{
		document.getElementById('countrydropdown').style.display = 'none';
		document.getElementById('number_non_us').style.display = 'inline';
	}
}


function copy_cc(first) { // copy selected coutry to country code
	if (first==1) {
		number='';
	} else {
	 	number = document.CallMeForm.us.value;
	}
	if (number.charAt(0) == 'c' || number.charAt(0) == 'k') { 
		number = number.substr(1);
	}
	if ( document.CallMeForm.SelectCountry.value.charAt(0) == '1' || document.CallMeForm.SelectCountry.value.charAt(0) == 'c') { // USA number format
		document.getElementById('number_us').style.display = 'inline'; 
		document.getElementById('number_non_us').style.display = 'none';
		document.CallMeForm.CountryCode.value = 1;
		document.CallMeForm.YourNumber1.value = number.substring(1,4);		
		document.CallMeForm.YourNumber2.value = number.substring(4,7);	
		document.CallMeForm.YourNumber3.value = number.substring(7,11);
		//document.CallMeForm.YourNumber1.focus();
		if (document.CallMeForm.SelectCountry.value.length>2) { // non USA/Canada but USA format 
			document.CallMeForm.YourNumber1.value = document.CallMeForm.SelectCountry.value.substring(1,4);		
			document.CallMeForm.YourNumber2.value = number.substring(4,7);	
			document.CallMeForm.YourNumber3.value = number.substring(7,11);
			//document.CallMeForm.YourNumber2.focus();
		}
		//if ( first == 0) { 
		copy_number_us();
		//} 
		copyfeedback(fb2);//document.CallMeForm.feedback.value = fb2;
	} else if (document.CallMeForm.SelectCountry.value == '') { // - select your country option
		document.getElementById('number_us').style.display = 'none'; 
		document.getElementById('number_non_us').style.display = 'inline';
		document.CallMeForm.CountryCode.value = "";
		document.CallMeForm.YourNumber.value = "";		
		document.CallMeForm.YourNumber1.value = "";		
		document.CallMeForm.YourNumber2.value = "";	
		document.CallMeForm.YourNumber3.value = "";
		copyfeedback(fb1);//document.CallMeForm.feedback.value = fb1;
	} else { // non USA number format
		document.getElementById('number_us').style.display = 'none'; 
		document.getElementById('number_non_us').style.display = 'inline';
		if ( document.CallMeForm.SelectCountry.value.charAt(0) == 'k') { // Kazakstan
			document.CallMeForm.CountryCode.value = 7;
			x=1;
		} else {
			x=document.CallMeForm.SelectCountry.value.length;
			document.CallMeForm.CountryCode.value = document.CallMeForm.SelectCountry.value;
		}
		document.CallMeForm.YourNumber.value = number.substring(x);
		//document.CallMeForm.YourNumber.focus();
		copyfeedback(fb2);//document.CallMeForm.feedback.value = fb2;
		//if ( first == 0) { 
		copy_number();
		//}
	}
	//if ( first != 0 ) {
		//document.CallMeForm.CALLME_TO_DESTINATION.value = "";
	//}
}



function movebox(activefield,nextfield,maxlen) 
{ 
	var activefieldlen = activefield.value.length; 

	if (activefieldlen == maxlen) 
		nextfield.focus(); 
} 

function copystep1(){
	var day = ownertime.getDay();
	var starttime = document.CallMeForm.elements['business_hours_start' + day].value;
	var endtime = document.CallMeForm.elements['business_hours_end' + day].value;
	ownertimestr = getownertime();
	var reason = "";
	stringFilter(document.CallMeForm.requesting_station);
	
	if (document.CallMeForm.business_summertime.value == '1') { 
		indicator = document.CallMeForm.business_summertime_indicator.value;
	} else { 
		indicator = document.CallMeForm.business_standardtime_indicator.value;	
	}
	
	if (document.CallMeForm.business_days.value.charAt(day) == "0") {
		if ( document.CallMeForm.forwarding_mode.value >= 2 ) {
			reason = fb21;
		} else {	
			reason = fb12 + " " + document.CallMeForm.business_days_text.value + ". " + fb13;
		}
	} else {
		if (ownertimestr < starttime || ownertimestr > endtime) {
			if ( document.CallMeForm.forwarding_mode.value >= 2 ) {
				reason = fb21;
			} else {	
				reason = fb14 + " " + starttime + " " + fb15 + " " + endtime + " (" + indicator + "). " + fb13;
			}
		} else {
			if (document.CallMeForm.block.value != "mn") {
				if (document.CallMeForm.SelectCountry.value != "") {
					reason = fb2 + fb16;
					if ( document.CallMeForm.SelectCountry.value == '1' ) {
						//document.CallMeForm.YourNumber1.focus();
					} else {
						//document.CallMeForm.YourNumber.focus();
					}
				} else {
					if (document.CallMeForm.enable.value.charAt(50) != "1") {
						//document.CallMeForm.SelectCountry.focus();
					}
					reason = fb1 + fb16;
				}
			} else {
				reason = fb5;
			}
		}
	}
	
	copyfeedback(reason);//document.CallMeForm.feedback.value = reason;
}

function copyfeedback(fb){
	document.getElementById('feedbackarea').innerHTML = fb; //document.CallMeForm.feedback.value = fb
}

function copyhelp(){
	//document.CallMeForm.feedback.value = fb3;
	document.getElementById('postithelp').style.visibility= 'hidden';
	document.getElementById('postithelp').innerHTML= fb3;
	document.getElementById('postit').style.visibility= 'visible';
	document.CallMeForm.SelectCountry.blur();
	//setTimeout ( "showpostithelp()", 500 );
	showpostithelp();
	
}
function showpostithelp() {
	document.getElementById('postittext').style.visibility= 'hidden';
	document.getElementById('postithelp').style.visibility= 'visible';
	th=setTimeout ( "closepostithelp()", 10000 );
}

function closepostithelp() {	
	//clearTimeout(th);
	document.getElementById('postithelp').style.visibility= 'hidden';
	document.getElementById('postit').style.visibility= 'hidden';	
} 

function showhelp() {
	document.getElementById('postithelp').style.visibility= 'hidden';
	document.getElementById('postithelp').innerHTML= fb3;
	document.getElementById('postit').style.visibility= 'visible';
	document.CallMeForm.SelectCountry.blur();
	document.getElementById('postittext').style.visibility= 'hidden';
	document.getElementById('postithelp').style.visibility= 'visible';
}

function hidehelp() {	
	document.getElementById('postithelp').style.visibility= 'hidden';
	document.getElementById('postit').style.visibility= 'hidden';	
}

function businessdays() {
	var string = "";
	for (y=0; y < 7; y++) {
		if (document.CallMeForm.business_days.value.charAt(y) == "1") {
			string = string + dayarray[y];
			string = string + ", ";
		}
	}
	string = string.substr(0,string.length -2);
	i = string.lastIndexOf(", ");
	if (i != -1) {
		string = string.substr(0,i) + " " + fb27 + string.substr(i+1); 
	}
	document.CallMeForm.business_days_text.value = string;		
}

function copytimes(){
	var day = ownertime.getDay();
	var starttime = document.CallMeForm.elements['business_hours_start' + day].value;
	var endtime = document.CallMeForm.elements['business_hours_end' + day].value;
	ownertimestr = getownertime();
	var reason = "";
	stringFilter(document.CallMeForm.requesting_station);
	
	if (document.CallMeForm.business_summertime.value == '1') { 
		indicator = document.CallMeForm.business_summertime_indicator.value;
	} else { 
		indicator = document.CallMeForm.business_standardtime_indicator.value;	
	}
	
	if (document.CallMeForm.business_days.value.charAt(day) == "0") {
		if ( document.CallMeForm.forwarding_mode.value >= 2 ) {
			reason = fb21;
		} else {	
			reason = fb12 + " " + document.CallMeForm.business_days_text.value + ". " + fb13;
		}
	} else {
		if (ownertimestr < starttime || ownertimestr > endtime) {
			if ( document.CallMeForm.forwarding_mode.value >= 2 ) {
				reason = fb21;
			} else {	
				reason = fb14 + " " + starttime + " " + fb15 + " " + endtime + " (" + indicator + "). " + fb13;
			}
		} else {
			reason = fb14 + " " + starttime + " " + fb15 + " " + endtime + " (" + indicator + "). " + fb16;
		}
	}
	
	copyfeedback(reason);//document.CallMeForm.feedback.value = reason;
}

function copy_number() { // number check non USA format
	if (document.CallMeForm.CountryCode.value == '') { // no country selected
		copyfeedback(fb4);
		document.CallMeForm.YourNumber.value = '';
	}
	else { // country selected
		stringFilter(document.CallMeForm.YourNumber);
		// strip zero
		if (document.CallMeForm.YourNumber.value.charAt(0) == "0" && document.CallMeForm.CountryCode.value != "39") {
			document.CallMeForm.requesting_station.value = document.CallMeForm.CountryCode.value + document.CallMeForm.YourNumber.value.substr(1);
		} else {
			document.CallMeForm.requesting_station.value = document.CallMeForm.CountryCode.value + document.CallMeForm.YourNumber.value;
		}
		copyfeedback(fb2);
		checkPrefix( document.CallMeForm.requesting_station,document.CallMeForm.DESTINATION,document.CallMeForm.CALLME_TO_DESTINATION);
		if (document.CallMeForm.mobiles.value == '0') {
			if (document.CallMeForm.CALLME_TO_DESTINATION.value.indexOf("Mobile")!=-1 ) {
				copyfeedback(fb5);
			}
		}
		if (document.CallMeForm.YourNumber.value.substr(0,2) == "70" && document.CallMeForm.CountryCode.value == "44") {
			copyfeedback(fb17);
			document.CallMeForm.YourNumber.value ="7";			
		}
		if ((document.CallMeForm.YourNumber.value.substr(0,3) == "844" || document.CallMeForm.YourNumber.value.substr(0,3) == "845" ||document.CallMeForm.YourNumber.value.substr(0,3) == "870" ||document.CallMeForm.YourNumber.value.substr(0,3) == "871") && document.CallMeForm.CountryCode.value == "44") {
			copyfeedback(fb18);
			document.CallMeForm.YourNumber.value ="";			
		}
		if (document.CallMeForm.YourNumber.value.substr(0,3) == "800" && document.CallMeForm.CountryCode.value != "1") {
			copyfeedback(fb19);
			document.CallMeForm.YourNumber.value ="";			
		}
		if (document.CallMeForm.YourNumber.value.substr(0,3) == "820" && document.CallMeForm.CountryCode.value == "43") {
			copyfeedback(fb19);
			document.CallMeForm.YourNumber.value ="";			
		}
		if (document.CallMeForm.YourNumber.value.substr(0,3) == "900" && (document.CallMeForm.CountryCode.value != "1" && document.CallMeForm.CountryCode.value != "47")) {
			copyfeedback(fb20);
			document.CallMeForm.YourNumber.value ="";			
		}
	}
}

function clear_number_us() {
	document.CallMeForm.YourNumber1.value="";
	document.CallMeForm.YourNumber2.value="";
}

function copy_number_us() { // copy us format numbers
	stringFilter(document.CallMeForm.YourNumber1);
	stringFilter(document.CallMeForm.YourNumber2);
	stringFilter(document.CallMeForm.YourNumber3);
	document.CallMeForm.requesting_station.value = document.CallMeForm.CountryCode.value + document.CallMeForm.YourNumber1.value + document.CallMeForm.YourNumber2.value + document.CallMeForm.YourNumber3.value;
	document.CallMeForm.YourNumber1.value=document.CallMeForm.requesting_station.value.substr(1,3);
	document.CallMeForm.YourNumber2.value=document.CallMeForm.requesting_station.value.substr(4,3);
	document.CallMeForm.YourNumber3.value=document.CallMeForm.requesting_station.value.substr(7,4);
	copyfeedback('');
	checkPrefix(document.CallMeForm.requesting_station,document.CallMeForm.DESTINATION,document.CallMeForm.CALLME_TO_DESTINATION);
	// usa numbers format and area codes check
	if (document.CallMeForm.YourNumber1.value.length==3) {
		if (document.CallMeForm.SelectCountry.value == "c1") { // canada check
			if ( canada_codes.indexOf(document.CallMeForm.YourNumber1.value)==-1 ) {	// non Canadian area code
				copyfeedback(fb22);
				document.CallMeForm.YourNumber1.value = "";		
				document.CallMeForm.YourNumber2.value = "";	
				document.CallMeForm.YourNumber3.value = "";
				document.CallMeForm.CALLME_TO_DESTINATION.value = "";
			}
		} else if (document.CallMeForm.SelectCountry.value == "1") { // USA check
			if ( canada_codes.indexOf(document.CallMeForm.YourNumber1.value)!=-1 || non_usa_codes.indexOf(document.CallMeForm.YourNumber1.value)!=-1) {	// non USA area code
				copyfeedback(fb23);
				document.CallMeForm.YourNumber1.value = "";		
				document.CallMeForm.YourNumber2.value = "";	
				document.CallMeForm.YourNumber3.value = "";
				document.CallMeForm.CALLME_TO_DESTINATION.value = "";
			}
		} else { // others check
			if (document.CallMeForm.YourNumber1.value != document.CallMeForm.SelectCountry.value.substring(1, 4)){ // non other area code
				copyfeedback(fb26);
				document.CallMeForm.YourNumber1.value = document.CallMeForm.SelectCountry.value.substring(1, 4);		
				document.CallMeForm.YourNumber2.value = "";	
				document.CallMeForm.YourNumber3.value = "";
				checkPrefix(document.CallMeForm.requesting_station,document.CallMeForm.DESTINATION,document.CallMeForm.CALLME_TO_DESTINATION);
			}
		}
	}
}

function padlength(what){
var output2=(what.toString().length==1)? "0"+what : what
return output2
}

function displaytime(){
usertime.setSeconds(usertime.getSeconds()+1);
ownertime.setSeconds(ownertime.getSeconds()+1);

if (document.CallMeForm.business_summertime.value == '1') { indicator = document.CallMeForm.business_summertime_indicator.value;
	}
	else { indicator = document.CallMeForm.business_standardtime_indicator.value;	
	}
var ownertimestring=padlength(ownertime.getHours())+":"+padlength(ownertime.getMinutes())+":"+padlength(ownertime.getSeconds())
var usertimestring=padlength(usertime.getHours())+":"+padlength(usertime.getMinutes())+":"+padlength(usertime.getSeconds())

document.getElementById("servertime").innerHTML=fb10+ownertimestring+" ("+indicator+") "+fb11+ usertimestring// + " " + serverday+ ownerday +userday
}



function getownertime(txt) {
	var hour = ownertime.getHours();
	var minute = ownertime.getMinutes();
	if (minute < 10) {pad = ':0';} else {pad = ':';}
	if (hour < 10) {zero = '0';} else {zero = '';}
	return txt = zero + hour + pad + minute;
}

function callmeonly(){
	var day = ownertime.getDay();

	var starttime = document.CallMeForm.elements['business_hours_start' + day].value;
	var endtime = document.CallMeForm.elements['business_hours_end' + day].value;
	ownertimestr = getownertime();
	
	// browser back fix
	document.CallMeForm.blcode.value=Math.round(Math.random()*100000000); 
	
	document.CallMeForm.requesting_destination.value = document.CallMeForm.CALLME_TO_DESTINATION.value ;
	
	if (document.CallMeForm.business_summertime.value == '1') { 
		indicator = document.CallMeForm.business_summertime_indicator.value;
	} else { 
		indicator = document.CallMeForm.business_standardtime_indicator.value;	
	}
	
	if (document.CallMeForm.mobiles.value == '0') {
		if (document.CallMeForm.CALLME_TO_DESTINATION.value.indexOf("Mobile")!=-1 ) {
			copyfeedback(fb5);
			setblock(0);
		}
	}
		
	if (document.CallMeForm.business_days.value.charAt(day) == "0") {
		if ( document.CallMeForm.forwarding_mode.value >= 2 ) {
			copyfeedback(fb21);
		} else {	
			copyfeedback(fb12 + ' ' + document.CallMeForm.business_days_text.value + '. ' + fb13);
		}
		setblock(1);			
	}
	if (ownertimestr < starttime || ownertimestr > endtime) {
		if ( document.CallMeForm.forwarding_mode.value >= 2 ) {
			copyfeedback(fb21);
		} else {	
			copyfeedback(fb14 + ' ' + starttime + ' ' + fb15 + ' ' + endtime + ' (' + indicator + '). ' + fb13);
		}
		setblock(2);
	}
	if (document.CallMeForm.CountryCode.value == '') {
		copyfeedback(fb1);
		return false;
	}
	if (document.CallMeForm.requesting_station.value == '') {
		copyfeedback(fb2);
		return false;
	}
    if (document.CallMeForm.requesting_station.value.length < 9) {
		copyfeedback(fb7);
		return false;
	}
	if (document.CallMeForm.requesting_station.value.length > 16) {
		copyfeedback(fb8);
		return false;
	}
	//if (document.CallMeForm.YourNumber.value.charAt(0) == "0" && document.CallMeForm.CountryCode.value != "39") {
	//	copyfeedback(fb6);
	//	return false;
	//}
	if (document.CallMeForm.requesting_station.value.charAt(0) == "1" && document.CallMeForm.requesting_station.value.length != 11) {
		copyfeedback(fb9);
		return false;
	}
	return true;
}

function stringFilter (input) {
	s = input.value;
	filteredValues = "1234567890";     // Characters allowed
	var i;
	var returnString = "";
	for (i = 0; i < s.length; i++) {  
		var c = s.charAt(i);
		if (filteredValues.indexOf(c) !== -1) returnString += c;
	}
	input.value = returnString;
}

function setblock(x) {
	result="";
	for (y=0; y < 8; y++){
		if (y == x) {
			result=result + "1";
			}
		else {
			result = result + document.CallMeForm.block_reason.value.charAt(y);
			}
		}
	document.CallMeForm.block_reason.value = result;
}

function randomString(argLength) {
    pool = new String("abcdefghijklmnopqrstuvwxyz123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ");
    var i = 0;
    var randomStr = " ";

    while (i <= argLength) {
        rand = parseFloat(Math.random()) * parseInt(pool.length);
        randomStr += pool.charAt(rand);
        i++;
    }
			
    randomStr = randomStr.substring(1, 32);
    return randomStr
}
function is_available() {
 	availabilit= new Image();
	availabilit.src = "is_available.php?cid="+ document.CallMeForm.cid.value+"&str=" +  randomString(32);
	//availabilit.src = "./engaged.gif";
	document.images['availability'].src=availabilit.src;
	//document.CallMeForm.enablestatus.value= availabilit.width;
	//document.CallMeForm.enablestatus.value= document.images['availability'].width;
 	
	setTimeout("is_available()", 1000*60);
}

function call_status(cust_call_id) {
 	leg1status= new Image();
	leg1status.src = "callme_leg1.php?cust_call_id="+ cust_call_id +"&str=" +  randomString(32);
	document.images['callmeleg1'].src=leg1status.src;
	
	setTimeout("call_status("+cust_call_id+")", 1000*3);
 }

var interval_id=0; 
function activate_post_it(closeit) { 
	if (closeit==1) {
		clearInterval(interval_id);
		document.getElementById('postit').style.visibility = 'hidden';
		document.getElementById('postithelp').style.visibility = 'hidden';
		document.getElementById('postittext').style.visibility = 'hidden';
	} else {
		interval_id=setInterval('display_post_it()', 10000);  
	}
}	 

function display_post_it(closeit){	 //post-it display
		
	var day = ownertime.getDay();

	var starttime = document.CallMeForm.elements['business_hours_start' + day].value;
	var endtime = document.CallMeForm.elements['business_hours_end' + day].value;
	ownertimestr = getownertime();
	
	if (document.CallMeForm.business_summertime.value == '1') { indicator = document.CallMeForm.business_summertime_indicator.value;
	}
	else { indicator = document.CallMeForm.business_standardtime_indicator.value;	
	}
	if (document.CallMeForm.master.value == '1' || document.CallMeForm.enable.value.charAt(0) == '0' ) { // master account or disabled account: show post-it message
		copyfeedback('Making calls through this account is disabled!');
		document.getElementById('postit').style.visibility= 'visible';
		setTimeout ( "showpostittext()", 500 );
	} else {
		if (document.CallMeForm.business_days.value.charAt(day) == "0") { //show post-it
			copyfeedback(fb12 + ' ' + document.CallMeForm.business_days_text.value + '. ' + fb13);
			document.getElementById('postit').style.visibility= 'visible';
			document.CallMeForm.SelectCountry.blur();
			setTimeout ( "showpostittext()", 500 );
		} else {
			if (ownertimestr < starttime || ownertimestr >= endtime) { //show post-it
				copyfeedback(fb14 + ' ' + starttime + ' ' + fb15 + ' ' + endtime + ' (' + indicator + '). ' + fb13);
				document.getElementById('postit').style.visibility= 'visible';
				document.CallMeForm.SelectCountry.blur();
				setTimeout ( "showpostittext()", 500 );
				//showit();
			} else { //hide post-it
				document.getElementById('postit').style.visibility = 'hidden';
				document.getElementById('postithelp').style.visibility = 'hidden';
				document.getElementById('postittext').style.visibility = 'hidden';
				copystep1();
				//closeit();
			}
		}
	}
}  

function showpostittext() {
	document.getElementById('postittext').style.visibility= 'visible';
	document.CallMeForm.SelectCountry.blur();
}
