

function checkcookie()
{
	
	if (document.cookie == "")
	{
		location.href="no_cookies.asp"
	}

}

// JavaScript Document
//Rollover images
function roll(img_name, img_src)
   {
   //alert(img_src)
   document[img_name].src = img_src;
   }
function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}
function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}

//Email validation
function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		var cont
		cont = "yes"
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail address, please enter the address again.")
		   cont = "no"
		   return cont
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail address, please enter the address again.")
		   cont = "no"
		   return cont
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail address, please enter the address again.")
			cont = "no"
		    return cont
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail address, please enter the address again.")
			cont = "no"
		    return cont
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail address, please enter the address again.")
			cont = "no"
		    return cont
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail address, please enter the address again.")
			cont = "no"
		    return cont
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail address, please enter the address again.")
			cont = "no"
		    return cont
		 }
return cont;
}

function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=1,statusbar=0,menubar=0,resizable=1,width=1000,height=1240,left = 112,top = 84');");
}
function largerimage(imagename,imageid,editbasket)
{
	window.open ("imagelarge.asp?thefile="+imagename+"&imageid="+imageid+"&editbasket="+editbasket,"LargerImage","location=1,resizable,status=1,scrollbars=1,  width=400,height=180");
}
function addtobasket(prodid,currentstock,basketstock)
{
	var referrer = window.location.pathname;
	var referrerpage=referrer.substring(referrer.lastIndexOf('http://www.wozaonline.com/ArtisticRubberStamps/') + 1);
	//alert(referrer)
	//alert(referrerpage)
	var thequerystring = window.location.search.substring(1);
	referrerpage = referrerpage + '?' + thequerystring
	//alert(referrerpage)
	//return
	//alert(basketstock)
	if (currentstock > basketstock)
	{
		location.href = 'http://www.wozaonline.com/ArtisticRubberStamps/basket/addtobasket.asp?productid='+prodid+'&referringpage='+referrerpage;
	}
	else
	{
		//alert('Not allowed!')
		alert ('Unfortunately we current only have '+currentstock+' of this stock on hand.\nYou will not be able to add any more of this type of product to your basket.')
	}
	
}

function deleteproduct(basketID)
{
	var referrer = window.location.pathname;
	var referrerpage=referrer.substring(referrer.lastIndexOf('/') + 1);
	var answer = confirm("Are you sure you want to delete this product?")
	if (answer)
	{
		location.href ='http://www.wozaonline.com/ArtisticRubberStamps/basket/deletefrombasket.asp?BasketID='+basketID+'&referringpage='+referrer;
	}
	else
	{
		
	}
}
function  addproduct(prodid,currentstock,basketstock)
{

	var referrer = window.location.pathname;
	var referrerpage=referrer.substring(referrer.lastIndexOf('/') + 1);
	if (currentstock > basketstock)
	{
		var answer = confirm("Are you sure you want to another item of this product to the basket?")
			if (answer)
			{
				location.href = 'http://www.wozaonline.com/ArtisticRubberStamps/basket/addtobasket.asp?productid='+prodid+'&referringpage='+referrer;
			}
			else
			{
			
			}
	}
	else
	{
		alert ('Unfortunately we current only have '+currentstock+' of this stock on hand.\nYou will not be able to add any more of this type of product to your basket.')
	}
}

function checkout()
{
	location.href='http://www.wozaonline.com/ArtisticRubberStamps/basket/editbasket.asp?checkout=yes'
}

function continueshopping(stage)
{
	switch(stage)
	{
		
		case 1: //Edit basket
		  	location.href = 'http://www.wozaonline.com/ArtisticRubberStamps/logon.asp?checkout=1'
		  break    
		case 2:
		 // execute code block 2
		  break
		default:
		 // code to be executed if n is
		  
	}
}
function showbasket()
{
	document.getElementById("baskettable").style.display="";
	document.getElementById("showbutton").disabled = true;
	document.getElementById("hidebutton").disabled = false;
}
function hidebasket()
{
	document.getElementById("baskettable").style.display="none";
	document.getElementById("showbutton").disabled = false;
	document.getElementById("hidebutton").disabled = true;
}
function display(section)
{
	switch(section)
	{
		case 'pp'://Paypal
			document.getElementById("ccTable").style.display="none";
			document.getElementById("ppTable").style.display="";
			document.getElementById("bkTable").style.display="none";
			document.getElementById("chequeTable").style.display="none";
			//document.getElementById("mandatory").style.display="";
			document.getElementById("continue").style.display="";
			 break 
		case 'cc': //Credit Card
		  	document.getElementById("ccTable").style.display="";
			document.getElementById("ppTable").style.display="none";
			document.getElementById("bkTable").style.display="none";
			document.getElementById("chequeTable").style.display="none";
			//document.getElementById("mandatory").style.display="";
			//document.getElementById("continue").style.display="none";
		  break    
		case 'bt': //Bank Transfer
			document.getElementById("ccTable").style.display="none";
			document.getElementById("ppTable").style.display="none";
			document.getElementById("bkTable").style.display="";
			document.getElementById("chequeTable").style.display="none";
			//document.getElementById("mandatory").style.display="none";
			document.getElementById("continue").style.display="";
		  break
		case 'chq': //Cheque
		 	document.getElementById("ccTable").style.display="none";
			document.getElementById("ppTable").style.display="none";
			document.getElementById("bkTable").style.display="none";
			document.getElementById("chequeTable").style.display="";
			//document.getElementById("mandatory").style.display="none";
			document.getElementById("continue").style.display="";
		  break
		  
	}
}
function validatepayment()
{
	var ischecked = false;
	for (var i=0; i<document.frm1.paymentmethod.length; i++) 
	{
		
			if (document.frm1.paymentmethod[i].checked)
			{
				ischecked = true;
				switch(i)
				{
					case 0: //Credit Card
					
					break
					case 1: //Bank Transfer
						
					break
					case 2: //Cheque
						
					break
				}
			 }
	}
	if (!ischecked)
	{
		alert("Please Select a payment method");
		return false;
	}
document.frm1.method.value='save'
document.frm1.submit();
}
//function reloadproducts(thevalue)
//{
//	document.location = '/products.asp?category='+thevalue
//}
function reloadhitsreport(thevalue)
{
	document.location = 'http://www.wozaonline.com/ArtisticRubberStamps/admin/Reports/hitsreports.asp?monthyear='+thevalue
}
function reloadbasket(thevalue)
{
	
	document.location = 'http://www.wozaonline.com/ArtisticRubberStamps/basket/editbasket.asp?checkout=yes&isinternational='+thevalue
}
function reloadcustomer(thevalue)
{
	document.location = 'http://www.wozaonline.com/ArtisticRubberStamps/admin/editcustomerdetails.asp?clientemail='+thevalue
}
function searchorder()
{
	var thevalue=document.getElementById("theorderid").value
	document.location = 'http://www.wozaonline.com/ArtisticRubberStamps/admin/editvieworder.asp?orderid='+thevalue	
}
function reloadorder(thevalue)
{
	document.location = 'http://www.wozaonline.com/ArtisticRubberStamps/admin/editvieworder.asp?orderid='+thevalue	
}
function  reloadproductsadmin(thevalue)
{
	document.location = 'http://www.wozaonline.com/ArtisticRubberStamps/admin/editproduct.asp?prodid='+thevalue	
}
function upperdeletedvalue()
{
		document.getElementById("theDeleted").value = document.getElementById("theDeleted").value.toUpperCase()
}
function reloadnewsletter(thevalue)
{
	document.location = 'http://www.wozaonline.com/ArtisticRubberStamps/admin/viewsendnewsletter.asp?newsletterID='+thevalue	
}
function reloadimage(thevalue)
{
	document.location = 'http://www.wozaonline.com/ArtisticRubberStamps/admin/editimages.asp?imageID='+thevalue
}
function reloadgalleryimage(thevalue)
{
	document.location = 'http://www.wozaonline.com/ArtisticRubberStamps/admin/editgalleryimages.asp?imageID='+thevalue
}
function sendtestletter()
{
	var newsletterid = document.getElementById("newsletterID").value;
	newslettersend.location.replace('newslettersend.asp?newsletterid='+newsletterid+'&type=test')
}
function sendactualletter()
{
	var newsletterid = document.getElementById("newsletterID").value;
	newslettersend.location.replace('newslettersend.asp?newsletterid='+newsletterid+'&type=actual')
}
function confirmdelete()
{
	if (document.frm1.permanentdelete.checked)
	{
		var answer = confirm("Are you ABSOLUTELY sure you want to permanently delete this product? (After Update this cannot be undone)")
		if (answer)
		{
			//Leave ticked	
		}
		else
		{
			document.frm1.permanentdelete.checked = false
		}
	}
}
function reloadadmincategory(thevalue,theaction)
{
	//2 = update
	//1 = insert
	document.location = 'http://www.wozaonline.com/ArtisticRubberStamps/admin/addeditcategory.asp?CategoryID='+thevalue+'&theaction='+theaction
}
function submitcategoryform(theaction)
{
	//2=Update
	//1=Insert
	if (theaction ==2)
	{
		if(document.getElementById("catname").value=="")
		{
			alert("Please fill in the category name")
			return false;
		}
		else
		{
			document.getElementById("themethod").value="update"
			document.frm2.submit()
		}
	}
	if (theaction == 1)
	{
		
		if(document.getElementById("cataddname").value=="")
		{
			alert("Please fill in the category name")
			return false;
		}
		else
		{
			document.getElementById("themethodadd").value="insert"
			document.frm1.submit()	
		}
	}
}
function reloadvariables(thevalue,theaction)
{
	document.location = 'http://www.wozaonline.com/ArtisticRubberStamps/admin/variables.asp?variableid='+thevalue+'&theaction='+theaction
}
function reloadiplist(thevalue,theaction)
{

	document.location = 'http://www.wozaonline.com/ArtisticRubberStamps/admin/ban.asp?id='+thevalue+'&theaction='+theaction
}
function reloadproductlist(thevalue,theaction)
{

	document.location = 'http://www.wozaonline.com/ArtisticRubberStamps/admin/stockvalues.asp?productid='+thevalue+'&theaction='+theaction
}
function submitipform(theaction)
{
	//alert (theaction)
	//2=Update
	//1=Insert	
	if (theaction ==2)
	{
		if(document.getElementById("ipbanned").value=="")
		{
			alert("Please enter YES OR NO")
			return false;
		}
		else
		{
			document.getElementById("themethod").value="update"
			document.frm2.submit()
		}
	}
}

function submitproductform(theaction)
{
	//2=Update
	//1=Insert
	if (theaction ==2)
	{
		if(document.getElementById("prodstock").value=="")
		{
			alert("Please fill in the stock value")
			return false;
		}
		else
		{
			document.getElementById("themethod").value="update"
			document.frm2.submit()
		}
	}
}
function submitvariableform(theaction)
{
	//2=Update
	//1=Insert
	if (theaction ==2)
	{
		if(document.getElementById("varname").value=="")
		{
			alert("Please fill in the variable value")
			return false;
		}
		else
		{
			document.getElementById("themethod").value="update"
			document.frm2.submit()
		}
	}
	if (theaction == 1)
	{
		
		if(document.getElementById("varaddname").value=="" || document.getElementById("varaddvalue").value=="")
		{
			alert("Please fill in the variable name and value!")
			return false;
		}
		else
		{
			document.getElementById("themethodadd").value="insert"
			document.frm1.submit()	
		}
	}
}
function deletetheimage()
{
	var answer = confirm("Are you ABSOLUTELY sure you want to permanently delete this image?\n  (This cannot be undone and products on the site that are linked to this image will not show this image anymore!)")
		if (answer)
		{
			document.getElementById("themethod").value="delete"
			document.frm2.submit()
		}
}
function reloadadminpage(thevalue)
{
	document.location = 'http://www.wozaonline.com/ArtisticRubberStamps/admin/editcontent.asp?pagename='+thevalue	
}
function displayorderforminfo()
{
	var answer = confirm("If you feel more comfortable placing an order with us by printing and sending us your order via post, please click OK to download an order form.This order form is in a PDF format and requires Adbobe Acrobat Reader to view the document\n\n\Alternatively if you wish to use our online order system, click Cancel.")
	if (answer)
	{
		document.location= 'http://www.wozaonline.com/ArtisticRubberStamps/documents/Order_Form.pdf'
	}
	else
	{
		return false;
	}
}
function disendescription()
{
	if (document.getElementById("dedicateimage").value=='normal')	
	{
		document.getElementById("description").disabled = true
	}
	else
	{
		document.getElementById("description").disabled = false
	}	
}
function advise()
{
		showModalDialog("http://www.wozaonline.com/ArtisticRubberStamps/paypalinfo.html", "Customer Information", "dialogWidth:530px; dialogHeight:310px; status:no; center:yes");
		document.getElementById("pleasewait").style.display='';
		//return false;
		
		//var answer = confirm("Please note you are going to be directed to PayPals secure website to make this transaction\n\nOnce you have completed entering in your payment details, please ensure you click the Return to Merchant website on the very last page on the paypal website to complete your shopping with us.\n\nThank you!")
	
	//if (answer)
	//{
		
	//}
	//else
	//{
	//	//alert(answer);
	//	return;
	//}
}
function prepayment(typ)
{
	document.getElementById("pleasewait").style.display='';
	document.pp.submit()
}
function expandlist()
{
	setTimeout("expandcat()",600)
}
//function collapselist()
//{
//	setTimeout("collapsecat()",600)
//}
function expandcat()
{
	//alert(<%=catheight%>);
	//document.getElementById('selcategory').style.height=<%=catheight%>+'px'
	document.getElementById('cattable').style.display="";
	
}
//function collapsecat()
//{
//	document.getElementById('selcategory').style.height='1px'
//}
function updaterpanel(section,thenumber)
{
	
	switch(section)
	{
	case 'newsupdate':
		//alert(1);
		document.getElementById("action1").value="update"
		document.newsupdate.submit()
	break
	case 'imageupdate':	
		switch(thenumber)
		{
			case 1:
				document.getElementById("action21").value="update"
				document.imageupdate1.submit()
			break
			case 2:
				document.getElementById("action22").value="update"
				document.imageupdate2.submit()
			break
			case 3:
				document.getElementById("action23").value="update"
				document.imageupdate3.submit()
			break
			case 4:
				document.getElementById("action24").value="update"
				document.imageupdate4.submit()
			break
			case 5:
				document.getElementById("action25").value="update"
				document.imageupdate5.submit()
			break
		}
	break
	case 'productimageupdate':	
	//alert(3);
		document.getElementById("action3").value="update"
		document.productimageupdate.submit()
	break
	}	
}

function sendback()
{
	document.location = 'payment.asp?checkout=1'	
}
function sendforward()
{
	//alert(1)
	document.getElementById("firstvisit").value="no"
	//alert(2)
	document.ordercomplete.submit()
	//alert(3)
}
function checkholder()
{
	var accl = 	 document.getElementById("accountholder").value
	if (accl.length > 0)
	{
		document.getElementById("continue").style.display = ''
	}
	else
	{
		document.getElementById("continue").style.display = 'none'	
	}
}
function showhideversesesction()
{
	if(document.getElementById("verseyorn").value=='1')
	{
		document.getElementById("versection").style.display=''
	}
	else
	{
		document.getElementById("versection").style.display='none'
	}
}
function viewverse(prodid)
{
		window.open ("verselarge.asp?theprodid="+prodid,"ViewVerse","location=1,resizable,status=1,scrollbars=1,  width=1000,height=1000");
}	
function backlink()
{
	document.location = 'rewrite.asp'
}
