
jQuery.preloadImages = function() {
	for(var i = 0; i<arguments.length; i++) {
		jQuery("<img>").attr("src", arguments[i]);
	}
}


var popupWin = null;

function NewWindow(mypage, myname, w, h, features) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	if (winl < 0) winl = 0;
	if (wint < 0) wint = 0;
	var settings = 'height=' + h + ',';
	settings += 'width=' + w + ',';
	settings += 'top=' + wint + ',';
	settings += 'left=' + winl + ',';
	settings += features;
	popupWin = window.open(mypage, myname, settings);
	popupWin.window.focus();
	return false;
}

function OpenSizing(whichChart) {
	w = 1000;
	h = 700;

	w += 32;
	h += 96;

	wleft = (screen.width - w) / 2;
	wtop = (screen.height - h) / 2;

	var win = window.open('/sizing.php?chart=' + whichChart,
	                      'sizing_window',
	                      'width=' + w + ', height=' + h + ', ' +
	                      'left=' + wleft + ', top=' + wtop + ', ' +
	                      'location=no, menubar=no, ' +
	                      'status=no, toolbar=no, scrollbars=no, resizable=no');

	// Just in case width and height are ignored
	win.resizeTo(w, h);

	// Just in case left and top are ignored
	win.moveTo(wleft, wtop);

	win.focus();

	return false;
}

function OpenVideo(whichVideo) {
	w = 1000;
	h = 560;

	w += 32;
	h += 96;

	wleft = (screen.width - w) / 2;
	wtop = (screen.height - h) / 2;

	var win = window.open('/sizing.php?tape=' + whichVideo,
	                      'sizing_window',
	                      'width=' + w + ', height=' + h + ', ' +
	                      'left=' + wleft + ', top=' + wtop + ', ' +
	                      'location=no, menubar=no, ' +
	                      'status=no, toolbar=no, scrollbars=no, resizable=no');

	// Just in case width and height are ignored
	win.resizeTo(w, h);

	// Just in case left and top are ignored
	win.moveTo(wleft, wtop);

	win.focus();

	return false;
}

function OpenWashingInstructions(categoryId) {
	w = 1000;
	h = 500;

	w += 32;
	h += 96;

	wleft = (screen.width - w) / 2;
	wtop = (screen.height - h) / 2;

	var win = window.open('/washing_instructions.php?id=' + categoryId,
	                      'washing_instructions_window',
	                      'width=' + w + ', height=' + h + ', ' +
	                      'left=' + wleft + ', top=' + wtop + ', ' +
	                      'location=no, menubar=no, ' +
	                      'status=no, toolbar=no, scrollbars=no, resizable=no');

	// Just in case width and height are ignored
	win.resizeTo(w, h);

	// Just in case left and top are ignored
	win.moveTo(wleft, wtop);

	win.focus();

	return false;
}

function DoConfirm(msg, redirectURL) {
	var answer = confirm(msg);
	if (answer) window.location.href = redirectURL;
}

function ConfirmDelete(msg) {
	return (confirm(msg)) ? true : false ;
}

function AddFabricToWishList() {
	theForm = document.fabric_order_f;
	var myURL = '/wishlist.php?add=' + theForm.add.value +
	            '&size=' + theForm.size[theForm.size.selectedIndex].value +
	            '&quantity=' + theForm.quantity.value;
	location.href = myURL;
}

