var req1 = null;
var req2 = null;
var req3 = null;
var req4 = null;
var req5 = null;
var req6 = null;
var req7 = null;

function validatenewsletters()
{
	myform = document.subscribe
	
	if(myform.name.value =="")
	{
		alert("Please key in your name!");
		myform.name.focus();
		return false;
	}
	else if(myform.email.value =="")
	{
		alert("Please key in your email!");
		myform.email.focus();
		return false;
	}
	else if(myform.email.value!="")

	{

		email = myform.email.value;

		AtPos = email.indexOf("@")

		StopPos = email.lastIndexOf(".")

		

		if (AtPos == -1 || StopPos == -1) {

			

			alert("Please key in valid email address!")

			myform.email.focus();

			return false;

		}



		if (StopPos < AtPos) {

			alert("Please key in valid email address!")

			myform.email.focus();

			return false;

		}



		if (StopPos - AtPos == 1) {

			alert("Please key in valid email address!")

			myform.email.focus();

			return false;

		}

	}
	else
	{
		return true;
	}
}


function validatefunc()

{

	myform = document.form1

	

	if (myform.companyname.value == "" )

	{

		alert("Please key in your company name!")

		myform.companyname.focus();

		return false;

	}

	else if (myform.contactperson.value =="" )

	{

		alert("Please key in your contact person!")

		myform.contactperson.focus();

		return false;

	} 

	else if (myform.email.value =="" )

	{

		alert("Please key in your email address!")

		myform.email.focus();

		return false;

	}

	else if(myform.email.value!="")

	{

		email = myform.email.value;

		AtPos = email.indexOf("@")

		StopPos = email.lastIndexOf(".")

		

		if (AtPos == -1 || StopPos == -1) {

			

			alert("Please key in valid email address!")

			myform.email.focus();

			return false;

		}



		if (StopPos < AtPos) {

			alert("Please key in valid email address!")

			myform.email.focus();

			return false;

		}



		if (StopPos - AtPos == 1) {

			alert("Please key in valid email address!")

			myform.email.focus();

			return false;

		}

	}

	else if (myform.subject.value =="" )

	{

		alert("Please key in your subject!")

		myform.contactperson.focus();

		return false;

	} 

	else if (myform.message.value =="" )

	{

		alert("Please key in your message!")

		myform.message.focus();

		return false;

	} 

	else

	{

		return true;

	}

	return true;

}





function validatenewsletter()

{

	myform = document.form2

	

	

	if (myform.name.value == "" )

	{

		alert("Please key in your name!")

		myform.companyname.focus();

		return false;

	}

	else if (myform.email.value =="" )

	{

		alert("Please key in your email address!")

		myform.email.focus();

		return false;

	}

	else if(myform.email.value!="")

	{

		email = myform.email.value;

		AtPos = email.indexOf("@")

		StopPos = email.lastIndexOf(".")

		

		if (AtPos == -1 || StopPos == -1) {

			

			alert("Please key in valid email address!")

			myform.email.focus();

			return false;

		}



		if (StopPos < AtPos) {

			alert("Please key in valid email address!")

			myform.email.focus();

			return false;

		}



		if (StopPos - AtPos == 1) {

			alert("Please key in valid email address!")

			myform.email.focus();

			return false;

		}

	}

	else

	{

		return true;

	}

	return true;

}









	var numLines =2;

	function addfriend1() {

	

	var e=document.getElementById("emailfriend");



	var divIdName = "upload"+numLines;

	var newdiv = document.createElement('div');

	newdiv.id = divIdName;

	newdiv.style.display="block";

	newdiv.innerHTML="<table width='671' height='32' border='0' cellpadding='2' cellspacing='0'><tr><td width='112'>Friend's Name</td><td width='177'><input type='text' name='friendname"+numLines+"' value='' /></td><td width='90'>Friend's Email</td><td width='157'><input type='text' name='friendemail"+numLines+"' value='' /></td><td width='115'></td></tr>";

	e.appendChild(newdiv);

	document.getElementById('count').value=numLines;

	numLines++;

	return true;

	}







function validateemail_friend()

{

	myform = document.form3

	

	

	if (myform.name.value == "" )

	{

		alert("Please key in your name!")

		myform.name.focus();

		return false;

	}

	else if (myform.email.value =="" )

	{

		alert("Please key in your email address!")

		myform.email.focus();

		return false;

	}

	else if (myform.friendname1.value =="" )

	{

		alert("Please key in your friend's name!")

		myform.friendname1.focus();

		return false;

	}

	else if (myform.friendmail1.value =="" )

	{

		alert("Please key in your friend's email!")

		myform.friendmail1.focus();

		return false;

	}

	else

	{

		return true;

	}

	return true;

}



function checkbilling_status()

{

	if(document.getElementById("billing_shipping_same").checked==true)

	{

		document.getElementById("billing_address_notsame").style.display="none";

		document.getElementById("delivery_address").style.display="none";

	}

	else

	{

		document.getElementById("billing_address_notsame").style.display="block";

	}

}



function opendelivery_add()

{

	document.getElementById("delivery_address").style.display="block";

}



function printorder()

{

		window.print();

}





function preferred_currency(currency)

{

	var currentwebsite=document.getElementById("current_website").value;

	location.href="process.php?preferred_currency="+currency+"&current_website="+currentwebsite;

}







function changeBillingCheckout(country){

try



		{



			req1 = new XMLHttpRequest();



		}



		catch (error)



		{



			try



			{



				req1 = new ActiveXObject("Microsoft.XMLHTTP");



			}



			catch (error)



			{	



				req1 = null;



				return false;



			}



		}



		



		url="adminAction.php?action=changeBillingCheckout&country="+country;



		



		req1.onreadystatechange = onreadystatechangechangeBillingCheckout;



		



		req1.open("GET",url,true);



		req1.send(null);



		return false;



}







function onreadystatechangechangeBillingCheckout(){

	if (req1.readyState == 4)

	{

		// If the data was retrieved successfully



		try

		{

			if (req1.status == 200)

			{

				document.getElementById("billingaddress").innerHTML=req1.responseText;

			}



			// IE returns a status code of 0 on some occasions, so ignore this case

			else if (req1.status != 0)

			{

				alert("There was an error while retrieving the URL: " + req1.statusText);



			}

		}



		catch (error)

		{

		alert("error");

		}



	}



	else{

	document.getElementById("billingaddress").innerHTML="<img src='images/loader.gif' align='center'/>";

	}

	return true;

}





function changedeliveryCheckout_country(country)

{

	try



		{



			req2 = new XMLHttpRequest();



		}



		catch (error)



		{



			try



			{



				req2 = new ActiveXObject("Microsoft.XMLHTTP");



			}



			catch (error)



			{	



				req2 = null;



				return false;



			}



		}



		



		url="adminAction.php?action=changedeliveryCheckout_country&country="+country;



		



		req2.onreadystatechange = onreadystatechangedeliveryCheckout_country;



		



		req2.open("GET",url,true);



		req2.send(null);



		return false;



}







function onreadystatechangedeliveryCheckout_country(){

	if (req2.readyState == 4)

	{

		// If the data was retrieved successfully



		try

		{

			if (req2.status == 200)

			{

				document.getElementById("deliveryaddress").innerHTML=req2.responseText;

			}



			// IE returns a status code of 0 on some occasions, so ignore this case

			else if (req2.status != 0)

			{

				alert("There was an error while retrieving the URL: " + req2.statusText);



			}

		}



		catch (error)

		{

		alert("error");

		}



	}



	else{

	document.getElementById("deliveryaddress").innerHTML="<img src='images/loader.gif' align='center'/>";

	}

	return true;

	

}




function user_account_changecountry(country){

try



		{



			req3 = new XMLHttpRequest();



		}



		catch (error)



		{



			try



			{



				req3 = new ActiveXObject("Microsoft.XMLHTTP");



			}



			catch (error)



			{	



				req3 = null;



				return false;



			}



		}




		url="/adminAction.php?action=useraccountchangecountry&type="+type+"&country="+country;



		



		req3.onreadystatechange = onreadystatechangeuseraccountchangecountry;



		



		req3.open("GET",url,true);



		req3.send(null);



		return false;



}







function onreadystatechangeuseraccountchangecountry(){

	if (req3.readyState == 4)

	{

		// If the data was retrieved successfully



		try

		{

			if (req3.status == 200)

			{

				document.getElementById("billingaddress").innerHTML=req3.responseText;

			}



			// IE returns a status code of 0 on some occasions, so ignore this case

			else if (req3.status != 0)

			{

				alert("There was an error while retrieving the URL: " + req3.statusText);



			}

		}



		catch (error)

		{

		alert("error");

		}



	}



	else{

	document.getElementById("billingaddress").innerHTML="<img src='images/loader.gif' align='center'/>";

	}

	return true;

}






function edit_user_changecountry(country){

try



		{



			req3 = new XMLHttpRequest();



		}



		catch (error)



		{



			try



			{



				req3 = new ActiveXObject("Microsoft.XMLHTTP");



			}



			catch (error)



			{	



				req3 = null;



				return false;



			}



		}




		url="/adminAction.php?action=edit_user_changecountry&country="+country;



		



		req3.onreadystatechange = onreadystatechangeedit_user_changecountry;



		



		req3.open("GET",url,true);



		req3.send(null);



		return false;



}







function onreadystatechangeedit_user_changecountry(){

	if (req3.readyState == 4)

	{

		// If the data was retrieved successfully



		try

		{

			if (req3.status == 200)

			{

				document.getElementById("billingaddress").innerHTML=req3.responseText;

			}



			// IE returns a status code of 0 on some occasions, so ignore this case

			else if (req3.status != 0)

			{

				alert("There was an error while retrieving the URL: " + req3.statusText);



			}

		}



		catch (error)

		{

		alert("error");

		}



	}



	else{

	document.getElementById("billingaddress").innerHTML="<img src='images/loader.gif' align='center'/>";

	}

	return true;

}




function edit_user_changeusercountry(country){

try



		{



			req3 = new XMLHttpRequest();



		}



		catch (error)



		{



			try



			{



				req3 = new ActiveXObject("Microsoft.XMLHTTP");



			}



			catch (error)



			{	



				req3 = null;



				return false;



			}



		}




		url="/adminAction.php?action=edit_user_changeusercountry&country="+country;



		



		req3.onreadystatechange = onreadystatechangeedit_user_changeusercountry;



		



		req3.open("GET",url,true);



		req3.send(null);



		return false;



}







function onreadystatechangeedit_user_changeusercountry(){

	if (req3.readyState == 4)

	{

		// If the data was retrieved successfully



		try

		{

			if (req3.status == 200)

			{

				document.getElementById("useraddress").innerHTML=req3.responseText;

			}



			// IE returns a status code of 0 on some occasions, so ignore this case

			else if (req3.status != 0)

			{

				alert("There was an error while retrieving the URL: " + req3.statusText);



			}

		}



		catch (error)

		{

		alert("error");

		}



	}



	else{

	document.getElementById("useraddress").innerHTML="<img src='images/loader.gif' align='center'/>";

	}

	return true;

}




function openaccount(popmenu){

try



		{



			req3 = new XMLHttpRequest();



		}



		catch (error)



		{



			try



			{



				req3 = new ActiveXObject("Microsoft.XMLHTTP");



			}



			catch (error)



			{	



				req3 = null;



				return false;



			}



		}



		



		url="adminAction.php?action=openaccount&popmenu="+popmenu;



		



		req3.onreadystatechange = onreadystatechangeopenaccount;



		



		req3.open("GET",url,true);



		req3.send(null);



		return false;



}







function onreadystatechangeopenaccount(){

	if (req3.readyState == 4)

	{

		// If the data was retrieved successfully



		try

		{

			if (req3.status == 200)

			{

				document.getElementById("user_account_pic").innerHTML=req3.responseText;

			}



			// IE returns a status code of 0 on some occasions, so ignore this case

			else if (req3.status != 0)

			{

				alert("There was an error while retrieving the URL: " + req3.statusText);



			}

		}



		catch (error)

		{

		alert("error");

		}



	}



	else{

	document.getElementById("user_account_pic").innerHTML="<img src='images/loader.gif' align='center'/>";

	}

	return true;


}



function deleteCategory(no){
	var a=confirm("Delete the category will also delete all the products for this category, do you want to proceed?");
	if(a) deleteCategory1(no); else return;
}


function deleteCategory1(no){
try
		{
			req5 = new XMLHttpRequest();
		}
		catch (error)
		{
			try
			{
				req5 = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (error)
			{	
				req5 = null;
				return false;
			}
		}
		
		
		url="../adminAction.php?action=deleteCategory&no="+no;

		req5.onreadystatechange = onreadystatechangedeleteCategory;
		req5.open("GET",url,true);
		
		req5.send(null);
		return false;
		
}

function onreadystatechangedeleteCategory(){
	if (req5.readyState == 4)
	{
		// If the data was retrieved successfully
		try
		{
			if (req5.status == 200)
			{
				alert(req5.responseText);
				window.location.reload(true);
			}
			// IE returns a status code of 0 on some occasions, so ignore this case
			else if (req5.status != 0)
			{
				alert("There was an error while 555 retrieving the URL: " + req5.statusText);
			}
		}

		catch (error)
		{
			alert("error");
		}
	}
	else{
	//document.getElementById("news_status").innerHTML="<img src='images/loader.gif' align='center'/>";
	}
	return true;
}


function changeStatus(orderno){
	var order=document.getElementById('status'+orderno).value;
	
	var a=confirm("Are you sure to change this status ?");
	if(a) changeStatus1(order,orderno); else return;
	
}



function changeStatus1(order,orderno){
try
		{
			req6 = new XMLHttpRequest();
		}
		catch (error)
		{
			try
			{
				req6 = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (error)
			{	
				req6 = null;
				return false;
			}
		}
		
		
		url="../adminAction.php?action=changeStatus&orderno="+orderno+"&orderstatus="+order;

		req6.onreadystatechange = onreadystatechangechangeStatus;
		req6.open("GET",url,true);
		
		req6.send(null);
		return false;
		
}

function onreadystatechangechangeStatus(){
	if (req6.readyState == 4)
	{
		// If the data was retrieved successfully
		try
		{
			if (req6.status == 200)
			{
				alert(req6.responseText);
				//window.location.reload(true);
			}
			// IE returns a status code of 0 on some occasions, so ignore this case
			else if (req6.status != 0)
			{
				alert("There was an error while 555 retrieving the URL: " + req6.statusText);
			}
		}

		catch (error)
		{
			alert("error");
		}
	}
	else{
	//document.getElementById("news_status").innerHTML="<img src='images/loader.gif' align='center'/>";
	}
	return true;
}



function addproductfeatures1() {
	var numLines =document.getElementById("count_feature1").value;
	var e=document.getElementById("addproductfeatures1");

	var num=numLines;
	var newnum=++num;
	
	var divIdName = "addproductfeatures1"+numLines;
	var newdiv = document.createElement('div');
	newdiv.id = divIdName;
	newdiv.style.display="block";
	
	newdiv.innerHTML="<div style='margin:3px 0 0 0'>"+newnum+") <input type='text' name='product_features[]' value='' size='60' id='product_features"+numLines+"'/></div>";
	
	e.appendChild(newdiv);
	
	
	numLines++;
	document.getElementById("count_feature1").value=numLines;
	
}



function addproductfeatures2() {
	var numLines =document.getElementById("count_feature2").value;
	
	var e=document.getElementById("addproductfeatures2");
	
	var num=numLines;
	var newnum=++num;

	var divIdName = "addproductfeatures2"+numLines;
	var newdiv = document.createElement('div');
	newdiv.id = divIdName;
	newdiv.style.display="block";
	
	newdiv.innerHTML="<div style='margin:3px 0 0 0'>"+newnum+") <input type='text' name='product_features_second[]s' value='' size='60' id='product_features_second"+numLines+"'/></div>";
	
	e.appendChild(newdiv);
	
	numLines++;
	
	document.getElementById("count_feature2").value=numLines;
	
}


function addproductpackaging() {
	var numLines =document.getElementById("count_packaging").value;
	
	var e=document.getElementById("addproductpackaging");
	
	var num=numLines;
	var newnum=++num;
	

	var divIdName = "addproductpackaging"+numLines;
	var newdiv = document.createElement('div');
	newdiv.id = divIdName;
	newdiv.style.display="block";
	
	newdiv.innerHTML="<div style='margin:3px 0 0 0'>"+newnum+") <input type='text' name='product_packaging[]' value='' size='40' id='product_packaging"+numLines+"'/></div>";
	
	
	e.appendChild(newdiv);
	
	
	var f=document.getElementById("addproductprice");
	var divIdName = "addproductprice"+numLines;
	var newdiv = document.createElement('div');
	newdiv.id = divIdName;
	newdiv.style.display="block";
	
	newdiv.innerHTML="<div style='margin:3px 0 0 0'>"+newnum+") <input type='text' name='product_price[]' value='' size='30' id='product_price"+numLines+"'/></div>";
	
	
	
	f.appendChild(newdiv);
	
	
	
	var g=document.getElementById("addproductweight");
	var divIdName = "addproductweight"+numLines;
	var newdiv = document.createElement('div');
	newdiv.id = divIdName;
	newdiv.style.display="block";
	
	newdiv.innerHTML="<div style='margin:3px 0 0 0'>"+newnum+") <input type='text' name='product_weight[]' value='' size='18' id='product_weight"+numLines+"'/>	&nbsp;grams</div>";
	g.appendChild(newdiv);
	
	
	var h=document.getElementById("addproductstock");
	var divIdName = "addproductstock"+numLines;
	var newdiv = document.createElement('div');
	newdiv.id = divIdName;
	newdiv.style.display="block";
	
	newdiv.innerHTML="<div style='margin:3px 0 0 0'>"+newnum+") <select name='product_stock[]' id='product_stock"+numLines+"'><option value='1'>Available</option><option value='0'>Out Of Stock</option></select></div>";
	h.appendChild(newdiv);
	
	numLines++;
	
	document.getElementById("count_packaging").value=numLines;
	
}




function addDescriptionPic() {
	
	
	var e=document.getElementById("AddDescriptionPic");
	parent.document.getElementById("product_pic").style.height=document.body.scrollHeight+40+"px"; 

	var divIdName = "description_pic"+numLines;
	var newdiv = document.createElement('div');
	newdiv.id = divIdName;
	newdiv.style.display="block";
	
	newdiv.innerHTML="<div style='margin:3px 0 0 0'><input type='file' name='description_pic[]' id='description_pic"+numLines+"'/></div>";
	
	
	e.appendChild(newdiv);
	
	
	var numLines =document.getElementById("count_description_pic").value;
	
	
	numLines++;
	document.getElementById("count_description_pic").value=numLines;
	
}


function addDescriptionPics() {
	
	
	var e=document.getElementById("AddDescriptionPic");

	var divIdName = "description_pic"+numLines;
	var newdiv = document.createElement('div');
	newdiv.id = divIdName;
	newdiv.style.display="block";
	
	newdiv.innerHTML="<div style='margin:3px 0 0 0'><input type='file' name='description_pic[]' id='description_pic"+numLines+"'/></div>";
	
	
	e.appendChild(newdiv);
	
	
	var numLines =document.getElementById("count_description_pic").value;
	
	
	numLines++;
	document.getElementById("count_description_pic").value=numLines;
	
}


function loadUploadImage()
{
	if(document.getElementById("product_pic").value=="")
	{
		alert("Please upload your product's picture");
		return false;
	}
	else
	{
		document.getElementById("uploadbar").style.display = 'block';
		return true;
	}
}


function EditProductPic()
{
		parent.document.getElementById("product_pic").style.height=document.body.scrollHeight+110+"px"; 
		document.getElementById("uploadbar").style.display = 'block';
		return true;
}



function deleteProduct(no){
	var a=confirm("Are you sure want to delete this product?");
	if(a) deleteProduct1(no); else return;
}


function deleteProduct1(no){
try
		{
			req5 = new XMLHttpRequest();
		}
		catch (error)
		{
			try
			{
				req5 = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (error)
			{	
				req5 = null;
				return false;
			}
		}
		
		
		url="../adminAction.php?action=deleteProduct&no="+no;

		req5.onreadystatechange = onreadystatechangedeleteProduct;
		req5.open("GET",url,true);
		
		req5.send(null);
		return false;
		
}

function onreadystatechangedeleteProduct(){
	if (req5.readyState == 4)
	{
		// If the data was retrieved successfully
		try
		{
			if (req5.status == 200)
			{
				alert(req5.responseText);
				window.location.reload(true);
			}
			// IE returns a status code of 0 on some occasions, so ignore this case
			else if (req5.status != 0)
			{
				alert("There was an error while 555 retrieving the URL: " + req5.statusText);
			}
		}

		catch (error)
		{
			alert("error");
		}
	}
	else{
	//document.getElementById("news_status").innerHTML="<img src='images/loader.gif' align='center'/>";
	}
	return true;
}


function DeleteProductPic(field,product_id)
{
	answer=confirm("Are you sure you want to delete this image?");

	if(answer)
	{
		 DeleteProductPic1(product_id);
		 Effect.Fade(field);
		 parent.document.getElementById("product_pic").style.height=document.body.scrollHeight-90+"px"; 
		
	}
}

function DeleteProductPic1(product_id){
	
try
		{
			req5 = new XMLHttpRequest();
		}
		catch (error)
		{
			try
			{
				req5 = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (error)
			{	
				req5 = null;
				return false;
			}
		}
		
		
		url="../adminAction.php?action=DeleteProductPic&product_id="+product_id;

		req5.onreadystatechange = onreadystatechangeDeleteProductPic;
		req5.open("GET",url,true);
		
		req5.send(null);
		return false;
		
}

function onreadystatechangeDeleteProductPic(){
	if (req5.readyState == 4)
	{
		// If the data was retrieved successfully
		try
		{
			if (req5.status == 200)
			{
				
			}
			// IE returns a status code of 0 on some occasions, so ignore this case
			else if (req5.status != 0)
			{
				alert("There was an error while 555 retrieving the URL: " + req5.statusText);
			}
		}

		catch (error)
		{
			alert("error");
		}
	}
	else{
	//document.getElementById("news_status").innerHTML="<img src='images/loader.gif' align='center'/>";
	}
	return true;
}





function DeleteProductFeature(field,product_id,height_image)
{
	answer=confirm("Are you sure you want to delete this image?");

	if(answer)
	{
		var height_image=height_image-20;
		 DeleteProductFeature1(product_id);
		 Effect.Fade(field);
		 parent.document.getElementById("product_pic").style.height=document.body.scrollHeight-height_image+"px"; 
		
	}
}





function DeleteProductFeature1(product_id){
	
try
		{
			req5 = new XMLHttpRequest();
		}
		catch (error)
		{
			try
			{
				req5 = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (error)
			{	
				req5 = null;
				return false;
			}
		}
		
		
		url="../adminAction.php?action=DeleteProductFeature1&product_id="+product_id;

		req5.onreadystatechange = onreadystatechangeDeleteProductFeature1;
		req5.open("GET",url,true);
		
		req5.send(null);
		return false;
		
}

function onreadystatechangeDeleteProductFeature1(){
	if (req5.readyState == 4)
	{
		// If the data was retrieved successfully
		try
		{
			if (req5.status == 200)
			{
				
			}
			// IE returns a status code of 0 on some occasions, so ignore this case
			else if (req5.status != 0)
			{
				alert("There was an error while 555 retrieving the URL: " + req5.statusText);
			}
		}

		catch (error)
		{
			alert("error");
		}
	}
	else{
	//document.getElementById("news_status").innerHTML="<img src='images/loader.gif' align='center'/>";
	}
	return true;
}




function DeleteProductFeature2(field,product_id,height_image)
{
	answer=confirm("Are you sure you want to delete this image?");

	if(answer)
	{
		var height_image=height_image-20;
		DeleteProductFeatureSecond(product_id);
		 Effect.Fade(field);
		  parent.document.getElementById("product_pic").style.height=document.body.scrollHeight-height_image+"px"; 
		
	}
}



function DeleteProductFeatureSecond(product_id){
	
try
		{
			req5 = new XMLHttpRequest();
		}
		catch (error)
		{
			try
			{
				req5 = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (error)
			{	
				req5 = null;
				return false;
			}
		}
		
		
		url="../adminAction.php?action=DeleteProductFeatureSecond&product_id="+product_id;

		req5.onreadystatechange = onreadystatechangeDeleteProductFeatureSecond;
		req5.open("GET",url,true);
		
		req5.send(null);
		return false;
		
}

function onreadystatechangeDeleteProductFeatureSecond(){
	if (req5.readyState == 4)
	{
		// If the data was retrieved successfully
		try
		{
			if (req5.status == 200)
			{
				
			}
			// IE returns a status code of 0 on some occasions, so ignore this case
			else if (req5.status != 0)
			{
				alert("There was an error while 555 retrieving the URL: " + req5.statusText);
			}
		}

		catch (error)
		{
			alert("error");
		}
	}
	else{
	//document.getElementById("news_status").innerHTML="<img src='images/loader.gif' align='center'/>";
	}
	return true;
}


function DeleteDescriptionImage(field,product_id)
{
	answer=confirm("Are you sure you want to delete this image?");

	if(answer)
	{
		var height_image=height_image-20;
		DeleteDescriptionImage1(product_id,field);
		 Effect.Fade("description_img_field"+field);
		
	}
}




function DeleteDescriptionImage1(product_id,field){
try
		{
			req5 = new XMLHttpRequest();
		}
		catch (error)
		{
			try
			{
				req5 = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (error)
			{	
				req5 = null;
				return false;
			}
		}
		
		
		url="../adminAction.php?action=DeleteDescriptionImage&field="+field+"&product_id="+product_id;

		req5.onreadystatechange = onreadystatechangeDeleteDescriptionImage;
		req5.open("GET",url,true);
		
		req5.send(null);
		return false;
		
}

function onreadystatechangeDeleteDescriptionImage(){
	if (req5.readyState == 4)
	{
		// If the data was retrieved successfully
		try
		{
			if (req5.status == 200)
			{
				
			}
			// IE returns a status code of 0 on some occasions, so ignore this case
			else if (req5.status != 0)
			{
				alert("There was an error while 555 retrieving the URL: " + req5.statusText);
			}
		}

		catch (error)
		{
			alert("error");
		}
	}
	else{
	//document.getElementById("news_status").innerHTML="<img src='images/loader.gif' align='center'/>";
	}
	return true;
}



function UpdateShoppingCart(packid)
{

	var packid=document.getElementById("pack_id"+packid).value;
	var qty=document.getElementById("qty"+packid).value;
	var productid=document.getElementById("product_id"+packid).value;
	

		if (IsNumeric(qty) == false)
		{
		  document.getElementById("qty"+packid).value=1;
		  qty=1;
		}
	if(document.getElementById("pack_id"+packid).checked==true)
	{
		UpdateShoppingCart1(packid,qty,"checked",productid);	
	}
	else if(document.getElementById("pack_id"+packid).checked==false)
	{
		UpdateShoppingCart1(packid,qty,"unchecked",productid);	
	}
}


function changeusdcurrency(currency){
if (IsNumeric(currency) == false && currency!="")
{
	alert("Please insert number only");
	
}
else {
try
		{
			req6 = new XMLHttpRequest();
		}
		catch (error)
		{
			try
			{
				req6 = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (error)
			{	
				req6 = null;
				return false;
			}
		}
		
		
		url="/adminAction.php?action=changeusdcurrency&currency="+currency;

		req6.onreadystatechange = onreadystatechangechangeusdcurrency;
		req6.open("GET",url,true);
		
		req6.send(null);
		return false;
}
}

function onreadystatechangechangeusdcurrency(){
	if (req6.readyState == 4)
	{
		// If the data was retrieved successfully
		try
		{
			if (req6.status == 200)
			{
				document.getElementById("usdcurrency").innerHTML=req6.responseText;
			}
			// IE returns a status code of 0 on some occasions, so ignore this case
			else if (req6.status != 0)
			{
				alert("There was an error while 555 retrieving the URL: " + req6.statusText);
			}
		}

		catch (error)
		{
			alert("error");
		}
	}
	else{
		document.getElementById("usdcurrency").innerHTML="<img src='../images/slimbox/loading.gif' align='center'/>";
	}
	return true;
}



function changesgdcurrency(currency){
if (IsNumeric(currency) == false && currency!="")
{
	alert("Please insert number only");
	
}
else {
try
		{
			req6 = new XMLHttpRequest();
		}
		catch (error)
		{
			try
			{
				req6 = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (error)
			{	
				req6 = null;
				return false;
			}
		}
		
		
		url="/adminAction.php?action=changesgdcurrency&currency="+currency;

		req6.onreadystatechange = onreadystatechangechangesgdcurrency;
		req6.open("GET",url,true);
		
		req6.send(null);
		return false;
}
}

function onreadystatechangechangesgdcurrency(){
	if (req6.readyState == 4)
	{
		// If the data was retrieved successfully
		try
		{
			if (req6.status == 200)
			{
				document.getElementById("sgdcurrency").innerHTML=req6.responseText;
			}
			// IE returns a status code of 0 on some occasions, so ignore this case
			else if (req6.status != 0)
			{
				alert("There was an error while 555 retrieving the URL: " + req6.statusText);
			}
		}

		catch (error)
		{
			alert("error");
		}
	}
	else{
		document.getElementById("sgdcurrency").innerHTML="<img src='../images/slimbox/loading.gif' align='center'/>";
	}
	return true;
}




function changegbpcurrency(currency){
if (IsNumeric(currency) == false && currency!="")
{
	alert("Please insert number only");
	
}
else {
try
		{
			req6 = new XMLHttpRequest();
		}
		catch (error)
		{
			try
			{
				req6 = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (error)
			{	
				req6 = null;
				return false;
			}
		}
		
		
		url="/adminAction.php?action=changegbpcurrency&currency="+currency;

		req6.onreadystatechange = onreadystatechangechangegbpcurrency;
		req6.open("GET",url,true);
		
		req6.send(null);
		return false;
}
}

function onreadystatechangechangegbpcurrency(){
	if (req6.readyState == 4)
	{
		// If the data was retrieved successfully
		try
		{
			if (req6.status == 200)
			{
				document.getElementById("gbpcurrency").innerHTML=req6.responseText;
			}
			// IE returns a status code of 0 on some occasions, so ignore this case
			else if (req6.status != 0)
			{
				alert("There was an error while 555 retrieving the URL: " + req6.statusText);
			}
		}

		catch (error)
		{
			alert("error");
		}
	}
	else{
		document.getElementById("gbpcurrency").innerHTML="<img src='../images/slimbox/loading.gif' align='center'/>";
	}
	return true;
}



function UpdateShoppingCartQuantity(packid)
{
	var packid=document.getElementById("pack_id"+packid).value;
	var qty=document.getElementById("qty"+packid).value;
	var productid=document.getElementById("product_id"+packid).value;
	
	document.getElementById("pack_id"+packid).checked=true;
	
	if(qty!="") {
		if (IsNumeric(qty) == false)
		{
		  document.getElementById("qty"+packid).value=1;
		  qty=1;
		}
	}
	if(document.getElementById("pack_id"+packid).checked==true)
	{
		UpdateShoppingCart1(packid,qty,"checked",productid);	
	}
	else if(document.getElementById("pack_id"+packid).checked==false)
	{
		UpdateShoppingCart1(packid,qty,"unchecked",productid);	
	}
}


function IsNumeric(strString)
   //  check for valid numeric strings 
   {
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }
   
   
   
 
function UpdateShoppingCart1(packid,qty,status,productid){
try
		{
			req6 = new XMLHttpRequest();
		}
		catch (error)
		{
			try
			{
				req6 = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (error)
			{	
				req6 = null;
				return false;
			}
		}
		
		
		url="adminAction.php?action=UpdateShoppingCart&qty="+qty+"&productid="+productid+"&status="+status+"&packid="+packid;

		req6.onreadystatechange = onreadystatechangeUpdateShoppingCart1;
		req6.open("GET",url,true);
		
		req6.send(null);
		return false;
		
}

function onreadystatechangeUpdateShoppingCart1(){
	if (req6.readyState == 4)
	{
		// If the data was retrieved successfully
		try
		{
			if (req6.status == 200)
			{
				
				document.getElementById("current_order").innerHTML=req6.responseText;
			}
			// IE returns a status code of 0 on some occasions, so ignore this case
			else if (req6.status != 0)
			{
				alert("There was an error while 555 retrieving the URL: " + req6.statusText);
			}
		}

		catch (error)
		{
			alert("error");
		}
	}
	else{
	document.getElementById("current_order").innerHTML="<img src='../images/slimbox/loading.gif' align='center'/>";
	}
	return true;
}


function DeleteOrder(no){
	var a=confirm("Are you sure want to delete this order?");
	if(a) DeleteOrder1(no); else return;
}



function DeleteOrder1(orderno){
	
try
		{
			req7 = new XMLHttpRequest();
		}
		catch (error)
		{
			try
			{
				req7 = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (error)
			{	
				req7 = null;
				return false;
			}
		}
		
		
		url="../adminAction.php?action=DeleteOrder&orderno="+orderno;

		req7.onreadystatechange = onreadystatechangeDeleteOrder;
		req7.open("GET",url,true);
		
		req7.send(null);
		return false;
		
}

function onreadystatechangeDeleteOrder(){
	if (req7.readyState == 4)
	{
		// If the data was retrieved successfully
		try
		{
			if (req7.status == 200)
			{
				alert(req7.responseText);
				window.location.reload(true);
			}
			// IE returns a status code of 0 on some occasions, so ignore this case
			else if (req7.status != 0)
			{
				alert("There was an error while 555 retrieving the URL: " + req7.statusText);
			}
		}

		catch (error)
		{
			alert("error");
		}
	}
	else{
	//document.getElementById("news_status").innerHTML="<img src='images/loader.gif' align='center'/>";
	}
	return true;
}
