
var nocache = 0;
			
		function login()
		{
		var xmlHttp;
		try
		  {
		  // Firefox, Opera 8.0+, Safari
		  xmlHttp=new XMLHttpRequest();
		  }
		catch (e)
		  {
		  // Internet Explorer
		  try
		    {
		    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		    }
		  catch (e)
		    {
		    try
		      {
		      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		      }
		    catch (e)
		      {
		      alert("Your browser does not support AJAX!");
		      return false;
		      }
		    }
		  }
			xmlHttp.onreadystatechange=function()
    			{
			
			    if(xmlHttp.readyState==4)
			      {
			      if (xmlHttp.responseText=="no")
				{
			      document.getElementById("yesno").innerHTML="<font color=\"red\"><small>Incorrect username/password.</small></font>"; }
			      else if (xmlHttp.responseText=="yes")
				{
					window.location='admin.php';
			     	}
			    }
			}
			  // Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding.
	                  var username = encodeURI(document.getElementById('username').value);
   		          var psw = encodeURI(document.getElementById('password').value);
			  // Set te random number to add to URL request
			  nocache = Math.random();
			  xmlHttp.open('GET', 'login.php?username='+username+'&psw='+psw+'&nocache = '+nocache);
			  xmlHttp.send(null);
			  }

		function showSubcat(str)
		{
		var xmlHttp;
		try
		  {
		  // Firefox, Opera 8.0+, Safari
		  xmlHttp=new XMLHttpRequest();
		  }
		catch (e)
		  {
		  // Internet Explorer
		  try
		    {
		    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		    }
		  catch (e)
		    {
		    try
		      {
		      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		      }
		    catch (e)
		      {
		      alert("Your browser does not support AJAX!");
		      return false;
		      }
		    }
		  }
			xmlHttp.onreadystatechange=function()
    			{
			
			    if(xmlHttp.readyState==4)
			      {
			      document.getElementById("subcat").innerHTML=xmlHttp.responseText;
			      //alert(xmlHttp.responseText);
			    }
			}
			  // Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding.
			  var url="getcats.php"
				url=url+"?cat="+str
				url=url+"&sid="+Math.random()
			  // Set te random number to add to URL request
			  nocache = Math.random();
			  xmlHttp.open('GET', url, true);
			  xmlHttp.send(null);
			  }
		
		function min1(str,str2)
		{
		var dir = "min";
		var xmlHttp;
		//var item = str;
		//var identifier = "quantity"+item;
		var current = document.getElementById(str).innerHTML;
		//alert(str);
		try
		  {
		  // Firefox, Opera 8.0+, Safari
		  xmlHttp=new XMLHttpRequest();
		  }
		catch (e)
		  {
		  // Internet Explorer
		  try
		    {
		    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		    }
		  catch (e)
		    {
		    try
		      {
		      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		      }
		    catch (e)
		      {
		      alert("Your browser does not support AJAX!");
		      return false;
		      }
		    }
		  }
			xmlHttp.onreadystatechange=function()
    			{
			
			    if(xmlHttp.readyState==4)
			      {
			      
			      document.getElementById(str).innerHTML=xmlHttp.responseText;
			      //setTimeout('getUK()', 200);
			      //totalexc();
			      //document.getElementById('refresh').style.display = 'block';
			      //document.getElementById('refresh2').style.display = 'block';
			      //alert(xmlHttp.responseText);
			      total();
			    }
			}
			  // Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding.
			  var url="changeqty.php"
				url=url+"?id="+str
				//url=url+"&qty="+str2
				url=url+"&qty="+current
				url=url+"&way="+dir
				url=url+"&sid="+Math.random()
			  // Set te random number to add to URL request
			  nocache = Math.random();
			  xmlHttp.open('GET', url, true);
			  xmlHttp.send(null);
			  }
			  
		
		function add1(str, str2)
		{
		var dir = "add";
		var xmlHttp;
		var current = document.getElementById(str).innerHTML;
		try
		  {
		  // Firefox, Opera 8.0+, Safari
		  xmlHttp=new XMLHttpRequest();
		  }
		catch (e)
		  {
		  // Internet Explorer
		  try
		    {
		    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		    }
		  catch (e)
		    {
		    try
		      {
		      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		      }
		    catch (e)
		      {
		      alert("Your browser does not support AJAX!");
		      return false;
		      }
		    }
		  }
			xmlHttp.onreadystatechange=function()
    			{
			
			    if(xmlHttp.readyState==4)
			      {
			      document.getElementById(str).innerHTML=xmlHttp.responseText;
			      //setTimeout('getUK()', 200);
			      //document.getElementById('refresh').style.display = 'block';
			      //document.getElementById('refresh2').style.display = 'block';
			      total();
			    }
			}
			  // Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding.
			  var url="changeqty.php"
				url=url+"?id="+str
				//url=url+"&qty="+str2
				url=url+"&qty="+current
				url=url+"&way="+dir
				url=url+"&sid="+Math.random()
			  // Set te random number to add to URL request
			  nocache = Math.random();
			  xmlHttp.open('GET', url, true);
			  xmlHttp.send(null);
			  }
		
		function total()
		{
		var xmlHttp;
		//var tote = document.getElementById('totalexc').innerHTML;
		try
		  {
		  // Firefox, Opera 8.0+, Safari
		  xmlHttp=new XMLHttpRequest();
		  }
		catch (e)
		  {
		  // Internet Explorer
		  try
		    {
		    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		    }
		  catch (e)
		    {
		    try
		      {
		      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		      }
		    catch (e)
		      {
		      alert("Your browser does not support AJAX!");
		      return false;
		      }
		    }
		  }
			xmlHttp.onreadystatechange=function()
    			{
			
			    if(xmlHttp.readyState==4)
			      {
			      document.getElementById("calculations").innerHTML=xmlHttp.responseText;
			      //setTimeout('totalexc2()',200);
			      //alert(xmlHttp.responseText);
			    }
			}
			  // Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding.
			  var url="updatecart.php"
				//url=url+"?tote="+tote
				//url=url+"&qty="+str2
				//url=url+"&qty="+current
				//url=url+"&way="+dir
				url=url+"?sid="+Math.random()
			  // Set te random number to add to URL request
			  nocache = Math.random();
			  xmlHttp.open('GET', url, true);
			  xmlHttp.send(null);
			  }
			  
		/*function totalexc2()
		{
		var xmlHttp;
		var current = document.getElementById('prodtotal').innerHTML;
		var deliv = document.getElementById('choices').innerHTML;
		try
		  {
		  // Firefox, Opera 8.0+, Safari
		  xmlHttp=new XMLHttpRequest();
		  }
		catch (e)
		  {
		  // Internet Explorer
		  try
		    {
		    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		    }
		  catch (e)
		    {
		    try
		      {
		      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		      }
		    catch (e)
		      {
		      alert("Your browser does not support AJAX!");
		      return false;
		      }
		    }
		  }
			xmlHttp.onreadystatechange=function()
    			{
			
			    if(xmlHttp.readyState==4)
			      {
			      document.getElementById("totalexc").innerHTML=xmlHttp.responseText;
			      setTimeout('totalinc()',200);
			      //alert(xmlHttp.responseText);
			    }
			}
			  // Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding.
			  var url="total_with_d_without_vat.php"
				url=url+"?curr="+current
				url=url+"&del="+deliv
				//url=url+"&qty="+current
				//url=url+"&way="+dir
				url=url+"&sid="+Math.random()
			  // Set te random number to add to URL request
			  nocache = Math.random();
			  xmlHttp.open('GET', url, true);
			  xmlHttp.send(null);
			  }
			  
		function totalinc()
		{
		var xmlHttp;
		var current = document.getElementById('prodtotal').innerHTML;
		var deliv = document.getElementById('choices').innerHTML;
		if (deliv == "FREE")
		{
		    deliv = 0;
		}
		var toti = parseFloat(current) + parseFloat(deliv);
		//alert(toti);
		try
		  {
		  // Firefox, Opera 8.0+, Safari
		  xmlHttp=new XMLHttpRequest();
		  }
		catch (e)
		  {
		  // Internet Explorer
		  try
		    {
		    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		    }
		  catch (e)
		    {
		    try
		      {
		      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		      }
		    catch (e)
		      {
		      alert("Your browser does not support AJAX!");
		      return false;
		      }
		    }
		  }
			xmlHttp.onreadystatechange=function()
    			{
			
			    if(xmlHttp.readyState==4)
			      {
			      document.getElementById("totalinc").innerHTML=xmlHttp.responseText;
			      //alert(xmlHttp.responseText);
			    }
			}
			  // Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding.
			  var url="totalexc.php"
				url=url+"?toti="+toti
				url=url+"&curr="+current
				//url=url+"&qty="+current
				//url=url+"&way="+dir
				url=url+"&sid="+Math.random()
			  // Set te random number to add to URL request
			  nocache = Math.random();
			  xmlHttp.open('GET', url, true);
			  xmlHttp.send(null);
			  }
		
		function getUK()
		{
		var xmlHttp;
		var prod = document.getElementById('prodtotal').innerHTML;
		var current = document.getElementsByName('quantity').innerHTML;
		//alert(prod);
		try
		  {
		  // Firefox, Opera 8.0+, Safari
		  xmlHttp=new XMLHttpRequest();
		  }
		catch (e)
		  {
		  // Internet Explorer
		  try
		    {
		    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		    }
		  catch (e)
		    {
		    try
		      {
		      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		      }
		    catch (e)
		      {
		      alert("Your browser does not support AJAX!");
		      return false;
		      }
		    }
		  }
			xmlHttp.onreadystatechange=function()
    			{
			
			    if(xmlHttp.readyState==4)
			      {
			      document.getElementById("choices").innerHTML=xmlHttp.responseText;
			      //alert(xmlHttp.responseText);
			      setTimeout('totalexc()',200)
			    }
			}
			  // Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding.
			  var url="getuk.php"
				url=url+"?prod="+prod
				url=url+"&qty="+current
				//url=url+"&qty="+current
				//url=url+"&way="+dir
				url=url+"&sid="+Math.random()
			  // Set te random number to add to URL request
			  nocache = Math.random();
			  xmlHttp.open('GET', url, true);
			  xmlHttp.send(null);
			  }*/
		    
		
			    function validate_required(field,alerttxt)
				{
					with (field)
					{
					if (value==null||value=="")
						{alert(alerttxt);return false;}
					else 
					{return true}
					}
				}
				
				function validate_pass(thisform)
				{
					with (thisform)
					{
					if (validate_required(username,"Please include your username.")==false)
						{username.focus();return false;}	
					if (validate_required(password,"Please include your password.")==false)
						{password.focus();return false;}				
							}					
				}
				
				function validate_file(thisform)
				{
					with (thisform)
					{
					if (validate_required_file(file,"Please include your username.")==false)
						{file.focus();return false;}					
							}					
				}
				
				var message="Right click disabled. Sorry"
				function click(e) {
					if (document.all) {
					if (event.button == 2) {
					alert(message);
					return false;
					}
					}
					if (document.layers) {
					if (e.which == 3) {
					alert(message);
					return false;
					}
					}
					}
					if (document.layers) {
					document.captureEvents(Event.MOUSEDOWN);
					}
					document.onmousedown=click;
					
				function calculate_res_width()
				{
					var res = document.getElementById('preres').value;
					parseInt(res);
					var result = (6400/(res));
					var resultingString = Math.round(result);
					document.getElementById("result").innerHTML = resultingString +"%";				
				}
				
				function calculate_res_height()
				{
					var res = document.getElementById('preres2').value;
					parseInt(res);
					var result = (4800/(res));
					var resultingString = Math.round(result);
					document.getElementById("result2").innerHTML = resultingString +"%";				
				}
				
				function getTip()
				{
				alert("For example: If you current image resolution is 1024*768 - you should type 1024 into the width text box and 768 into the height text box. \n\nIf you then open Paint application, located in Start Menu - Accessories. \n\nOpen your image, Click the 'Image' Tab in the drop down menu and click Resize/Skew. \n\nYou can then enter the percentages you have been given in the 'Resize' section of the pop-up. \n\nSave the image with a different name (by clicking 'Save as') so you don't lose your original image. Now you are ready to upload this new image to your gallery.");
				}
				
				function validate_form(thisform)
				{
					with (thisform)
					{
					if (ValidateForm(newemail,"Please include a valid email address. Your email address is NOT passed along to any third parties.")==false)
						{newemail.focus();return false;}
							}
				}
				
						function echeck(str) {
					
						    var at="@"
						    var dot="."
						    var lat=str.indexOf(at)
						    var lstr=str.length
						    var ldot=str.indexOf(dot)
						    if (str.indexOf(at)==-1){
						       alert("Invalid E-mail ID")
						       return false
						    }
				    
						    if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
						       alert("Invalid E-mail ID")
						       return false
						    }
				    
						    if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
							alert("Invalid E-mail ID")
							return false
						    }
				    
						     if (str.indexOf(at,(lat+1))!=-1){
							alert("Invalid E-mail ID")
							return false
						     }
				    
						     if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
							alert("Invalid E-mail ID")
							return false
						     }
				    
						     if (str.indexOf(dot,(lat+2))==-1){
							alert("Invalid E-mail ID")
							return false
						     }
						    
						     if (str.indexOf(" ")!=-1){
							alert("Invalid E-mail ID")
							return false
						     }
				    
						     return true					
					    }

					    function ValidateForm(field,alerttxt){
						    //var emailID=document.frmSample.txtEmail
						    with (field){
						    if ((value==null)||(value=="")){
							    alert("Please Enter your Email ID")
							    focus()
							    return false
						    }
						    if (echeck(value)==false){
							    value=""
							    focus()
							    return false
						    }
						    return true
					     }
						    }
				