//browser sniffer--------------------------------------------------------
  function Is() {
    var agent = navigator.userAgent.toLowerCase();
    
    var msieIndex = navigator.appVersion.indexOf("MSIE") + 5;   

    var msieRealVer = parseFloat(navigator.appVersion.substr(msieIndex,3));

    this.major = parseInt(navigator.appVersion);
    this.minor = parseFloat(navigator.appVersion);
      this.ns = ((agent.indexOf('mozilla')!=-1) && ((agent.indexOf('spoofer')==-1)
    && (agent.indexOf('compatible') == -1)));
      this.ns2 = (this.ns && (this.major == 3));
      this.ns3 = (this.ns && (this.major == 3));
      this.ns4b = (this.ns && (this.minor < 4.04));
      this.ns4 = (this.ns && (this.major >= 4));
      this.ie = (agent.indexOf("msie") != -1);
    this.ie3 = (this.ie && (this.major == 2));
    this.ie4 = (this.ie && (this.major >= 4));
    this.ie5 = (this.ie && (msieRealVer == 5.00));    
    this.ie55 = (this.ie && (msieRealVer >= 5.5));        
      this.op3 = (agent.indexOf("opera") != -1);
      this.win = (agent.indexOf("win")!=-1);
      this.mac = (agent.indexOf("mac")!=-1);
    this.unix = (agent.indexOf("x11")!=-1);

}

var is = new Is();

//DOM Equalization statements -------------------------------------------
var docRef = (is.ns4) ? "document" : "document.all";
var styleRef = (is.ns4) ? "" : ".style";
var VISIBLE = (is.ns4) ? "show" : "visible";
var HIDDEN = (is.ns4) ? "hide" : "hidden";

var oldBlock = "0";
var whichBlock = 0;

//Intialize DIV ---------------------------------------------------------
function init(){
  nav0Txt = eval(docRef+'["nav0TxtDiv"]'+styleRef);
  nav1Txt = eval(docRef+'["nav1TxtDiv"]'+styleRef);
//  document.internationalForm.country.selectedIndex = 2;

}

function init2(){
  usernamePromptRef = eval(docRef+'["usernamePrompt"]'+styleRef);
  oldBlock = "usernamePrompt";
}

//Toggle DIV -------------------------------------------------------------
function visToggle(whichNumber){
  //alert(selBox.country);
  var num = parseInt(whichNumber);

  if (num >= 1)
    whichBlock = 1;
  else 
    whichBlock = 0;
  var newTarg = eval("nav"+whichBlock+"Txt");
//  alert("switching to this block: "+whichBlock);
  var oldTarg = eval("nav"+oldBlock+"Txt");

  newTarg.visibility = VISIBLE;
  oldTarg.visibility = (whichBlock==oldBlock) ?  VISIBLE : HIDDEN;

  oldBlock = whichBlock;
}

function toggleOn(whichBlock){
  var newTarg = eval(whichBlock+"Ref");
  newTarg.visibility = VISIBLE;
}

function toggleOff(whichBlock){
  var newTarg = eval(whichBlock+"Ref");
  newTarg.visibility = HIDDEN;
}

// This function pops up the error message for a page is there are any errors.
function errorPopup(s)
{
  var errMsg = s;
  var msg = "";
  if (errMsg) {
    msg += "\n";
    msg += errMsg;
    alert(msg);
  }
  return false;
}

function popWindow(url, height, width) {
    var optionListing = "HEIGHT="+height+",WIDTH="+width+",innerHeight="+height+",innerWidth="+width+",channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=0,scrollbars=yes,status=0,toolbar=0,screenX=10,screenY=20"
    remote = window.open(url,"Popup",optionListing);
    if (remote != null)  {
    //  remote.name = "popup";
      remote.focus();
    } // end if
}

function handleResize() {
  location.reload();
  return false;
}
if (is.ns) {
  window.captureEvents(Event.RESIZE);
  window.onresize = handleResize;
}


var allowToSubmit = true; // by default, allow form submission.
var currentField;

// Validate user's entry, and decide if the form can be submitted.
function setAllowToSubmit(field) {
  if (!validateTextField(field)) {
    allowToSubmit = false;
  }
  else {
    allowToSubmit = true;
  }
}

// Submit form only if allowed to do so.
function submitForm() {
  
  setAllowToSubmit(currentField);
  if (allowToSubmit) {
    return submitStatus();
  }
  else {
    return false;
  }
}
 
// The following function prevent a form from being resubmitted, when a user clicks on a "Submit" button/image multiple times.
var notAResubmit = true;

function submitStatus() {
  document.body.style.cursor = "wait";
  if (!notAResubmit) { // is a resubmit
    return false;
  }
  else {
    notAResubmit = false;
    return true;
  }
}

function submitStatusFormSource(thisForm, environmentLocale, formSource) {
  var formValidationResult = false;
 
  if (formSource == "login"){
  	formValidationResult = validateLoginForm(thisForm, environmentLocale);
  }
  else if (formSource == "movil"){
  	formValidationResult = validateMovilForm(thisForm, environmentLocale);
  }
  else if (formSource == "103818"){
  	formValidationResult = validateNewEmailRegForm(thisForm, environmentLocale);
  }
  else if (formSource == "newsletter"){
  	formValidationResult = validateNewsletterRegForm(thisForm);
  }
  else if (formSource == "newslettermkt"){
  	formValidationResult = validateNewsletterMktRegForm(thisForm);
  }
  else if (formSource == "nonewsletter"){
  	return true;
  }
  else if (formSource == "confirmmovil"){
  	return true;
  }
  else if (formSource == "717134"){
      	//formValidationResult = validateRegFormNew1(thisForm, environmentLocale);
      	formValidationResult = validateUnileverRegForm(thisForm, environmentLocale);
  } 
  /*else if (formSource == "onesiteprofile"){
    	formValidationResult = validateOneSiteProfileRegForm(environmentLocale);
  }
  else if (formSource == "100024" || formSource == "100032" || formSource == "102004" || formSource == "100099" || formSource == "757649" || formSource == "100073" || formSource == "529641" || formSource == "102079" || formSource == "439109" || || formSource == "247542"){
  	//alias required
  	formValidationResult = validateRegForm(thisForm, environmentLocale);
  }
  else{
  	//no alias name
  	formValidationResult = validateRegFormNew(thisForm, environmentLocale);
  }*/
  else if (formSource == "100065"){//NFL
      	formValidationResult = validateNFLRegForm(thisForm, environmentLocale);
  } 
  else
  {
  	formValidationResult = validateIntegrateRegForm(thisForm, environmentLocale);
  }
  
  if (formValidationResult == false)
    return false;

    document.body.style.cursor = "wait";
    if (!notAResubmit) {
      return false;
    }
    else {
      notAResubmit = false;
      return true;
    }
}

// To prevent a link being clicked again before the response comes back
var linkClickCount=0;
function clickCount(environmentLocale)
{
	linkClickCount = linkClickCount + 1;
	if(linkClickCount >= 2 )
	{
		if (environmentLocale == "Sp")
		{
			alert("Tu pedido ha sido recibido y será procesado muy pronto.");
		}
		else if (environmentLocale == "En")
		{
			alert("Your request is being processed and will be completed shortly.");
		}
	}
}

function check_cookies_accepted()
{
	var message_accept_univ_cookie_sp = "Para usar ciertos servicios que requieren registro, tienes que aceptar cookies de Univision.com.   En tu navegador, ve a [Tools] > [Internet Settings] y entra a la sección  [Privacy]. Allí debes seleccionar [Medium High] o [Medium] para poder aceptar cookies  de Univision.com. Gracias.";
	var message_accept_univ_cookie_en = "To use certain services that require registration, you will need to accept cookies from Univision.com. In your browser, go to  [Tools]  > [Internet Settings] and click to the section  [Privacy]. In this section, please select either [Medium High] or [Medium] so that you can accept cookies from Univision.com. Thank you.";
	
	var cookieName = 'testCookie' + (new Date().getTime());
	document.cookie = cookieName + '=cookieValue';
	var cookiesEnabled = document.cookie.indexOf(cookieName) != -1;
	if (cookiesEnabled)
		return "Enabled";
	else
	{
		alert(message_accept_univ_cookie_sp + "\n\n"+ message_accept_univ_cookie_en);
		return "Disabled or accept based on PROMP";
	}

}



