<!--

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		home = newImage("/images/home-over.gif");
		aboutUs_over = newImage("/images/aboutUs-over.gif");
		newsComment_aboutUs_over = newImage("/images/newsComment-aboutUs_over.gif");
		currentIssue_aboutUs_over = newImage("/images/currentIssue-aboutUs_over.gif");
		backIssues_aboutUs_over = newImage("/images/backIssues-aboutUs_over.gif");
		featuredArtist_aboutUs_over = newImage("/images/featuredArtist-aboutUs_over.gif");
		postcards_aboutUs_over = newImage("/images/postcards-aboutUs_over.gif");
		newsResources_aboutUs_over = newImage("/images/newsResources-aboutUs_over.gif");
		contactUs_over = newImage("images/contactUs-over.gif");
		writeForUs_contactUs_over = newImage("/images/writeForUs-contactUs_over.gif");
		subscribe_contactUs_over = newImage("/images/subscribe-contactUs_over.gif");
		advertise_contactUs_over = newImage("/images/advertise-contactUs_over.gif");
		preloadFlag = true;
	}
}

function openwin(popurl)
{
	winpops=window.open(popurl,"testimonials","width=470,height=485,top=1,left=600,scrollbars=no");
	winpops.focus();
}

function toggleCountryText() {
	if (document.orderform.country.value == "International") {
		document.orderform.country_text.style.display = "inline";
	} else {
		document.orderform.country_text.style.display = "none";
		document.orderform.country_text.style.color = "red";
		document.orderform.country_text.value = "Specify Country";
	}
}

function ClearText() {
	if (document.orderform.country_text.value == "Specify Country") {
		document.orderform.country_text.style.color = "black";
		document.orderform.country_text.value = "";
	}
}

function calcTotals() {
	var pricemag = 0;
	var pricecas = 0;
	var pricecd = 0;
	var totalqty = 0;
	var totalall = 0;
	var shippingall = 0;
	var grandtotal = 0;
	var sCountry = document.orderform.country.value;
	
	//individual prices
	pricemag += 5 * Number(document.orderform.magqty1.value);
	pricemag += 5 * Number(document.orderform.magqty2.value);
	pricemag += 5 * Number(document.orderform.magqty3.value);

	pricecas += 10 * Number(document.orderform.casqty1.value);
	pricecas += 10 * Number(document.orderform.casqty2.value);
	pricecas += 10 * Number(document.orderform.casqty3.value);

	pricecd += 12 * Number(document.orderform.cdqty1.value);
	pricecd += 12 * Number(document.orderform.cdqty2.value);
	pricecd += 12 * Number(document.orderform.cdqty3.value);

	//total price
	totalall = pricemag + pricecas + pricecd;
	
	//total quantity
	totalqty += Number(document.orderform.magqty1.value);
	totalqty += Number(document.orderform.magqty2.value);
	totalqty += Number(document.orderform.magqty3.value);

	totalqty += Number(document.orderform.casqty1.value);
	totalqty += Number(document.orderform.casqty2.value);
	totalqty += Number(document.orderform.casqty3.value);

	totalqty += Number(document.orderform.cdqty1.value);
	totalqty += Number(document.orderform.cdqty2.value);
	totalqty += Number(document.orderform.cdqty3.value);

	//total shipping
	shippingall = calcShipping(sCountry, totalqty);
	
	//grand total	
	grandtotal = totalall + shippingall;
	
	if (document.orderform.int_delivery.checked == true && sCountry == "International")
		grandtotal += 10;
	else
		document.orderform.int_delivery.checked = false;
			
	document.orderform.pricemag.value = pricemag;
	document.orderform.pricecas.value = pricecas;
	document.orderform.pricecd.value = pricecd;
	document.orderform.totalall.value = totalall;
	document.orderform.shippingall.value = shippingall;
	document.orderform.grandtotal.value = grandtotal;
}

function calcShipping(sCountry, iQty) {
	var sVal = 0;
	if (sCountry != "International") {
		if (iQty >= 1 && iQty <= 2) {
			sVal += 4;
		} else if (iQty >= 3 && iQty <= 5) {
			sVal += 8;
		} else if (iQty >= 6 && iQty <= 10) {
			sVal+= 12;
		} else if (iQty > 10) {
			sVal+= 12;
		}
	} else {
		if (iQty >= 1 && iQty <= 2) {
			sVal += 8;
		} else if (iQty >= 3 && iQty <= 5) {
			sVal += 12;
		} else if (iQty >= 6 && iQty <= 10) {
			sVal += 16;
		} else if (iQty > 10) {
			sVal += 16;
		}
	}
	return sVal;		
}

function calcSubscriptionTotal() {
	var grandtotal = 0;
		
	//arrSuboptionVal = Array("0","35","42","45","25","30","35","60","65","70","-1","-1","60","72","80")
	var arrSuboptionVal = new Array(0,35,42,45,25,30,35,60,65,70,-1,-1,60,72,80);
	var SuboptionVal = arrSuboptionVal[Number(document.orderform.suboption.value)];
	
	if (SuboptionVal != -1) {
		grandtotal += SuboptionVal;
	}
	
	if (document.orderform.postcards.value != "0" && document.orderform.postcardtype.value != "0") {
		if (document.orderform.postcardtype.value == "$50 - Unsigned Postcard Set") {
			grandtotal += 50;
		} else if (document.orderform.postcardtype.value == "$250 - Signed Postcard Set") {
			grandtotal += 250;
		}
		grandtotal += 5; //postage;
	}

	if (document.orderform.cd1.checked) {
		grandtotal += Number(document.orderform.cd1.value);
	}	

	document.orderform.grandtotal.value = grandtotal;
}

function proc_suboption() {		
	var suboption = document.getElementById('suboption');
	var selectedopt = suboption.options[suboption.selectedIndex].text;
	if (selectedopt.indexOf("student") > 0) {
		$("#divstudentno").show();			
		document.orderform.needstudentno.value = "yes";
	} else {
		$("#divstudentno").hide();
		document.orderform.needstudentno.value = "no";
	}
}

$(document).ready(function() {
	preloadImages();
});

// -->
