// Set the horizontal and vertical position for the popup
PositionX = 100;
PositionY = 100;
// Set these value approximately 20 pixels greater than the
// size of the largest image to be used (needed for Netscape)
defaultWidth  = 500;
defaultHeight = 500;
// Set autoclose true to have the window close automatically
// Set autoclose false to allow multiple popup windows
var AutoClose = true;

// Do not edit below this line...
// ================================
if (parseInt(navigator.appVersion.charAt(0))>=4){
var isNN=(navigator.appName=="Netscape")?1:0;
var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;
function popImage(imageURL,imageTitle){
if (isNN){imgWin=window.open('about:blank','',optNN);}
if (isIE){imgWin=window.open('about:blank','',optIE);}
with (imgWin.document){
writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');
writeln('<sc'+'ript>');
writeln('var isNN,isIE;');
writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
writeln('isNN=(navigator.appName=="Netscape")?1:0;');
writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
writeln('function reSizeToImage(){');
writeln('if (isIE){');
writeln('window.resizeTo(100,100);');
writeln('width=100-(document.body.clientWidth-document.images[0].width);');
writeln('height=100-(document.body.clientHeight-document.images[0].height);');
writeln('window.resizeTo(width+50,height+60);}');
writeln('if (isNN){');       
writeln('window.innerWidth=document.images["racepages"].width+50;');
writeln('window.innerHeight=document.images["racepages"].height+60;}}');
writeln('function doTitle(){document.title="'+imageTitle+'";}');
writeln('</sc'+'ript>');
if (!AutoClose) writeln('</head><body bgcolor=FFFFFF scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
else writeln('</head><body bgcolor=FFFFFF scroll="no" onload="reSizeToImage();doTitle();self.focus()"  onselectstart="return false" ondragstart="return false" oncontextmenu="return false">');
writeln('<table align=center><tr><td>');
writeln('<img onclick="self.close()" name="racepages" alt="'+imageTitle+'" title="'+imageTitle+'" src='+imageURL+' style="display:block"></body></html>');
writeln('</td></tr>');
writeln('<tr><td>&nbsp;<tr><td style="text-align:center"><a style="color:black;" href="#" onclick="self.close()">Close Window</a></td></tr></table>');

close();		
}}


function pop_more(image, title, text) {
	
	PositionX = 100;
	PositionY = 100;
	defaultWidth  = 660;
	defaultHeight = 560;
	var opt='resizable=yes,scrollbars=yes,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
	window.open('/includes/popup.php?type=more&image='+image+'&title='+title+'&text='+text,'',opt);
	
}

function getCompare(f) {
		var R = '';
		var cnt = 0;
		for(var n=0; n<50; n++) {
			
			var e = document.getElementById("comp"+n);
			if(e != null) {
				if(e.checked) {
					R += e.value + ' ';
					cnt++;
				}
			}
		}
		
		if(cnt < 2) {
			alert("Please Select at least (2) two products for comparision");
			return false;
		}
		
		if(R.length > 0) {
			f.R.value = R;
			return true;
		} else {
			return false;
		}
	}
	
	function validateChecks(f) {

		var R = '';
		var chkCnt = 0;
		for(var n=0; n<50; n++) {
			
			var e = document.getElementById("comp"+n);
			if(e != null) {
				if(e.checked) {
					chkCnt++;
				}
			}
			
			if(chkCnt > 3) {
				alert("You may select up to (3) three products to compare");
				f.checked = false;
				break;
			}
		}

		
	}
	
	$(function() {
		
		var cat_id = 0;
		
		$("div.cat_li_toggle").each(function() {
			
			cat_id++;
			var cat_id_id = cat_id;
			
			$(this).click(function() {
				
				var el_li 		= document.getElementById("cat_li_id_" + cat_id_id);
				var el_img_li = document.getElementById("img_li_id_" + cat_id_id);
				
				if (el_li.style.display == 'none') {
					$(el_li).slideDown();
					el_img_li.src = 'images/minus.png';
				} else {
					$(el_li).slideUp();
					el_img_li.src = 'images/plus2.png';
				}
				
			});
			
		});
		
		
	});
	
	var parts = [];
var rm_count = 0;
var script_loaded = [];
script_loaded.wp_script_loaded = false;

fmtMoney = function(n, c, d, t){
	var m = (c = Math.abs(c) + 1 ? c : 2, d = d || ",", t = t || ".",
			/(\d+)(?:(\.\d+)|)/.exec(n + "")), x = m[1].length > 3 ? m[1].length % 3 : 0;
	return (x ? m[1].substr(0, x) + t : "") + m[1].substr(x).replace(/(\d{3})(?=\d)/g,
			"$1" + t) + (c ? d + (+m[2] || 0).toFixed(c).substr(2) : "");
};

function include_js(file) {
    var html_doc = document.getElementsByTagName('head').item(0);
    js = document.createElement('script');
    js.setAttribute('type', 'text/javascript');
    js.setAttribute('src', file);
    html_doc.appendChild(js);
		return false;
}

function check_script_loaded(script_loaded_val, prices, waittime, interval) {
	if (!script_loaded[script_loaded_val]) {
		rm_count++;
		if ((rm_count*interval) == waittime) {
			setPricing(prices);
			return false;
		}
		setTimeout(function() {check_script_loaded(script_loaded_val, prices, waittime, interval)}, interval);
	} else {
		setPricing(prices);
		return false;
	}
}

function setPricing(price_class) {
	$("form." + price_class).each(function() {
		var el_id 		= this.id.value;
		var el_pnum 	= this.part_number.value;
		var el_bc 		= this.brand_code.value;
		var el_price 	= this.price.value;
		var el_core 	= this.core.value;
		
		if (parts[el_pnum + "|||||" + el_bc] != undefined) {
			el_price 				= parts[el_pnum + "|||||" + el_bc].price;
			el_core 				= parts[el_pnum + "|||||" + el_bc].core;
			this.bpp.value 	= parts[el_pnum + "|||||" + el_bc].key;
			this.price.value = el_price;
			this.core.value	 = el_core;
		}
			
		$("#price_" + el_id).html('$' + fmtMoney(el_price,2,'.',','));
		if (el_core > 0) {
			$("#core_" + el_id).append('$' + fmtMoney(el_core,2,'.',','));
			$("#core_" + el_id).css('display', 'block');
		}
	});
}

function popship() {
// Set the horizontal and vertical position for the popup
PositionX = 100;
PositionY = 100;
// Set these value approximately 20 pixels greater than the
// size of the largest image to be used (needed for Netscape)
defaultWidth  = 450;
defaultHeight = 285;
// Set autoclose true to have the window close automatically
// Set autoclose false to allow multiple popup windows
var AutoClose = true;

// Do not edit below this line...
// ================================
if (parseInt(navigator.appVersion.charAt(0))>=4){
var isNN=(navigator.appName=="Netscape")?1:0;
var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;

if (isNN){imgWin=window.open('about:blank','',optNN);}
if (isIE){imgWin=window.open('about:blank','',optIE);}
with (imgWin.document){
writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');
writeln('<script>');
writeln('var isNN,isIE;');
writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
writeln('isNN=(navigator.appName=="Netscape")?1:0;');
writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
writeln('function doTitle(){document.title="Free Shipping Details";}');
writeln('</script>');
if (!AutoClose) writeln('</head><body bgcolor=FFFFFF scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
else writeln('</head><body bgcolor=FFFFFF scroll="no" onload="doTitle();self.focus()"  onselectstart="return false" ondragstart="return false" oncontextmenu="return false">');
writeln('<table align=center width=425>');
writeln('<tr><td rowspan=3 valign=top><img src="http://www.racepages.com/images/free_shipping.jpg"></td><td style="font-size:20px; font-weight:bold; color:blue;">Free Shipping On All Orders Over $50</td></tr>');
writeln('<tr><td><b>Free UPS Shipping</b> - When you choose to ship ground with us it is free of charge on orders that total over $50.00 and applies only to the continuous 48 states.</td></tr>');
writeln('<tr><td>Shipping time is usually between 4 to 7 business days.</td></tr>');
writeln('<tr><td>&nbsp;</td></tr>');
writeln('<tr><td colspan=2 style="text-align:center"><a style="color:black;" href="#" onclick="self.close()">Close Window</a></td></tr></table>');
close();		
}
}
function popphone() {
// Set the horizontal and vertical position for the popup
PositionX = 100;
PositionY = 100;
// Set these value approximately 20 pixels greater than the
// size of the largest image to be used (needed for Netscape)
defaultWidth  = 450;
defaultHeight = 200;
// Set autoclose true to have the window close automatically
// Set autoclose false to allow multiple popup windows
var AutoClose = true;

// Do not edit below this line...
// ================================
if (parseInt(navigator.appVersion.charAt(0))>=4){
var isNN=(navigator.appName=="Netscape")?1:0;
var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;

if (isNN){imgWin=window.open('about:blank','',optNN);}
if (isIE){imgWin=window.open('about:blank','',optIE);}
with (imgWin.document){
writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');
writeln('<script>');
writeln('var isNN,isIE;');
writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
writeln('isNN=(navigator.appName=="Netscape")?1:0;');
writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
writeln('function doTitle(){document.title="Call Toll Free";}');
writeln('</script>');
if (!AutoClose) writeln('</head><body bgcolor=FFFFFF scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
else writeln('</head><body bgcolor=FFFFFF scroll="no" onload="doTitle();self.focus()"  onselectstart="return false" ondragstart="return false" oncontextmenu="return false">');
writeln('<table align=center width=425>');
writeln('<tr><td rowspan=2 valign=top><img src="http://www.racepages.com/images/tollfree.jpg"></td><td style="font-size:20px; font-weight:bold; color:blue;">Operators are Standing By!</td></tr>');
writeln('<tr><td>Call 1-800-814-8638 Toll-Free 24 Hours a Day, 7 Days a Week.  Place your orders morning, noon or night!  We\'ll always have someone waiting to take your call and assist you any way they can.</td></tr>');
writeln('<tr><td colspan=2 style="text-align:center"><br><a style="color:black;" href="#" onclick="self.close()">Close Window</a></td></tr></table>');
close();		
}
}

function showYears() {
	var yDiv = document.getElementById("ydiv");
	var yLnk = document.getElementById("ylnk");
	yDiv.style.display = '';
	yLnk.style.display = 'none';
}
	
function showFitsInformation(combo_id, link_id) {
	var yDiv = document.getElementById(combo_id);
	var yLnk = document.getElementById(link_id);
	yDiv.style.display = '';
	yLnk.style.display = 'none';
}
	
function show_ref(type) {
	var Div = document.getElementById(type + "div");
	var Lnk = document.getElementById(type + "lnk");
	var Hide = document.getElementById(type + "hide");
	Div.style.display = '';
	Lnk.style.display = 'none';
	Hide.style.display = '';
}
function hide_ref(type) {
	var Div = document.getElementById(type + "div");
	var Lnk = document.getElementById(type + "lnk");
	var Hide = document.getElementById(type + "hide");
	Div.style.display = 'none';
	Lnk.style.display = '';
	Hide.style.display = 'none';
}
