 <!-- // JavaScript Document

// create the ajax request object for all functions
var d = document;

function createObject()
{
	var ajaxRequest;
	try				{	ajaxRequest = new XMLHttpRequest(); } 
	catch (e)	{	try				{	ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");	} 
						catch (e)	{	try		{	ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");	}
						catch (e)	{	alert("Your browser does not support the technology this website uses. Please upgrade your browser!");		
											return false;	}
					}					}
	return ajaxRequest;
}

//update the card details when a thumbnail image is clicked
function changeImage(cardID,folder)
{
	var url = serverName(); // find the active URL for the site
	var ajaxRequest = createObject(); // create the ajaxRequest object
	ajaxRequest.onreadystatechange = function()
		{
			if(ajaxRequest.readyState == 4) 
				{
					d.getElementById("cardDesc").innerHTML = ajaxRequest.responseText; 
				}
		}
	
	var queryString = url + "/" + folder + "/update.php?cardid=" + cardID;
	ajaxRequest.open("GET",queryString, true);
	ajaxRequest.send(null); 
}

//update the product details when a thumbnail image is clicked
function changeAccessoryImage(productID)
{
	var url = serverName(); // find the active URL for the site
	var ajaxRequest = createObject(); // create the ajaxRequest object
	ajaxRequest.onreadystatechange = function()
		{
			if(ajaxRequest.readyState == 4) 
				{
					d.getElementById("cardDesc").innerHTML = ajaxRequest.responseText; 
				}
		}

	var queryString = url + "/accessories/update.php?productid=" + productID;
	ajaxRequest.open("GET",queryString, true);
	ajaxRequest.send(null); 
}

//Shows a selected accessory selected from the card finishing options sleect menu on stationer/index.php
function showAccessory(rowID)
{
	var url = serverName();
	var ajaxRequest = createObject(); // create the ajaxRequest object
	var selectedAccessory = getSelectedIndex("cardInfo_id_options_" + rowID);
	ajaxRequest.onreadystatechange = function()
		{
			if(ajaxRequest.readyState == 4) 
				{
					d.getElementById("selectedFontWording").style.visibility = "visible";
					d.getElementById("selectedFontWording").innerHTML = ajaxRequest.responseText; 
				}
		}

	var queryString = url + "/stationery/update.php?changeAccessory=" + selectedAccessory;
	ajaxRequest.open("GET",queryString, true);
	ajaxRequest.send(null); 
}

//UPDATE THE WORDING OR FONT DIV IN THE CHRISTMAS/CARD.PHP 
function showXmDiv(divName)
{
	var url = serverName(); // find the active URL for the site
	var ajaxRequest = createObject(); // create the ajaxRequest object
	var indexid = getSelectedIndex(divName);
	var queryString = url + "/christmas/update.php?changeDiv=" + divName + "&changeid=" + indexid;

	d.getElementById("selectedFontWording").style.visibility = "visible";

	ajaxRequest.onreadystatechange = function()
		{	
			if(ajaxRequest.readyState == 4) 
				{	
					d.getElementById("selectedFontWording").innerHTML = ajaxRequest.responseText; 
				}	
		}
		
	ajaxRequest.open("GET",queryString, true);
	ajaxRequest.send(null);
}


//change the font image in the wording/index.php page
function updateFontImage(cellID,rowID,type)
{
	var url = serverName(); // find the active URL for the site
	var ajaxRequest = createObject(); // create the ajaxRequest object
	var typestyleID = getSelectedIndex(cellID);
	
	ajaxRequest.onreadystatechange = function()
		{	
			if(ajaxRequest.readyState == 4) 
				{	
					d.getElementById("selectedFont").innerHTML = ajaxRequest.responseText; 
				}		
		}

	var queryString = url + "/wording/update.php?typestyleID=" + typestyleID + "&id=" + rowID + "&type=" + type;
	ajaxRequest.open("GET",queryString, true);
	ajaxRequest.send(null);
}


function updateFontColour(cellID,rowID)
{

//	alert("Font Colour Changed");

	var url = serverName(); // find the active URL for the site
	var ajaxRequest = createObject(); // create the ajaxRequest object
	var colourID = getSelectedIndex(cellID);
	var queryString = url + "/wording/update.php?colourID=" + colourID + "&id=" + rowID;
	ajaxRequest.open("GET",queryString, true);
	ajaxRequest.send(null);
}

//change the font image in the wording/index.php page
function changeWordingView(wordingID)
{
	var url = serverName(); // find the active URL for the site
	var ajaxRequest = createObject(); // create the ajaxRequest object
	
	ajaxRequest.onreadystatechange = function()
		{	
			if(ajaxRequest.readyState == 4) 
				{	
					d.getElementById("selectedWording").innerHTML = ajaxRequest.responseText; 
				}		
		}

	var queryString = url + "/stationery/update.php?wordingID=" + wordingID;
	ajaxRequest.open("GET",queryString, true);
	ajaxRequest.send(null);
}

//HIDES AND SHOWS CARD DETAILS ON THE /STATIONERY/CARdocument.PHP PAGE
function showCardInfo(type,rowID,cardID)
{
	var ajaxRequest = createObject(); // create the ajaxRequest object
	var tableName = type + rowID;
	var activeCard = d.getElementById("ActiveCard").value;
	if(type == "cardInfo_")
		{
			var totalTables = document.getElementById("cardCount").value;
			var totalClose = document.getElementById("assocCount").value;
			var closeType = "similarInfo_";
		}
	else
		{
			var totalTables = document.getElementById("assocCount").value;
			var totalClose = document.getElementById("cardCount").value;
			var closeType = "cardInfo_";
		}
	for( var i = 1; i <= totalClose; i++ )
		{
			document.getElementById(closeType + i).style.display = "none";
		}	
	for( var i = 1; i <= totalTables; i++ )
		{
			document.getElementById(type + i).style.display = "none";
		}
	document.getElementById(type + rowID).style.display = "block";

	if(cardID != activeCard)
		{
			var url = serverName(); // find the active URL for the site
			ajaxRequest.onreadystatechange = function()
				{	
					if(ajaxRequest.readyState == 4) 
						{	
							d.getElementById("cardDesc").innerHTML = ajaxRequest.responseText; 
						}		
				}

			var queryString = url + "/stationery/update.php?changeCard=" + cardID;
			ajaxRequest.open("GET",queryString, true);
			ajaxRequest.send(null);
		}
}

//change the prices on the christmas card depending of a charity is selected or not on christmas/card.php
function showXmInfo(rowID,type,pricecode,designID,location)
{
	var url = serverName(); // find the active URL for the site
	var ajaxRequest = createObject(); // create the ajaxRequest object
	var tableName = "cardInfo_" + rowID;
	var activeType = d.getElementById("priceType").value;
	var totalCharity = d.getElementById("cardCount").value;
	var totalPricecode = d.getElementById("priceCodeCount").value;
	var quantity = getSelectedIndex("qty");
	var i;

	if(activeType != type)
		{
			ajaxRequest.onreadystatechange = function()
				{	
					if(ajaxRequest.readyState == 4) 
						{	
							d.getElementById("XmasQtyInfo").innerHTML = ajaxRequest.responseText; 
						}		
				}

			var queryString = url + "/christmas/update.php?changePrice=" + pricecode + "&type=" + type + "&quantity=" + quantity;
			ajaxRequest.open("GET",queryString, true);
			ajaxRequest.send(null);
		}

	if(location == "charity")
		{
			for(i = 1; i <= totalCharity; i++)
				{
					d.getElementById("charityInfo_" + i).style.display = "none";
				}
			d.getElementById("charityInfo_" + rowID).style.display = "block";

			for(i = 1; i <= totalPricecode; i++)
				{
					d.getElementById("pricecodeInfo_" + i).style.display = "none";
					d.getElementById("xm_pricecode_id_" + i).checked = false;
				}
		}
	else
		{
			for(i = 1; i <= totalCharity; i++)
				{
					d.getElementById("charityInfo_" + i).style.display = "none";
					d.getElementById("xm_charity_id_" + i).checked = false;
				}
			for(i = 1; i <= totalPricecode; i++)
				{
					d.getElementById("pricecodeInfo_" + i).style.display = "none";
					d.getElementById("xm_pricecode_id_" + i).checked = false;
				}
			d.getElementById("pricecodeInfo_" + rowID).style.display = "block";
			d.getElementById("xm_pricecode_id_" + rowID).checked = true;
		}
}

function updateXmExtras(extraID,rowID)
{
	var url = serverName(); // find the active URL for the site
	var ajaxRequest = createObject(); // create the ajaxRequest object
	
	ajaxRequest.onreadystatechange = function()
		{	
			if(ajaxRequest.readyState == 4) 
				{	
					d.getElementById("ExtrasTitle_" + rowID).innerHTML = ajaxRequest.responseText; 
				}		
		}
	
	if(d.getElementById("ws_extras_" + rowID).checked == true)
		{
			var type = "add";
		}
	else
		{
			var type = "delete";
		}
	var queryString = url + "/christmas/update.php?changeExtra=" + extraID + "&type=" + type;
	ajaxRequest.open("GET",queryString, true);
	ajaxRequest.send(null);

}

function changeMMPrice(newPricecode)
{
	var url = serverName(); // find the active URL for the site
	var ajaxRequest = createObject(); // create the ajaxRequest object
	var activePricecode = document.getElementById("ActivePriceCode").value;
	var designID = document.getElementById("ActiveDesignCode").value;
	
	
	if(activePricecode != newPricecode)
		{
			ajaxRequest.onreadystatechange = function() { if(ajaxRequest.readyState == 4) {	d.getElementById("cardDesc").innerHTML = ajaxRequest.responseText;  } }
			var queryString = url + "/memoriam/update.php?designID="+designID+"&pricecode="+newPricecode;
			ajaxRequest.open("GET",queryString, true);
			ajaxRequest.send(null);
		}
	changeMMPriceSelect(newPricecode);
}

function changeMMPriceSelect(newPricecode)
{
	var url = serverName(); // find the active URL for the site
	var qty = getSelectedIndex("mm_qty");
	var ajaxRequest = createObject(); // create the ajaxRequest object
	ajaxRequest.onreadystatechange = function() { if(ajaxRequest.readyState == 4) {	d.getElementById("select_mm_qty").innerHTML = ajaxRequest.responseText;  } }
	var queryString = url + "/memoriam/update.php?changePrice="+newPricecode+"&qty="+qty;
	ajaxRequest.open("GET",queryString, true);
	ajaxRequest.send(null);
}
-->