function popUp5(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=745,height=380,left =100,top = 100');");
}


function showphoto(photo,itemno) { //v3.0
	//var photo;
	document.mainphoto.src = "http://www.discountmugs.com/us/prodimage/othercolor/"+photo;
	
	/*if (document.getElementById('productMainImage')) document.getElementById('productMainImage').innerHTML='<a href="http://www.discountmugs.com/us/prodimage/othercolor/'+photo+'" title="Move mouse away from product image to close this window." class="MagicZoom MagicThumb" rel="zoom-position: custom" id="mzoom"><img src="http://www.discountmugs.com/us/prodimage/othercolor/'+photo+'" border="0" name="mainphoto" id="mainphoto"></a>';
	*/
	if (document.getElementById("mzoom")) {
		MagicZoom_stopZooms();
		document.getElementById("mzoom").href = "http://www.discountmugs.com/us/prodimage/othercolor/"+photo;
		MagicZoom_findZooms();
	}	
}

function popUp5(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=580,height=360,left =100,top = 100');");

}

function printdiv(printpage)   
{   
var headstr = "<html><head><title></title></head><body>";   
var footstr = "</body>";   
var newstr = document.all.item(printpage).innerHTML;   
var oldstr = document.body.innerHTML;   
document.body.innerHTML = headstr+newstr+footstr;   
window.print();    
document.body.innerHTML = oldstr;   
return false;   
}   

//Data validation using object names to reference objects
function validate(form) {
if (form.company.value == "") { 
alert("Please enter your Company Name"); 
form.company.focus() 
return false;} 
if (form.code.value == "") { 
alert("Please enter your ASI/PPAI/SAGE Code"); 
form.code.focus() 
return false;} 
if (isNaN(form.code.value)) {
alert('Sorry this is not a valid ID number.');
form.code.focus() 
return false;}
if (form.code.value.length < 5 || form.code.value.length > 6) { 
alert("Sorry this is not a valid ID number.  Please contact your local distributor."); 
form.code.focus() 
return false;} 
if (form.yemail.value == "") {
alert("You must enter a Email Address");
form.yemail.focus()
return false;}
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(form.yemail.value)){
return (true)}
alert("Invalid E-mail Address! Please re-enter.")
return (false)}
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=820,height=472,left =200,top = 200');");
}
 
function popUp1(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=600,height=360,left =200,top = 200');");
}
function popUp2(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=620,height=600,left =100,top = 100');");
}
function popUp3(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=350,height=350,left =200,top = 100');");
}
function popUp31(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=350,height=350,left =200,top = 100');");
}
function popUp5(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=575,height=360,left =100,top = 100');");
}
function popUp6(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=620,height=420,left =100,top = 100');");
}

function check_quantity(val,t)
{
	var v=parseInt(val);
	var t1=parseInt(t);
	if(t1<v)
	{
		alert("The minimum no of quantity is "+v);
	}
}

function calc_price(minval,val,frm)
{
	var slabStr=document.getElementById('str').value;
	var slabArrMain=slabStr.split('#');
	
	var quantity=parseInt(document.getElementById('quantity').value);
	var mv=parseInt(minval);
	
	var color=document.getElementById('color').value;	
	var slab=document.getElementById('slab').value.split(',');
	
	var totp=document.getElementById('totp').value;	
	//alert(slab);
	var pos='';
	for(var j=0;j<slab.length;j++)
	{
		//alert(slab[j+1]);
		if(j<slab.length)
		{
			if(quantity>=parseInt(slab[j]) && parseInt(slab[j+1])>=quantity)
			{
				pos=j;
			}
		}
	}
	
	var arr1=new Array();
	var arr2=new Array();
	var arr3=new Array();
	
	arr1=slabArrMain[0].split(':');
	arr2=slabArrMain[1].split(':');
	arr3=slabArrMain[2].split(':');
	//alert(arr1);alert(arr2);alert(arr3);
	
	var price=new Array();
	
	
	if(arr1[0]==color)
	{
		price=arr1[1].split('|');
	}
	if(arr2[0]==color)
	{
		price=arr2[1].split('|');
	}
	if(arr3[0]==color)
	{
		price=arr3[1].split('|');
	}
	
	//alert(price[pos]);
	if(quantity>=minval)
	{
		switch(frm)
		{
			case 'quan':
				var total_price=parseInt(price[pos])*quantity;
				break;
			case 'color':
				var total_price=parseInt(price[pos])*quantity;
				break;
		}
		document.getElementById('total_price').innerHTML=total_price;
	}
	
	
}
