var Cookies = {
	init: function () {
		var allCookies = document.cookie.split('; ');
		for (var i=0;i<allCookies.length;i++) {
			var cookiePair = allCookies[i].split('=');
			this[cookiePair[0]] = cookiePair[1];
		}
	},
	create: function (name,value,days) {
		if (days) {
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		}
		else var expires = "";
		document.cookie = name+"="+value+expires+"; path=/";
		this[name] = value;
	},
	erase: function (name) {
		this.create(name,'',-1);
		this[name] = undefined;
	}
}

Cookies.init();

var cname;
var x;
var cookiedata;
var elist;
var eID;
itmNum = Cookies['tt_queue'];
removed = 0;
noticeOut = 77;
tipTimeout = 77;
okToGo = 0;
sPath = window.location.pathname;
sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
iqChange = false;

mail = "&#109;&#97;&#105;&#108;&#116;&#111;";
me1 = "&#115;&#97;&#108;&#101;&#115;";
meAt = "&#64;";
me2 = "&#116;&#101;&#114;&#114;&#121;&#116;&#114;&#111;&#112;&#104;&#121;";
meCom = "&#99;&#111;&#109;";

ieNav = false;
browser = navigator.userAgent;
if(browser.match("MSIE 7.0") == "MSIE 7.0")
{
	ieNav = true;
}
// write cookie to the browser (cname is the cookie name, x is the amount of days until expiry)
function wrtCookie(cname,x)
{
	Cookies.create(cname,x,1);
}
// check if a cookie exists, and compare its contents see checkData() for example
function chkCookie(cname)
{
	var nameEQ = cname + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
// remove cookie from browser
function rmvCookie(cname)
{
	Cookies.erase(cname);
	itmNum = null;
}

// check if cookies are enabled, screen is large enough, and that javascript is enabled
function checkData()
{
	wrtCookie('test', 'test');
	if(chkCookie('test') == "test")
	{
		rmvCookie('test');
	} else {
		alert("In order to use the inquiry list you must enable Cookies in your browser.");
	}
	if(screen.width<800)
	{
		alert("Your screen resolution is "+screen.width+"x"+screen.height+", this webpage might not display properly in your current screen resolution.\nThis website was designed for 1024x768 resolution.");
	}
}
// put item "num" into the cookie
function putItem(num)
{
	if(itmNum == null)
	{
		itmNum = "" + num + "";
		wrtCookie('tt_queue',itmNum);
		itmNum = Cookies['tt_queue'];
		createNotice("<font face=Tahoma size=3>Item added to the Shop List.</font>", 3000);
		newItems();
	} else {
		if(itmNum.match(num) == num)
		{
			createNotice("<font face=Tahoma size=3>That item is already in your Shop List.</font>", 3000);
		} else {
			itmNum = itmNum + ", " + num;
			wrtCookie('tt_queue',itmNum);
			itmNum = Cookies['tt_queue'];
			createNotice("<font face=Tahoma size=3>Item added to the Shop List.</font>", 3000);
		}
		newItems();
	}
}

var itemsInCookie = Cookies['tt_queue'];

var Item = {
	Add: function(pageNum, number, descrip, image, price)
	{
		var found=0;
		if(itemsInCookie == undefined || itemsInCookie == "")
		{
			itemsInCookie = "";
		} else {
			var itmAdd = eval("["+itemsInCookie+"]");
			for(x in itmAdd)
			{
				if(itmAdd[x]['Number'] == number)
				{
					createNotice("<font face=Tahoma size=3>That item is already in your Shop List.</font>", 3000);
					found=1;
				} else {
					found=0;
				}
			}
		}
		if(found == 0)
		{
			if(itemsInCookie == "")
			{
				itemsInCookie = "{'Page':'"+pageNum+"','Number':'"+number+"','Description':'"+descrip+"','Image':'"+image+"','Price':'"+price+"','Quantity':'1','Modifier':['None']}";
				wrtCookie('tt_queue', itemsInCookie);
				createNotice("<font face=Tahoma size=3>Item added to the Shop List.</font>", 3000);
			} else {
				itemsInCookie += ",{'Page':'"+pageNum+"','Number':'"+number+"','Description':'"+descrip+"','Image':'"+image+"','Price':'"+price+"','Quantity':'1','Modifier':['None']}";
				wrtCookie('tt_queue', itemsInCookie);
				createNotice("<font face=Tahoma size=3>Item added to the Shop List.</font>", 3000);
			}
			newItems();
		}
	},
	/*
	Function still changes every item's modifiers at once, instead of just changing it's own
	*/
	AddModifier: function(number, mod)
	{
		var modifier = eval("["+itemsInCookie+"]");
		var found=0;
		var replaced=0;
		var modBuild = "";
		for(mo in modifier)
		{
			tempBuff = mod.split("^");
			if(modifier[mo]['Number'].match(number))
			{
				for(y in modifier[mo]['Modifier'])
				{
					if(modifier[mo]['Modifier'][y].search(tempBuff[0]) > -1 || modifier[mo]['Modifier'][y].match("None"))
					{
						if(modBuild != "") modBuild += ", '"+tempBuff[0]+" "+tempBuff[1]+"'";
						else modBuild += modBuild += "'"+tempBuff[0]+" "+tempBuff[1]+"'";
						createNotice("<font face=Tahoma size=3>Replaced old "+tempBuff[0]+" modifier with new "+tempBuff[0]+" modifier</font>", 3000);
						replaced=1;
					} else {
						if(modBuild != "") modBuild += ", '"+modifier[mo]['Modifier'][y]+"'";
						else modBuild += "'"+modifier[mo]['Modifier'][y]+"'";
					}
				}
				if(replaced==0) modBuild += ", '"+tempBuff[0]+" "+tempBuff[1]+"'";
				found=1;
			}
		}
		if(found==0)
		{
			createNotice("<font face=Tahoma size=3>You must add item "+number+" before you can add modifiers to it.</font>", 3000);
		} else {
			itemsInCookie = "";
			for(x in modifier)
			{
				if(itemsInCookie == "")
				{
					itemsInCookie = "{'Page':'"+modifier[x]['Page']+"','Number':'"+modifier[x]['Number']+"','Description':'"+modifier[x]['Description']+"','Image':'"+modifier[x]['Image']+"','Price':'"+modifier[x]['Price']+"','Quantity':'"+modifier[x]['Quantity']+"','Modifier':[";
					if(modifier[x]['Number'].match(number)) itemsInCookie += modBuild+"]}";
					else itemsInCookie += "'"+modifier[x]['Modifier']+"']}";
				} else {
					itemsInCookie += ",{'Page':'"+modifier[x]['Page']+"','Number':'"+modifier[x]['Number']+"','Description':'"+modifier[x]['Description']+"','Image':'"+modifier[x]['Image']+"','Price':'"+modifier[x]['Price']+"','Quantity':'"+modifier[x]['Quantity']+"','Modifier':[";
					if(modifier[x]['Number'].match(number)) itemsInCookie += modBuild+"]}";
					else itemsInCookie += "'"+modifier[x]['Modifier']+"']}";
				}
			}
			wrtCookie('tt_queue', itemsInCookie);
			if(replaced==0) createNotice("<font face=Tahoma size=3>Item Modifier added to "+number+".</font>", 3000);
		}
	}
}


modifierList = {
	/*
	Open: function(number, modsArray)
	{
		$('#modifiers').stop();
		modsList = modsArray.split(";");
		$('#modifiers').show().animate({ 'opacity':1, 'height':'80%', 'width':'80%' }, 
		function()
		{
			$('#modifiers').animate({ 'top':getCenter.Object("#modifiers")['height'],'left':getCenter.Object("#modifiers")['width'] }, 
			function()
			{
				$('#modifiers').html("<div id='modifierDiv' style='overflow: auto;' height='100%'><table cellpadding='0' cellspacing='5' border='0' id='ColumnTable' width='100%'><tr style='font-size: 150%;font-weight: bold;cursor: pointer;' onclick='$(\"#ColumnContent\").slideToggle()'>Columns</tr><tr id='ColumnContent'></tr></table><table cellpadding='0' cellspacing='5' border='0' id='BaseTable' width='100%'><tr style='font-size: 150%;font-weight: bold;cursor: pointer;' onclick='$(\"#BaseContent\").slideToggle()'>Bases</tr><tr id='BaseContent'></tr></table><table cellpadding='0' cellspacing='5' border='0' id='FigureTable' width='100%'><tr style='font-size: 150%;font-weight: bold;cursor: pointer;' onclick='$(\"#FigureContent\").slideToggle()'>Figures</tr><tr id='FigureContent'></tr></table></div><button onclick='modifierList.Close()'>Close</button>");
				for(x in modsList)
				{
					modList = modsList[x].split(", ");
					if(modList[0] == "None")
					{
						$('#modifierDiv').html("<center>Modifications are not available for this item.</center>");
					} else {
						$('#'+modList[0]+'Content').append("<td align='center' style='font-size: 11px;font-family:Tahoma;' onclick='Item.AddModifier(\""+number+"\",\""+modList[0]+"^"+modList[1]+"\")'><img src='mods/"+modList[2]+"' /><br />"+modList[0]+" "+modList[1]+"</td>");
					}
				}
			}
			);
		}
		);
	},
	*/
	Open: function(number, modsArray, Applied)
	{
		$('#modifiers').stop();
		modsList = modsArray.split(";");
		$('#modifiers').show().animate({ 'opacity':1, 'height':'80%', 'width':'80%' }, 
		function()
		{
			$('#modifiers').animate({ 'top':getCenter.Object("#modifiers")['height'],'left':getCenter.Object("#modifiers")['width'] }, 
				function()
				{
					$.post(
						"ModifierReturn.php",
						{
							number: number,
							AppliesTo: Applied
						},
						function(data)
						{
							$('#modifiers').html(data);
						}
					);
				}
			);
		}
		);
	},
	Close: function()
	{
		$('#modifiers').fadeOut('slow', function(){$('#modifiers').html('').css({"top": 0, "left": 0, "width": 0, "height": 0})});
	}
}

// remove multiple items as selected from the cookie
function rmvMany(num)
{
	vnum = ", " + num;
	fnum = num + ", ";
	if(itmNum.match(vnum) == vnum)
	{
		wrtCookie('tt_queue', itmNum.replace(vnum, ""));
		itmNum = Cookies["tt_queue"];
	}
	else if(itmNum.match(fnum) == fnum)
	{
		wrtCookie('tt_queue', itmNum.replace(fnum, ""));
		itmNum = Cookies["tt_queue"];
	} else {
		rmvCookie('tt_queue');
		newItems();
		removed = 1;
	}
}
// remove every item from the inquiry list (deletes cookie)
function rmvAll()
{
	if(confirm("Remove all items from the queue?") == 1)
	{
		rmvCookie('tt_queue');
		newItems();
		window.location.reload();
	}
}
// remove multiple items as selected from the inquiry list
function rmLot()
{
	var fID = document.getElementById("rForm");
	it = 0;
	if(confirm("Remove selected item(s)?") == 1)
	{
		for(i=2;i<(fID.length-2);i++)
		{
			if(fID.elements[i].checked == true)
			{
				rmvMany(fID.elements[i].value);
				it++;
			}
		}
		if(it == 0)
		{
			alert("No items to remove");
		}
		if(chkCookie('tt_queue') == null)
		{
			window.location.reload();
		}
		removed = 0;
		window.location.reload();
	}
}
// Update the item quantity from the inquiry list
function updateQuantAll(h)
{
	var fID = document.getElementById("rForm");
	y = 0;
	for(i=2;i<fID.length - 3;i++)
	{
		if(fID.elements[i].value.search(":") != -1)
		{
			sOV = new Array;
			sOV = fID.elements[i].value.split(":");
			quantN = eval("document.getElementById('quan"+y+"').value");
			if(quantN == "0" || quantN == "")
			{
				rmvMany(fID.elements[i].value);
				y++;
				continue;
			}
			if(isNaN(quantN) == true)
			{
				alert("You must enter numbers only for a quantity.");
				break;
			} else {
				itmNum = Cookies['tt_queue'];
				if(itmNum.search(sOV[1]) != -1)
				{
					wrtCookie('tt_queue',itmNum.replace(sOV[1]+":"+sOV[2], sOV[1]+":"+quantN));
				}
				y++;
			}
		}
	}
	window.top.iqChange = false;
	fID.reset();
	itmNum = Cookies['tt_queue'];
	if(h!=1)window.location.reload();
}

function updateQuantity(qCNumber, quantity)
{
	quantityArray = eval("["+itemsInCookie+"]");
	itemsInCookie = "";
	for(x in quantityArray)
	{
		if(quantityArray[x]['Number'].match(qCNumber))
		{
			if(itemsInCookie == "")
			{
				itemsInCookie = "{'Page':'"+quantityArray[x]['Page']+"','Number':'"+quantityArray[x]['Number']+"','Description':'"+quantityArray[x]['Description']+"','Image':'"+quantityArray[x]['Image']+"','Price':'"+quantityArray[x]['Price']+"','Quantity':'"+quantity+"','Modifier':['None']}";
			} else {
				itemsInCookie += ",{'Page':'"+quantityArray[x]['Page']+"','Number':'"+quantityArray[x]['Number']+"','Description':'"+quantityArray[x]['Description']+"','Image':'"+quantityArray[x]['Image']+"','Price':'"+quantityArray[x]['Price']+"','Quantity':'"+quantity+"','Modifier':['None']}";
			}
		} else {
			if(itemsInCookie == "")
			{
				itemsInCookie = "{'Page':'"+quantityArray[x]['Page']+"','Number':'"+quantityArray[x]['Number']+"','Description':'"+quantityArray[x]['Description']+"','Image':'"+quantityArray[x]['Image']+"','Price':'"+quantityArray[x]['Price']+"','Quantity':'1','Modifier':['None']}";
			} else {
				itemsInCookie += ",{'Page':'"+quantityArray[x]['Page']+"','Number':'"+quantityArray[x]['Number']+"','Description':'"+quantityArray[x]['Description']+"','Image':'"+quantityArray[x]['Image']+"','Price':'"+quantityArray[x]['Price']+"','Quantity':'1','Modifier':['None']}";
			}
		}
	}
	wrtCookie('tt_queue', itemsInCookie);
}

var QuantityEdit = {
	Show: function(tOffset, lOffset)
	{
		$('#quantityEdit').css({ "top":(tOffset-34), "left":(lOffset-125), "zIndex":0 }).fadeIn('fast');
	},
	Hide: function()
	{
		$('#quantityEdit').fadeOut('fast');
	}
}

// Change the status of the inquiry page
function changeStat()
{
	window.top.iqChange = true;
}
// set onload vars for list.php
function setList()
{
	selItm(1);
}
// select items in the list, 0 for all, 1 for none
function selItm(j)
{
	if(itmNum != null)
	{
		fID = document.getElementById("rForm");
		for (i=2;i<fID.length-2;i++)
		{
			if(j == 0)
			{
				fID.elements[i].checked = true;
			} else {
				fID.elements[i].checked = false;
			}
		}
	}
}

var Select = {
	All: function()
	{
		$(":checkbox").attr({"checked":true});
	},
	None: function()
	{
		$(":checkbox").attr({"checked":false});
	}
}

var Remove = {
	All: function()
	{
		itemsInCookie = "";
		rmvCookie("tt_queue");
		createNotice("<font face=Tahoma size=3>All items in your Queue were successfully removed.</font>", 3000);
	},
	One: function(itemNumber)
	{
		itemsArray = eval("["+itemsInCookie+"]");
		itemsInCookie = "";
		returnValue = false;
		for(x in itemsArray)
		{
			CBID = $(':checkbox:checked').attr("id");
			if(itemsArray[x]['Number'].match(itemNumber))
			{
				returnValue = true;
			} else {
				if(itemsInCookie == "")
				{
					itemsInCookie = "{'Page':'"+itemsArray[x]['Page']+"','Number':'"+itemsArray[x]['Number']+"','Description':'"+itemsArray[x]['Description']+"','Image':'"+itemsArray[x]['Image']+"','Price':'"+itemsArray[x]['Price']+"','Quantity':'1','Modifier':['None']}";
				} else {
					itemsInCookie += ",{'Page':'"+itemsArray[x]['Page']+"','Number':'"+itemsArray[x]['Number']+"','Description':'"+itemsArray[x]['Description']+"','Image':'"+itemsArray[x]['Image']+"','Price':'"+itemsArray[x]['Price']+"','Quantity':'1','Modifier':['None']}";
				}
			}
		}
		return returnValue;
	},
	Item: function()
	{
		remNumber = 0;
		checkedNum = $('input:checkbox:checked').length;
		for(a=0;a<=checkedNum;a++)
		{
			if(Remove.One($(':checked').val()))
			{
				remNumber++;
				$(':checkbox:checked#'+CBID).attr({"checked":false});
			}
		}
		if(remNumber >= 1)
		{
			if(itemsInCookie == "") rmvCookie("tt_queue");
			else wrtCookie('tt_queue', itemsInCookie);
			createNotice("<font face=Tahoma size=3>The "+(remNumber == 1 ? "item":"items")+" you selected "+(remNumber == 1 ? "was":"were")+" successfully removed. Refresh the page to see results.</font>", 3000);
		} else {
			createNotice("<font face=Tahoma size=3>No items were removed, there may have been an error. Try refreshing and trying again.</font>", 3000);
		}
	}
}
// select one item where clicked
function selOne(itm)
{
	if(document.getElementById(itm).checked == true)
	{
		document.getElementById(itm).checked = false;
	} else {
		document.getElementById(itm).checked = true;
	}
}
// parse cookie data into ordered list
function parseItm()
{
	elist = new Array();
	elist = itmNum.split(", ");
	elist.sort();
	pgnum = new Array();
	pgvar = new Array();
	pgint = new Array();
	for(x in elist)
	{
		pgnum = elist[x].split(":");
		pgvar[x] = pgnum[1];
		pgint[x] = pgnum[0];
	}
}
// ask for permission to the inquiry form
function callInq()
{
	if(itmNum == null)
	{
		alert("You have no items in your Shopping List to inquire about.");
	} else {
		changeContent("inqform","php");
	}
}
// create the item notice contents, and move the box to the screen
function createNotice(Note)
{
	$('#notice').stop().html(Note).css({ "opacity": 0.9, "top": getCenter.Object("#notice")['height'], "left": getCenter.Object("#notice")['width'] }).fadeIn('slow');
	killNotice(0, 3000);
}
// destroy the notice if 1, start destroy timer if 0
function killNotice(action, time)
{
	if(action == 1)
	{
		$('#notice').fadeOut('slow', function(){ $('#notice').css({ "opacity": 0 }).html('') });
	} else {
		if(noticeOut != 77)
		{
			clearTimeout(noticeOut);
		}
		noticeOut = setTimeout('killNotice(1, 0)',time);
	}
}
// Show the new items dialog over the inquiry list
function newItems()
{
	if(chkCookie('tt_queue'))
	{
		var bX = $("#cart").offset()['left']-10;
		var bY = $("#cart").offset()['top']+15;
		$('#notify').css({ "top": bY, "left": bX, "opacity": 1 }).html("<img src='notify.png' border='0' usemap='#notifyM' /><map id='notifyM' name='notifyM'><area shape ='rect' coords ='15,13,299,37' href='javascript:changeContent(\"qlist\", \"php\")' title='Click here to see your Shopping List' /><area shape ='rect' coords ='305,18,321,33' href='javascript:removeDialog()' title='Close notice' />").fadeIn('slow');
	} else {
		removeDialog();
	}
}
// Remove the shopping list dialog
function removeDialog()
{
	$('#notify').fadeOut('slow', function(){ $('#notify').css({ "top": 0, "left": 0, "opactiy": 0 }).html('') });
}

function previewImage(image)
{
	$('#bg').stop().html("<br /><img id='previewElement' src='loader.gif' />").css({ "top": getCenter.Object('#bg')['height'], "left": getCenter.Object('#bg')['width'], "opacity": 1 }).fadeIn('slow');
	$('#previewElement').click(function(){ $('#bg').fadeOut('slow', function(){ $('#bg').html('') }) });
	img=new Image();
	img.onload = function()
	{
		$('#previewElement').attr({ "src": image });
		$('#bg').animate({ "top": getCenter.Object('#bg')['height'], "left": getCenter.Object('#bg')['width'] });
	}
	img.src=image;
}

function getRandom()
{
	xmlhttp=null
	if(window.XMLHttpRequest)
	{
		xmlhttp=new XMLHttpRequest()
	}
	else if(window.ActiveXObject)
	{
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
	if(xmlhttp!=null)
	{
		xmlhttp.onreadystatechange=function()
		{
			if (xmlhttp.readyState==4)
			{
				if (xmlhttp.status==200)
				{
					var data = xmlhttp.responseText;
					dataArray = new Array();
					dataArray = data.split(";");
					$("#rImg").html("<style type='text/css'>img.rand { border: #98b3ba solid thick; }</style><center><font face='Tahoma' size=3 color='#464646'><b>Featured Item</b></font><br /><a href='javascript:Item.Add(\""+dataArray[0]+"\", \"" + dataArray[1] + "\", \"" + dataArray[2] + "\", \""+dataArray[3]+"\", \""+dataArray[4]+"\")' id='randItm'><img src='products/" + dataArray[3] + "' height='250' class='rand'><br /><font face='Tahoma' size=2 color=464646><b>Item Number:</b> " + dataArray[1] + "<br /><b>Description:</b> "+dataArray[2]+"</font></a></center>");
				} else {
					alert("Problem retrieving XML data")
				}
			}
		}
		xmlhttp.open("GET","randImg.php",true)
		xmlhttp.setRequestHeader('Content-Type', 'text/html');
		xmlhttp.setRequestHeader('Content-Type', 'charset=windows-1252');
		xmlhttp.send(null)
	} else {
		alert("Your browser does not support AJAX.")
	}
}

var windowDim = {
	Height: function()
	{
		if(window.innerHeight != undefined)
		{
			var wHeight = window.innerHeight;
		} else {
			var wHeight = document.documentElement['clientHeight'];
		}
		
		return wHeight;
	},
	Width: function()
	{
		if(window.innerWidth != undefined)
		{
			var wWidth = window.innerWidth;
		} else {
			var wWidth = document.documentElement['clientWidth'];
		}
		
		return wWidth;
	}
}

var getCenter = {
	Dimension: function(width, height)
	{

		var dim = new Array('width', 'height');
		dim['width'] = (windowDim.Width() / 2)-(width / 2);
		dim['height'] = (windowDim.Height() / 2)-(height / 2);
		
		return dim;
	},
	Object: function(objID)
	{
		var obj = new Array('width', 'height');
		obj['width'] = (windowDim.Width() / 2)-($(objID).width() / 2);
		obj['height'] = (windowDim.Height() / 2)-($(objID).height() / 2);
		
		return obj;
	}
}

// Change image on parent frame (imagef) to iSrc (must be a valid image)
function changeImg(iSrc)
{
	$('#thumb_prev').attr({ "src": "products/"+iSrc });
}

function viewSupplierPage(supplier)
{
	$('#dark').css({ "opacity": 0.7, "height": "100%", "width": "100%" }).fadeIn('slow');
	$('#supplieriFrame').animate({ 'height':'85%', 'width':'95%' }, 'slow', function(){ $('#supplieriFrame').html('<iframe src="'+supplier+'" width="100%" height="100%" scrolling="auto" style="overflow-x:auto;overflow-y:auto;"></iframe><button onclick="javascript:closeSupplierPage()" style="width: 100%;">[ Close ]</button>').animate({ 'top':getCenter.Object('#supplieriFrame')['height'], 'left':getCenter.Object('#supplieriFrame')['width'] }) });
}

function closeSupplierPage()
{
	$('#dark').fadeOut('slow');
	$('#supplieriFrame').fadeOut('slow', function(){$('#supplieriFrame').html('').css({"top": 0, "left": 0, "width": 0, "height": 0})});
	window.stop();
}

function changeContent(contentName, ext)
{
	if(iqChange == true)
	{
		if(confirm("You currently have unsaved changes to your list, would you like to save them?\n(Your changes will be lost otherwise)\nClick \"OK\" to save the list, or \"Cancel\" to continue to your desired page without saving.") == 1)
		{
			iqChange = false;
			updateQuantAll(1);
			window.location = "index.php?page="+contentName+"&ext="+ext;
		} else {
			iqChange = false;
			window.location = "index.php?page="+contentName+"&ext="+ext;
		}
	} else {
		window.location = "index.php?page="+contentName+"&ext="+ext;
	}
}

function changeContentWithVariable(contentName, ext, variable)
{
	if(iqChange == true)
	{
		if(confirm("You currently have unsaved changes to your list, would you like to save them?\n(Your changes will be lost otherwise)\nClick \"OK\" to save the list, or \"Cancel\" to continue to your desired page without saving.") == 1)
		{
			iqChange = false;
			updateQuantAll(1);
			window.location = "index.php?page="+contentName+"&ext="+ext+variable;
		} else {
			iqChange = false;
			window.location = "index.php?page="+contentName+"&ext="+ext+variable;
		}
	} else {
		window.location = "index.php?page="+contentName+"&ext="+ext+variable;
	}
}