var countryID = "1";
var countryCode = "1";
var bInternationalEnabled = 0;


function init() {
	window.focus();
	document.input.number.focus();
	var bodyH = (window.ie ? document.body.scrollHeight + 50 : document.height + 120);
	
	
	window.resizeTo(380, bodyH);
	
	
	if (getCookie('RINGME%5FCOUNTRY') != null) {	
		countryValue = unescape(getCookie('RINGME%5FCOUNTRY'));
	} else {
		countryValue = null;
	}	
	
	
}



function checkParams() {

if(document.getElementById('number').value=='')
	{
	
		document.getElementById('phnno').style.color = "red";
		document.getElementById('number').focus();
		return false;
	}
	with ( document.input ) {
		if (number.value.length < 10 && countryCode == 1) {
			number.focus();
			return false;
		} else if (bInternationalEnabled && number.value.indexOf('+') > -1) {
			number.focus();
			return false;
		}
		if (!checkIntPhoneEx(number, 0, 'XPDBID            57182416Mailbox')) {
			number.focus();
			return false;
		}
		
	}
	return true;
}

function timerFunc() {
 	d = new Date();
	time = d.getTime();
	timeLeft = (timeToStart - time)/1000;
	$('StatusDIV').innerHTML = (Math.round(timeLeft) + ' second(s) left before call');
	if (timeLeft <= 0) {
		window.clearInterval(id_time);
		document.input.submit();
	}
}

function sendData() {
	if (checkParams()) {			
		d = new Date();
		delay = document.input.delay.value;
		if (delay != 0) {
			time = d.getTime();
			timeToStart = time + parseInt(delay);
			timerFunc();
			id_time = window.setInterval(timerFunc, 1000);
		} else {
			document.input.submit();
		}
	}	
}

function showFlag(country) {
	countryArr = country.split(';'); countryID = countryArr[0]; countryCode = countryArr[1];
	document.getElementById('flag').innerHTML = "<img src=\"/Picture/flags/" + countryID + ".gif\" alt=\"\" border=\"0\" width=\"16\" height=\"16\"/>";	
	if (countryCode != 1) {
		document.getElementById('CountryCode').innerHTML = '+' + countryCode;
		
		document.getElementById('HintRow').innerHTML = '&nbsp;';
		
	} else {
		document.getElementById('CountryCode').innerHTML = '&nbsp;';
		document.getElementById('HintRow').innerHTML = 'Ex: (510) 555-1212 x101';
	}
}

