var options=null;

sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

// for the price looker-upper
function swap(url,set,month,year) { 
	document.images['graph'].src="graph.php"+url;
	document.images['graphmonth'].src="graphmonth.php"+url;

	if (document.getElementById){ 
		document.getElementById('monthGraphText').innerHTML = '&nbsp;&nbsp;&nbsp;&nbsp; ' + month + ' &nbsp;::&nbsp; ' + set;
		document.getElementById('yearGraphText').innerHTML = '&nbsp;&nbsp;&nbsp;&nbsp; ' + year + ' &nbsp;::&nbsp; ' + set;
	}
}

// for the price looker-upper
function cardswap(card,set,setText,foil) { 
	var urlBits = document.images['graph'].src.split("?");
	var url = urlBits[0] + "?card=" + card + "&set=" + set;
	if(foil){
		url = url + "&foil=1";
	}
	var bits = urlBits[1].split("&");
	for(var a=0;a<bits.length;a++){
		if(!((bits[a].substring(0,4)=="card")||(bits[a].substring(0,3)=="set")||(bits[a].substring(0,4)=="foil"))){
			url = url + "&" + bits[a];
		}
	}
	document.images['graph'].src=url;
	//alert(url);

	if (document.getElementById){ 
		document.getElementById('yearGraphText').innerHTML = '&nbsp;&nbsp;&nbsp;&nbsp; ' + setText;
		if(foil){ document.getElementById('yearGraphText').innerHTML += " Foil"; }
	}
}

// for the price looker-upper
function timeswap(scale){
	var urlBits = document.images['graph'].src.split("?");
	var url = urlBits[0] + "?t=" + scale;
	var bits = urlBits[1].split("&");
	for(var a=0;a<bits.length;a++){
		if(!(bits[a].substring(0,1)=="t")){
			url = url + "&" + bits[a];
		}
	}
	document.images['graph'].src=url;
	//alert(url);

	if (document.getElementById){ 
		switch (scale) {
			case "a": document.getElementById('graphTimeline').innerHTML = 'All Data'; break;
			case "2y": document.getElementById('graphTimeline').innerHTML = 'Past Two Years'; break;
			case "1y": document.getElementById('graphTimeline').innerHTML = 'Past Year'; break;
			case "6m": document.getElementById('graphTimeline').innerHTML = 'Past Six Months'; break;
			case "3m": document.getElementById('graphTimeline').innerHTML = 'Past Three Months'; break;
			case "1m": document.getElementById('graphTimeline').innerHTML = 'Past Month'; break;
		}
	}
}

// for the price looker-upper
function superswap() { 
	options = document.forms[1].elements[0].options;
	var urlBits = document.images['graph'].src.split("&s=");
	var url = urlBits[0];
	for(var a=0;a<options.length;a++){
		if(options[a].selected){
			url = url + "&s="+options[a].value;
		}
	}
	document.images['graph'].src=url;
	//alert(url);
}
