<!--
if(typeof jsImageSrcPrepend=='undefined')
	var jsImageSrcPrepend = '';
if(typeof jsImageTagPrepend=='undefined')
	var jsImageTagPrepend = '';
//window.top.name="preview";
/*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 == "+" || search == " ") {
		alert('Your search criteria is too general.\nPlease add to it and try again.');
		document.searchForm.query.focus();
		return false;
	}
	else if ((search.indexOf("gift card")>-1)  || (search.indexOf("giftcard")>-1) || search == "gc")
	{
		// TODO: update the catId when gift card is broken out into two genders again, but still probably default to Women's
		window.location = "/" + jsContextRoot + "/browse/category.jsp?catId=cat80013";
		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;
	}
}
//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) // calling with new name, see below.  only keeping this in case it works on some pages and other things rely on it
{
	return GenericPopup(url,w,h);
}
function GenericPopup(url,w,h,winName) // renamed because there are other things named popup on the page so the function wasn't working
{
	if (winName == null)
		winName = "MAO";
	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,winName,'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;
}
function clearNameCookie(){
document.cookie="DYN_PROFILE_ID=;-1;path=/";
}
//-->

var navAnimationEnabled = false;
var lockNavAnimation = false;
var navAnimationDelay = .3; // seconds
var navRevertDelay = .8; // seconds

navAnimationDelay = navAnimationDelay * 1000; // convert to miliseconds
navRevertDelay = navRevertDelay * 1000; // convert to miliseconds

var navAnimationTimeout = null;  // initialize these for later
var navRevertTimeout = null;
var currentCategory = null;
var navContentInitial = '';

// For IE6 to do the hover effect without flickering
var navIEHoverDelay = 10; // miliseconds
var navIEHoverTimeout = null;
var currentNavIEHoverElement = null;
var mainnav_sections = $(document);
var sectionsnavwrapper = $(document);
var mainnav_categories = $(document);

function initNavAnimation()
{
	mainnav_sections = $('#mainnav_sections');
	sectionsnavwrapper = $('#sectionsnavwrapper');
	mainnav_categories = $('#mainnav_categories');	navAnimationEnabled = true;
	navContentInitial = $('#onstatewrapper').html();
	if(navAnimationEnabled)
	{
		sectionsnavwrapper.bind('mouseover', function(e){
			clearRevertTimeout();  // make sure nav doesn't revert back
		});
		sectionsnavwrapper.bind('mouseout', function(e){
			setRevertTimeout(); // to revert back to this page's proper nav
		});
		mainnav_categories.bind('mouseover', function(e){
			animateHeader(e); // initialize root category animation
		});
		mainnav_categories.bind('mouseout', function(e){
			stopAnimateHeader(e); 
		});
		
		// For IE6 to do the hover effect on the nav without flickering
		initNavAnimationForIE6();
	}
}
function initNavAnimationForIE6()
{
	// For IE6 to do the hover effect on the nav without flickering
	if(jQuery.browser.msie && getInternetExplorerVersion() < 7)
	{
		clearNavIEHoverTimeout();
		navIEHoverTimeout = currentNavIEHoverElement = null;
		$(".submenucontent").mouseout(function(){
			setNavIEHoverTimeout(this);
		}).mouseover(function(){
			onOverNavIEHover(this);
		});
	}else return;
}

function onOverNavIEHover(el)
{
	
	if(el != currentNavIEHoverElement && currentNavIEHoverElement != null) onOutNavIEHover();
	clearNavIEHoverTimeout();
	$(el).addClass('hover');
}
function onOutNavIEHover()
{
	if(currentNavIEHoverElement != null) $(currentNavIEHoverElement).removeClass('hover');
	currentNavIEHoverElement = null;
}
function setNavIEHoverTimeout(el)
{
	currentNavIEHoverElement = el;
	navIEHoverTimeout = window.setTimeout(onOutNavIEHover, navIEHoverDelay);
}
function clearNavIEHoverTimeout()
{
	clearTimeout(navIEHoverTimeout);
}
function setRevertTimeout()
{
	navRevertTimeout = window.setTimeout('startAnimateHeader("'+pageCategory+'")', navRevertDelay);
}
function clearRevertTimeout()
{
	clearTimeout(navRevertTimeout);
}
function animateHeader(e)
{
	if(navAnimationEnabled){
		if (!e) var e = window.event;
		var target_element = (window.event) ? e.srcElement : e.target;
		//var check = true;
		if (target_element.nodeName != 'A') return;
		var related_element = (e.relatedTarget) ? e.relatedTarget : e.fromElement;
		try {
			if (related_element.nodeType == 3) // safari selects text as target, so we need the parent element in this case
				related_element = related_element.parentNode;
			if (related_element == target_element) return;
			var isSectionParent = $(related_element).parents('div#mainnav_sections');
			if(isSectionParent.length > 0) clearRevertTimeout();
			var target_id = target_element.id;
			var category = target_id.substring(3, target_id.lastIndexOf('l'));

			navAnimationTimeout = window.setTimeout('startAnimateHeader("'+category+'")', navAnimationDelay);			
		} catch (err) {}
	}
}
function stopAnimateHeader(e)
{
	if(navAnimationEnabled)
	{
		if(!lockNavAnimation) { // animation hasn't started
			clearTimeout(navAnimationTimeout);
		}
		else
		{
			mainnav_sections.stop();
			mainnav_sections.css('height', '120px');
						
			// unlock animation
			lockNavAnimation = false;
		}
		
		if (!e) var e = window.event;
		var target_element = (window.event) ? e.srcElement : e.target;
		var related_element = (e.relatedTarget) ? e.relatedTarget : e.toElement;
		try {
			if (related_element.nodeType == 3) // safari selects text as target, so we need the parent element in this case
				related_element = related_element.parentNode;
			if (related_element == target_element) return;
			var isCategoryParent = $(related_element).parents('div#mainnav_categories');
			var isSectionParent = $(related_element).parents('div#mainnav_sections');
			if(!(isCategoryParent.length <= 0) || !(isSectionParent.length <= 0)) return;
			navAnimationTimeout = window.setTimeout('startAnimateHeader("'+pageCategory+'")', navAnimationDelay);
		} catch (err) {}
	}
}
function startAnimateHeader(category)
{
	if(!lockNavAnimation && category != currentCategory)
	{
		clearRevertTimeout();  // make sure nav doesn't revert back
		animateMainNavigation(category)
	} // if not lockNavAnimation
}
function animateMainNavigation(category)
{
	var blindDownTime = .3; // seconds
	var blindDownEasing = 'swing';
	
	blindDownTime = blindDownTime * 1000; // convert to miliseconds
	
	lockNavAnimation = true;
	
	mainnav_sections.css('height', '0px');
	
	swapNavContent(category);
	
	mainnav_sections.animate(
		{
			height:'120px'
		},
		blindDownTime, 
		blindDownEasing,
		function()
		{
			lockNavAnimation = false;
		}
	);
}
function swapNavContent(category)
{
	//var newContent = category == '' ? '' : $('#'+category+'NavContent').html();
	var newContent = category == '' ? navContentInitial : $('#'+category+'NavContent').html();
	$('#onstatewrapper').html(newContent); // swap content
	currentCategory = category;
	$('#mainnav_categories > a').removeClass('current');
	$('#nav'+category+'link').addClass('current');	
}
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;
}
// 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);
	}
}
//used in Cart.jsp to apply the promotion during proceed to checkout 
function scanProcessCheckout(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{ 
		document.addToCart.fCouponCode.value=document.addToCart.CouponCode.value;
		return true;
	}
}
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 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 initSectionLinkJumps(scopeObj) {
    if (!!scopeObj) {
		var tabSet = scopeObj.find('ul.sectionList'),
		tabLinks = tabSet.find('a'),
		scrollContainer = scopeObj.find('div.sectionContent');
		
		tabLinks.each(function( i, elm ) {
			elm = $(elm);
			var scrollVal = scrollContainer.find(elm.attr('href').replace(/^.*(\#[^\#]+)$/, '$1')).offset().top - scrollContainer.offset().top;
			elm.click(function( event ) {
				event.preventDefault();
                //scrollContainer[0].scrollTop = scrollVal;  // non-animated version
                setTimeout(function() {  // Should avoid animation if we are already there
					scrollContainer.stop();
					scrollContainer.animate({scrollTop: scrollVal + 'px'}, 'fast');
				}, 0);
			});
		});
	}
}
////////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);

