/* GENERIC */

function displayTitle(theid,displaytext) {
theid.Otitle = theid.title;
theid.OinnerHTML = theid.innerHTML;
if (theid.title) {
if (displaytext == 1) {
displaytext = '<strong>' + theid.innerHTML + '</strong><br>';
} else {
displaytext = "";
}
theid.innerHTML = theid.innerHTML + '<div class="titletext-display"><div>' + displaytext + theid.title + '</div></div>';
theid.suppresedtitle = theid.title;
}
theid.title = "";
}
function hideTitle(theid) {
theid.title = theid.Otitle;
theid.innerHTML = theid.OinnerHTML;
}

function moveBtnOn(imgSrc,imgName,t) {
imgSrc = "/images/buttons/" + imgSrc + "_on.gif";
if (t) {
imgName.src=imgSrc;
} else {
document[imgName].src=imgSrc;
}
}

function moveBtnOff(imgSrc,imgName,t) {
imgSrc = "/images/buttons/" + imgSrc + ".gif";
if (t) {
imgName.src=imgSrc;
} else {
document[imgName].src=imgSrc;
}
}
function smallWinLink(url,width,height) {
win=window.open(url,"smallwin","width=" + width + ",height=" + height + ",scrollbars,resizable,left=10,top=10");
}

function displayItem(theid) {
if (document.getElementById(theid) != null) {
var theidn = document.getElementById(theid);
theidn.style.display = "";
}
}
function hideItem(theid) {
if (document.getElementById(theid) != null) {
var theidn = document.getElementById(theid);
theidn.style.display = "none";
}
}
function changeClass(theitem,theclass) {
if (document.getElementById(theitem) != null) {
var theid = document.getElementById(theitem);
theid.className = theclass;
}
}

function updateFieldText(theitem,thetext) {
if (document.getElementById(theitem) != null) {
var theid = document.getElementById(theitem);
theid.innerHTML = thetext;
}
}

function updateFieldWithSource(theitem,thesource) {
if (document.getElementById(theitem) != null) {
if (document.getElementById(thesource) != null) {
var theid = document.getElementById(theitem);
theid.innerHTML = document.getElementById(thesource).innerHTML;
}
}
}

function updateFieldValue(theitem,thetext) {
if (document.getElementById(theitem) != null) {
var theid = document.getElementById(theitem);
theid.value = thetext;
}
}
function updateCheckbox(theitem,theaction) {
if (document.getElementById(theitem) != null) {
var theid = document.getElementById(theitem);
if (theaction) {
theid.checked = true;
} else {
theid.checked = false;
}
}
}

function getObj() {
var thingy = arguments[0];
if ( typeof thingy == 'object' ) {
return thingy;
} else if ( typeof thingy == 'string' ) {
return document.getElementById(thingy);
}
}

function toggleDisplay() {
var toggleDiv = getObj(arguments[0]);
with (toggleDiv.style) { display = (display=='none'||display==''?'block':'none'); }
}

function showDisplay() {
var showDiv = getObj(arguments[0]);
with (showDiv.style) { display = 'block'; }
}

function hideDisplay() {
var hideDiv = getObj(arguments[0]);
with (hideDiv.style) { display = 'none'; }
}

function toggleVisibility() {
var toggleDiv = getObj(arguments[0]);
with (toggleDiv.style) { visibility = (visibility=='hidden'?'visible':'hidden'); }
}

function showVisibility() {
var showDiv = getObj(arguments[0]);
with (showDiv.style) { visibility = 'visible'; }
}

function hideVisibility() {
var hideDiv = getObj(arguments[0]);
with (hideDiv.style) { visibility = 'hidden'; }
}


/* DESIGN FUNCS */

function adjustHeights() {
var topad = document.getElementById("topad");
var topadtoolarge = document.getElementById("topad-toolarge");
if (topad.clientWidth > 480) {
topadtoolarge.innerHTML = topad.innerHTML;
topad.innerHTML = "";
}
if(document.getElementById("evt-header") != null){
var header = document.getElementById("evt-header");
var superh = document.getElementById("mn-superh");
var reserve = document.getElementById("mn-superh-reserve");
var icon = document.getElementById("hzone-membership");
var leftad = document.getElementById("leftads");
reserve.style.height = (header.offsetHeight-13) + "px";
	if(header.offsetHeight >= 157){
	leftad.style.paddingTop = (header.offsetHeight-152) + "px";
	} else {
	superh.style.height = (header.offsetHeight) + "px";
	leftad.style.paddingTop = (header.offsetHeight+5) + "px";
	icon.style.display = "none";	
	}
}
}

function wrapOnload () {
adjustHeights();
}

function searchBoxHandler(theitem) {
if (theitem.value == "Enter Keyword or Number" || theitem.value == "Enter a Search Term" || theitem.value == "YYYY") {
theitem.value = "";
}
}

function inputFieldSuggestClear(theid) {
if (theid.value == theid.title) {
theid.value = "";
}
}

function pnTabs(theon) {
changeClass('pn-content',''); 
for (i = 1; i < 10; i++) {
changeClass('pntab' + i,''); 
}
changeClass('pntab' + theon,'navon'); 
changeClass('pn-content','pn-on-tab' + theon); 
}


function hpTabs(theon) {
changeClass('pn-content',''); 
changeClass('hp-tabs','hp-tabs hptab'+theon); 
changeClass('pn-content','pn-on-tab' + theon); 
}


function manageInlineTabDisplay(theon) {
for (var i = 1; i < 8; i++) {
changeClass('tabDisplay' + i,'');
hideItem('tabDisplayContent' + i);
}
changeClass('tabDisplay' + theon,'tabon');
displayItem('tabDisplayContent' + theon);
}


function manageDPanelTabs(theon) {
for (var i = 1; i < 8; i++) {
changeClass('dpanel-tab' + i,'');
hideItem('dpanel-content' + i);
}
changeClass('dpanel-tab' + theon,'tabon');
displayItem('dpanel-content' + theon);
}


function manageRFilter(thegroup,theon,theaction) {
changeClass("sbrw-update-btn1","sbrw-update");
changeClass("sbrw-update-btn2","sbrw-update");
if (theaction == 2) {
for (var i = 1; i < 20; i++) {
changeClass("sbrwc-" + thegroup + i,"sbrwc-off");
updateCheckbox("sbrwc-check-" + thegroup + i, 0);
}
changeClass("sbrwc-" + theon,"sbrwc-on");
updateCheckbox("sbrwc-check-" + theon, 1);
} else if (theaction == 1) {
changeClass("sbrwc-" + theon,"sbrwc-on");
updateCheckbox("sbrwc-check-" + theon, 1);
} else {
changeClass("sbrwc-" + theon,"sbrwc-off");
updateCheckbox("sbrwc-check-" + theon, 0);
}
}

/* */
function performColl(theitem) {
if (document.getElementById("plig-" + theitem).className == "clpse-expanded") {
changeClass('plig-' + theitem,'clpse-collapsed')
displayItem(theitem + "-viewmore");
} else {
changeClass('plig-' + theitem,'clpse-expanded')
hideItem(theitem + "-viewmore");
}
}



/* */
function doOverlay(thewidth,theleft,thetitle) {
if (thewidth) {} else {thewidth = 650;}document.getElementById("overlay").style.width = thewidth + "px";
if (theleft) {} else {theleft = 180;}document.getElementById("overlay").style.left = theleft + "px";
document.getElementById("overlay-heading").innerHTML = thetitle;
displayItem("overlay");
document.getElementById("overlay").scrollIntoView(true);
if (document.getElementById("ftzone") != null) {document.getElementById("ftzone").style.marginTop = "400px"}
}
function doIframe(theheight,thepath) {
document.getElementById("overlay-content").innerHTML = '<div style="width:100%;"><iframe src="' + thepath + '" frameborder="0" id="overlay-iframe" name="overlayiframe" scrolling="no" style="height:' + theheight + 'px; width:100%;"></iframe></div>';
}

function doIframeSetHeight(theheight) {
document.getElementById("overlay-iframe").style.height = theheight + "px";
}

function clearOverlay() {
hideItem("overlay");
document.getElementById("overlay-heading").innerHTML = "";document.getElementById("overlay-content").innerHTML = "";
if (document.getElementById("ftzone") != null) {document.getElementById("ftzone").style.marginTop = "0px"}
}

function addToCartOvelay(theurl) {
doOverlay(0,0,"Added to Shopping Cart");
getThePart("overlay-content",theurl);
}

function postToIframe(thename,theheight) {
doIframe(theheight,"/images/pixel.gif");
document.forms[thename].submit();
}





/* */
function spltNav(theaction,thepanel) {
var theid = document.getElementById("splt-items" + thepanel);
window.clearTimeout(document.spltMove);
var maxPanel = document.spltPanelCount[thepanel] - 1;
if (theaction == 'next') {
document.spltCurrentItem[thepanel] = document.spltCurrentItem[thepanel] + 1;
if (document.spltCurrentItem[thepanel] > (document.spltPanelCount[thepanel] - 2)) {document.spltCurrentItem[thepanel] = document.spltPanelCount[thepanel] - 1;}
document.spltMoveTill[thepanel] = (document.spltPanelWidth[thepanel] * document.spltCurrentItem[thepanel]) * -1;
spltNavNext(thepanel);
} else if (theaction == 'back') {
document.spltCurrentItem[thepanel] = document.spltCurrentItem[thepanel] - 1;
if (document.spltCurrentItem[thepanel] < 0) {document.spltCurrentItem[thepanel] = 0;}
document.spltMoveTill[thepanel] = (document.spltPanelWidth[thepanel] * document.spltCurrentItem[thepanel]) * -1;
spltNavBack(thepanel);
}
if (document.spltCurrentItem[thepanel] == 0) {
if (thepanel == 1) {hideItem("splt-back");} else if (thepanel < 100) {changeClass("splt-back" + thepanel,"splt-nav splt-back splt-dimmed");} else {changeClass("splt-back" + thepanel,"sub-i-nav-backdim");}
} else {

if (thepanel == 1) {displayItem("splt-back");} else if (thepanel < 100) {changeClass("splt-back" + thepanel,"splt-nav splt-back");} else {changeClass("splt-back" + thepanel,"sub-i-nav-back");}
}
if (document.spltCurrentItem[thepanel] < maxPanel) {

if (thepanel == 1) {displayItem("splt-next");} else if (thepanel < 100) {changeClass("splt-next" + thepanel,"splt-nav splt-next");} else {changeClass("splt-next" + thepanel,"sub-i-nav-next");}
} else {

if (thepanel == 1) {hideItem("splt-next");} else if (thepanel < 100) {changeClass("splt-next" + thepanel,"splt-nav splt-next splt-dimmed");} else {changeClass("splt-next" + thepanel,"sub-i-nav-nextdim");}
}
}
function spltNavBack(thepanel) {
var theid = document.getElementById("splt-items" + thepanel);
if (parseInt(theid.style.left) >= document.spltMoveTill[thepanel]) {
window.clearTimeout(document.spltMove);
document.spltMoveTill[thepanel] = 0;
} else {
theid.style.left = parseInt(theid.style.left) + document.spltMoveLeft[thepanel] + "px";
document.spltMove = window.setTimeout('spltNavBack(' + thepanel + ')', 1);
}
}
function spltNavNext(thepanel) {
var theid = document.getElementById("splt-items" + thepanel);
if (parseInt(theid.style.left) <= document.spltMoveTill[thepanel]) {
window.clearTimeout(document.spltMove);
document.spltMoveTill[thepanel] = 0;
} else {
theid.style.left = parseInt(theid.style.left) - document.spltMoveLeft[thepanel] + "px";
document.spltMove = window.setTimeout('spltNavNext(' + thepanel + ')', 1);
}
}

var spltPanelCount = Array();
var spltPanelWidth = Array();
var spltCurrentItem = Array();
var spltMoveLeft = Array();
var spltMoveTill = Array();
spltPanelCount[1] = 5;
spltPanelWidth[1] = 238;
spltCurrentItem[1] = 0;
spltMoveLeft[1] = 17;
spltMoveTill[1] = 0;
spltPanelCount[2] = 5;
spltPanelWidth[2] = 950;
spltCurrentItem[2] = 0;
spltMoveLeft[2] = 95;
spltMoveTill[2] = 0;
document.spltPanelCount = spltPanelCount;
document.spltPanelWidth = spltPanelWidth;
document.spltCurrentItem = spltCurrentItem;
document.spltMoveLeft = spltMoveLeft;
document.spltMoveTill = spltMoveTill;



/* */
var loadingWidget = '<div style="position:absolute; width:70%; text-align:center; z-index:800;"><div style="position:relative; margin:auto; z-index:801; width:120px; border:1px dashed #BBBBBB; background-color:#444444; color:#FFFFFF; font-weight:600; padding:5px;">Loading.<blink>.</blink>.<br>Please Wait!</div></div>';


function makeHttpObject() {
var xmlHttpObj;
/*@cc_on
@if (@_jscript_version >= 5)
try {
xmlHttpObj = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlHttpObj = new ActiveXObject("Microsoft.XMLHTTP");
 } catch (E) {
xmlHttpObj = false;
}
}
@else
xmlHttpObj = false;
@end @*/
if (!xmlHttpObj && typeof XMLHttpRequest != 'undefined') {
try {
xmlHttpObj = new XMLHttpRequest();
} catch (e) {
xmlHttpObj = false;
}
}
return xmlHttpObj;
}
var httpObj = makeHttpObject(); // create the HTTP Object

function getHttpResponse() {
if (httpObj.readyState == 4) {
if (httpObj.status == 200) {
var theHTML = httpObj.responseText;
var idname = document.thetargetid;
document.getElementById(idname).innerHTML = theHTML;
} else {
//alert("There was a problem with the response: " + httpObj.statusText);
}
}
}
document.last = "";
document.laststartat = 0;

function getThePart(thetarget,theurl) {
var tarit = document.getElementById(thetarget);
tarit.innerHTML = loadingWidget + tarit.innerHTML;


document.thetargetid = thetarget;
document.therecipid = "";
var uid = "&uid__9="+ new Date();
if(  theurl.indexOf("?") <= -1 )
    uid =  "?uid__9="+ new Date();
theurl = theurl + uid; 
httpObj.open("GET", theurl, true);
httpObj.onreadystatechange = getHttpResponse;
httpObj.send(null);
}




/* BUBBLE */
function Locate(e){
var posx=0,posy=0;
if(e==null) e=window.event;
if(e.pageX || e.pageY){
posx=e.pageX; posy=e.pageY;
} else if(e.clientX || e.clientY){
if(document.documentElement.scrollTop){
posx=e.clientX+document.documentElement.scrollLeft;
posy=e.clientY+document.documentElement.scrollTop;
} else {
posx=e.clientX+document.body.scrollLeft;
posy=e.clientY+document.body.scrollTop;
}
}
var YsafeOffset = posy - 8;
var XsafeOffset = posx - document.openHelpSize;
if (YsafeOffset < 0) {YsafeOffset = 0;}
if (XsafeOffset < 0) {XsafeOffset = 0;}
document.getElementById("helpbubble").style.top= YsafeOffset + "px";
document.getElementById("helpbubble").style.left= XsafeOffset + "px";
}

function openHelp(elm,offside) {
if (offside == 'left') {
document.openHelpSize = 250;
changeClass("helpbubble","");
} else {
document.openHelpSize = -50;
changeClass("helpbubble","helpbubble-right");
}
displayItem("helpbubble");
document.getElementById("helpbubble-title").innerHTML = elm.innerHTML;
document.getElementById("helpbubble-text").innerHTML = elm.title;
elm.onmousemove = Locate;
elm.title = "";
}

function closeHelp(elm) {
elm.title = document.getElementById("helpbubble-text").innerHTML;
hideItem("helpbubble");
}



