﻿// JScript File

function openDlgWin(sURL, sParam, iwidth, iHeight, srcWin, iLeft, iTop) {
  if (!iLeft){iLeft = (screen.width - iwidth) / 2;}
  if (!iTop){iTop = (screen.Height - iHeight) / 2;}
  var aParm = 'help=no;resizeable=no;status=no;';
  aParm  += 'dialogwidth=' + iwidth + 'px;dialogHeight=' + iHeight + 'px;dialogLeft=' + iLeft + 'px;dialogTop=' + iTop + 'px;';
  var aRes = window.showModalDialog(sURL, sParam, aParm);
  if (srcWin) {srcWin.location.href = srcWin.location.href}
  return aRes;
}

function openNewWin(sURL, sWinName, iwidth, iHeight, srcWin, iLeft, iTop) {
  if (!iLeft){iLeft = (screen.width - iwidth) / 2;}
  if (!iTop){iTop = (screen.Height - iHeight) / 2;}
  var aParm = 'channelmode=no,directories=no,fullscreen=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,titlebar=no,toolbar=no,';
  aParm  += 'width=' + iwidth + 'px,height=' + iHeight + 'px,left=' + iLeft + 'px,top=' + iTop + 'px';
  window.open(sURL, sWinName, aParm);
  if (srcWin) {srcWin.location.href = srcWin.location.href;}
}

function openNewWinMenuBar(sURL, sWinName, iwidth, iHeight, srcWin, iLeft, iTop) {
  if (!iLeft){iLeft = (screen.width - iwidth) / 2;}
  if (!iTop){iTop = (screen.Height - iHeight) / 2;}
  var aParm = 'channelmode=no,directories=no,fullscreen=no,location=yes,menubar=yes,resizable=yes,scrollbars=yes,status=no,titlebar=yes,toolbar=yes,';
  aParm  += 'width=' + iwidth + 'px,height=' + iHeight + 'px,left=' + iLeft + 'px,top=' + iTop + 'px';
  window.open(sURL, sWinName, aParm);
  if (srcWin) {srcWin.location.href = srcWin.location.href;}
}

function toggleLayer(whichLayer, show)
{
    var style;
    var style = GetItem(whichLayer).style;
   
    
    if (show == true)
    {
        style.display = "block";
    }
    else
    {
        style.display = "none";
    }
}

function GetItem(itemName)
{
    var _item;
    if (document.getElementById)
    {
        // this is the way the standards work
        _item =  document.getElementById(itemName);
    }
    else if (document.all)
    {
        // this is the way old msie versions work
        _item = document.all[itemName];
    }
    else if (document.layers)
    {
        // this is the way nn4 works
        _item = document.layers[itemName];
    }
    
    return _item;
}

function SetItemClass(item, className)
{
    item.className = className;
}

function ChangeClassOnRolloverById(itemId, className)
{
    var item = GetItem(itemId);
    if(item)
    {
        ChangeClassOnRollover(item, className); 
    }
}

var oldClassName;
function ChangeClassOnRollover(item, className)
{
    oldClassName = item.className;
    SetItemClass(item, className);
}

function ChangeClassBack(item)
{
    item.className = oldClassName;
}

var lastIndustry="", lastCompany="";
function selIndustry(imgID){ 
    GetItem('landingDiv').style.display = 'none';
    var curIndustry="imgIndustry"+imgID; var curCompany="divCompany"+imgID;
    if (lastIndustry!=""){toggleMarker(lastIndustry, "none");lastIndustry="";}
    if (lastCompany!=""){toggleMarker(lastCompany, "none");lastCompany="";}
    toggleMarker(curIndustry, "block");lastIndustry=curIndustry;
    toggleMarker(curCompany, "block");lastCompany=curCompany;
}

function toggleMarker(tagID, toggle){
    var oItem=MM_findObj(tagID);if(!oItem)return;oItem.style.display=toggle;
}

function MM_findObj(n, d) { //v4.01
  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);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function IsValidEmail(EmailAddr) {
     var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
     var regex = new RegExp(emailReg);
     return regex.test(EmailAddr);
}

function pcLogin(EmailAddr){
    var msg = "";
    if (EmailAddr=='' || EmailAddr=='your email') {msg += "The Email Address must be completed." + "\n";}
    else if(!IsValidEmail(EmailAddr)) {msg += "The Email Address must be a valid Email Address." + "\n";}
    if(msg != ""){alert("Please enter or correct the following:\n\n" + msg);return false;}
    window.location.href = "PrefCtr.aspx?email=" + EmailAddr;
}

function SetNewsLetterClass(button)
{
    var _item = GetItem(button);
    if(_item != null)
    {
        if (window.navigator.appName == "Microsoft Internet Explorer")
        {
            _item.className = "newsLetterInput";
        }
        else
        {
            _item.className = "newsLetterInputFirefox";
        }
    }
}
