function objectById(id)
{ 
	if (document.getElementById) return document.getElementById(id); 
	else if (document.all) return document.all[id]; 
	else if (document.layers) return document.layers[id]; 
}
function fixPng()
{
    var a=navigator.appVersion.split("MSIE"),v=parseFloat(a[1]);
    if ((v>=5.5)&&(v<7.0)&&(document.body.filters)){
    for(var c=0;c<document.images.length;c++){
    var i=document.images[c],imgName=i.src.toUpperCase();
    if (imgName.substring(imgName.length-3,imgName.length)=="PNG"){
    var iI=(i.id)?"id='"+i.id+"' ":"",iC=(i.className)?"class='"+i.className+"' ":"",iT=(i.title)?"title='"+i.title+"' ":"title='"+i.alt+"' ",iS="display:inline-block;"+i.style.cssText;
    if (i.align=="left")iS="float:left;"+iS;if (i.align=="right")iS ="float:right;"+iS;if (i.parentElement.href)iS="cursor:hand;"+iS;
    i.outerHTML = "<span "+iI+iC+iT+" style=\"width:"+i.width+"px;height:"+i.height+"px;"+iS+";filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'"+i.src+"\',sizingMethod='scale');\"></span>";
    c=c-1;}}}
}
function cursorHand(a) { a.style.cursor='pointer'; }
function cursorAuto(a) { a.style.cursor='auto'; }





var v;
function radSlideLoad(a,b){v=a.get_minimumValue();radSlideChange(a,null);}
function radSlideChange(a, b){var c=document.getElementById('radSlide'),d=document.getElementById('radSlideContent'),e=(b)?b.get_oldValue():a.get_minimumValue(),f=a.get_value()-e,g=d.scrollWidth-c.offsetWidth,h=g/((a.get_maximumValue()-a.get_minimumValue())/a.get_slideStep());v=v-f*h;if(a.get_value()==a.get_minimumValue()){d.style.left=0+'px';v=a.get_minimumValue();}else{d.style.left=v+'px';}}

// common variables
var popUpWin = false;

// close any existing popup windows
function closePopups()
{
	if (popUpWin) popUpWin.close();
}

function popUpPage(url)
{
	if (popUpWin.open) popUpWin.close();
	
	popUpWin = window.open(url, "popupwin", "width=650,height=500,scrollbars=1,toolbar=1")
}

// generic popup image function - opens a set width and height and displays the image as passed in through imagePath at the full width and height specified
function popUpImage(imagePath, width, height, windowTitle, scroll)
{
	windowTitle = windowTitle || "";
	closePopups();
	popUpWin = window.open("", "popupwin", "width=" + width + ",height=" + height + ",left=" +( (screen.width / 2) - (width / 2)) + ",top=" + ((screen.height / 2) - (height / 2)) + ",scrollbars=" + ((scroll) ? 1 : 0));
	popUpWin.document.open();
	popUpWin.document.write("<html><head><title>" + windowTitle + "</title></head><body bottommargin=0 topmargin=0 leftmargin=0 rightmargin=0 marginwidth=0 marginheight=0><table border=0 cellspacing=0 cellpadding=0 width=100% height=100%><tr><td align=center valign=middle><img src='" + imagePath + "' alt='" + windowTitle + "'></td></tr></table></body></html>");
	popUpWin.document.close();
}



function quickSearchCatchEnter(e)
{
	var keyCode;
	if (window.event) keyCode = window.event.keyCode;
	else if (e) keyCode = e.which;
	
	if (keyCode == 13)
	{
		quickSearchGo();
		return false;
	}
	else return true;
}

function quickSearchGo()
{
	var url = FolderRoot + "search-results";
	if ((document.forms[0].txtSearch.value != "") && (document.forms[0].txtSearch.value != "Enter Search Text")) url += "&Text=" + document.forms[0].txtSearch.value.replace(/[\<\%\&\@\#\=\+\>]*/g, "").replace(/\s+/g, " ").replace(/^\s+/, "").replace(/\s+$/, "");
	location.href = url;
}

function advSearchCatchEnter(e)
{
	var keyCode;
	if (window.event) keyCode = window.event.keyCode;
	else if (e) keyCode = e.which;
	
	if (keyCode == 13)
	{
		advSearchGo(ddlAdvSearchManu, ddlAdvSearchCat);
		return false;
	}
	else return true;
}

function Controls(obj) {
    alert(obj[obj.selectedIndex].value);
}

function advSearchGo(objManu,objCat)
{
	var u = FolderRoot + "product-list&AdvSearch=true";
	var o, i;
	
	o = objectById(objManu);
	i = o[o.selectedIndex].value;
	if (i > 0) u += "&Manufacturer=" + i;
	
	o = objectById(objCat);
	i = o[o.selectedIndex].value;
	if (i > 0) u += "&Category=" + i;
	
	if ((document.forms[0].txtAdvSearch.value != "") && (document.forms[0].txtAdvSearch.value != "Enter Search Text")) u += "&Text=" + document.forms[0].txtAdvSearch.value.replace(/[\<\%\&\@\#\=\+\>]*/g, "").replace(/\s+/g, " ").replace(/^\s+/, "").replace(/\s+$/, "");
	
	location.href = u;
}

// cross browser function to find an element by id
function objectById(id)
{ 
	if (document.getElementById) return document.getElementById(id); 
	else if (document.all) return document.all[id]; 
	else if (document.layers) return document.layers[id]; 
} 

// textbox focus and blur events (change active css)
function focusTxt(obj) { obj.className = obj.className + " Selected"; }
function blurTxt(obj) { obj.className = obj.className.replace(" Selected", ""); }

function showCV2Help()
{
	if (objectById('checkoutCV2Help').style.display == "none") objectById('checkoutCV2Help').style.display = "";
	else objectById('checkoutCV2Help').style.display = "none";
}

// change manufacturer selection in product search
function changeManufacturer(sender)
{
	// determine url without the current attribute filter, and append the new value if one is selected
	eval("var url = baseUrl.replace(/&Manufacturer=[0-9]+/, \"\")");
	if (sender.selectedIndex > 0) url += "&Manufacturer=" + sender.options[sender.selectedIndex].value;
	location.href = url;
}

// change attribute selection in product search
function changeAttributeFilter(sender, keyName)
{
	// determine url without the current attribute filter, and append the new value if one is selected
	eval("var url = baseUrl.replace(/&P." + keyName + "=[0-9]+/, \"\")");
	if (sender.selectedIndex > 0) url += "&P." + keyName + "=" + sender.options[sender.selectedIndex].value;
	location.href = url;
}

function changeRPP(sender, defaultRPP)
{
	// determine url without the RPP selection
	eval("var url = baseUrl.replace(/&RPP=[0-9]+/, \"\")");
	if (sender.options[sender.selectedIndex].value != defaultRPP) url += "&RPP=" + sender.selectedIndex;
	location.href = url;
}

function changeSortBy(sender, defaultSort)
{
	// determine url without the sort by selection
	eval("var url = baseUrl.replace(/&Sort=[0-9]+/, \"\")");
	if (sender.options[sender.selectedIndex].value != defaultSort) url += "&Sort=" + sender.selectedIndex;
	location.href = url;
}
function bookmark()
{
    var a=location.href,b=document.title;
    if (window.sidebar)window.sidebar.addPanel(b,a,"");
    else if(window.opera && window.print){var c=document.createElement('a');c.setAttribute('href',a);c.setAttribute('title',b);c.setAttribute('rel','sidebar');c.click();}
    else if(document.all)window.external.AddFavorite(a,b);
}
