function changeBackground(pObj) {
	var obj = pObj;
	if (obj.style.backgroundColor == "rgb(207, 227, 235)" || obj.style.backgroundColor == "#cfe3eb") {
		obj.style.backgroundColor = "#FFFFFF";
	} else {
		obj.style.backgroundColor = "#CFE3EB";
	}
}

var xmlHttp
var url
var featuresDesc = new Array()

function stateChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
		if (xmlHttp.status == 200) {
			document.getElementById("ajaxContent").innerHTML=xmlHttp.responseText
		}
	}
} 

function GetXmlHttpObject()
{ 
	var objXMLHttp=null
	if (window.XMLHttpRequest)
	{
	objXMLHttp=new XMLHttpRequest()
	}
	else if (window.ActiveXObject)
	{
	objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
	return objXMLHttp
}

function getNews(id) {
	url = "scripts/getNews.asp?nid="+id+"&rnd="+Math.random();
	xmlHttp = GetXmlHttpObject()
	xmlHttp.onreadystatechange=stateChanged
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

var activeTab = "description";

	function showHide(obj) {
		var e = document.getElementById(obj+"_content")
		var x  = document.getElementById(activeTab+"_content")
		x.style.display = "none";
		document.getElementById(activeTab+"_title").style.fontWeight="normal";
		activeTab = obj;
		document.getElementById(obj+"_title").style.fontWeight="bold";
		e.style.display = "";
	}
	function highlightTab(obj) {
		var e = document.getElementById(obj+"_content")
		if (e.style.display == "none") { //Only do tab highlighting if its not an active tab
			e = document.getElementById(obj+"_title")
			if (e.style.fontWeight == "bold") {
				e.style.fontWeight = "normal";
			} else {
				e.style.fontWeight = "bold";
			}
		}
	}
	function featureInfo(id) {
		var e = document.getElementById("features_info")
		var x = document.getElementById("features_info_text")
		var y = document.getElementById("tab_info")
		var yourBrowser = navigator.userAgent
		var tempX = document.getElementById("feature_"+id).offsetLeft;
		var tempY
		if (yourBrowser.indexOf("MSIE") > -1) {
			tempY = document.getElementById("feature_"+id).offsetParent;
			tempY = tempY.offsetTop;
		}
		if (yourBrowser.indexOf("Firefox") > -1) {
			tempY = document.getElementById("feature_"+id).offsetTop;
		}
		e.style.left = tempX + "px";
		e.style.top = tempY + "px";
		e.style.display = "";
		x.innerHTML = featuresDesc[id];
	}


function toggleTopics(obj,toggleArea) {
	var e = jQuery(obj).children(); //get all children of current div
	e = jQuery(e[0]).children().filter("img"); //filter out the children of the first div element to get the image
	e = e[0];
	if (e) { //check we have an element
		// see if it is an IMG tag, if so alter the img src
		if (e.tagName == "IMG") {
			if (e.src.indexOf("Down") > -1) { 
				e.src = e.src.replace("Down","Up");
				e.alt = "Collapse";
				e.title = "Collapse";
			} else {
				e.src = e.src.replace("Up","Down");
				e.alt = "Expand";
				e.title = "Expand";
			}	
		}
	}
	e = null;
	jQuery("#toggleArea_"+toggleArea).toggle();
}
function rowHover(obj) {
	var newClass = obj.className + " " + obj.className + "Hover";
	obj.className = newClass;
	newClass = null;
}
function rowOff(obj) {
	var revertClass = obj.className.split(" ");
	obj.className = revertClass[0];
	revertClass = null;
}

function addSection(rootID) {
	document.getElementById("techSupportIframe").src = "scripts/supportAddArea.asp?id="+rootID;
	showEditBox()
}
function editSection(rootID) {
	document.getElementById("techSupportIframe").src = "scripts/supportEditArea.asp?id="+rootID;
	showEditBox();
}
function deleteSection(rootID) {
	var answer = confirm("Are you sure you want to delete this support area? This cannot be undone...")
	if (answer) {
		document.getElementById("techSupportIframe").src = "scripts/supportDeleteArea.asp?id="+rootID;
		showEditBox();
	}
}
function addSupportItem(rootID){
	document.getElementById("techSupportIframe").src = "scripts/supportAddItem.asp?id="+rootID;
	showEditBox()
}
function editSupportItem(itemID){
	//document.getElementById("techSupportIframe").src = "scripts/supportEditItem.asp?id="+itemID;
	document.getElementById("techSupportIframe").src = "/administration/supportItem.aspx?siID="+itemID;
	showEditBox()
}
function supportFiles(){
	document.getElementById("techSupportIframe").src = "/administration/supportFiles.aspx";
	showEditBox()
}
function deleteSupportItem(itemID){
	var answer = confirm("Are you sure you want to delete this support item? This cannot be undone...")
	if (answer) {
		document.getElementById("techSupportIframe").src = "scripts/supportDeleteItem.asp?id="+itemID;
		showEditBox();
	}
}
function moveSupport(id,type) {
	if (type == 0) { //move area
		document.getElementById("techSupportIframe").src = "scripts/supportMove.asp?itemid="+id+"&type=0";
	}
	else if (type == 1) { //move item
		document.getElementById("techSupportIframe").src = "scripts/supportMove.asp?itemid="+id+"&type=1";
	}
	showEditBox()	
}
function showEditBox() {
	jQuery("#techSupportEditContainer").toggle();
	document.getElementById("techSupportEditContainer").style.left = ((document.body.clientWidth/2)-(document.getElementById("techSupportEditContainer").offsetWidth/2)) + "px";
	//document.getElementById("techSupportEditContainer").style.top = ((document.body.clientHeight/2)-(document.getElementById("techSupportEditContainer").offsetHeight/2))-100 + "px"	
	document.getElementById("techSupportEditContainer").style.top = "30px"	
}
function closeEditBox() {
	document.getElementById("techSupportIframe").src = "scripts/supportLoading.htm";
	jQuery("#techSupportEditContainer").toggle();
}


var curOpen = "";
var anchorOpen = null;

function getOrder(anchorLink,orderID) {
	
	if (curOpen != "") 
	{
		document.getElementById("orderitems"+curOpen).style.display = "none";
		document.getElementById("orderhead"+curOpen).className = "";
		document.getElementById("ordermain"+curOpen).className = "";
		anchorOpen.innerHTML = "view order";
	}
	
	document.getElementById("orderitems"+orderID).style.display = "block";
	document.getElementById("orderhead"+orderID).className = "highlightHead";
	document.getElementById("ordermain"+orderID).className = "highlight";
	anchorLink.innerHTML = "collapse";
	
	if (curOpen == orderID) 
	{
		document.getElementById("orderitems"+curOpen).style.display = "none";
		document.getElementById("orderhead"+orderID).className = "";
		document.getElementById("ordermain"+orderID).className = "";
		anchorOpen.innerHTML = "view order";
		curOpen = "";
	} 
	else 
	{
		curOpen = orderID;	
		anchorOpen = anchorLink;
	}
}
function highlightRow(rowObj) {
	rowObj.className = "highlightHead";
}
function highlightRowOff(rowObj) { 
	if (rowObj.id != "orderhead"+curOpen) {
		rowObj.className = "";
	}
}

function checkValue(obj,e) {
	if(obj.value == "" && e == 1) { //blur
		obj.value = 0;
	} else {
		if (obj.value == 0) obj.value = "";
	}
}


function MarkInput(objEl)
{
	
}

function CheckForm()
{
	ErrorMsg = "";
	
	company = document.orderform.company;
		if (company.value == "") 
			MarkInput(company);
			
	cname = document.orderform.cname;
		if (cname.value == "")
			MarkInput(cname);
			
	address = document.orderform.address;
		if (address.value == "")
			MarkInput(address);
			
	email = document.orderform.email;
		if (email.value == "")
			MarkInput(email);
	
	tel = document.orderform.tel;
		if (tel.value)
			MarkInput(tel);
	
	paymentType = document.orderform.paymentType;
	paymentSelected = null;
	for (var i = 0; i < paymentType.length; i++)
	{
		if (paymentType[i].checked)
		{
			paymentSelected = paymentType[i].value;
		}
	}
	if (!paymentSelected)
		//MarkInput(paymentType);
	
	designName = document.orderform.designName;
		if (designName.value == "")
			MarkInput(designName);
			
	widthCent = document.orderform.widthCent;			
	heightCent = document.orderform.heightCent;	
	widthInch = document.orderform.widthInch;
	heightInch = document.orderform.heightInch;
	if (widthCent.value == "" || heightCent.value == "" || widthInch.value == "" || heightInch.value)
	{
		ErrorMsg += "<br />Please enter both sizes in either Centimeter OR Inches";
	}
	
	designFormat = document.orderform.designFormat;
	designFormatOther = document.orderform.designFormatOther;
	designFormatSelected = null;
	for (var i = 0; i < designFormat.length; i++)
	{
		if (designFormat[i].checked)
		{
			designFormatSelected = designFormat[i].value;
		}
	}
	if ((!designFormatSelected) && designFormatOther.value == "")
	{
		//MarkInput(designFormat);
		ErrorMsg += "<br />Please selected a design format, or enter your own";
	}
		
	numColours = document.orderform.numColours;
		if (numColours.value == "")
			MarkInput(numColours);
	
	fabric = document.orderform.fabric;		
	fabricOther = document.orderform.fabricOther;
	fabricSelected = null;
	for (var i = 0; i < fabric.length; i++)
	{
		if (fabric[i].checked)
		{
			fabricSelected = fabric[i].value;
		}
	}	
	if ((!fabricSelected) && fabricOther.value == "")
	{
		//MarkInput(fabric);
		ErrorMsg += "<br />Please selected a fabric, or enter your own";
	}
	
	
	return true;
}

