function $() {
	var elements = new Array();
	for (var i = 0; i < arguments.length; i++) {
		var element = arguments[i];
		if (typeof element == 'string')
			element = $(element);
		if (arguments.length == 1)
			return element;
		elements.push(element);
	}
	return elements;
}

function hide(theDiv) {
    document.getElementById(theDiv).style.visibility = "hidden";
}


function show(theDiv) {
    document.getElementById(theDiv).style.visibility = "visible";
}



function toggle(theDiv) {
    var elem = $(theDiv);
    elem.style.visibility = (elem.style.visibility == "hidden")?"":"visible";
}

function sub_on(divid){eval("this.style.backgroundColor='#999999';$('"+divid+"').style.color='#ffffff'");}


function sub_off(divid){eval("this.style.backgroundColor='transparent';$('"+divid+"').style.color='#666666'");}


function main_on(tdid, textid){eval("$('"+tdid+"').style.backgroundColor='#999999';$('"+textid+"').style.color='#ffffff'");}


function main_off(tdid, textid){eval("$('"+tdid+"').style.backgroundColor='transparent';$('"+textid+"').style.color='#666666'");}


function sub_menu_on(divid){eval("this.style.backgroundColor='#999999';$('"+divid+"').style.visibility='visible';this.style.color='#ffffff'");}


function sub_menu_off(divid){eval("this.style.backgroundColor='transparent'; $('"+divid+"').style.visibility='hidden';this.style.color='#666666'");}


function getDirections(address, state, city, zip){
	var link = 'http://www.mapquest.com/maps/map.adp?address=' + address + '&city=' + city + '&state=' + state + '&zip=' + zip + '&zoom=8'
	newWin = window.open(link, 'directions', 'height=750,width=600,top=10,left=10,scrollbars=yes,resizable=yes');
}


function changebg(id, bgcolor){
  var id;
  eval("$('+id+').style.backgroundColor='#"+bgcolor+"'");
}


function swapColor(detail, img, color){
	document.images[detail].src = img;
}


function popZoom(info) {
	var newWin;
	newWin = window.open(info,"zoom","height=446,width=396,status=no,toolbar=no,menubar=no,location=no,resizable=no,titlebar=no,scrollbars=no,fullscreen=no,top="+(screen.availHeight-500)/2+",left="+(screen.availWidth-440)/2);
	newWin.focus();
}


function allowNumbers(e){
	var key;
	var keychar;
	var re = /[\d\x08\x0D\-.]/;

	if(window.event) {
			key = e.keyCode;
	} else if(e.which) {
			key = e.which;
	} else {
			return true;
	}

	keychar = String.fromCharCode(key);
	return re.test(keychar);
}


function setFocus(tag) {
  document.getElementById(tag).focus();
}


function on(tag) { document.forms[1].elements[tag].style.background=('#fff'); }


function off(tag) { document.forms[1].elements[tag].style.background=('#eee'); }


function setForm() {
  for (var i=1; i<document.forms[1].elements.length; i++) {
    off(i);
  }
}



function submitdata(lvl){
		if (lvl == 0){
				if(document.frmsearch.Collectionid.value != "All"){
						document.frmsearch.method="Post";
						document.frmsearch.action="styleFinderResults.asp";
						document.frmsearch.submit();
				}else{
						alert("Select A Collection first");
						document.frmsearch.Collectionid.focus();
						return false;
				}
		}else{

				if (lvl == 1){
						if(document.frmsearch.typeId.value == "All" && lvl == 1){
								document.frmsearch.method="Post";
								document.frmsearch.action="styleGuide.aspx?lvl=" + 4;
								document.frmsearch.submit();
						}else if(document.frmsearch.typeId.value != "All" && lvl == 1){
								document.frmsearch.method="Post";
								document.frmsearch.action="styleGuide.aspx?lvl=" + lvl;
								document.frmsearch.submit();
						}
				}else if(lvl == 2){
						if(document.frmsearch.featureId.value == "All" && lvl == 2){
								document.frmsearch.method="Post";
								document.frmsearch.action="styleGuide.aspx?lvl=" + 1;
								document.frmsearch.submit();
						}else if(document.frmsearch.featureId.value != "All" && lvl == 2){
								document.frmsearch.method="Post";
								document.frmsearch.action="styleGuide.aspx?lvl=" + lvl;
								document.frmsearch.submit();
						}
				}else if(lvl==3){
						if(document.frmsearch.size.value == "All" && lvl == 3){

								document.frmsearch.method="Post";
								document.frmsearch.action="styleGuide.aspx?lvl=" + 2;
								document.frmsearch.submit();
						}else if(document.frmsearch.size.value != "All" && lvl == 3){
								document.frmsearch.method="Post";
								document.frmsearch.action="styleGuide.aspx?lvl=" + lvl;
								document.frmsearch.submit();
						}
				}else if(lvl==4){
						if(document.frmsearch.size.value == "All" && lvl == 3){
								document.frmsearch.method="Post";
								document.frmsearch.action="styleGuideResults.aspx?lvl=" + 2;
								document.frmsearch.submit();
						}else if(document.frmsearch.size.value != "All" && lvl == 3){
								document.frmsearch.method="Post";
								document.frmsearch.action="styleGuideResults.aspx?lvl=" + lvl;
								document.frmsearch.submit();
						}
				}else{
						document.frmsearch.method="Post";
						document.frmsearch.action="styleGuide.aspx?lvl=" + lvl;
						document.frmsearch.submit();
				}
		}
}

