// JavaScript Document

function replaceOriginalValue(theDefaultText, theSearchBoxName) {
	if (document.getElementById(theSearchBoxName).value == theDefaultText) {
		document.getElementById(theSearchBoxName).value = "";
	}
}
function switchBackgroundOn(theImageSlideID) {
	document.getElementById(theImageSlideID).style.backgroundImage = "url('/images/interface/imageSlide2.gif')";
}
function switchBackgroundOff(theImageSlideID) {
	document.getElementById(theImageSlideID).style.backgroundImage = "url('/images/interface/imageSlide1.gif')";
}
<!-- Copyright 2006 Bontrager Connection, LLC
var cX = 0; var cY = 0;
function UpdateCursorPosition(e){ cX = e.pageX; cY = e.pageY;}
function UpdateCursorPositionDocAll(e){ cX = event.clientX; cY = event.clientY;}
if(document.all) { document.onmousemove = UpdateCursorPositionDocAll; }
else { document.onmousemove = UpdateCursorPosition; }
function AssignPosition(d) {
	var winW = document.body.clientWidth || window.innerWidth;
	var winH = document.documentElement.clientHeight;
	
	if (parseInt(cX+400) >= winW){
		d.style.left = (cX-300) + "px";
	} else {
		d.style.left = (cX+10) + "px";
	}
	
	if (parseInt(cY+346) >= winH){
		d.style.top = (cY-346) + "px";
	} else {
		d.style.top = (cY+10) + "px";
	}
	//d.style.top = (cY+10) + "px";

}
function HideContent(d) {
	if(d.length < 1) { return; }
	document.getElementById(d).style.display = "none";
}
function ShowContent(d, theID, theTitle, theBrand, theSKUs) {
	if(d.length < 1) { return; }
	var dd = document.getElementById(d);
	AssignPosition(dd);
    dd.style.opacity = 0;
    dd.style.MozOpacity = 0;
    dd.style.KhtmlOpacity = 0;
    dd.style.filter = "alpha(opacity=" + 0 + ")";
	dd.style.display = "";
	changeContent(theID, theTitle, theBrand, theSKUs);
}
function ReverseContentDisplay(d) {
if(d.length < 1) { return; }
var dd = document.getElementById(d);
AssignPosition(dd);
if(dd.style.display == "none") { dd.style.display = ""; }
else { dd.style.display = "none"; }
}

function changeContent(theContent, theTitle, theBrand, theSKUs) {
	document.getElementById("assetPreviewBox").innerHTML = '<img class="brand" src="/images/brands/' + theBrand + 'Big.gif" /><img src="/images/dynamic/assetPreviewSearchResultsBig.aspx?id=' + theContent + '" class="bigPreview" /><h3>' + theTitle + '</h3><p>' + theSKUs + '</p>';
	opacity('assetPreviewBox', 0, 100, 450)
}

function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
} 
function checkTermsBoxSelected(theTermsBoxID, theAlert) {
	//alert(document.getElementById(theTermsBoxID).checked);
	if (!document.getElementById(theTermsBoxID).checked) {
		alert(theAlert);
		document.downloadReturnValue = false;
		return false;
	} else {
		document.downloadReturnValue = true;
		return true; 
	}
}
function changeGraphic(theImageButtonID, theGraphicPath) {
	document.getElementById(theImageButtonID).src = theGraphicPath
}
function updateSelectedImages(theID, theButtonText, theHiddenFormValueID, theButtonID) {
	var theCurrentTotal = parseInt(document.getElementById(theHiddenFormValueID).value);
	//alert('total: ' + eval(document.getElementById(theHiddenFormValueID).value));
	if (document.getElementById(theID).checked == true) {
		theCurrentTotal +=1;
	} else {
		theCurrentTotal -=1;
	}
	document.getElementById(theHiddenFormValueID).value = theCurrentTotal;
	if (theCurrentTotal == 0) {
		document.getElementById(theButtonID).disabled=true;
		document.getElementById(theButtonID).value = theButtonText;
		document.getElementById(theButtonID).className ='addToBasketOff';
	} else {
		document.getElementById(theButtonID).disabled=false;
		document.getElementById(theButtonID).value = theButtonText + " (" + theCurrentTotal + ")";
		document.getElementById(theButtonID).className ='addToBasketOn';
	}

}
function workOutHeight(theHeightTextBox, theWidthTextBox, theMaxHeight, theMaxWidth, theUnitPullDown, thePixelHeight, thePixelWidth, theDPIPullDown)
{
	if ( isNaN(document.getElementById(theWidthTextBox).value) || (document.getElementById(theWidthTextBox).value <= 0) || (document.getElementById(theWidthTextBox).value > theMaxWidth)) { 
		document.getElementById(theWidthTextBox).value = theMaxWidth;
		document.getElementById(theHeightTextBox).value = theMaxHeight;
	} else {
		theHeight = (document.getElementById(theWidthTextBox).value * theMaxHeight) / theMaxWidth;
		if (document.getElementById(theUnitPullDown).value.toString() == "0") {
			document.getElementById(theHeightTextBox).value = parseInt(theHeight);
		} else {
			document.getElementById(theHeightTextBox).value = Math.round(theHeight*100)/100;
		} 
		writePixelSizes(theHeightTextBox, theWidthTextBox, theMaxHeight, theMaxWidth, theUnitPullDown, thePixelHeight, thePixelWidth, theDPIPullDown)
	}
}
function workOutWidth(theHeightTextBox, theWidthTextBox, theMaxHeight, theMaxWidth, theUnitPullDown, thePixelHeight, thePixelWidth, theDPIPullDown)
{
	if ( isNaN(document.getElementById(theHeightTextBox).value) || (document.getElementById(theHeightTextBox).value <= 0) || (document.getElementById(theHeightTextBox).value > theMaxHeight)) { 
		document.getElementById(theWidthTextBox).value = theMaxWidth;
		document.getElementById(theHeightTextBox).value = theMaxHeight;
	} else {
		theWidth = (document.getElementById(theHeightTextBox).value * theMaxWidth) / theMaxHeight;
		//theHeight = (document.getElementById(theWidthTextBox).value * theMaxHeight) / theMaxWidth;
		if (document.getElementById(theUnitPullDown).value.toString() == "0") {
			document.getElementById(theWidthTextBox).value = parseInt(theWidth);
		} else {
			document.getElementById(theWidthTextBox).value = Math.round(theWidth*100)/100;
		} 
		writePixelSizes(theHeightTextBox, theWidthTextBox, theMaxHeight, theMaxWidth, theUnitPullDown, thePixelHeight, thePixelWidth, theDPIPullDown)
	}
}

function writePixelSizes(theHeightTextBox, theWidthTextBox, theMaxHeight, theMaxWidth, theUnitPullDown, thePixelHeight, thePixelWidth, theDPIPullDown)
{
	document.getElementById(thePixelWidth).value = workOutPixelSize(document.getElementById(theWidthTextBox).value, document.getElementById(theUnitPullDown).value, theDPIPullDown);
	document.getElementById(thePixelHeight).value = workOutPixelSize(document.getElementById(theHeightTextBox).value, document.getElementById(theUnitPullDown).value, theDPIPullDown);
	
	if (document.getElementById(thePixelHeight).value > theMaxHeight || document.getElementById(thePixelWidth).value > theMaxWidth) {
		document.getElementById(theWidthTextBox).value = theMaxWidth;
		document.getElementById(theHeightTextBox).value = theMaxHeight;
		if (document.getElementById(theUnitPullDown).value.toString() == "0") {
			document.getElementById(thePixelWidth).value = theMaxWidth;
			document.getElementById(thePixelHeight).value = theMaxHeight;
		} else {
			theNumber = (theMaxWidth/document.getElementById(theDPIPullDown).value)*document.getElementById(theUnitPullDown).value;
			theNumber = Math.round(theNumber*100)/100;
			document.getElementById(theWidthTextBox).value = theNumber;
			theNumber = (theMaxHeight/document.getElementById(theDPIPullDown).value)*document.getElementById(theUnitPullDown).value;
			theNumber = Math.round(theNumber*100)/100;
			document.getElementById(theHeightTextBox).value = theNumber;
		} 

	}
}
function workOutPixelSize(theSize, theUnitValue, theDPIPullDown)
{
	switch(theUnitValue)
	{
	case "0":
	  return theSize;
	  break    
	default:
		theNumber = (theSize / theUnitValue)*document.getElementById(theDPIPullDown).value;
		return parseInt(theNumber);
	}
}
function changeUnits(unitPullDown, theWidthUnitText, theHeightUnitText, thePixelHeight, thePixelWidth, theDPIID, theHeightTextBox, theWidthTextBox) {
	var theIndex = document.getElementById(unitPullDown).selectedIndex;	
	document.getElementById(theWidthUnitText).innerHTML = document.getElementById(unitPullDown).options[theIndex].text;
	document.getElementById(theHeightUnitText).innerHTML = document.getElementById(theWidthUnitText).innerHTML;
	changeDPIValue(unitPullDown, theDPIID, theHeightTextBox, theWidthTextBox, thePixelHeight, thePixelWidth);
}
function changeDPIValue(theUnitID, theDPIID, theHeightTextBox, theWidthTextBox, thePixelHeight, thePixelWidth)
{
	if (document.getElementById(theUnitID).value.toString() != "0") {
		theNumber = (document.getElementById(thePixelWidth).value/document.getElementById(theDPIID).value)*document.getElementById(theUnitID).value;
		theNumber = Math.round(theNumber*100)/100;
		document.getElementById(theWidthTextBox).value = theNumber;
		theHeight = (document.getElementById(thePixelHeight).value/document.getElementById(theDPIID).value)*document.getElementById("units").value;
		theHeight = Math.round(theHeight*100)/100;
		document.getElementById(theHeightTextBox).value = theHeight;
	} else {
		document.getElementById(theHeightTextBox).value = document.getElementById(thePixelHeight).value;
		document.getElementById(theWidthTextBox).value = document.getElementById(thePixelWidth).value;
	}
}
function ShowContentLogo(d, theID, theTitle) {
	if(d.length < 1) { return; }
	var dd = document.getElementById(d);
	AssignPosition(dd);
    dd.style.opacity = 0;
    dd.style.MozOpacity = 0;
    dd.style.KhtmlOpacity = 0;
    dd.style.filter = "alpha(opacity=" + 0 + ")";
	dd.style.display = "";
	changeContentLogo(theID, theTitle);
}
function changeContentLogo(theContent, theTitle) {
	document.getElementById("assetPreviewBox").innerHTML = '<img class="brand" src="/images/invisible.gif" /><img src="/images/logoPreviews/2/2_' + theContent + '.jpg" class="bigPreview" /><h3>' + theTitle + '</h3>';
	opacity('assetPreviewBox', 0, 100, 450)
}
function openHelpWindow(page) {
	OpenWin = this.open(page, "HelpWindow", "width=450,height=350,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=no");
}