<!--
//prepend all Image sources with this globalization variable Q.03.13.06
var ImageServerVar='';
//alert(testing);
window.top.name="preview";
// Detect OS type
if (navigator.userAgent.indexOf('Windows NT 5.1') != -1) var ostype="winxp";
else if (navigator.userAgent.indexOf('Windows NT 5.0') != -1) var ostype="win2000";
else if (navigator.userAgent.indexOf('Windows 98') != -1) var ostype="win98";
else if (navigator.userAgent.indexOf('Windows 95') != -1) var ostype="win95";
else if ((navigator.userAgent.indexOf('WinNT') != -1) || (navigator.userAgent.indexOf('Windows NT') != -1)) var ostype="winnt";
else if ((navigator.userAgent.indexOf('Mac') != -1)) var ostype="mac";
else var ostype="undefined";
// Detect Browser type
var bN = navigator.appName;
var agent = navigator.userAgent.toLowerCase();

/* USE THIS TO DISABLE SEARCH 
function CatchEmptySearch() {
	alert('Search is currently unavailable.\nPlease try back later.');
	return false;
}*/

function CatchEmptySearch() {
	var search = document.searchForm.query.value;
	var valid = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-.%' ";
	var temp = "";
	var invalidflag = 0;
	
	if (search == "") {
		alert('Please enter your search criteria\nthen click the Go button.');
		document.searchForm.query.focus();
		return false;
	}
	else if (search.substring(0,1) == " ") {
		alert('Please remove any leading spaces\nfrom your search criteria and try again.');
		document.searchForm.query.focus();
		return false;
	}
	else if (search == "-" || search == "." || search == "%" || search == "'" || search == " ") {
		alert('Your search criteria is too general.\nPlease add to it and try again.');
		document.searchForm.query.focus();
		return false;
	}
	
	for (var i=0; i < search.length; i++)
	{
		temp="" + search.substring(i,i+1);
		if (valid.indexOf(temp)=="-1") {
			invalidflag = 1;
			break;
		}
	}
		
	if (invalidflag==1) {
		alert("Your search criteria contains an invalid character(s).\nValid characters are numbers, letters, spaces, and . - % '.\nPlease remove any invalid characters and try again.");
		document.searchForm.query.focus();
		return false;
	}
	else {
		return true;
	}
}

function changeImages() {
	if (document.images) {
		for (var i=0; i<changeImages.arguments.length; i+=3) {
			document[changeImages.arguments[i]].src = eval(changeImages.arguments[i+1] + ".src");
		}
	}
}

function ShowSizeChart(chart){
	var LeftPosition = (screen.width) ? (screen.width-602)/2 : 0;
	var TopPosition = (screen.height) ? (screen.height-580)/2 : 0;
	var page = 'http://www.ae.com/'+jsContextRoot+'/browse/sizechart/'+chart+'.jsp';
	var popup = window.open(page,"sizechart",'toolbar=0,top='+TopPosition+',left='+LeftPosition+',location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=602,height=580');
	popup.focus();
}

function writeme() {
	window.defaultStatus="";
	return true;
}

function setMiniCartColor(backcolor,fcolor)
{
document.getElementById('minicart').style.backgroundColor=backcolor;
document.getElementById('minicart').style.color=fcolor;
document.getElementById('minicart').minicart=fcolor;
}

//Configurable Function for Popups
function ConfigurablePopup(url,w,h,winName,scroll,resiz,topPos,leftPos)
{
var popup = window.open(url,winName,'toolbar=0,top='+topPos+',left='+leftPos+',width='+w+',height='+h+',location=0,directories=0,status=0,menubar=0,scrollbars='+scroll+',resizable='+resiz);
popup.location=url;
popup.opener=self;
popup.focus();
}

//Generic Function for Popups
function popup(url,w,h)
{
var width = w;
var height = h;
var LeftPosition = (screen.width) ? (screen.width-width)/2 : 0;
var TopPosition = (screen.height) ? (screen.height-height)/2 : 0;
var popupURL = url;
var popup = window.open(popupURL,"AEO",'toolbar=0,top='+TopPosition+',left='+LeftPosition+',width='+width+',height='+height+',location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1');
popup.location=popupURL;
popup.opener=self;
popup.focus();
}

function popaeradio(x,y)
{
var winl = (screen.width - x) / 2;
var wint = (screen.height - y) / 2;
ShowWindow=window.open('http://aeliveyourlife.com/tunes/playerHolder.php?ref='+escape(document.location.href+"<?=$qs?>"),'popup','width='+x+',height='+y+',scrollbars=no,top='+wint+',left='+winl+',screenX=100,screenY=0,status,resizable=no');
ShowWindow.focus();
}

/*******************************************************************************************
 * Function	: scanKeypress
 * Parameters	: Key press event
 * This function submits the form when the user hits the enter key(IE and NN compatable )
 *******************************************************************************************/
var nav4=window.Event ? true : false;
if (document.layers) document.captureEvents(Event.KEYPRESS);

if (nav4 && document.layers)
 document.onkeypress=scanKeypress;
 
function scanKeypress(e)
{
    if (nav4)
   		var whichCode=e.which;
	else
    	if (e.type=="keypress")
      		var whichCode=e.keyCode;
    	else
      		var whichCode=e.button;
 	if (whichCode==13)
	{
		return false;
	}
	else return true;
}

/*******************************************************************************************
 * Function	: flash page embed
 * Parameters	: all params for both Embed and Object
 * This function loads the flash page params via javascript to the html & jsp pages
 * it allows the IE browser to render it without the page script block event
 *******************************************************************************************/
var fsURL; //-- url do not include prepend --//
var fsWidth; //-- File width --//
var fsHeight; //-- File Height --//
var fsID; //-- ID and Name --//
var fsVersion;//-- Codebase version number --//
var fsBgcolor; //-- Background color #b7d692 --//
var fsQuality; //-- Quality --//
var fsAlign; //-- Alignment --//
var fsScptAcc //-- default is sameDomain, also avaliable is 'always', 'never'--//
var fsWinMode //--background opacity --//
function flash(){
document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" '+
'codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+fsVersion+'" '+
'width="'+fsWidth+'" '+
'height="'+fsHeight+'" '+
'id="'+fsID+'" '+
'align="'+fsAlign+'">'+
'<param name="movie" value="http://a248.e.akamai.net/a755bdded7308e72e7fac2eae90715fc.com'+fsURL+'" />'+
'<param name="quality" value="'+fsQuality+'" />'+ 
'<param name="bgcolor" value="'+fsBgcolor+'" />'+ 
'<param name="allowScriptAccess" value="'+fsScptAcc+'" />'+ 
'<param name="wmode" value="'+fsWinMode+'" />'+ 
'<embed  '+
'width="'+fsWidth+'" '+ 
'height="'+fsHeight+'" '+ 
'name="'+fsID+'" '+ 
'align="'+fsAlign+'" '+ 
'src="http://a248.e.akamai.net/a755bdded7308e72e7fac2eae90715fc.com'+fsURL+'" '+ 
'quality="'+fsQuality+'" '+ 
'bgcolor="'+fsBgcolor+'" '+
'allowScriptAccess="'+fsScptAcc+'" '+ 
'wmode="'+fsWinMode+'" '+ 
'type="application/x-shockwave-flash" '+ 
'pluginspage="http://www.macromedia.com/go/getflashplayer" />'+
'</object>')
}

/*******************************************************************************************
 * Function	: sitewide background images set to and from cookie
 * This function loads the page backgrounds, styles, and images via javascript cookie called styleCookie
 *******************************************************************************************/
/*
function styleSet(sName, sValue){
	var sCookie = sName + "=" +encodeURIComponent(sValue)+ ";path=/"
	document.cookie=sCookie;
	}
	
function getCookie(sName){
	var sRE = "(?:;)?" +sName + "=([^;]*);?";
	var oRE = new RegExp(sRE)
		if(oRE.test(document.cookie)){
		return decodeURIComponent(RegExp["$1"]);
		}
	}		
function getColor(){
	var sName= getCookie('styleCookie');
		if (sName=="blue"){
			document.body.className="blue";
		} else if (sName=="silver"){
			document.body.className="silver";
		} else if (sName=="green"){
			document.body.className="green";
		} else {
			document.body.className="red";
		}
	}
window.onload = getColor; 
*/
function ClearStat() {
	window.status='';
}
function SetStatus(value) {
	window.status=value;
}

/*******************************************************************************************
 * Function	: staitc header and footer tables
 * These functions loads the page opening and cloasing tables
 *******************************************************************************************/
function topTableCell(){
getColor();
document.write('<table width="760px" align="center" cellpadding="0px" cellspacing="0px" border="0px"><tr><td colspan="3" class="bgTop" width="760px" height="19px"><img src="//a248.e.akamai.net/a755bdded7308e72e7fac2eae90715fc.com/Images/spacer.gif" width="20px" height="19px"alt="">'+
'</td></tr><tr><td class="bgLeft" width="17px"><img src="//a248.e.akamai.net/a755bdded7308e72e7fac2eae90715fc.com/Images/spacer.gif" width="17px" height="20px"alt="">'+
'</td><td width="725px" align="center"><table cellpadding="0px" cellspacing="0px" border="0px" ><tr><td class="layoutTable" >');
}

function bottomTableCell(){
document.write('</td></tr></table></td><td class="bgRight" width="17px"><img src="//a248.e.akamai.net/a755bdded7308e72e7fac2eae90715fc.com/Images/spacer.gif" width="17px" height="50px"alt=""></td>'+
'</tr><tr><td colspan="3" class="bgBot" width="760px" height="20px"><img src="//a248.e.akamai.net/a755bdded7308e72e7fac2eae90715fc.com/Images/spacer.gif" width="760px" height="20px"alt=""></td></tr>'+
'<tr><td colspan="3"><div style="position:relative; height:140px; width:700px"><img src="//a248.e.akamai.net/a755bdded7308e72e7fac2eae90715fc.com/Images/spacer.gif" width="1px" height="140px" border="0"></td></tr></table>');
}

//-->

// vday sweep popup function
function vDaySweepsPopup(){
	ConfigurablePopup('/'+jsContextRoot+'/popups/a_vDaySweep.html','431','350','','0','0','30','30');
}

///// giftcard balance popup
function BalInqPopup()
{
	var LeftPosition = (screen.width) ? (screen.width-340)/2 : 0;
	var TopPosition = (screen.height) ? (screen.height-222)/2 : 0;
	var balanceurl = '/'+jsContextRoot+'/checkout/gc_balance_inquiry_popup.jsp';
	var balPopup = window.open(balanceurl,"balance_pop",'toolbar=0,top='+TopPosition+',left='+LeftPosition+',location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=340,height=275');
	if(navigator.appName.substring(0,8)=="Netscape")
	{
		balPopup.location = balanceurl;
		balPopup.opener = self;
	}
	balPopup.focus();
}

//////////popup for freeshipping
function PopItLikeAColar(){
	ConfigurablePopup('/'+jsContextRoot+'/popups/freeShipping_popup.html','460','325','','0','0','30','30');
}

//////////popup for free bag delete after spring
function freeBagPop(){
	ConfigurablePopup('/'+jsContextRoot+'/popups/freeBag_popup.html','460','325','','0','0','30','30');
}

//////////popup aerie feel free.
function freeGift(){
	ConfigurablePopup('/'+jsContextRoot+'/popups/aerieGift.jsp','607','406','','0','0','30','30');
}


function cartFmDropDown(){
	$(document).ready(function() {
		if(typeof hideAllExpressShop == 'function') hideAllExpressShop(true);
		setTimeout("loadMenuBag()", 1000);
	});
}

function loadMenuBag() {
	$('#showcartarea').load('/'+jsContextRoot+'/global/nav/f_nav_cart_all.jsp', '', animateIt);
	var timer_scroll=setTimeout("window.scrollTo(0,0);",5);
}

function animateIt() {
	$('#shoppingbag').empty().append( $('#allcartcountdrop') ).show();
	$('#menushoppingbag').empty().append( $('#allcartrecent') ).slideDown('fast', function() {
		setTimeout("$('#menushoppingbag').slideUp('fast', reloadMenuBag)", 3000);
	});		
}	

function reloadMenuBag() {
	$('#shoppingbag').empty().append( $('#allcartcount') ).show();
	$('#menushoppingbag').empty().append( $('#allcartall') );
}
		

function getViewportDimensions()
{
	var viewportwidth;
	var viewportheight;
	// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
	if (typeof window.innerWidth != 'undefined')
	{
		viewportwidth = window.innerWidth,
		viewportheight = window.innerHeight
	}
	// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
	else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0)
	{
		viewportwidth = document.documentElement.clientWidth,
		viewportheight = document.documentElement.clientHeight
	}
	// older versions of IE
	else
	{
		viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
		viewportheight = document.getElementsByTagName('body')[0].clientHeight
	}
	return new Array(viewportwidth, viewportheight);
}

function trim(str){
	while(''+str.charAt(0)==' ')
	str=str.substring(1,str.length);
	while(''+str.charAt(str.length-1)==' ')
	str=str.substring(0,str.length-1);
	return str;
}

function initNavAnimationForIE6() {
	// For IE6 to do the hover effect
	if(jQuery.browser.msie && getInternetExplorerVersion() < 7) {
		$.each( { girls: ".girlsSubNav ", tgirls: ".tgirlsSubNav ", boys: ".boysSubNav ", tboys: ".tboysSubNav ", gifts: ".giftsSubNav " }, function(i, n){
			$.each( { IEhover: ".submenucontent", IEhoverleft: ".submenuleft" }, function(j, o){
				$(n + o).hover(
					function () {
						$(this).addClass(i + '_' + j);
					}, 
					function () {
						$(this).removeClass(i + '_' + j);
					}
				);
			});
		});
	} else return;
}
$(document).ready(function() {
	initNavAnimationForIE6();
});
function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
  var rv = -1; // Return value assumes failure.
  if (navigator.appName == 'Microsoft Internet Explorer')
  {
    var ua = navigator.userAgent;
    var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null)
      rv = parseFloat( RegExp.$1 );
  }
  return rv;
}

function isArray(obj) {
   if (obj.constructor.toString().indexOf("Array") == -1)
      return false;
   else
      return true;
}

// to limit characters in a textarea or text input field
// limitField : ID of form element to limit (string)
// limitCount : ID of element to place characters remaining count (string)
// limitNum : the maximum number of characters to allow in field (int)
function limitChars(limitField, limitCount, limitNum) {
	limitField = $('#'+limitField);
	limitCount = $('#'+limitCount);
	if (limitField.val().length > limitNum) {
		limitField.val(limitField.val().substring(0, limitNum));
		limitCount.html('0');
	} else {
		var count = limitNum - limitField.val().length;
		count = count === 0 ? '0' : count; // jQuery won't put the number value of 0 in the element using html(), so make a string
		limitCount.html(count);
	}
}
function mapAnchor(anchor){
window.location.hash = anchor;
}

//////// FRAMEWORK FUNCTIONS ... EXTENDING JQUERY ////////
(function($) {
	
	$.fn.useAjax = function( ajaxOpts ) {
		var instance = this;
		
		var useOverlay = !!ajaxOpts.useOverlay;
		delete ajaxOpts.useOverlay;
		if (useOverlay) {
			(new Image()).src = jsImageSrcPrepend + '/Images/captainCheckout/checkout_step_loader.gif';
			$(document).ready(function() {
				if (!$('#ajaxOverlay').length) {
					if (!!$('#ajaxIconOverlay').length) {
						$('#ajaxIconOverlay').remove();
					}
					var overlayIconStyles = {
						position: 'absolute',
						zIndex: 90001
					},
					overlayStyles = {
						position: 'absolute',
						zIndex: 90000
					},
					overlayIconObj = $('<img id="ajaxIconOverlay" src="' + jsImageSrcPrepend + '/Images/captainCheckout/checkout_step_loader.gif" alt="loading..."/>').appendTo(document.body).hide(),
					overlayObj = $('<div id="ajaxOverlay"></div>').appendTo(document.body).hide();
					overlayIconObj.css(overlayIconStyles);
					overlayObj.css(overlayStyles);
					
					$(window).resize(function() {
						overlayIconObj.centerObj();
						overlayObj.stretchObj();
					});
				}
			});
			
			var successFunc = ajaxOpts.success,
			errorFunc = ajaxOpts.error || function() { window.location.href = '/' + jsContextRoot + '/global/unknownError.jsp'; };
			ajaxOpts.success = function() {
				$('#ajaxOverlay').hide();
				$('#ajaxIconOverlay').hide();
				successFunc.apply(instance, Array.prototype.slice.call(arguments));
			};
			ajaxOpts.error = function() {
				$('#ajaxOverlay').hide();
				$('#ajaxIconOverlay').hide();
				errorFunc.apply(instance, Array.prototype.slice.call(arguments));
			};
		}
		
		function AjaxOpts() {}
		AjaxOpts.prototype = ajaxOpts;
		
		return instance.each(function( i, formEl ) {
			var jQformEl = $(formEl);
			
			$('input:submit,input:image,button:submit', jQformEl).each(function( j, submitEl ) {
				var jQsubmitEl = $(submitEl);
				jQsubmitEl.unbind('click.ajax'); // just in case we are trying to bind the event to this more than once (could result in double submit)
				if (submitEl.type == 'image') {
					jQsubmitEl.bind('click.ajax', function( evt ) {
						formEl.submitData = {};
						formEl.submitData[submitEl.name] = submitEl.value;
						formEl.submitData[submitEl.name + '.x'] = 0;  // I mean really??? are these even necessary? answer according to atg... "yes"
						formEl.submitData[submitEl.name + '.y'] = 0;
					});
				} else {
					jQsubmitEl.bind('click.ajax', function( evt ) {
						formEl.submitData = {};
						formEl.submitData[submitEl.name] = submitEl.value;
					});
				}
			});
			jQformEl.unbind('submit.ajax'); // just in case we are trying to bind the event to this more than once (could result in double submit)
			jQformEl.bind('submit.ajax', function( evt ) {
				evt.preventDefault();
				
				if (useOverlay) {
					$('#ajaxOverlay').show().stretchObj();
					$('#ajaxIconOverlay').show().centerObj();
				}
				
				var ajaxOpts = new AjaxOpts(),
				fieldOpts = {},
				additionalOpts = ajaxOpts.data || {},
				submitOpts = formEl.submitData || {};
				
				$.each(jQformEl.serializeArray(), function( i, elData ) {
					fieldOpts[elData.name] = elData.value;
				});
				
				//  Validation form selector
				//  Don't like this existing here... but I don't know where else to put it.
				var uniqueIdVal = jQformEl.attr('id');
				if (!uniqueIdVal) {
					// Generate random id on the form
					while (!!$('#' + (uniqueIdVal = 'validationForm' + Math.round(Math.random() * 100000))).length) {}
					jQformEl.attr('id', uniqueIdVal);
				}
				submitOpts.validationFormSelector = '#' + uniqueIdVal;
				
				ajaxOpts.url = ajaxOpts.url || fieldOpts.ajaxSuccess || jQformEl.attr('action') || window.location.href;
				
				ajaxOpts.data = $.extend(fieldOpts, submitOpts, additionalOpts);
				
				$.ajax(ajaxOpts);
				
				setTimeout(function() {
					formEl.submitData = null;  // should be "delete formEl.submitData;", but IE doesn't like this for some reason... maybe because it is a DOM element.
				}, 0);
			});
		});
	};

	$.getViewSize = function() {
		/*
			getViewSize - Gets the current document view height and width
			PARAMETERS:	none
			RETURN:	an object containing the height and width of the current view
		*/
		
		function ViewSize() {
			/*
				ViewSize - The class used to define an object containing the current height and width of the document view (cross-browser compatible)
			*/
			var dDe = document.documentElement, dB = document.body, viewW = 0, viewH = 0;
			if (self.innerHeight) {
				viewW = self.innerWidth;
				viewH = self.innerHeight;
			} else if (dDe && dDe.clientHeight) {
				viewW = dDe.clientWidth;
				viewH = dDe.clientHeight;
			} else if (dB) {
				viewW = dB.clientWidth;
				viewH = dB.clientHeight;
			}
			this.x = this.X = this.w = this.W = viewW;
			this.y = this.Y = this.h = this.H = viewH;
		}
		
		return new ViewSize();
	};
	
	$.getPageSize = function() {
		/*
			getPageSize - Gets the current document body height and width
			PARAMETERS:	none
			RETURN:	an object containing the height and width of the current document
		*/
		
		function PageSize() {
			/*
				PageSize - The class used to define an object containing the current height and width of the document body (cross-browser compatible)
			*/
			var dB = document.body, pageW = 0, pageH = 0;
			if (dB.scrollHeight > dB.offsetHeight) {
				pageW = dB.scrollWidth;
				pageH = dB.scrollHeight;
			} else {
				pageW = dB.offsetWidth;
				pageH = dB.offsetHeight;
			}
			this.x = this.X = this.w = this.W = pageW;
			this.y = this.Y = this.h = this.H = pageH;
		}
		
		return new PageSize();
	};
	
	$.getPageOffset = function() {
		/*
			getPageOffset - Gets the current page offset height and width
			PARAMETERS:	none
			RETURN:	an object containing the y and x of the current page offset
		*/
		
		function PageOffset() {
			/*
				PageOffset - The class used to define an object containing the current height and width of the page offset (cross-browser compatible)
			*/
			var dDe = document.documentElement, dB = document.body, scrollW, scrollH;
			if (self.pageYOffset) {
				scrollW = self.pageXOffset;
				scrollH = self.pageYOffset;
			} else if (dDe && dDe.scrollTop) {
				scrollW = dDe.scrollLeft;
				scrollH = dDe.scrollTop;
			} else if (dB) {
				scrollW = dB.scrollLeft;
				scrollH = dB.scrollTop;
			}
			this.x = this.X = this.w = this.W = scrollW;
			this.y = this.Y = this.h = this.H = scrollH;
		}
		
		return new PageOffset();
	};
	
	$.fn.centerObj = function( pad, isFixed ) {
		/*
			centerObj - Centers a specific HTML element in the document view
			PARAMETERS:	pad - the minimum distance between an edge and the centered HTML element as an integer (of pixels)
						isFixed - whether or not an HTML element has position: fixed as a boolean
			RETURN:	none
		*/
		pad = $.forceInt(pad);
		var obj = $(this), suffix = 'px', sizes = $.getViewSize(), offsets = $.getPageOffset(),
		yVal = Math.round((sizes.h / 2) - (obj.outerHeight() / 2) + (isFixed ? 0 : offsets.h)),
		xVal = Math.round((sizes.w / 2) - (obj.outerWidth() / 2) + (isFixed ? 0 : offsets.w));
		
		obj.css({
			top: (((yVal > pad) || (pad < 0))? yVal : pad) + suffix,
			left: (((xVal > pad) || (pad < 0))? xVal : pad) + suffix
		});
	};
	
	$.fn.stretchObj = function( pad, isFixed ) {
		/*
			stretchObj - Stretches a specific HTML element across the document view
			PARAMETERS:	pad - the distance from an edge that the HTML element should stretch to as an integer (of pixels)
						isFixed - whether or not an HTML element has position: fixed as a boolean
			RETURN:	none
		*/
		var obj = $(this), suffix = 'px', pSizes = $.getPageSize(), vSizes = $.getViewSize(),
		hVal = (!isFixed && (pSizes.h > vSizes.h))? pSizes.h : vSizes.h,
		wVal = (!isFixed)? pSizes.w : vSizes.h;
		pad = $.forceInt(pad);
		
		obj.css({
			top: pad + suffix,
			left: pad + suffix,
			height: (hVal - (pad * 2)) + suffix,
			width: (wVal - (pad * 2)) + suffix
		});
	};
	
	$.toPrice = function( num, currency ) {
		/*
			toPrice - Converts a number value into a formatted price string; commas are added at thousand mark, decimals are forced to 2 digits, and the currency is added to the front of the string.
			PARAMETERS:	num - the price as a number
						currency - the currency as a string
			RETURN:	the price with a specific currency as a string
		*/
		if (num) {
			num = $.forceFloat(num).toFixed(2).toString();
			var intEnd = num.indexOf('.') - 3;
			for (var i = intEnd, j = 0; i > j; i -= 3) {
				num = num.substring(0, i) + ',' + num.substring(i, num.length);
			}
			num = num;
		} else {
			num = '0.00';
		}
		if (!currency || (typeof currency != 'string')) {
			currency = '$';
		}
		return currency + num;
	};
	
	$.forceInt = function( num ) {
		/*
			forceInt - Forces data of an undefined type into an integer value
			PARAMETERS:	num - should be an integer value, but may be of a different type
			RETURN:	an integer value
		*/
		return (isNaN(num = parseInt((typeof num == 'string')? num.replace(/\,/g,'').replace(/^.*?([\+\-]?[\d\.]+).*?$/, '$1') : num)))? 0 : num;
	};
	
	$.forceFloat = function( num ) {
		/*
			forceFloat - Forces data of an undefined type into an floating point value
			PARAMETERS:	num - should be an floating point value, but may be of a different type
			RETURN:	an floating point value
		*/
		return (isNaN(num = parseFloat((typeof num == 'string')? num.replace(/\,/g,'').replace(/^.*?([\+\-]?[\d\.]+).*?$/, '$1') : num)))? 0.0 : num;
	};
	
	$.setCookie = function( cookieOpts ) {
		/*
			setCookie - Sets a browser cookie
			PARAMETERS:	cookieOpts - the object containing the information to be set regarding the cookie
							ex: {
								name: [the name of the cookie as a string],
								val: [the value of the cookie as a string],
								path: [the path of the cookie as a string],
								domain: [the domain of the cookie as a string],
								expireDays: [the amount of days before the cookie expires as an integer or the amount of time as a date object],
								expireMins: [the amount of minutes before the cookie expires as an integer or the amount of time as a date object]
							}
			RETURN:	none
		*/
		if (!cookieOpts.val) {
			cookieOpts.val = '';
			cookieOpts.expireDays = 0;
		}
		var fullVal = '';
		if (!!cookieOpts.name) {
			fullVal = cookieOpts.name + '=' + cookieOpts.val;
			if (!!cookieOpts.path) {
				fullVal += ';path=' + cookieOpts.path;
			}
			if (!!cookieOpts.domain) {
				fullVal += ';domain=' + cookieOpts.domain;
			}
			if (!!cookieOpts.expireDays) {
				var expDate = new Date();
				expDate.setDate(expDate.getDate() + cookieOpts.expireDays);
				fullVal += ';' + expDate.toGMTString();
			} else if (!!cookieOpts.expireMins || !cookieOpts.val) {
				var expDate = new Date();
				expDate.setTime(expDate.getTime() + (cookieOpts.expireMins * 60000));
				fullVal += ';' + expDate.toGMTString();
			}
		}
		
		if (!!fullVal) {
			document.cookie = fullVal;
		}
	};
	
	$.getCookie = function( cookieName ) {
		/*
			getCookie - Gets the value of a specific cookie
			PARAMETERS:	cookieName - the name of the cookie as a string
			RETURN:	the cookie value as a string
		*/
		var dCookie = document.cookie;
		if ((dCookie.length > 0) && cookieName){
			var cBegin = dCookie.indexOf(cookieName += '=');
			if (cBegin != -1){
				cBegin = cBegin + cookieName.length;
				var cEnd = dCookie.indexOf(';', cBegin);
				if (cEnd == -1) cEnd = dCookie.length;
				return dCookie.substring(cBegin, cEnd);
			}
		}
		return '';
	};
	
})(jQuery);