function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}





function addToWishlist(prod_id,member_id){
	xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
 
	document.getElementById("wishlist").style.backgroundColor='LemonChiffon';


 	var url="../../../../ajax/addToWishlist.php"
	url=url+"?sid="+Math.random()
	url=url+"&prod_id="+prod_id
	url=url+"&member_id="+member_id


xmlHttp.onreadystatechange=wishlistingUpdate 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
	
}

function wishlistingUpdate() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
	  var returnedValues = xmlHttp.responseText;
	  alert(returnedValues);
	document.getElementById("wishlist").style.backgroundColor='white';
	document.getElementById("wishlist").innerHTML='Added to Wishlist';

 } 
}




function changeCatStatus(row_id,cat_id,cat_type){
	xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
 
	document.getElementById("row_"+row_id).style.backgroundColor='LemonChiffon';
	var cat_status = document.getElementById("status_"+row_id).attributes.name.value ;


 	var url="../ajax/change_cat_status.php"
	url=url+"?sid="+Math.random()
	url=url+"&row_id="+row_id
	url=url+"&cat_id="+cat_id
	url=url+"&cat_type="+cat_type
	url=url+"&cat_status="+cat_status


xmlHttp.onreadystatechange=catstatusUpdate 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
	
}

function catstatusUpdate() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
	  var returnedValues = xmlHttp.responseText.split(",");
       var row_id = "row_"+returnedValues[1];
	  
	  if(returnedValues[2] == 1) {
 	  document.getElementById("status_"+returnedValues[1]).innerHTML='LIVE';
 	  document.getElementById("status_"+returnedValues[1]).style.color='green';
 	  document.getElementById("status_"+returnedValues[1]).setAttribute('name','0');
	  }
	  if(returnedValues[2] == 0) {
 	  document.getElementById("status_"+returnedValues[1]).innerHTML='INACTIVE';
 	  document.getElementById("status_"+returnedValues[1]).style.color='red';
 	  document.getElementById("status_"+returnedValues[1]).setAttribute('name','1');
	  }
	document.getElementById(row_id).style.backgroundColor='white';

 } 
}





function updateCatName(row_id,cat_id,cat_type){
	xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
 
	document.getElementById("row_"+row_id).style.backgroundColor='LemonChiffon';
	document.getElementById("update_"+row_id).value='Wait';
	var cat_name = document.getElementById("cat_box_"+row_id).value ;


 	var url="../ajax/change_cat_name.php"
	url=url+"?sid="+Math.random()
	url=url+"&row_id="+row_id
	url=url+"&cat_id="+cat_id
	url=url+"&cat_type="+cat_type
	url=url+"&cat_name="+cat_name

xmlHttp.onreadystatechange=catNameUpdate 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
	
}

function catNameUpdate() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
	  var returnedValues = xmlHttp.responseText.split(",");
       var row_id = "row_"+returnedValues[1];


	document.getElementById(row_id).style.backgroundColor='white';
	document.getElementById("update_"+returnedValues[1]).value='Edit';

 } 
}






function delCat(row_id,cat_id,cat_type){
	xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
 
	document.getElementById("row_"+row_id).style.backgroundColor='LemonChiffon';
	
	//var cat = document.getElementById(buy_box).value;
	//var price2 = document.getElementById(sell_box).value;
	//var delivery = document.getElementById(delivery).value;
	var url="../ajax/del_cat.php"
	url=url+"?sid="+Math.random()
	url=url+"&row_id="+row_id
	url=url+"&cat_id="+cat_id
	url=url+"&cat_type="+cat_type
	
	//url=url+"&buy_box="+price1
	//url=url+"&sell_box="+price2
	//url=url+"&delivery="+delivery
	//url=url+"&prod_id="+prod_id
	

xmlHttp.onreadystatechange=delUpdate 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
	
}

function delUpdate() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
	  var returnedValues = xmlHttp.responseText.split(",");
       var row_id = "row_"+returnedValues[0];
 	 // document.getElementById(done_id).innerHTML=thecode;
	document.getElementById(row_id).style.display='none';

 } 
}







function changeCatOrder(cat_order,cat_type){
	xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
 
 	var url="../ajax/change_cat_order.php"
	url=url+"?sid="+Math.random()
	url=url+"&order="+cat_order
	url=url+"&cat_type="+cat_type


xmlHttp.onreadystatechange=catOrderUpdate 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
	
}

function catOrderUpdate() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
	  var returnedValues = xmlHttp.responseText.split(",");
       var row_id = "row_"+returnedValues[1];

 } 
}












function moveCat(dropper_id,row_id,cat_id){
	xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
 
	document.getElementById("row_"+row_id).style.backgroundColor='LemonChiffon';
 

 	var url="../ajax/move_cat.php"
	url=url+"?sid="+Math.random()
	url=url+"&dropper_id="+dropper_id
	url=url+"&row_id="+row_id
	url=url+"&cat_id="+cat_id


xmlHttp.onreadystatechange=movecatdoUpdate 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
	
}

function movecatdoUpdate() 
{ 

if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
	 var returnedValues = xmlHttp.responseText;
      var row_id = "row_"+returnedValues;
  	document.getElementById("status_"+returnedValues).innerHTML='MOVING';
 	 document.getElementById("status_"+returnedValues).style.color='blue';
	
	 document.getElementById(row_id).style.backgroundColor='white';
	setTimeout("hiderow("+returnedValues+")", 3000);
 
 	
 }
}


function hiderow(row_id){

document.getElementById('row_'+row_id).style.display='none';	
}








function changeProdStatus(row_id,prod_id){
	xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
 
	document.getElementById("row_"+row_id).style.backgroundColor='LemonChiffon';
	var prod_status = document.getElementById("status_"+row_id).attributes.name.value ;


 	var url="../ajax/change_prod_status.php"
	url=url+"?sid="+Math.random()
	url=url+"&row_id="+row_id
	url=url+"&prod_id="+prod_id
 	url=url+"&prod_status="+prod_status

xmlHttp.onreadystatechange=prodstatusUpdate 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
	
}

function prodstatusUpdate() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
	  var returnedValues = xmlHttp.responseText.split(",");
       var row_id = "row_"+returnedValues[1];
	  
	  if(returnedValues[2] == 1) {
 	  document.getElementById("status_"+returnedValues[1]).innerHTML='LIVE';
 	  document.getElementById("status_"+returnedValues[1]).style.color='green';
 	  document.getElementById("status_"+returnedValues[1]).setAttribute('name','0');
	  }
	  if(returnedValues[2] == 0) {
 	  document.getElementById("status_"+returnedValues[1]).innerHTML='INACTIVE';
 	  document.getElementById("status_"+returnedValues[1]).style.color='red';
 	  document.getElementById("status_"+returnedValues[1]).setAttribute('name','1');
	  }
	document.getElementById(row_id).style.backgroundColor='white';

 } 
}








function changeMembMarketing(row_id,memb_id){
	xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
 
	document.getElementById("row_"+row_id).style.backgroundColor='LemonChiffon';
	var marketing = document.getElementById("marketing_"+row_id).attributes.name.value ;


 	var url="../ajax/change_memb_marketing.php"
	url=url+"?sid="+Math.random()
	url=url+"&row_id="+row_id
	url=url+"&memb_id="+memb_id
 	url=url+"&marketing="+marketing
	

xmlHttp.onreadystatechange=membmarketingUpdate 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
	
}

function membmarketingUpdate() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
	  var returnedValues = xmlHttp.responseText.split(",");
       var row_id = "row_"+returnedValues[1];
	   
	  if(returnedValues[2] == 1) {
 	  document.getElementById("marketing_"+returnedValues[1]).innerHTML='Yes';
 	  document.getElementById("marketing_"+returnedValues[1]).style.color='green';
 	  document.getElementById("marketing_"+returnedValues[1]).setAttribute('name','0');
	  }
	  if(returnedValues[2] == 0) {
 	  document.getElementById("marketing_"+returnedValues[1]).innerHTML='No';
 	  document.getElementById("marketing_"+returnedValues[1]).style.color='red';
 	  document.getElementById("marketing_"+returnedValues[1]).setAttribute('name','1');
	  }
	  if(returnedValues[1] == 0) {
	document.getElementById(row_id).style.backgroundColor='#FAE2E2';
	  } else {
	document.getElementById(row_id).style.backgroundColor='white';
	  }

 } 
}





function changeMembActivate(row_id,memb_id){
	xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
 
	document.getElementById("row_"+row_id).style.backgroundColor='LemonChiffon';
	var activate = document.getElementById("activate_"+row_id).attributes.name.value ;


 	var url="../ajax/change_memb_activate.php"
	url=url+"?sid="+Math.random()
	url=url+"&row_id="+row_id
	url=url+"&memb_id="+memb_id
 	url=url+"&activate="+activate

xmlHttp.onreadystatechange=membactivateUpdate 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
	
}

function membactivateUpdate() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
	  var returnedValues = xmlHttp.responseText.split(",");
       var row_id = "row_"+returnedValues[1];
	  
	  if(returnedValues[2] == 1) {
 	  document.getElementById("activate_"+returnedValues[1]).innerHTML='LIVE';
 	  document.getElementById("activate_"+returnedValues[1]).style.color='green';
 	  document.getElementById("activate_"+returnedValues[1]).setAttribute('name','0');
	  }
	  if(returnedValues[2] == 0) {
 	  document.getElementById("activate_"+returnedValues[1]).innerHTML='INACTIVE';
 	  document.getElementById("activate_"+returnedValues[1]).style.color='red';
 	  document.getElementById("activate_"+returnedValues[1]).setAttribute('name','1');
	  }
	document.getElementById(row_id).style.backgroundColor='white';

 } 
}














function changeProdBest(row_id,prod_id){
	xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
 
	document.getElementById("row_"+row_id).style.backgroundColor='LemonChiffon';
	var best = document.getElementById("best_"+row_id).attributes.name.value ;


 	var url="../ajax/change_prod_best.php"
	url=url+"?sid="+Math.random()
	url=url+"&row_id="+row_id
	url=url+"&prod_id="+prod_id
 	url=url+"&best="+best

xmlHttp.onreadystatechange=prodbestUpdate 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
	
}

function prodbestUpdate() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
	  var returnedValues = xmlHttp.responseText.split(",");
       var row_id = "row_"+returnedValues[1];
	  
	  if(returnedValues[2] == 0) {
 	  document.getElementById("best_"+returnedValues[1]).innerHTML='-----';
 	  document.getElementById("best_"+returnedValues[1]).style.color='grey';
 	  document.getElementById("best_"+returnedValues[1]).setAttribute('name','1');
	  }
	  if(returnedValues[2] == 1) {
 	  document.getElementById("best_"+returnedValues[1]).innerHTML='YES';
 	  document.getElementById("best_"+returnedValues[1]).style.color='green';
 	  document.getElementById("best_"+returnedValues[1]).setAttribute('name','0');
	  }
	document.getElementById(row_id).style.backgroundColor='white';

 } 
}
















function changeProdFeatured(row_id,prod_id){
	xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
 
	document.getElementById("row_"+row_id).style.backgroundColor='LemonChiffon';
	var featured = document.getElementById("featured_"+row_id).attributes.name.value ;


 	var url="../ajax/change_prod_featured.php";
	url=url+"?sid="+Math.random()
	url=url+"&row_id="+row_id
	url=url+"&prod_id="+prod_id
 	url=url+"&featured="+featured
xmlHttp.onreadystatechange=prodfeaturedUpdate 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function prodfeaturedUpdate() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
	  var returnedValues = xmlHttp.responseText.split(",");
       var row_id = "row_"+returnedValues[1];
	   
	  if(returnedValues[2] == 0) {
 	  document.getElementById("featured_"+returnedValues[1]).innerHTML='-----';
 	  document.getElementById("featured_"+returnedValues[1]).style.color='grey';
 	  document.getElementById("featured_"+returnedValues[1]).setAttribute('name','1');
	  }
	  if(returnedValues[2] == 1) {
 	  document.getElementById("featured_"+returnedValues[1]).innerHTML='YES';
 	  document.getElementById("featured_"+returnedValues[1]).style.color='green';
 	  document.getElementById("featured_"+returnedValues[1]).setAttribute('name','0');
	  }
	document.getElementById(row_id).style.backgroundColor='white';

 } 
}











function changeProdPrice(row_id,prod_id){

	xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
 
	document.getElementById("row_"+row_id).style.backgroundColor='LemonChiffon';
	document.getElementById("edit_"+row_id).value='Wait';
	var price = document.getElementById("price_"+row_id).value ;


 	var url="../ajax/change_prod_price.php"
	url=url+"?sid="+Math.random()
	url=url+"&row_id="+row_id
	url=url+"&prod_id="+prod_id
 	url=url+"&price="+price


xmlHttp.onreadystatechange=priceUpdate 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function priceUpdate() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
	  var returnedValues = xmlHttp.responseText.split(",");
       var row_id = "row_"+returnedValues[1];
	  
	document.getElementById(row_id).style.backgroundColor='white';
	 document.getElementById("edit_"+returnedValues[1]).value='Done';
	document.getElementById("edit_"+returnedValues[1]).style.color='blue';
	setTimeout("resetButton("+returnedValues[1]+")", 1500);

 } 
}

function resetButton(row_id){

	document.getElementById("edit_"+row_id).value='Update';
	document.getElementById("edit_"+row_id).style.color='black';
 
}















function changeProdStock(row_id,prod_id){

	xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
 
	document.getElementById("row_"+row_id).style.backgroundColor='LemonChiffon';
	document.getElementById("edit_"+row_id).value='Wait';
	var stock = document.getElementById("stock_"+row_id).value ;


 	var url="../ajax/change_prod_stock.php"
	url=url+"?sid="+Math.random()
	url=url+"&row_id="+row_id
	url=url+"&prod_id="+prod_id
 	url=url+"&stock="+stock


xmlHttp.onreadystatechange=stockUpdate 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function stockUpdate() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
	  var returnedValues = xmlHttp.responseText.split(",");
       var row_id = "row_"+returnedValues[1];


	document.getElementById(row_id).style.backgroundColor='white';
	document.getElementById("edit_"+returnedValues[1]).value='Done';
	document.getElementById("edit_"+returnedValues[1]).style.color='blue';
	setTimeout("resetButton("+returnedValues[1]+")", 1500);

 } 
}

function resetButton(row_id){

	document.getElementById("edit_"+row_id).value='Update';
	document.getElementById("edit_"+row_id).style.color='black';
}




