function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function ClearInput(value, id){
    var input = document.getElementById(id);
	if(value == input.value){
		input.value = ''; 
	}
	else{
		input.value = input.value;
	}
}
//popUp div start
var amID = "blank";
function showMe(containerId){
	if(amID != "blank"){
		hideMe(amID);
	}
	amID = containerId;
	showContainer(containerId);
}
function showContainer(containerId){
	obj = MM_findObj(containerId);
	if (!obj) return;
	obj.style.display = 'block';
}
function hideMe(containerId){
	obj2 = MM_findObj(containerId)
	if (!obj2) return;
	obj2.style.display = 'none';
}
//popUp div end

// feed in an id as '#elmentId' or a css class selector as 'div.myclass'

function show(id){
    Spry.$$(id).setStyle('display: block;');
}
function hide(id){
    Spry.$$(id).setStyle('display: none;');
}

var previousShow = null;

function showHidePrevious(id){
    if( previousShow != null ) hide(previousShow);
    if( previousShow != id ) show(id);
        previousShow = (previousShow == id ? null : id);
}

function toggleCartRemoveHover(id){
    Spry.$$(id).toggleClassName('cartRemoveHover');
}
function toggleActive(id){
    Spry.$$(id).toggleClassName('active');
}
function addActiveLeftComp(id){
    Spry.$$(id).addClassName('leftNavCompActive');
}
function removeActiveLeftComp(id){
    Spry.$$(id).removeClassName('leftNavCompActive');
}
function addActiveLeftCompBrand(id){
    Spry.$$(id).addClassName('leftNavCompActiveBrand');
}
function removeActiveLeftCompBrand(id){
    Spry.$$(id).removeClassName('leftNavCompActiveBrand');
}
function addActiveLeftNav(id){
    Spry.$$(id).addClassName('leftNavActive');
}
function removeActiveLeftNav(id){
    Spry.$$(id).addClassName('leftNavActive');
}

var previousToggle = null;

function toggleActivePrevious(id){
    if( previousToggle != null ) toggleActive(previousToggle);
    if( previousToggle != id ) toggleActive(id);
        previousToggle = (previousToggle == id ? null : id);
}
function genericByBrand(){
    removeActiveLeftComp('#leftNavCompType');
    addActiveLeftCompBrand('#leftNavCompBrand');
    addActiveLeftNav('#leftNav');
    show('#byType');
    hide('#byTypeActive');
    show('#byBrandActive');
    hide('#byBrand');
}
function genericByType(){
    removeActiveLeftCompBrand('#leftNavCompBrand');
    addActiveLeftComp('#leftNavCompType');
    removeActiveLeftNav('#leftNav');
    show('#byBrand');
    hide('#byBrandActive');
    show('#byTypeActive');
    hide('#byType');
}
function copyText(origin, destination) {
    var txt1 = MM_findObj(origin);
    var txt2 = MM_findObj(destination);

    txt2.value = txt1.value;
}
function PostBackOnReturn(event, postbackMethod){
    if(event){
        if(event.keyCode==13){
            __doPostBack(postbackMethod,'');
        }
    }
}
function popupWindow(url) {
    window.open(url, "Window1", "location=no,menubar=no,scrollbars=yes,status=yes,titlebar=no,resizable=yes,width=520,height=400,toolbar=no");
}