//Used by HierMenus
if(window.event + "" == "undefined") event = null;
function HM_f_PopUp(){return false};
function HM_f_PopDown(){return false};
popUp = HM_f_PopUp;
popDown = HM_f_PopDown;

// convert all characters to lowercase to simplify testing 
var agt=navigator.userAgent.toLowerCase(); 
var appVer = navigator.appVersion.toLowerCase(); 

// *** BROWSER VERSION *** 

var is_minor = parseFloat(appVer); 
var is_major = parseInt(is_minor); 

// Note: On IE, start of appVersion return 3 or 4 
// which supposedly is the version of Netscape it is compatible with. 
// So we look for the real version further on in the string 

var iePos  = appVer.indexOf('msie'); 
if (iePos !=-1) { 
   is_minor = parseFloat(appVer.substring(iePos+5,appVer.indexOf(';',iePos))) 
   is_major = parseInt(is_minor); 
} 

var is_getElementById   = (document.getElementById) ? "true" : "false"; // 001121-abk 
var is_getElementsByTagName = (document.getElementsByTagName) ? "true" : "false"; // 001127-abk 
var is_documentElement = (document.documentElement) ? "true" : "false"; // 001121-abk 

var is_gecko = ((navigator.product)&&(navigator.product.toLowerCase()=="gecko"))?true:false; 
var is_gver  = 0; 
if (is_gecko) is_gver=navigator.productSub; 

var is_moz   = ((agt.indexOf('mozilla/5')!=-1) && (agt.indexOf('spoofer')==-1) && 
                (agt.indexOf('compatible')==-1) && (agt.indexOf('opera')==-1)  && 
                (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1)     && 
                (is_gecko) && 
                ((navigator.vendor=="")||(navigator.vendor=="Mozilla"))); 
if (is_moz) { 
   var is_moz_ver = (navigator.vendorSub)?navigator.vendorSub:0; 
   if(!(is_moz_ver)) { 
       is_moz_ver = agt.indexOf('rv:'); 
       is_moz_ver = agt.substring(is_moz_ver+3); 
       is_paren   = is_moz_ver.indexOf(')'); 
       is_moz_ver = is_moz_ver.substring(0,is_paren); 
   } 
   is_minor = is_moz_ver; 
   is_major = parseInt(is_moz_ver); 
} 

var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) 
            && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) 
            && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1) 
            && (!(is_moz))); 

// Netscape6 is mozilla/5 + Netscape6/6.0!!! 
// Mozilla/5.0 (Windows; U; Win98; en-US; m18) Gecko/20001108 Netscape6/6.0 
// Changed this to use navigator.vendor/vendorSub - dmr 060502   
// var nav6Pos = agt.indexOf('netscape6'); 
// if (nav6Pos !=-1) { 
if ((navigator.vendor)&& 
    ((navigator.vendor=="Netscape6")||(navigator.vendor=="Netscape"))&& 
    (is_nav)) { 
   is_major = parseInt(navigator.vendorSub); 
   // here we need is_minor as a valid float for testing. We'll 
   // revert to the actual content before printing the result. 
   is_minor = parseFloat(navigator.vendorSub); 
} 

var is_opera = (agt.indexOf("opera") != -1); 
var is_opera2 = (agt.indexOf("opera 2") != -1 || agt.indexOf("opera/2") != -1); 
var is_opera3 = (agt.indexOf("opera 3") != -1 || agt.indexOf("opera/3") != -1); 
var is_opera4 = (agt.indexOf("opera 4") != -1 || agt.indexOf("opera/4") != -1); 
var is_opera5 = (agt.indexOf("opera 5") != -1 || agt.indexOf("opera/5") != -1); 
var is_opera6 = (agt.indexOf("opera 6") != -1 || agt.indexOf("opera/6") != -1); // new 020128- abk 
var is_opera5up = (is_opera && !is_opera2 && !is_opera3 && !is_opera4); 
var is_opera6up = (is_opera && !is_opera2 && !is_opera3 && !is_opera4 && !is_opera5); // new020128 

var is_nav4up = (is_nav && is_minor >= 4);
var is_nav6   = (is_nav && is_major==6);
var is_nav6up = (is_nav && is_minor >= 6);
var is_ie   = ((iePos!=-1) && (!is_opera));

//Used to get coordinates of "More Info" image in IE
//Returns the Y value
function getRealTop(imgElem) {
  yPos = eval(imgElem).offsetTop;
  tempEl = eval(imgElem).offsetParent;
  while (tempEl != null) {
      yPos += tempEl.offsetTop;
      tempEl = tempEl.offsetParent;
    }
  return yPos;
}

//Called by href on the "More Info" image
//Moves both the "More Info" layer and the hidemoreInfo layer
//Calls MM_showHideLayers to show the layers once moved
function moveLayer(imgID) {
  //Finds the moreInfo layer
  if(is_nav6up)
    var obj = tmt_findObj('moreInfo');
  else
    var obj = MM_findObj('moreInfo');
  
  //If IE or Netscape 6+
  if (is_ie || is_nav6up) {
    where = getRealTop(imgID);
    obj.style.top = where
  }
  //If Netscape 4.x
  else {
    where = eval(imgID).y
    obj.top = where
  }
  //Finds the hidemoreInfo layer and sets it to be 15 px higher than the "More Info" layer
  if(is_nav6up)
    obj = tmt_findObj('hidemoreInfo');
  else
    obj = MM_findObj('hidemoreInfo');
    
  if (is_ie || is_nav6up) obj.style.top = where - 15
  else obj.top = where - 15

  //Shows the layers
  MM_showHideLayers('moreInfo','','show','hidemoreInfo','','show')
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function tmt_findObj(n){
  var x,t; if((n.indexOf("?"))>0&&parent.frames.length){t=n.split("?");
  x=eval("parent.frames['"+t[1]+"'].document.getElementById('"+t[0]+"')");
  }else{x=document.getElementById(n)}return x;
}

function MM_showHideLayers() { //v3.0A Modified by Al Sparber and Massimo Foti for NN6 Compatibility
  var i,p,v,obj,args=MM_showHideLayers.arguments;if(document.getElementById){
   for (i=0; i<(args.length-2); i+=3){ obj=tmt_findObj(args[i]);v=args[i+2];
   v=(v=='show')?'visible':(v='hide')?'hidden':v;
   if(obj)obj.style.visibility=v;}} else{
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }}
}

rnd.today=new Date();
rnd.seed=rnd.today.getTime();
function rnd() {
  rnd.seed = (rnd.seed*9301+49297) % 233280;
  return rnd.seed/(233280.0);
}

function rand(number) {
  return Math.ceil(rnd()*number);
}

function PopUp(url,h,w,sb,rs,st,tb,mb,ti,lc) 
{
  lft = (screen.availWidth -w)/2;
  t = (screen.availHeight -h)/2;
  p = "scrollbars=" + sb + ",resizable=" + rs + ",status=" + st + ",toolbar=" + tb + ",menubar=" + mb + ",titlebar=" + ti + ",location=" + lc + ",top=" + t + ",left=" +lft + ",width=" + w + ",height=" + h;
  window.open(url, rand(101)-1, p);
}

// function for player window
function HQ_newWin (moviename) {
  var newwinwidth = 600;
  var newwinheight = 370;
  var winl = (screen.width / 2) - (newwinwidth / 2);
  var wint = (screen.height / 2) - (newwinheight / 2);
  var page = "video/speed.php?moviename=" + moviename;
  //alert (page);
  newwindow = window.open(page,'new_window','toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,copyhistory=no,scrollbars=no,width=600,height=370,top='+wint+',left='+winl);
}
// function for player window with no links
function HQ_newWin_nolinks (moviename) {
  var newwinwidth = 380;
  var newwinheight = 460;
  var winl = (screen.width / 2) - (newwinwidth / 2);
  var wint = (screen.height / 2) - (newwinheight / 2);
  var page = "video/speed_nolinks.php?moviename=" + moviename;
  //alert (page);
  newwindow = window.open(page,'new_window','toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,copyhistory=no,scrollbars=no,width=380,height=460,top='+wint+',left='+winl);
}

//********Form Validation Functions***********
function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  { 
    test=args[i+2]; val=tmt_findObj(args[i]);strFriendlyName = args[i+1];
    if (val) 
    { 
      nm=val.name; if ((val=val.value)!="" && isWhitespace(val)!=true) 
    {
    
    if (test.indexOf('isDate')!=-1) 
    {
      if (!isDate(val)) errors+='- '+strFriendlyName+' must contain a valid date that is in the past.\n';
    }
    else if (test.indexOf('isEmail')!=-1)
    {
      if (isEmail(val)==false) errors+='- '+strFriendlyName+' must contain an e-mail address.\n';
    }
    else if (test.indexOf('isLetters')!=-1)
    {
      if (isLetter(val)==false) errors+='- '+strFriendlyName+' must contain only letters.\n';
    }
    else if (test!='R') 
    {
      if (isNaN(val)) errors+='- '+strFriendlyName+' must contain a number.\n';
      if (test.indexOf('inRange') != -1) 
      { 
        p=test.indexOf(':');
        min=test.substring(8,p); max=test.substring(p+1);
        if (val-0<min || max<val-0) errors+='- '+strFriendlyName+' must contain a number between '+min+' and '+max+'.\n';
      }
    }
    }
    else if (test.charAt(0) == 'R') 
    {
      errors += '- '+strFriendlyName+' is required.\n'; 
    }
    }
  } 
  if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}

var whitespace = " \t\n\r";
function isWhitespace (s)

{   var i;

    // Is s empty?
    if (isEmpty(s)) return true;

    // Search through string's characters one by one
    // until we find a non-whitespace character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);

        if (whitespace.indexOf(c) == -1) return false;
    }

    // All characters are whitespace.
    return true;
}

function isEmail (s)
{   
    if (s.indexOf(" ")!=-1) return false;

    if (isEmpty(s)) 
       if (isEmail.arguments.length == 1) return defaultEmptyOK;
       else return (isEmail.arguments[1] == true);
   
    // is s whitespace?
    if (isWhitespace(s)) return false;
    
    // there must be >= 1 character before @, so we
    // start looking at character position 1 
    // (i.e. second character)
    var i = 1;
    var sLength = s.length;

    // look for @
    while ((i < sLength) && (s.charAt(i) != "@"))
    { i++
    }

    if ((i >= sLength) || (s.charAt(i) != "@")) return false;
    else i += 2;

    // look for .
    while ((i < sLength) && (s.charAt(i) != "."))
    { i++
    }

    // there must be at least one character after the .
    if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
    else return true;
}

function isInteger(s){
  var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function isAlphabetic (s){   
  var i;
  for (i = 0; i < s.length; i++){   
      // Check that current character is letter.
      var c = s.charAt(i);
      if (!isLetter(c))
      return false;
  }
  return true;
}

function isLetter (c){
  return ( ((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z")) )
}

function goTo(page) {
 w=800;
 h=400;
 lft = (screen.availWidth -w)/2;
 t = (screen.availHeight -h)/2;
 p = "scrollbars=yes,resizable=yes,status=yes,toolbar=yes,menubar=yes,titlebar=yes,location=yes,top=" + t + ",left=" +lft + ",width=" + w + ",height=" + h;
 if(confirm("Le agradecemos mucho su interés por nuestra empresa. Estamos encaminándolo a nuestro sitio en inglés"))
 window.open(page, rand(101)-1,p);
}

// Generate a Random Number between 1 and 2
rnd.today=new Date();
rnd.seed=rnd.today.getTime();

function rnd() {
  rnd.seed = (rnd.seed*9301+49297) % 233280;
  return rnd.seed/(233280.0);
}
function rand(number) {
  return Math.ceil(rnd()*number);
};
    
randomnumber = rand(2);
