// JavaScript Document
function ghostTextFocus(id){
	if(document.getElementById(id).value == 'Introduzca su código postal'){
		document.getElementById(id).value = '';
	}
	if(document.getElementById(id).value == 'CÃ³digo postal'){
		document.getElementById(id).value = '';
	}
}
function ghostTextBlur(id,inner){
	if(inner == true){
		if(document.getElementById(id).value == ''){
			document.getElementById(id).value = 'CÃ³digo postal';
		}
	}
	else{
		if(document.getElementById(id).value == ''){
			document.getElementById(id).value = 'Introduzca su código postal';
		}
	}
}
function gup(name)
{
  /*name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");*/
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp(regexS);
  var results = regex.exec(window.location.href);
  if(results == null)
    return "";
  else
    return results[1];
}
function allstateQuote(textID){
	var zip = document.getElementById(textID).value;
	var tfn = gup('tfn');
	var src = gup('src');
	var Campaign = gup('Campaign');
	if ((zip.length < 5) || (zip.length > 5)) {
		alert("No se pudo encontrar el cÃ³digo postal y/o direcciÃ³n suministrada.");
	} else {
		window.location='https://quote.allstate.com/ConfiguratorFrame.aspx?lang=es&ZipCode='+zip+'&tfn='+tfn+'&src='+src+'&Campaign='+Campaign;
	}
}
function allstateAgent(textID){
	var zip = document.getElementById(textID).value;
	var tfn = gup('tfn');
	var src = gup('src');
	var Campaign = gup('Campaign');
	if ((zip.length < 5) || (zip.length > 5)) {
		alert("No se pudo encontrar el cÃ³digo postal y/o direcciÃ³n suministrada.");
	} else {
		window.location = 'http://agent.allstate.com/agentlocator/SearchResultsPage.aspx?&Language=Spanish&ZipCode='+zip+'&tfn='+tfn+'&src='+src+'&Campaign='+Campaign;
	}
}

function IsNumeric(e,elem) {
  var currentText = elem.value; 
  if(window.event) // MSIE
   {
    keynum = e.keyCode;
   }
   else if(e.which)  // Netscape/Firefox/Opera
   {
    keynum = e.which;
   }
   return  (keynum >= 48 && keynum <= 57)  // allow numeric keys
   || (keynum == 8) || (keynum == 9)  || (keynum == 127);  // allow delete, tab and backspace keys
  } 