<!--
//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();
}

//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	: 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;
}

// 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 allModals != 'undefined'){ // close quick view on add to bag
			var openModals = allModals.openSet();
			$.each(openModals, function(key, modal){
				if(modal.isQuickView()) modal.close();
			});
		}
		setTimeout("loadMenuBag()", 1000);
	});
}

function noAjaxCartFmDropDown( htmlVal ) {
	$(document).ready(function() {
		if(typeof allModals != 'undefined'){ // close quick view on add to bag
			var openModals = allModals.openSet();
			$.each(openModals, function(key, modal){
				if(modal.isQuickView()) modal.close();
			});
		}
		setTimeout(function() {
			noAjaxLoadMenuBag(htmlVal);
		}, 1000);
	});
}

function noAjaxLoadMenuBag( htmlVal ) {
	if (!!htmlVal) {
		$('#showcartarea').html(htmlVal);
		window.scrollTo(0,0);
		animateIt();
	}
}

function noAjaxUpdateMenuBag( htmlVal ) {
	if (!!htmlVal) {
		$('#showcartarea').html(htmlVal);
		reloadMenuBag();
	}
}

function loadMenuBag() {
	$('#showcartarea').load('/'+jsContextRoot+'/global/nav/f_nav_cart_all.jsp', '', animateIt);
	var timer_scroll=setTimeout("window.scrollTo(0,0);",5);
}
/* this updates the content of the bag drop down and the count without causing the drop down to appear */
function updateMenuBag(){
	$('#showcartarea').load('/'+jsContextRoot+'/global/nav/f_nav_cart_all.jsp', '', reloadMenuBag);
}

function animateIt() {
	$.ie6selectFix({toggle: 'hide', className: DROPDOWNie6selectFixClass});
	setTimeout(function() {
		$('#shoppingbag').empty().append( $('#allcartcountdrop') ).show();
		$('#menushoppingbag').empty().append( $('#allcartrecent') ).slideDown('fast', function() {
			setTimeout("$('#menushoppingbag').slideUp('fast', reloadMenuBag)", 3000);
		});
	}, 0);
}

function reloadMenuBag() {
	$.ie6selectFix({className: DROPDOWNie6selectFixClass});
	$('#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 [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($.browser.msie && ($.browser.version < 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 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 parseQueryString( queryVal ) {
	/*
		parseQueryString - Extracts a query (key - value set) from the href of the current page; the href can also be overridden by passing a queryStr as the first parameter
		PARAMETERS:	queryVal - the href string to test; if none is supplied window.location.search is used
		RETURN:	a javascript object containing the query data
	*/
	queryVal = queryVal || window.location.search;
	if (queryVal) {
		var queryStart = queryVal.indexOf('?');
		if (queryStart !== -1) {
			queryVal = queryVal.substr(queryStart + 1);
			if (!queryVal) {
				return null;
			}
		} else {
			return null;
		}
		var data = {}, sets = queryVal.split('&');
		for (var i = 0, j = sets.length; i < j; i++) {
			var set = sets[i].split('=');
			if (set) {
				data[decodeURIComponent(set[0])] = (set[1])? decodeURIComponent(set[1]) : '';
			}
			set = null;
		}
		sets = null;
		return data;
	}
	queryVal = null;
	return null;
	
}
function generateQueryString( queryVal, locationVal ) {
	/*
		generateQueryString - Generates a query string from a set of data and a location
		PARAMETERS:	queryVal - the query data as a javascript object; the data can also be passed as a string
					locationVal - the href as a string; if empty, window.location.href is used and the new query is appended to any previously existing query
		RETURN:	the href including the query set as a string
	*/
	if (!locationVal) {
		locationVal = window.location.href;
	}
	if (queryVal) {
		var queryStart = locationVal.indexOf('?'), prevQuery = '';
		if (queryStart !== -1) {
			prevQuery = locationVal.substr(queryStart + 1);
			if (prevQuery && (prevQuery.charAt(prevQuery.length - 1) !== '&')) {
				locationVal += '&';
			}
		} else {
			locationVal += '?';
		}
		queryStart = prevQuery = null;
		var queryType = typeof queryVal;
		if (queryType == 'string') {
			locationVal += encodeURI(queryVal);
		} else if (queryType == 'object') {
			for (var i in queryVal) {
				locationVal += encodeURIComponent(i) + '=' + encodeURIComponent(queryVal[i]) + '&';
			}
			locationVal = stripLast(locationVal, '&');
		}
		queryType = null;
		locationVal = stripLast(locationVal, '?');
	}
	return locationVal;
}
function stripLast( str, chr ) {
	/*
		stripLast - Removes the end of a string if it matches a substring
		PARAMETERS:	str - the string to check
					chr - the substring to match
		RETURN:	the string without the match on the end
	*/
	if ((typeof str === 'string') && (typeof chr === 'string')) {
		var lastChar = str.length - chr.length;
		if (str.substr(lastChar) === chr) {
			str = str.substr(0, lastChar);
		}
		lastChar = null;
	}
	return str;
}

//////// FRAMEWORK FUNCTIONS ... EXTENDING JQUERY ////////
(function($) {
	
	$.ie6selectFix = (function() {
		if ($.browser.msie && ($.browser.version < 7)) {
			$(document).ready(function() {
				$(document.body).prepend('<style type="text/css">select.ie6electHide{visibility: hidden !important;}</style>');
			});
			
			return function( configOpts ) {
				function DUMMYopts() {}
				DUMMYopts.prototype = {
					toggle: 'show',
					scope: null,
					className: 'ie6electHide'
				};
				
				var bod = $(document.body),
				opts = new DUMMYopts();
				
				$.each(opts, function( key ){
					if (typeof configOpts[key] != 'undefined') {
						switch (key) {
							case 'className':
								if (!$('#ie6selectHideStyles_' + configOpts[key]).length) {
									$(document.body).prepend('<style id="ie6selectHideStyles_' + configOpts[key] + '" type="text/css">select.' + configOpts[key] + '{visibility: hidden !important;}</style>');
								}
							default:
								opts[key] = configOpts[key];
						}
					}
				});
				
				if (opts.toggle == 'hide') {
					bod.find('select').addClass(opts.className);
				} else {
					if (!opts.scope) {
						opts.scope = bod;
					} else {
						bod.find('select').addClass(opts.className);
					}
					opts.scope.find('select').removeClass(opts.className);
				}
			};
		} else {
			return function(){};
		}
	})();
	
	$.fn.useAjax = function( ajaxOpts ) {
		var instance = this;
		
		var IE6selectFixClass = 'ie6selectFixAjaxSubmit';
		
		var useOverlay = !!ajaxOpts.useOverlay;
		delete ajaxOpts.useOverlay;
		if (useOverlay) {
			var loaderContext = 'ae';
			switch (jsContextRoot) {
				case '77kids':
					loaderContext = 'kids';
					break;
				case 'aerie':
					loaderContext = 'aerie';
					break;
			}
			var LOADER_IMG_PATH = jsImageSrcPrepend + '/Images/captainCheckout/loading/loader_' + loaderContext + '.gif';
			(new Image()).src = LOADER_IMG_PATH;
			$(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="' + LOADER_IMG_PATH + '" alt="loading..."/>').prependTo(document.body).hide(),
					overlayObj = $('<div id="ajaxOverlay"></div>').prependTo(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();
				$.ie6selectFix({className: IE6selectFixClass});
				successFunc.apply(instance, Array.prototype.slice.call(arguments));
			};
			ajaxOpts.error = function() {
				$('#ajaxOverlay').hide();
				$('#ajaxIconOverlay').hide();
				$.ie6selectFix({className: IE6selectFixClass});
				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 ) {
				if (!evt.isDefaultPrevented()) {
					evt.preventDefault();
					
					if (useOverlay) {
						$.ie6selectFix({toggle: 'hide', className: IE6selectFixClass});
						$('#ajaxOverlay').show().stretchObj();
						$('#ajaxIconOverlay').show().centerObj();
					}
					
					var ajaxOpts = new AjaxOpts(),
					fieldOpts = {},
					additionalOpts = ajaxOpts.data || {},
					submitOpts = formEl.submitData || {};
					
					$.each(jQformEl.serializeArray(), function( i, elData ) {
						if (!fieldOpts[elData.name]) {
							fieldOpts[elData.name] = [];
						}
						fieldOpts[elData.name].push(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);
