/**
 * Get cookie values, then check for country and language
 **/
function GetCookie(name) {
    var value = "";
    if ((begin = document.cookie.indexOf(name + "=")) >= 0) {
        if ((end = document.cookie.indexOf(";",begin)) >= 0) {
            value = document.cookie.substring(begin + name.length + 1,end);
        } else {
            value = document.cookie.substr(begin + name.length + 1);
            }
        }
    return(unescape(value));
}

// 20060815 bpeterson	Altered logic to work in dev
// 20061017 ekristoff  Alter href to include current URL as a parameter (fix IE bug)
if ((GetCookie("country")=="" || GetCookie("country")=="null" || GetCookie("lang")=="" || GetCookie("lang")=="null") && location.host.match(/.*ptc\.com(:\d*)?$/)) {
	window.location.href = "/appserver/common/locale/options.jsp?&referer=" + escape(document.location);
}

/**
 * Global navigation drop down code
 **/
sfHover = function() {
	var sfEls = document.getElementById("globalNav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

s1Hover = function() {
        var menuels = document.getElementById("s1select");
		if (menuels) {
			menuels = document.getElementById("s1select").getElementsByTagName("LI");
		
        for (var i=0; i<menuels.length; i++) {
                menuels[i].onmouseover=function() {
                        this.className+=" s1hover";
                }
                menuels[i].onmouseout=function() {
                        this.className=this.className.replace(new RegExp(" s1hover\\b"), "");
                }
        	}
		}
}
if (window.attachEvent) window.attachEvent("onload", s1Hover);

/**
 * Alternate style sheet swap code
 **/
function setActiveStyleSheet(title) {
   var i, a, main;
   for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
     if(a.getAttribute("rel").indexOf("style") != -1
        && a.getAttribute("title")) {
       a.disabled = true;
       if(a.getAttribute("title") == title) a.disabled = false;
     }
   }
}

/**
 * Image functions for swapping, preloading, etc
 **/
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_openBrWindow(theURL,winName,features) { //v2.0
    var newWindow = window.open(theURL,winName,features);
    newWindow.focus();
}

function GoUrl(s)
{	var d = s.options[s.selectedIndex].value;
	window.top.location.href = d;
	s.selectedIndex = 0;
}

// 20050920 ekristoff  Make sure people don't double-click submits.
// Scopus Case #861801
var submitLocked = false;
function canSubmitForm () { 
	if ( submitLocked ) {  
		return false; 
	} else {
		submitLocked = true;  
		return true;
	}
}

/**
 * Clear search text input on focus
 **/
function clearInput(obj, theText) {
	if (obj.value == "") 
		{obj.value = theText;}
	else
		{obj.value = "";}
}
