﻿// JScript File

function S4() {
  return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
}
function guid() {
  return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4());
}
function GetElement(nameid)
{
  return document.getElementById(nameid);
}
function GetSelectValue(nameid)
{
  var elm = document.getElementById(nameid);
  if (elm)
  {
    return elm.options[elm.selectedIndex].value;
  }
  return "#";
}
function ButtonDiv(id, iname)
{
  var elm = GetElement("divButtonSaleUCE" + id);
  if (elm)
  {
  if (id==1)
  elm.style.cssText = "background: transparent url('Images/" + iname + "-left-1.gif') no-repeat top left; " + 
                      "text-decoration: none; display: block; font: bold 13px Tahoma; line-height: 16px; " +
                      "height: 24px; padding-left: 11px;";
  else
  elm.style.cssText = "background: transparent url('Images/" + iname + "-left-1.gif') no-repeat top left; " + 
                      "text-decoration: none; display: block; float: left; font: bold 13px Tahoma; line-height: 16px; " +
                      "height: 24px; padding-left: 11px;";
  }
}
function ButtonDivHover(id, iname)
{
  var elm = GetElement("divButtonSaleUCE" + id);
  if (elm)
  {
  if (id==1)
  elm.style.cssText = "background: transparent url('Images/" + iname + "-left-2.gif') no-repeat bottom left; " + 
                      "text-decoration: none; display: block; font: bold 13px Tahoma; line-height: 16px; " +
                      "height: 24px; padding-left: 11px; text-decoration: none; cursor:hand";
  else
  elm.style.cssText = "background: transparent url('Images/" + iname + "-left-2.gif') no-repeat bottom left; " + 
                      "text-decoration: none; display: block; float: left; font: bold 13px Tahoma; line-height: 16px; " +
                      "height: 24px; padding-left: 11px; text-decoration: none; cursor:hand";
  }
}
function ButtonSpan(id, iname)
{
  var elm = GetElement("spanButtonSaleUCE" + id);
  if (elm)
  elm.style.cssText = "background: transparent url('Images/" + iname + "-right-1.gif') no-repeat top right; " +
                      "display: block; padding: 4px 11px 4px 0; text-decoration: none;";
}
function ButtonSpanHover(id, iname)
{
  var elm = GetElement("spanButtonSaleUCE" + id);
  if (elm)
  elm.style.cssText = "background: transparent url('Images/" + iname + "-right-2.gif') no-repeat bottom right; " +
                      "display: block; padding: 4px 11px 4px 0; color: black; text-decoration: none; cursor:hand";
}  
function LoadStyles(id, iname)
{
  setTimeout("ButtonDiv(\'" + id + "\', \'" + iname + "\')", 200);
  setTimeout("ButtonSpan(\'" + id + "\', \'" + iname + "\')", 200);
}
function HidePart(d) 
{ 
  document.getElementById(d).style.display = "none";  
}
function ShowPart(d) 
{ 
  document.getElementById(d).style.display = "block"; 
}
function linkClick(d)
{
  if(d)
  {
    ShowPart(d);
  }
  else
  {
    HidePart(d);
  }
}
function ValidateForm (myForm) 
{
  if (/^(([\w-]+\.)+[\w-]+|([a-zA-Z]{1}|[\w-]{2,}))@((([0-1]?[0-9]{1,2}|2{1}[0-5]{2})\.([0-1]?[0-9]{1,2}|2{1}[0-5]{2})\.([0-1]?[0-9]{1,2}|2{1}[0-5]{2})\.([0-1]?[0-9]{1,2}|2{1}[0-5]{2})){1}|([\d]*[a-zA-Z]+[\w-]+\.)+[a-zA-Z]{2,6})$/.test(myForm.EmailFrom.value))
  {
    myForm.style.display = "none";
    myForm.action += window.location.search.substring(0);
    myForm.submit();
    return (true)
  }
  alert("Invalid E-mail Address! Please re-enter.")
  return (false)
}
function verify()
{
  var myForm = document.form1;
  var themessage = "You are required to complete the following fields: ";
  if (myForm.NameForm.value =="") 
  {
    themessage = themessage + " - Name";
  }
  if (myForm.EmailFrom.value=="")
  {
    themessage = themessage + " -  E-mail";
  }
  if (myForm.SubjectForm.value=="")
  {
    themessage = themessage + " -  Subject";
  }
  if (myForm.BodyForm.value=="" || BodyCleanCounter>0)
  {
    themessage = themessage + " -  Body";
  }
    
  //alert if fields are empty and cancel myForm submit
  if (themessage == "You are required to complete the following fields: ") 
  {
    ValidateForm(myForm);
  }
  else 
  {
    alert(themessage);
    return false;
  }
}
function linkBtnClick(a,b)
{
  ShowPart(b);
  HidePart(a);
}
function displayOption()
{
  var elm = document.getElementById("DropDownLanguage");
  if (elm)
  {
    var query = window.location.search.substring(0); 
    window.location = elm.options[elm.selectedIndex].value + query;
  }
}
function redirectPage()
{
  var lan = "en";  
  if (window.navigator.userLanguage)
  {
    lan = window.navigator.userLanguage;
  }
  else if (window.navigator.language)
  {
    lan = window.navigator.language; 
  }
  
  if (lan && lan.length >= 2 && lan.substr(0, 2) == "fr")
  {
    var query = window.location.search.substring(0); 
    window.location = "SupportChannels_fr.htm" + query;
  }
  else if (lan && lan.length >= 2 && lan.substr(0, 2) == "es")
  {
    var query = window.location.search.substring(0); 
    window.location = "SupportChannels_es.htm" + query;
  }
  else if (lan && lan.length >= 2 && lan.substr(0, 2) == "de")
  {
    var query = window.location.search.substring(0); 
    window.location = "SupportChannels_de.htm" + query;
  }
}
function getmailsupport()
{
  var em = getmailaddress();
  if (em && em.length > 0)
  {
    window.open("mailto:" + em + "?subject=Support");
  }
}
function WriteMessage(msg)
{
  var query = window.location.search.substring(0); 
  if (query.match("ticket=ok"))
    document.write(msg);
}
function LoadHiddenFields()
{
  var dom; 
  if (document.referrer == '')
  {
    dom = document.URL;
  } 
  else 
  { 
    dom = document.referrer;
  }
  if (document.getElementById) 
  {
    var elmSec = document.getElementById('hturl');
    if (elmSec) 
    {
      elmSec.value=dom;
    }
  }
}
var BodyCleanCounter = 1;
function CleanMessage()
{
  var elm = GetElement("BodyForm");
  if (elm && BodyCleanCounter-- > 0)
  {
    elm.value = "";
  }
}
