	var imageDir = "images/";
	var defColor = '';
	
	
	var IMG_WIDTH_MAX = 220;
	var IMG_HEIGHT_MAX = 100;
	var lastTimeOut = null;

	/* ******************************************************************
	Better way to detect browser methof and retrieve html objects,
	without putting redundant if statment all through your code.
	How to use:
		1. Call this method/function, replacing idString with an HTML elements id.
		2. Checks to make sure the string is not null and that the element exist
			ex: getObject("debugWindow");
	 ********************************************************************/
	function GetObject(idString)
	{
		var theObj = null;
		
		if (idString == null) return false;
		//else
		if (document.getElementById)
			theObj = document.getElementById(idString);
		else if (document.all)
			theObj = document.all[idString];
		else if (document.layers)
			theObj = document.layers[idString];

		if (theObj) return theObj;
		
		return false;
	}
	
	
	function SwapBGImage(theElement, fileName)
	{
		var elementObj = GetObject(theElement);
		if (elementObj)
			return elementObj.style.backgroundImage = "url(" + imageDir + fileName + ")";
	}
	
	function SetColor(theElement, theColor)
	{
		if (document.getElementById)
		{
			theElement = document.getElementById(theElement);
			theElement.style.backgroundColor = theColor;
		}
	}
	
	
		//Credit for this function goes to www.shawnolson.net.
	function changecss(theClass,element,value)
	{
		//documentation for this script at http://www.shawnolson.net/a/503/
		var cssRules;
		
		if (document.all)
			cssRules = 'rules';
		else if (document.getElementById)
			cssRules = 'cssRules';
			
		for (var S = 0; S < document.styleSheets.length; S++)
		{
			for (var R = 0; R < document.styleSheets[S][cssRules].length; R++)
			{
				if (document.styleSheets[S][cssRules][R].selectorText == theClass)
					document.styleSheets[S][cssRules][R].style[element] = value;
			}
		}	
	}
	
	
	function ThumbWin(theURL, wdt, hgt)
	{
		var dimensions = "";
		if (wdt > 0)
			dimensions = "width=" + wdt;
		if (hgt > 0)
			dimensions += ",height" + hgt;
		dimensions = ',height=' + tempImage.height + ',width=' + tempImage.width;
		
		window.open(theURL,'','scrollbars=no,menubar=no' + dimensions + ',resizable=yes,toolbar=no,location=no,status=no');
	}
	
	
	/*
	* Purpose: Creates a new resizable window (object) fit to the dimensions of the specified image and a title title to boot.
	* returns: The window object on success, false otherwise.
	*/
	function NewImageWindow(imageURL, theTitle)
	{
		var theWindow = null;
		var errorMsg = null;
		
		theWindow = window.open("", theTitle, "resizable");
		
		if (!theWindow.closed)
		{
			//errorMsg = 'onerror="javaScript: document.write(\'error loading image\');"';
			errorMsg = 'onload="javaScript: window.resizeTo(this.width, this.height)"';
			
			theWindow.document.writeln('<html>\n\t<head>\n\t\t<title>' + theTitle + '</title>\n\t</head>'
				+ '\n\n\t<body style="background: white; margin: 0px; padding: 0px" onLoad="self.focus();">'
				+ '\n\t\t<img style="display: block; border: none" id="theImage" src="' + imageURL + '" ' + errorMsg + ' />'
				//+ '\n\t\t<img style="display: block; border: none" id="theImage" src="' + imageURL + '" />'
				+ '\n\t</body>\n</html>');
			theWindow.document.close();
			
			//return theWindow;
			return true;
		}//else
		return false;
	}
	
	
	function ResizeToImage(theImage)
	{
		window.resizeTo(theImage.width, theImage.height);
		
		return false;
	}
	
	function ScaleToImage(theImage)
	{
		if (theImage.width > window.innerWidth)
			theImage.width - 1;
		else theImage.width + 1;
		
		if (theImage.height > window.innerHeight)
			theImage.height - 1;
		else theImage.height + 1;
		
		theWindow.resizeTo(theWidth, theHeight)
	}
	
function PopupPic(sPicURL)
{
	window.open("popUpPic.php?" + sPicURL, "", "scrollbars,height=200,width=200");
}

function Grow(theImageID)
{
	var doExpand = false;
	var theImageObj = GetObject(theImageID);
	
	if (theImageObj.width < IMG_WIDTH_MAX)
	{
		//newWidth = theImageID.width + 10;
		theImageObj.width = theImageObj.width + 2;
		doExpand = true;
	}
	
	if (theImageObj.height < IMG_HEIGHT_MAX)
	{
		//newHeight = theImageID.height + 10;
		theImageObj.height = theImageObj.height + 2;
		doExpand = true;
	}
	
	thatImage = "Grow(" + theImageID + ")";
	
	if (doExpand)
	{
		alert('do expand');
		setTimeout(thatImage, 1000);
	}
}

function ExpandImage(theImageID, theWidth, theHeight, increaseBy)
{
	var doExpand = false;
	var theImageObj = GetObject(theImageID);
	if (parseInt(increaseBy) < 0) increaseBy = 1
		
	if (theImageObj.width < parseInt(theWidth))
	{
		//newWidth = theImageID.width + 10;
		theImageObj.width = theImageObj.width + increaseBy;
		doExpand = true;
	}
	if (theImageObj.height < parseInt(theHeight))
	{
		//newHeight = theImageID.height + 10;
		theImageObj.height = theImageObj.height + increaseBy;
		doExpand = true;
	}
	
}

function SetFocus(theElementID)
{
	theElementID = GetObject(theElementID);
	if (theElementID)
	{
		theElementID.focus();
	}
}



/*
	Taken from http://www.quirksmode.org/js/findpos.html
	by Khalifah on 1/5/2007 @ 9:47am
*/
function findPos(obj)
{
	var curleft = curtop = 0;

	if (obj.offsetParent)
	{
		curleft = obj.offsetLeft;
		curtop = obj.offsetTop;
		
		while (obj = obj.offsetParent)
		{
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		}
	}
	
	return [curleft,curtop];
}
		
			
		/*
			Created by Khalifah on 1/5/2007 @ 10:54am
			Completed by Khalifah on 1/5/2007 @ 10:54am
			Modified by Khalifah on  @ 
		*/
		function HideObj(theElementID)
		{
			var theObj = GetObject(theElementID);
			
			if (theObj)
				theObj.style.display = "none";
			
			return true;
		}
		
		
		/*
			Created by Khalifah on 1/10/2007 @ 2:17pm
			Completed by Khalifah on 1/10/2007 @ 2:18
			Modified by Khalifah on  @ 
		*/
		function DisplayObj(theElementID, theDisplayType)
		{
			var theObj = GetObject(theElementID);
			
			if (theObj)
				theObj.style.display = theDisplayType;
			
			return true;
		}
		
		
		/**
			Created by Khalifah on 06/01/2007 @ 10:21pm
			Completed by Khalifah on 06/01/2007 @ 10:21pm
		*/
		function ShowObj(theElementID, theBool)
		{
			var theObj = GetObject(theElementID);
			
			if (theObj && theBool) // Show
				theObj.style.visibility = "visible";
			else // Hide
				theObj.style.visibility = "hidden";
			return true;
		}
		
function verifyPromotionalCode(){
	var code = document.theForm.promotionalCode.value;
	if(code.length < 1){
		alert("Please enter a promotional code.");
	}
	else{
		window.open("validatePromoCode.asp?promotionalCode=" + code, 'Promotional_Code','width=300,height=75,scrollbars=no');
	}
}

function showPromoCodeNotice(){
	document.getElementById("promoCodeNotice").style.visibility = "visible";
	document.getElementById("applyBtn").style.backgroundColor = "#0eff00";
}



function videoPreview(theLink, theTitle)
{ 
	var windowpage = 'http://www.aedownloadables.com/flvplayer.php?video=' + theLink + '&mTitle=' + theTitle;
	window.open(windowpage, 'Preview_Window', 'width=500,height=450');
}

function videoPreviewWide(theLink, theTitle)
{ 
	var windowpage = 'flvplayer.php?video=' + theLink + '&mTitle=' + theTitle;
	window.open(windowpage, 'Preview_Window', 'width=786,height=450');
}

function audioPreview(edp)
{ 
	var windowpage = 'mp3player.php?edp=' + edp;
	window.open(windowpage, 'Preview_Window','width=500,height=200');
}

function popUpPage(file)
{
	window.open(file, 'Exhibit_Text','width=500,height=200,scrollbars=yes');
}
function showSets()
{
	document.getElementById("showSets").style.visibility = "visible";
}
function hideDiv(theDiv)
{
	document.getElementById("showSets").style.visibility = "hidden";
}
function eMaps(file)
{
	window.open(file,'Viewing_Items','width=820,height=620,scrollbars=no');
}

function CancelLink()
{
	//alert("Im going there!");
	//var theResponse = confirm("Warning: you should login and save your cart OR complete your shopping and checkout before leaving this division; As you are NOT able to shop across divisions. If you choose to leave now, you MUST return to this site in ordeer to checkout your <?php $SUBJECT; ?> items at a later time.");
	var theResponse = confirm("OOOOOPS!!\nDear Customer,\nForeign Language, Science, Social Studies and English each represent an individual store within our company.\n We are sorry but shopping carts, wish lists and other information are not transferrable.\nPlease finish all shopping and check your items out before you switch to a different store.\n\nThank you!");
	if (!theResponse) return false;
	// else
	return true;
}

function checkSize(){
	//document.getElementById('wrapper_head').style.width = document.body.clientWidth > 850 ? '850px' : (document.body.clientWidth < 571 ? '570px' : '94%')
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer"){		
		setInterval("setSize();",500);
	}
}
function setSize(){             
	if(document.documentElement.clientWidth < 980){
		document.getElementById('wrapper_head').style.width = "980px";
	} else {
		document.getElementById('wrapper_head').style.width = "";
	}
}

