var xmlHttp;

function createXMLHttpRequest()
{
	//if we are using MSIE, use the MSIE class
	if(window.ActiveXObject)
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	//Firefox, Opera, Safari, etc use this to start a XMLHttp Request
	else if(window.XMLHttpRequest)
	{
		xmlHttp = new XMLHttpRequest;
	}
}


function admin_noti(number)
{
	if (confirm("Are you sure?"))
	{
		change = number;
		createXMLHttpRequest();
		xmlHttp.onreadystatechange = admin_noti_change;
		//request the file
		url = "?noti=" + number;
		xmlHttp.open("GET", url, true);
		xmlHttp.send(null);
	}
}

function admin_noti_change()
{
	if(xmlHttp.readyState == 4)
	{

		if(xmlHttp.status == 200)
		{
			document.getElementById(change).innerHTML = xmlHttp.responseText;
		}
	}
}

function reissue_pass(number)
{
	if (confirm("Are you sure you want to re-issue a new password to customer (" + number + ")? It can't be undone. Customer will be emailed with new details"))
	{
		change = number;
		createXMLHttpRequest();
		xmlHttp.onreadystatechange = reissue_pass_change;
		//request the file
		url = "&reissue=" + number;
		xmlHttp.open("GET", url, true);
		xmlHttp.send(null);
	}
}

function reissue_pass_change()
{
	if(xmlHttp.readyState == 4)
	{

		if(xmlHttp.status == 200)
		{
			document.getElementById(change).innerHTML = xmlHttp.responseText;
		}
	}
}


function remove_sidebanner(number)
{
	if (confirm("Are you sure you want to delete this Banner (" + number + ")? It can't be undone."))
	{
		change = number;
		createXMLHttpRequest();
		xmlHttp.onreadystatechange = remove_sidebanner_change;
		//request the file
		url = "?remove=" + number;
		xmlHttp.open("GET", url, true);
		xmlHttp.send(null);
	}
}

function remove_sidebanner_change()
{
	if(xmlHttp.readyState == 4)
	{

		if(xmlHttp.status == 200)
		{
			document.getElementById(change).innerHTML = xmlHttp.responseText;
		}
	}
}

function banner_reorder(number, reorder)
{

		change = number;
		createXMLHttpRequest();
		xmlHttp.onreadystatechange = product_reorder_change;
		//request the file
		url = "?banner_id=" + number + "&reorder=" + reorder;
		xmlHttp.open("GET", url, true);
		xmlHttp.send(null);

}

function update_publish(number)
{

	change = number;
	change1 = "update" + change;
	createXMLHttpRequest();
	xmlHttp.onreadystatechange = update_publish_change;

	

	var comment = document.getElementById(change1).value;

	
	
	
	//request the file
	url = "?publish=" + number;
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}
function update_publish_change()
{
	if(xmlHttp.readyState == 4)
	{

		if(xmlHttp.status == 200)
		{
			document.getElementById(change1).innerHTML = xmlHttp.responseText;
		}
	}
}


function remove_cat(number)
{
	if (confirm("Are you sure you want to delete this Category (" + number + ")? It can't be undone."))
	{
		change = number;
		createXMLHttpRequest();
		xmlHttp.onreadystatechange = remove_cat_change;
		//request the file
		url = "?remove=" + number;
		xmlHttp.open("GET", url, true);
		xmlHttp.send(null);
	}
}

function remove_cat_change()
{
	if(xmlHttp.readyState == 4)
	{

		if(xmlHttp.status == 200)
		{
			document.getElementById(change).innerHTML = xmlHttp.responseText;
		}
	}
}


function remove_prod(number)
{
	if (confirm("Are you sure you want to delete this Product (" + number + ")? It can't be undone."))
	{
		change = number;
		createXMLHttpRequest();
		xmlHttp.onreadystatechange = remove_cat_change;
		//request the file
		url = "?remove=" + number;
		xmlHttp.open("GET", url, true);
		xmlHttp.send(null);
	}
}

function remove_prod_change()
{
	if(xmlHttp.readyState == 4)
	{

		if(xmlHttp.status == 200)
		{
			document.getElementById(change).innerHTML = xmlHttp.responseText;
		}
	}
}

function remove_prod_option(number)
{
	if (confirm("Are you sure you want to delete this Option (" + number + ")? It can't be undone."))
	{
		change = number;
		createXMLHttpRequest();
		xmlHttp.onreadystatechange = remove_prod_option_change;
		//request the file
		url = "&remove=" + number;
		xmlHttp.open("GET", url, true);
		xmlHttp.send(null);
	}
}

function remove_prod_option_change()
{
	if(xmlHttp.readyState == 4)
	{

		if(xmlHttp.status == 200)
		{
			document.getElementById(change).innerHTML = xmlHttp.responseText;
		}
	}
}
function product_reorder(number, reorder)
{

		change = number;
		createXMLHttpRequest();
		xmlHttp.onreadystatechange = product_reorder_change;
		//request the file
		url = "&option_id=" + number + "&reorder=" + reorder;
		xmlHttp.open("GET", url, true);
		xmlHttp.send(null);

}

function product_reorder_change()
{
	if(xmlHttp.readyState == 4)
	{

		if(xmlHttp.status == 200)
		{
			location.reload(true);
			//document.getElementById(change).innerHTML = xmlHttp.responseText;
		}
	}
}

function option_update_price(number, price)
{

		change = number;
		createXMLHttpRequest();
		xmlHttp.onreadystatechange = product_reorder_change;
		//request the file
		url = "&option_id=" + number + "&price=" + price;
		xmlHttp.open("GET", url, true);
		xmlHttp.send(null);

}

function remove_prod_image(number)
{
	if (confirm("Are you sure you want to delete this Image (" + number + ")? It can't be undone."))
	{
		change = number;
		createXMLHttpRequest();
		xmlHttp.onreadystatechange = remove_prod_option_change;
		//request the file
		url = "&remove=" + number;
		xmlHttp.open("GET", url, true);
		xmlHttp.send(null);
	}
}

function image_reorder(number, reorder)
{

		change = number;
		createXMLHttpRequest();
		xmlHttp.onreadystatechange = product_reorder_change;
		//request the file
		url = "&image_id=" + number + "&reorder=" + reorder;
		xmlHttp.open("GET", url, true);
		xmlHttp.send(null);

}

function remove_page(number)
{
	if (confirm("Are you sure you want to delete this Page (" + number + ")? It can't be undone."))
	{
		change = number;
		createXMLHttpRequest();
		xmlHttp.onreadystatechange = remove_prod_option_change;
		//request the file
		url = "?remove=" + number;
		xmlHttp.open("GET", url, true);
		xmlHttp.send(null);
	}
}

function page_reorder(number, reorder)
{

		change = number;
		createXMLHttpRequest();
		xmlHttp.onreadystatechange = product_reorder_change;
		//request the file
		url = "?page_id=" + number + "&reorder=" + reorder;
		xmlHttp.open("GET", url, true);
		xmlHttp.send(null);

}

function remove_option_extra_link(number)
{
	if (confirm("Are you sure you want to delete this Option EXTRA (" + number + ")? It can't be undone."))
	{
		change = number;
		createXMLHttpRequest();
		xmlHttp.onreadystatechange = remove_prod_option_change;
		//request the file
		url = "&remove=" + number;
		xmlHttp.open("GET", url, true);
		xmlHttp.send(null);
	}
}

function link_update_price(number, price)
{

		change = number;
		createXMLHttpRequest();
		xmlHttp.onreadystatechange = product_reorder_change;
		//request the file
		url = "&link_id=" + number + "&price=" + price;
		xmlHttp.open("GET", url, true);
		xmlHttp.send(null);

}

function extra_update_text(number, text_details)
{

		change = number;
		createXMLHttpRequest();
		xmlHttp.onreadystatechange = product_reorder_change;
		//request the file
		url = "?extra_id=" + number + "&name=" + text_details;
		xmlHttp.open("GET", url, true);
		xmlHttp.send(null);

}

function remove_extra_listing(number)
{
	if (confirm("Are you sure you want to delete this Option Extra (" + number + ")? It can't be undone."))
	{
		change = number;
		createXMLHttpRequest();
		xmlHttp.onreadystatechange = remove_prod_option_change;
		//request the file
		url = "?remove=" + number;
		xmlHttp.open("GET", url, true);
		xmlHttp.send(null);
	}
}
///issue tracker update con
function collection_con(number)
{
		change = number;
		createXMLHttpRequest();
		xmlHttp.onreadystatechange = collection_con_update;
		//request the file
		url = "?con_update=" + number;
		xmlHttp.open("GET", url, true);
		xmlHttp.send(null);
}

function collection_con_clear()
{
		createXMLHttpRequest();
		xmlHttp.onreadystatechange = collection_con_update;
		//request the file
		url = "?con_clear=";
		xmlHttp.open("GET", url, true);
		xmlHttp.send(null);
}

function collection_con_update()
{
	if(xmlHttp.readyState == 4)
	{

		if(xmlHttp.status == 200)
		{
			document.getElementById("updatecon").innerHTML = xmlHttp.responseText;
		}
	}
}

function collection_con_save(number, con)
{
		state = number;
		var con = document.getElementById('con').value;
		consignment = con;
		createXMLHttpRequest();
		xmlHttp.onreadystatechange = collection_con_save_update;
		//request the file
		url = "?con_update_save=" + state + "&con=" + consignment;
		xmlHttp.open("GET", url, true);
		xmlHttp.send(null);
}

function collection_con_save_update()
{
	if(xmlHttp.readyState == 4)
	{

		if(xmlHttp.status == 200)
		{
			document.getElementById("consignment" + state).innerHTML = xmlHttp.responseText;
			collection_con_clear();
		}
	}
}
////
///issue tracker update CR and CH invoice number
function creditcharge_inv(number, type)
{
		change = number;
		type = type;
		createXMLHttpRequest();
		xmlHttp.onreadystatechange = collection_con_update;
		//request the file
		url = "?inv_update=" + number + "&type=" + type;
		xmlHttp.open("GET", url, true);
		xmlHttp.send(null);
}
function creditcharge_inv_update()
{
	if(xmlHttp.readyState == 4)
	{

		if(xmlHttp.status == 200)
		{
			document.getElementById("updatecon").innerHTML = xmlHttp.responseText;
		}
	}
}
function chargecredit_inv_save(number, type)
{
		state = number;
		itype = type;
		var inv2 = document.getElementById('inv').value;
		createXMLHttpRequest();
		xmlHttp.onreadystatechange = chargecredit_inv_save_update;
		//request the file
		url = "?inv_update_save=" + state + "&inv=" + inv2 + "&type=" + itype;
		xmlHttp.open("GET", url, true);
		xmlHttp.send(null);
}

function chargecredit_inv_save_update()
{
	if(xmlHttp.readyState == 4)
	{

		if(xmlHttp.status == 200)
		{
			document.getElementById("new_invoice" + state + "" + itype).innerHTML = xmlHttp.responseText;
			collection_con_clear();
		}
	}
}
////////
///issue tracker update Claim ref number
function claim_ref(number, type)
{
		change = number;
		type = type;
		createXMLHttpRequest();
		xmlHttp.onreadystatechange = collection_con_update;
		//request the file
		url = "?claim_update=" + number + "&type=" + type;
		xmlHttp.open("GET", url, true);
		xmlHttp.send(null);
}
function claim_ref_update()
{
	if(xmlHttp.readyState == 4)
	{

		if(xmlHttp.status == 200)
		{
			document.getElementById("updatecon").innerHTML = xmlHttp.responseText;
		}
	}
}
function claim_ref_save(number)
{
		state = number;
		var ref2 = document.getElementById('ref').value;
		createXMLHttpRequest();
		xmlHttp.onreadystatechange = claim_ref_save_update;
		//request the file
		url = "?claim_ref_save=" + state + "&ref=" + ref2;
		xmlHttp.open("GET", url, true);
		xmlHttp.send(null);
}

function claim_ref_save_update()
{
	if(xmlHttp.readyState == 4)
	{

		if(xmlHttp.status == 200)
		{
			document.getElementById("claim" + state).innerHTML = xmlHttp.responseText;
			collection_con_clear();
		}
	}
}
////////
/************************/
//Mark Collection as collected
/************************/
function collection_collected(number)
{
		change = number;
		createXMLHttpRequest();
		xmlHttp.onreadystatechange = collection_collected_update;
		//request the file
		url = "?collected=" + number;
		xmlHttp.open("GET", url, true);
		xmlHttp.send(null);

}
function collection_collected_update()
{
	if(xmlHttp.readyState == 4)
	{

		if(xmlHttp.status == 200)
		{
			//location.reload(true);
			document.getElementById("collected" + change).innerHTML = xmlHttp.responseText;
		}
	}
}
/************************/
//Mark Collection as returned
/************************/
function collection_returned(number)
{
	if (confirm("If you marked this as returned, it will use TODAYs date and will mark the status of this as COMPLETE."))
	{
		change = number;
		createXMLHttpRequest();
		xmlHttp.onreadystatechange = collection_returned_update;
		//request the file
		url = "?returned=" + number;
		xmlHttp.open("GET", url, true);
		xmlHttp.send(null);
	}
}
function collection_returned_update()
{
	if(xmlHttp.readyState == 4)
	{

		if(xmlHttp.status == 200)
		{
			//location.reload(true);
			document.getElementById("returned" + change).innerHTML = xmlHttp.responseText;
		}
	}
}
