
function MM_reloadPage(init) {  
	if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
	document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
	else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function verifyAddValues(form, checkValue) { 
	if (form["sItemQuantity[" + checkValue + "]"].value < 1) {
		form["sItemQuantity[" + checkValue + "]"].value = 1;
	}
}

$(document).ready(function () {
	$("#coRushProcessing").click(function () {
		$(".standardShip").toggle();
		$(".rushShip").toggle();
//		$('input[name="form_shipping_method"]')[1].checked = true;
	});
	setInterval("changeGraphicBlock()",5000);
	$("#search_text").autocomplete("/java_searchSuggest2.php", { minChars:2,delay:400 });
});


numberoftimes = 0;

function onlyonce() {
	numberoftimes += 1;
	if (numberoftimes > 1) {
		
		var themessage = "Please be patient. You have already submitted this form. Pressing submit multiple times will result in your account being billed multiple times. You will receive a response momentarily.";
		if (numberoftimes == 3) {
			themessage = "DO NOT PRESS SUBMIT MULTIPLE TIMES!!! YOUR ACCOUNT WILL BE BILLED EACH TIME YOU PRESS SUBMIT!!! Processing may take a couple minute.";
		}
		alert(themessage);
		return false;
	} else {
		return true;
	}
}


function shippingRestrictions(str) {
	OpenWindow=window.open("/site_messageDisplay.php?displayChoice=" + str, "shipResWin", "height=150, width=475,toolbar=no,scrollbars=yes,menubar=no");
}

function shippingwindow() {
	OpenWindow=window.open("/main_shippingCalculator.php", "shipwin", "height=600, width=475,toolbar=no,scrollbars=yes,menubar=no");
}


function rushProcessingWindow() {
	OpenWindow=window.open("/main_rushShipping.php", "rushProcessing", "height=200, width=500,toolbar=no,scrollbars=yes,menubar=no");
}


function productInfo(choice, h1, w1) {
	OpenWindow=window.open("/main_productInfo.php?choice=" + choice + "", "productInfo", "height=" + h1 + ", width=" + w1 + ",toolbar=no,scrollbars=yes,menubar=no");
}


function wishListWindow(pID, oos) { 
	OpenWindow=window.open("/user_addToWishList.php?pid=" + pID + "&oos=" + oos + "", "wishlistwin", "height=400, width=600,toolbar=no,scrollbars=no,menubar=no");
}

//if (top.location == location) {
//	self.name = 'mainWindow';
//}
//if (top.location == location) {
//	self.name = 'freeShippingWindow';
//}

function conPickUpCheck() {
	if (document.getElementById("pickUpAtCon").checked) {
		document.getElementById("shipSameAsBilling").checked = true;
	}
}

function freeShippingWindow() { 
	OpenWindow=window.open("/site_freeShipping.php", "freeShippingWin", "height=200, width=450,toolbar=no,scrollbars=yes,menubar=no");
}
function freeShippingMayfair() { 
	OpenWindow=window.open("/site_freeShipping.php?pa=mayfair", "freeShippingWin", "height=200, width=450,toolbar=no,scrollbars=yes,menubar=no");
}
function freeShippingBoardGames() { 
	OpenWindow=window.open("/site_freeShipping.php?pa=boardgames", "freeShippingWin", "height=200, width=450,toolbar=no,scrollbars=yes,menubar=no");
}
function shippingDetailsPopUp(val) { 
	OpenWindow=window.open("/site_freeShipping.php?pa=" + val + "", "shippingDetailsPopUp", "height=200, width=450,toolbar=no,scrollbars=yes,menubar=no");
}

objImgLoad1 = new Image();
objImgLoad1.src='/images/ajax_progress.gif';
objImgLoad2 = new Image();
objImgLoad2.src='/images/Processing_2.gif';
objImgLoad3 = new Image();
objImgLoad3.src='/images/continue_2.gif';

function action_CO() {
	var ss = document.getElementById('costep');
	ss.innerHTML = '<nobr><img src="/images/ajax_progress.gif" border=0><img src="/images/Processing_2.gif" border=0></nobr>';
}


function jqCheckAll( id, name, flag ) {
	if (flag == 0) {
		$("form#" + id + " INPUT[@name=" + name + "][type='checkbox']").attr('checked', false);
	} else {
		$("form#" + id + " INPUT[@name=" + name + "][type='checkbox']").attr('checked', true);
	}
}
$('#checkAllAuto').click(
	function() {
		$("INPUT[type='checkbox']").attr('checked', $('#checkAllAuto').is(':checked'));
	}
)
function jqCheckAll2( id, name ) {
	$("INPUT[@name^=" + name + "][type='checkbox']").attr('checked', $('#' + id).is(':checked'));	
}
function jqCheckAll3( id, pID ) {
	$( "#" + pID + " :checkbox").attr('checked', $('#' + id).is(':checked'));
}




function ImageExpander(oThumb, sImgSrc) {
	this.oThumb = oThumb;
	this.oThumb.expander = this;
	this.oThumb.onclick = function() { this.expander.expand(); }
	
	this.smallWidth = oThumb.offsetWidth;
	this.smallHeight = oThumb.offsetHeight;	

	this.bExpand = true;
	this.bTicks = false;
	
	if (!window.aImageExpanders) {
		window.aImageExpanders = new Array();
	}
	window.aImageExpanders.push(this);

	this.oImg = new Image();
	this.oImg.expander = this;
	this.oImg.onload = function(){this.expander.onload();}
	this.oImg.src = sImgSrc;
}

ImageExpander.prototype.onload = function() {
	this.oDiv = document.createElement("div");
	document.body.appendChild(this.oDiv);
	this.oDiv.appendChild(this.oImg);
	this.oDiv.style.position = "absolute";
	this.oDiv.style.zIndex = 20;
	this.oDiv.expander = this;
	this.oDiv.onclick = function() {this.expander.toggle();};
	this.oImg.title = "Click to reduce.";
	this.bigWidth = this.oImg.width;
	this.bigHeight = this.oImg.height;
	
	if (this.bExpand) {
		this.expand();
	} else {
		this.oDiv.style.visibility = "hidden";
		this.oImg.style.visibility = "hidden";
	}
}
ImageExpander.prototype.toggle = function() {
	this.bExpand = !this.bExpand;
	if ( this.bExpand ) {
		for ( var i in window.aImageExpanders )
			if ( window.aImageExpanders[i] !== this )
				window.aImageExpanders[i].reduce();
	}
}
ImageExpander.prototype.expand = function() {
	this.bExpand = true;

	for ( var i in window.aImageExpanders )
		if ( window.aImageExpanders[i] !== this )
			window.aImageExpanders[i].reduce();

	if ( !this.oDiv ) return;
	
	this.oThumb.style.visibility = "hidden";
	
	this.x = this.oThumb.offsetLeft;
	this.y = this.oThumb.offsetTop;
	this.w = this.oThumb.clientWidth;
	this.h = this.oThumb.clientHeight;
	
	this.oDiv.style.left = this.x + "px";
	this.oDiv.style.top = this.y + "px";
	this.oImg.style.width = this.w + "px";
	this.oImg.style.height = this.h + "px";
	this.oDiv.style.visibility = "visible";
	this.oImg.style.visibility = "visible";
	
	if (!this.bTicks) {
		this.bTicks = true;
		var pThis = this;
		window.setTimeout(function(){pThis.tick();},25);	
	}
}
ImageExpander.prototype.reduce = function() {
	this.bExpand = false;
}
ImageExpander.prototype.tick = function() {
	var cw = document.body.clientWidth;
	var ch = document.body.clientHeight;
	var cx = document.body.scrollLeft + cw / 2;
	var cy = document.body.scrollTop + ch / 2;

	var tw,th,tx,ty;
	if (this.bExpand) {
		tw = this.bigWidth;
		th = this.bigHeight;
		if (tw > cw) {
			th *= cw / tw;
			tw = cw;
		}	
		if (th > ch) {
			tw *= ch / th;
			th = ch;
		}
		tx = cx - tw / 2;
		ty = cy - th / 2; 
	} else {
		tw = this.smallWidth;
		th = this.smallHeight;
		tx = this.oThumb.offsetLeft;
		ty = this.oThumb.offsetTop;
	}
	var nHit = 0;
	var fMove = function(n,tn) {
		var dn = tn - n;
		if ( Math.abs(dn) < 3 ) {
			nHit++;
			return tn;
		} else {
			return n + dn / 5;
		}
	}
	this.x = fMove(this.x, tx);
	this.y = fMove(this.y, ty);
	this.w = fMove(this.w, tw);
	this.h = fMove(this.h, th);
	
	this.oDiv.style.left = this.x + "px";
	this.oDiv.style.top = this.y + "px";
	this.oImg.style.width = this.w + "px";
	this.oImg.style.height = this.h + "px";

	if (!this.bExpand && (nHit == 4)) {
		this.oImg.style.visibility = "hidden";
		this.oDiv.style.visibility = "hidden";
		this.oThumb.style.visibility = "visible";

		this.bTicks = false;
	}
	
	if ( this.bTicks ) {
		var pThis = this;
		window.setTimeout(function(){pThis.tick();},25);
	}
}

function changeGraphicBlock() {
	graphblocks = $(".top-bar").size();
	for (i = 1; i <= graphblocks; i++) {
		j = i+1;
		if (j > graphblocks) { j = 1; }
		if (sidebaranimate(i,j)) {
			return;	
		}
	}
}
function sidebaranimate(i,j) {
	if ($("#graphic-block"+i).is(":visible")) {
		$("#graphic-block"+i).fadeOut("slow",function() {
			$("#graphic-block"+j).fadeIn("slow");
		});
		return true;
	}
	return false;	
}

/**/
