<!--

var Language = "EN";

var ajaxRequest;

function ajaxFunction() {
  try {
    ajaxRequest = new XMLHttpRequest();
    ajaxRequest.overrideMimeType('text/html');
    return true;
  } catch ( e ) {
    try {
      ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
      return true;
    } catch ( e ) {
      try {
        ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
        return true;
      } catch ( e ) {
        alert("Your Internet browser does not support AJAX (Asynchronous Javascript And XML). Update it!");
        return false;
      }
    }
  }
}

function QueryString(qn) {
  qs = window.location.search.substring(1);
  rq = qs.split("&");
  for ( i = 0; i < rq.length; i++ ) {
    qe = rq[i].split("=");
    if ( qe[0] == qn ) return qe[1];
	else return "";
  }
}

function FindObject(n, d) {
  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 = FindObject(n, d.layers[i].document);
  if ( !x && d.getElementById ) x = d.getElementById(n);
  return x;
}

function ValidateForm() {
  if ( typeof(Language) == "undefined" ) Language = "PT";
  
  var smField = ( Language == "PT" )?"Campo ":"";
  var smSelect = ( Language == "PT" )?"deve ser selecionado":"must be selected";
  var smEmail = ( Language == "PT" )?"deve ser um endereço de e-mail válido":"must be a valid e-mail address";
  var smNumber = ( Language == "PT" )?"deve conter um número":"must contain a number";
  var smBetween = ( Language == "PT" )?"entre":"between";
  var smAnd = ( Language == "PT" )?"e":"and";
  var smRequired = ( Language == "PT" )?"é requerido":"is required";
  
  var k = 0, i, p, q, nm, test, val, num, vmin, vmax, errors = "", args = ValidateForm.arguments;
  for ( i = 0; i < ( args.length - 2 ); i += 3 ) {
    test = args[i+2]; val = FindObject(args[i]);
    if ( val ) {
      nm = ( args[i+1] != "" )?args[i+1]:val.name; nm = smField + nm;
      if ( val.type == "select-one" || val.type == "select-multiple" ) {
        if ( val.options && val.selectedIndex <= 0 ) errors += "- " + nm + " " + smSelect + ".\n";
      } else {
        if ( ( val = val.value ) != "" ) {
          if ( test.indexOf("isEmail") != -1 ) {
            p = val.indexOf("@"); if ( p < 1 || p == ( val.length - 1 ) ) errors += "- " + nm + " " + smEmail + ".\n";
          } else if ( test != "R" ) {
            p = val.indexOf(","); if ( p != -1 ) val = val.substring(0, p) + "." + val.substring(p + 1);
            num = parseFloat(val); if ( val != "" + num && val.indexOf(".") == -1 ) errors += "- " + nm + " " + smNumber + ".\n";
            if ( test.indexOf("inRange") != -1 ) {
              p = test.indexOf(":"); vmin = parseFloat(test.substring(8,p)); vmax=parseFloat(test.substring(p+1));
              if ( num < vmin || vmax < num ) errors += "- " + nm + " " + smNumber + " " + smBetween + " " + vmin + " " + smAnd + " " + vmax + ".\n";
            }
          }
        } else if ( test.charAt(0) == "R" ) errors += "- " + nm + " " + smRequired + ".\n";
      }
    }
  }
  return errors;
}

function CheckAll(f) {
  var df;
  if ( !f ) df = document.forms[0];
  else if ( isNaN(f) ) df = document.forms(f);
  else df = document.forms[f];
  new_value = ( !df.elements[0].checked );
  for ( var i = 0; i < df.elements.length; i++ ) {
    df.elements[i].checked = new_value;
  }
}

function DisableAll(f) {
  var df;
  if ( !f ) df = document.forms[0];
  else if ( isNaN(f) ) df = document.forms(f);
  else df = document.forms[f];
  for ( var i = 0; i < df.elements.length; i++ ) {
    if ( df.elements[i].type == "button" ) df.elements[i].disabled = true;
  }
}

function styleAbbr() {
  var oldBodyText, newBodyText, reg
  isIE = (document.all)?true:false;
  if ( isIE ) {
    oldBodyText = document.body.innerHTML;
    reg = /<ABBR([^>]*)>([^<]*)<\/ABBR>/g;
    newBodyText = oldBodyText.replace(reg, '<ABBR $1><SPAN class=\"abbr\" $1>$2</SPAN></ABBR>');
    document.body.innerHTML = newBodyText;
  }
}

function NumbersOnly(myfield, e) {
  if ( myfield.length == 0 ) myfield.value = 0;
  var key;
  var keychar;
  if ( window.event ) key = window.event.keyCode;
  else if ( e ) key = e.which;
  else return true;
  keychar = String.fromCharCode(key);
  if ((key == null) || (key == 0) || (key == 8) || (key == 9)|| (key == 13)|| (key == 27)) return true;
  else if ( (("0123456789").indexOf(keychar) > -1) ) return true;
  else {
    //alert(( Language == "PT" )?"Somente números são permitidos para esta entrada!":"Only numbers are allowed for this entry!");
    return false;
  }
}

function OpenWindow(theURL, winName, features) {
  window.open(theURL, winName, features);
}

function ReloadWindow() {
  window.location.reload();
}

function CloseWindow() {
  window.opener.focus();
  window.close();
}

function CloseDisplay() {
  var i, val, args = CloseDisplay.arguments;
  for ( i = 0; i < args.length; i++ ) {
    val = FindObject(args[i]);
	if ( val && val.tagName != "DIV" && typeof(val.style.display) != "undefined" ) val.style.display = "none";
    else if ( val && typeof(val.style.visibility) != "undefined" ) val.style.visibility = "hidden";
    else if ( val && typeof(val.style.display) != "undefined" ) val.style.display = "none";
  }
}

function pageWidth() {
  return window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;
}

function pageHeight() {
  return window.innerHeight != null ? window.innerHeight : document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body != null ? document.body.clientHeight : null;
}

function posLeft() {
  return typeof window.pageXOffset != "undefined" ? window.pageXOffset :document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0;
}

function posTop() {
  return typeof window.pageYOffset != "undefined" ?  window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0;
}

function posRight() {
  return posLeft() + pageWidth();
}

function posBottom() {
  return posTop() + pageHeight();
}
                    
function Reposition() {
  var p, args = Reposition.arguments;
  
  if ( args.length > 0 ) p = args[0];
  else p = "middle";
  
  if ( p == "topleft" ) {
    x = 0;
    y = 0;
  } else if ( p == "topright" ) {
    x = screen.availWidth - pageWidth() - 30;
    y = 0;
  } else if ( p == "bottomright" ) {
    x = screen.availWidth - pageWidth() - 30;
    y = screen.availHeight - pageHeight() - 10;
  } else {
    x = ( screen.availWidth - pageWidth() ) / 2;
    y = ( screen.availHeight - pageHeight() ) / 2;
  }
  
  if ( x < 0 ) x = 0;
  if ( y < 0 ) y = 0;
  
  window.moveTo(x, y);
  
  self.focus();
}

function Redimension() {
  var args = Redimension.arguments, x = 0, y = 0;
  
  if ( args.length == 0 ) {
    x = self.document.body.scrollWidth + self.document.body.offsetWidth - self.document.body.clientWidth + 7;
    y = self.document.body.scrollHeight + self.document.body.offsetHeight - self.document.body.clientHeight + 15 + 58;
  } else if ( args.length >= 2 ) {
    if ( args.length >= 1 ) x = args[0];
    if ( args.length >= 2 ) y = args[1];
  }
  
  if ( x > 0 && y > 0 ) self.resizeTo(x, y);
  
  if ( args.length >= 3 ) Reposition();
}

function PreLoadImages() {
  var d = document;
  if ( d.images ) {
    if ( !d.apics ) d.apics = new Array();
    var i, j = d.apics.length, a = PreLoadImages.arguments;
    for ( i = 0; i < a.length; i++ ) if ( a[i].indexOf("#") != 0 ) {
      d.apics[j] = new Image;
      d.apics[j++].src = a[i];
    }
  }
}

function CharsLeft(f, h, m) {
  if ( typeof(Language) == "undefined" ) Language = "PT";
  
  var smLeft = ( Language == "PT" )?"caracteres restantes":"characters left";
  var smNoLeft = ( Language == "PT" )?"Nenhum caractere restante":"No characters left";
  
  val = FindObject(f);
  hlp = FindObject(h);
  if ( val && hlp ) {
    l = m - val.value.length;
    if ( l > 0 ) hlp.innerHTML = "" + l + " " + smLeft + "!";
    else if ( l == 0 ) hlp.innerHTML = smNoLeft + "!";
    else val.value = val.value.substring(0, m);
  }
}

function FormatCurrency(num) {
  if ( typeof(Language) == "undefined" ) Language = "PT";
  
  var smCurrency = ( Language == "PT" )?"R$":"$";
  var smThousand = ( Language == "PT" )?".":",";
  var smDecimal = ( Language == "PT" )?",":".";
  
  num = num.toString().replace(/\$|\,/g,'');
  if ( isNaN(num) ) num = "0";
  sign = ( num == ( num = Math.abs(num) ) );
  num = Math.floor(num*100+0.50000000001);
  cents = num%100;
  num = Math.floor(num/100).toString();
  if ( cents < 10 ) cents = "0" + cents;
  for ( var i = 0; i < Math.floor((num.length-(1+i))/3); i++ ) {
    num = num.substring(0,num.length-(4*i+3)) + smThousand + num.substring(num.length-(4*i+3));
  }
  return ( ((sign)?'':'-') + smCurrency + num + smDecimal + cents );
}

function GetPhoneNumber(f) {
  var pn = FindObject(f);
  var p1 = FindObject(f + "_Zone");
  var p2 = FindObject(f + "_Prefix");
  var p3 = FindObject(f + "_Number");
  var p4 = FindObject(f + "_Extension");
  var strTemp = "";
  if ( p1 && p1.value != "" ) strTemp = strTemp + "(" + p1.value + ")";
  if ( p2 && p3 && ( p2.value != "" || p3.value != "" ) ) strTemp = strTemp + p2.value + "-" + p3.value;
  if ( p4 && p4.value != "" ) strTemp = strTemp + " " + p4.value;
  if ( pn ) pn.value = strTemp;
}

var sTitle = "";

function SwapImage(i, s) {
  var objI = FindObject(i), objS = FindObject(s);
  if ( objI && objS ) objI.src = objS.src;
}

function SwapText(i, s) {
  var objI = FindObject(i);
  if ( objI ) objI.innerHTML = s;
}

function ViewImage(i, t) {
  window.open("view.asp?img=" + i + "&ttl=" + t, "POPUP", "left=10, top=10, width=160, height=120, scrollbars=no");
}

function ShowSlide() {
  var i, f = "", args = ShowSlide.arguments;
  for ( i = 0; i < args.length; i++ ) f += "&img" + eval( i + 1 ) + "=" + args[i];
  window.open("view.asp?act=slide&qty=" + args.length + f + "&ttl=" + sTitle, "POPUP", "left=10, top=10, width=160, height=120, scrollbars=yes");
}

function ViewColors() {
  var i, s = "", args = ViewColors.arguments;
  for ( i = 0; i < args.length; i++ ) {
    if ( i > 0 ) s += ",";
    s += args[i];
  }
  window.open("view.asp?act=colors&id=" + s, "POPUP", "left=10, top=10, width=320, height=240, scrollbars=yes");
}

function EmailToFriend() {
  window.open("email.asp", "POPUP", "left=10, top=10, width=160, height=120, scrollbars=no");
}

function PrintFriedly(q) {
  window.open("print.asp?"+q, "POPUP", "left=10, top=10, width=640, height=480, scrollbars=yes");
}

function HelpWindow(t) {
  window.open("help.asp?tag="+t, "POPUP", "left=10, top=10, width=360, height=480, scrollbars=yes");
}

function Reminder(t) {
  window.open("reminder.asp?tag="+t, "POPUP", "left=10, top=10, width=160, height=120, scrollbars=yes");
}

function GetAccount(f,i,v) {
  var ok = false;
  if ( v != "" && ajaxFunction() ) {
    ok = true;
    var fcd = FindObject(i), fnm = FindObject(i + "_Name");
    ajaxRequest.onreadystatechange = function() {
      if ( ajaxRequest.readyState == 4 ) {
        var ajax = ajaxRequest.responseText; ajax = ajax.split("\n");
        if ( ajax.length >= 2 ) {
          if ( fcd ) fcd.value = ajax[0];
          if ( fnm ) fnm.value = ajax[1];
        } else ok = false;
      }
    }
    var parameters = "ajax=" + encodeURI(v) + "&";
    ajaxRequest.open("POST", "get_account.asp", true);
    ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    ajaxRequest.setRequestHeader("Content-length", parameters.length);
    ajaxRequest.setRequestHeader("Connection", "close");
    ajaxRequest.send(parameters);
  }
  if ( !ok ) window.open("get_account.asp?form="+f+"&input="+i+"&value="+v, "POPUP", "left=10, top=10, width=320, height=80, scrollbars=yes");
}

function GetProduct(f,i,v,p) {
  var ok = false;
  if ( v != "" && ajaxFunction() ) {
    ok = true;
    var fcd = FindObject(i), fnm = FindObject(i + "_Name");
    var fqt = FindObject(i.replace("SKU_", "QTY_"));
    ajaxRequest.onreadystatechange = function() {
      if ( ajaxRequest.readyState == 4 ) {
        var ajax = ajaxRequest.responseText; ajax = ajax.split("\n");
        if ( ajax.length >= 2 ) {
          if ( fcd ) fcd.value = ajax[0];
          if ( fnm ) fnm.value = ajax[1];
          if ( fqt ) {
            if ( isNaN(fqt.value) ) fqt.value = "1";
          }
        } else ok = false;
      }
    }
    var parameters = "ajax=" + encodeURI(v) + "&";
    ajaxRequest.open("POST", "get_product.asp", true);
    ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    ajaxRequest.setRequestHeader("Content-length", parameters.length);
    ajaxRequest.setRequestHeader("Connection", "close");
    ajaxRequest.send(parameters);
  }
  if ( !ok ) window.open("get_product.asp?form="+f+"&input="+i+"&value="+v+"&price="+p, "POPUP", "left=10, top=10, width=320, height=80, scrollbars=yes");
}

function Calendar(f) {
  var d, p = f.indexOf(".");
  if ( p ) d = f.substring(p+1);
  else d = f;
  if ( Language == "PT" ) FindObject(d).value = FindObject(d+"_D").value + "/" + FindObject(d+"_M").value + "/" + FindObject(d+"_Y").value;
  else FindObject(d).value = FindObject(d+"_M").value + "/" + FindObject(d+"_D").value + "/" + FindObject(d+"_Y").value;
  window.open("calendar.asp?targetField="+f, "POPUP", "left=10, top=10, width=250, height=260, scrollbars=no");
}

function Customize() {
  var args = Customize.arguments, qry = "";
  if ( args.length >= 2 ) {
    qry = "proid=" + args[0] + "&pisku=" + args[1];
    if ( args.length >= 3 ) qry += "&cart=" + args[2];
    if ( args.length >= 4 ) qry += "&input=" + args[3];
    window.open("wording.asp?"+qry, "POPUP", "left=10, top=10, width=320, height=80, scrollbars=yes");
  }
}

function Agreement(i) {
  window.open("terms_and_conditions.asp?popup=1&id="+i, "POPUP", "left=10, top=10, width=640, height=480, scrollbars=yes");
}

//-->
