// JavaScript Document
// This JS for MagazineArena.com
function checkform ( form )
{
// ** START **
if (form.search.value == "") {
alert( "Please enter seach keyword." );
form.search.focus();
return false ;
}
// ** END **
return true ;
}
function popupZoom(pid) {
window.open('http://www.magazinearena.com/product-zoom.php?pid='+pid,'','toolbar=no, width=410, height=480, resizable=1, scrollbars=1'); 
void('');
}
function gotoPage(s) {
var p = s.options[s.selectedIndex].value;
document.location = 'http://www.magazinearena.com/top-title-magazine-x' + p +'.html';
}
function gotoCat(s) {
var p = s.options[s.selectedIndex].value;
document.location = 'http://www.magazinearena.com/top-category-catid' + p+'-page1.html';
}
function openwindow1()
{
// window.alert("OK");
window.open("http://www.magazinearena.com/emailoffer.php","mywindow","menubar=0,resizable=0,width=400,height=400");
//window.open("emailoffer.php","mywindow","menubar=0,resizable=0,width=400,height=400");
}
function openwindow()
{
// window.alert("OK");
//window.open("http://www.magazinearena.com/emailafriend.php","mywindow","menubar=0,resizable=0,width=400,height=500");
window.open("emailafriend.php","mywindow","menubar=0,resizable=0,width=400,height=500");
}
function open_w3_window()
{
// window.alert("OK");
var wurl="http://validator.w3.org/check?uri=referer";
//window.open("http://www.magazinearena.com/emailafriend.php","mywindow","menubar=0,resizable=0,width=400,height=500");
window.open(wurl,"validator","menubar=0,resizable=0,width=700,height=500");
}
function fdp(n,d){
	//alert(n);
	var xx = n.indexOf('.')
	var l = n.length
	var zstr = '0000000000000000000000'
	var theInt = ''
	var theFrac = ''
	var theNo = ''
	rfac = ''
	rfacx = 0
	nx = 0
	var xt = parseInt(d) + 1
	var rstr = '' + zstr.substring(1,xt)
	var rfac = '.' + rstr + '5'
	var rfacx = parseFloat(rfac)
	if (xx == -1 ) 	{    // No fraction
		theFrac = zstr
		theInt = "" + n
	}
	else if (xx == 0) {
		theInt = '0'
		nx = 0 + parseFloat(n) + parseFloat(rfacx)
		n = nx + zstr
		theFrac = '' + n.substring(1, n.length)
	}
	else {
		theInt = n.substring(0,xx)
		nx = parseFloat(n) + rfacx
		n = '' + nx + zstr
		theFrac = '' + n.substring(xx+1,xx + 1 + parseInt(d))
		var astr = 'd = ' + d
	}
	theFrac = theFrac.substring(0,parseInt(d))
	var ii = 0
	theNo = theInt + '.' + theFrac
	return theNo
} 	

function printPrice(){
			var qty = document.getElementById('txtqty').value;
			
			var price = $(document.forms[1]["cmbissue"]);
			for(var i =0;i< price.length ; i++){
				
				if(price[i].checked==true){
					price = price[i].value;
					break;
				}
			}


			var price = price.split("|");
			//var coverPrice = price[0] + (price[0]*40)/100;
			var coverPrice = parseFloat( price[0]) + parseFloat((price[0]*40)/100);
			var total = price[0];			
			var myPrice = coverPrice - total;
			document.getElementById("myPrice").innerHTML = "\$"+Math.round((total*qty)*100)/100;
			document.getElementById("myCoverPrice").innerHTML = "<font face=\"Verdana, Arial, Helvetica, sans-serif\"  style=\"font-size:12px;font-weight:bold\">\$"+Math.round((coverPrice * qty)*100)/100 +"</font>";			
			document.getElementById("yousaved").innerHTML = "<font face=\"Verdana, Arial, Helvetica, sans-serif\"  style=\"font-size:12px;font-weight:bold\">\$"+Math.round((myPrice *qty)*100)/100 +"</font>";
}
function checkformqty ( form )
{
  // ** START **
  if (form.txtqty.value == 0) {
    alert( "Please enter Quantity." );
    form.txtqty.focus();
    return false ;
  }
  // ** END **
  return true ;
}
var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i
function checkmail(e){
var returnval=emailfilter.test(e.value)
if (returnval==false){
alert("Please enter a valid e-mail address.")
e.select()
}
return returnval
}