﻿// JScript File

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_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

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 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 onlyNumbers(evt)
{
	var e = event || evt; // for trans-browser compatibility
	var charCode = e.which || e.keyCode;

	if (charCode > 31 && (charCode < 48 || charCode > 57))
		return false;

	return true;

}
function onlyAlpha(evt) {
    var e = event || evt; // for trans-browser compatibility
    var charCode = e.which || e.keyCode;

    if ((charCode > 64 && charCode < 91) || (charCode > 96 && charCode < 123) || charCode == 8)
        return true;

    return false;

}
// Global JavaScript Functions,Object,etc.
//	Global JavaScript Include
////////////////////////////////
// Determine browser
var isMinNS4 = (document.layers) ? 1 : 0;
var isMinIE4 = (document.all) ? 1 : 0;
var isNS6 = (document.getElementById && !document.all) ? 1 : 0;
var isMac = (navigator.userAgent.indexOf("Mac") > 0) ? 1 : 0;
var winHeight, winWidth;

//	Netscape 4.x bug fixes 
//	Relatively positioned layers fix - prevents crashing when resizing browser
if (document.layers) {
    document.write('<LAYER NAME="NOTHING" VISIBILITY="HIDE" Z-INDEX="0" LEFT="0" TOP="0"></LAYER>');
}

// default page load method
function pageLoad() {
    // window size variables for DHTML reloading
    winHeight = getWindowHeight();
    winWidth = getWindowWidth();
}

// Reload function to handle any DHTML required reloads of the page
function reloadIt() {
    // only resize if the new window height is different from the old one
    if (winHeight != getWindowHeight() || winWidth != getWindowWidth())
        document.location.replace(document.location);
}

//	Opens a new window with specified properties
function openWin(url, name, w, h, scroll, resize, status, title, tool, menubar) {
    var sFeatures;
    if (typeof (h) == "undefined") h = 300;
    if (typeof (w) == "undefined") w = 400;

    var screenW = screen.width;
    var screenH = screen.height;
    var posX = (screenW / 2) - (w / 2);
    var posY = (screenH / 2) - (h / 2);

    sFeatures = "screenY=" + posY + ",screenX=" + posX + ",top=" + posY + ",left=" + posX + ",height=" + h + ",width=" + w;

    if (typeof (scroll) != "undefined") { sFeatures += ",scrollbars=" + scroll; }
    if (typeof (resize) != "undefined") { sFeatures += ",resizable=" + resize; }
    if (typeof (status) != "undefined") { sFeatures += ",status=" + status; }
    if (typeof (title) != "undefined") { sFeatures += ",titlebar=" + title; }
    if (typeof (tool) != "undefined") { sFeatures += ",toolbar=" + tool; }
    if (typeof (menubar) != "undefined") { sFeatures += ",menubar=" + menubar; }

    //alert(sFeatures);
    var win = window.open(url, name, sFeatures);
    win.focus();
}

//	Opens a new blank window with specified properties
function openBlankWin(url, name) {

    //	alert(sFeatures);
    var win = window.open(url, name);
    win.focus();
}


//	Preload function called from web page
//	arImgs is the array of image paths passed
function preload(imgs, pths) {
    var i;

    if (document.images) {
        for (i = 0; i < pths.length; i++) {
            imgs[i] = new Image();
            imgs[i].src = pths[i];
            //	alert(pths[i]);
        }
    }

    /*	Use the following template to preload images on the individual web pages
    var imags = new Array();	//Image array to preload
    var paths = new Array();	//Image paths
    paths[0] = "";
    preload(imags,paths);
    */
}

//	Image swapping function
function swap_image(nme, imag) {
    if (document.images) {
        var img_obj = findImage(nme, document);
        if (img_obj != null && typeof (imag) != 'undefined') img_obj.src = imag.src;
    }
}

//Where to Buy Right Chanell Select Box
function setDropDown(strComp) {
    var strFilename, pos1, pos2;

    strFilename = "";

    pos1 = window.location.pathname.indexOf('wheretobuy_');
    if (pos1 >= 0) {
        pos1 += 11; // len of "wheretobuy_"
        pos2 = window.location.pathname.lastIndexOf('.');
    } else {
        pos1 = window.location.pathname.indexOf('esp_');
        if (pos1 >= 0) {
            pos1 += 4; // len of "esp_"
            pos2 = window.location.pathname.indexOf('_', pos1);
        }
    }

    if (pos1 >= 0) {
        strFilename = window.location.pathname.substring(pos1, pos2);
    }

    if (strComp == strFilename) {
        return true;
    }
    else {
        return false;
    }
}

// Positioning Methods (Used primarily for top nav positioning
/* Window and page properties */
function getWindowWidth() {
    if (isMinNS4) { return window.innerWidth; }
    else if (isMinIE4 || isNS6) { return document.body.clientWidth; }
    return -1;
}

function getWindowHeight() {
    if (isMinNS4) { return window.innerHeight; }
    else if (isMinIE4 || isNS6) { return document.body.clientHeight; }
    return -1;
}

/*  Image utilities */
function getImage(name) {
    if (isMinNS4) { return findImage(name, document); }
    else if (isMinIE4) { return eval('document.all.' + name); }
    else if (isNS6) { return document.getElementById(name); }
    return null;
}

function findImage(name, doc) {
    var i, img;
    for (i = 0; i < doc.images.length; i++) {
        if (doc.images[i].name == name) { return doc.images[i]; }
    }
    for (i = 0; i < doc.layers.length; i++) {
        if ((img = findImage(name, doc.layers[i].document)) != null) {
            img.container = doc.layers[i];
            return img;
        }
    }
    return null;
}

function getImagePageLeft(img) {
    var x, obj;
    if (isMinNS4) {
        if (img.container != null) { return img.container.pageX + img.x; }
        else { return img.x; }
    } else if (isMinIE4 || isNS6) {
        x = 0;
        obj = img;
        if (obj != null) {
            do {
                x += obj.offsetLeft;
                obj = obj.offsetParent;
            } while (obj != null);
        }
        return x;
    }
    return -1;
}

function getImagePageTop(img) {
    var y, obj;
    if (isMinNS4) {
        if (img.container != null) { return img.container.pageY + img.y; }
        else { return img.y; }
    } else if (isMinIE4 || isNS6) {
        y = 0;
        obj = img;
        if (obj != null) {
            do {
                y += obj.offsetTop;
                obj = obj.offsetParent;
            } while (obj != null);
        }
        return y;
    }
    return -1;
}

// Used by the DropDownList in Expert Solution Providers channel block
function providerSelect(obj) {
    //	Change URL when the user selects a new country from drop down.
    var strWhereToNext, i;
    strWhereToNext = 'select';
    for (i = 0; i < obj.length; i++)
        if (obj.options[i].selected == true) strWhereToNext = obj.options[i].value;
    if (strWhereToNext != 'select') window.location = strWhereToNext;
}

// display external link message
function extLink(link) {
    window.open(link);
}

function isNumberPeriodKey(evt) {
    var charCode = (evt.which) ? evt.which : event.keyCode
    if (charCode != 46 && charCode > 31 && (charCode < 48 || charCode > 57))
        return false;

    return true; 


}
function isNumberKey(evt) {
    var charCode = (evt.which) ? evt.which : event.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57))
        return false;

    return true;
}
 
