// disables tab flickering in IE6
// http://davidwalsh.name/preventing-the-ie6-css-background-flicker
try { document.execCommand('BackgroundImageCache', false, true); } catch(e) {}

// makes subnavs work in IE6
startList = function() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("category");
		if (navRoot != null && navRoot.childNodes != null) {
			for (i=0; i<navRoot.childNodes.length; i++) {
				node = navRoot.childNodes[i];
				if (node.nodeName=="LI") {
					node.onmouseover=function() {
						this.className+=" over";
					}
					node.onmouseout=function() {
						this.className=this.className.replace(" over", "");
					}
				}
			}
		}
	}
}
window.onload=startList;

var initialValue;

function HandleClientLoaded(sender, eventArgs)
{
    initialValue = sender.get_minimumValue();
    HandleClientValueChange(sender, null);
}

function HandleClientValueChange(sender, eventArgs)
{
    var wrapperDiv = document.getElementById('boxes_wrapper');
    var contentDiv = document.getElementById('boxes_content');
    
    var oldValue = (eventArgs) ? eventArgs.get_oldValue() : sender.get_minimumValue();
    var change = sender.get_value() - oldValue; 
    
    var contentDivWidth = contentDiv.scrollWidth - wrapperDiv.offsetWidth; 
    var calculatedChangeStep = contentDivWidth / ((sender.get_maximumValue() - sender.get_minimumValue()) / sender.get_slideStep());
    
    initialValue = initialValue - change * calculatedChangeStep;
    
    if (sender.get_value() == sender.get_minimumValue())
    {
        contentDiv.style.left = 0 + 'px';
        initialValue = sender.get_minimumValue();
    }
    else
    {
        contentDiv.style.left = initialValue + 'px';
    }

}

//Search Functionality   
function clearSearchField() {
	box = document.getElementById("ctl00_SearchCriteria");
	if (box != null) box.value = "";
}

function SearchCriteriaButton_onclick() {

    var sc = "";
    var sc1 = document.getElementById("ctl00_SearchCriteria");
    //window.alert(sc1.value);
    //window.alert(sc2.value);
        //window.alert("sc1:" + sc1 + sc1.value.length);
        //window.alert("sc2:" + sc2 + sc2.value.length);
        if (sc1 != null && sc1 != "" && sc1.value.length != null && sc1.value.length > 0) sc = sc1.value;
        //if (sc2 != null && sc2 != "" && sc2.value.length != null && sc2.value.length > 0) sc = sc2.value;
        //window.alert("sc1:" + sc1 + sc1.value.length + sc);

//<--% Session["SearchCriteria"] = SearchCriteria%>

	// checks for IE 5 or higher
	if (navigator.userAgent.indexOf("MSIE") == -1){
		// Non-IE browser, navigate to a different page
		//window.alert("Non-IE:search.aspx?SearchCriteria=" + sc);
		window.location.href = "search.aspx"; //?SearchCriteria=" + sc;
	} else {
		//window.alert("IE:search.aspx?SearchCriteria=" + sc);
		window.navigate("search.aspx"); //?SearchCriteria=" + sc);
	}  
}