	//////////////////////////////////////////////////////////////////////
	//## Cookies
		function createCookie(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=/";
		}

		function readCookie(name) {
			var nameEQ = name + "=";
			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) return c.substring(nameEQ.length,c.length);
			}
			return null;
		}

		function eraseCookie(name) {
			createCookie(name,"",-1);
		}
	//! END: Cookies
	//////////////////////////////////////////////////////////////////////

	//////////////////////////////////////////////////////////////////////
	//## Shopping Cart
		function AddToCart()
		{
			var arr_inputs = document.getElementsByTagName( 'input' );
			var arr_params = Array();
			for( var i = 0; i < arr_inputs.length; i++ )
			{
				var input = arr_inputs[i];
				if( input.type == 'text' )
				{
					var re = /quantity\[(\d+)\]/;
					var m = re.exec( input.name );
					if( m != null )
						arr_params.push( m[1] + "=>" + input.value );
				}
			}

			alert( arr_params.join( '#' ) );
			AjaxExecute( null, 'AddToCart', arr_params.join( '#' ) );
		}
	//! END: Shopping Cart
	//////////////////////////////////////////////////////////////////////

	//////////////////////////////////////////////////////////////////////
	//## Modals
		function SystemAlert( title, msg )
		{
			var params = new Array();
			params['css'] = 'modal';
			params['css_title'] = 'modal_title';
			params['css_ok_button'] = 'button';
			params['css_cancel_button'] = 'button';
			params['ok_caption'] = 'Close';
			params['img_url_icon'] = VIRTUAL_DIR_ROOT + 'images/question_big.gif';

			var modal = Modal.CreateInstance( Modal.POPUP, params, null, null );
			ShowModal( modal, title, msg );
		}

		function ShowModal( modal, title, msg )
		{
			title = decodeURIComponent( title );
			msg = decodeURIComponent( msg );

			modal.Show( title, msg );
		}

		function SystemConfirm( oThis, title, msg )
		{
			if( oThis.getAttribute( "already_confirmed" ) )
			{
				var str_already_confirmed = oThis.getAttribute( "already_confirmed" );
				var arr_already_confirmed = str_already_confirmed.split( "," );
				for( var i = 0; i < arr_already_confirmed.length; i++ )
					if( arr_already_confirmed[i] == title )
						return true;
			}
			oThis.setAttribute( "current_modal_title", title );

			var modal = Modal.CreateInstance( Modal.CONFIRM, GetModalInputParams(), SystemConfirmOkay, null );
			modal.SetCustomData( oThis );
			ShowModal( modal, title, msg );
			return false;
		}

		function GetModalInputParams()
		{
			var params = Array();
			params['css'] = 'modal_input';
			params['css_title'] = 'modal_input_title';
			params['css_ok_button'] = 'button';
			params['css_cancel_button'] = 'button';
			params['ok_caption'] = 'Ok';
			params['cancel_caption'] = 'Cancel';
			params['img_url_icon'] = VIRTUAL_DIR_ROOT + 'images/exclamation_point_icon_big.gif';
			return params;
		}

		function SystemConfirmOkay()
		{
			var oThis = this.GetCustomData();
			var str_already_confirmed = oThis.getAttribute( "already_confirmed" );
			if( str_already_confirmed )
			{
				var arr_already_confirmed = str_already_confirmed.split( ',' );

				arr_already_confirmed.push( oThis.getAttribute( "current_modal_title" ) );
				oThis.setAttribute( "already_confirmed", arr_already_confirmed.join( ',' ) );
			}
			else
				oThis.setAttribute( "already_confirmed", oThis.getAttribute( "current_modal_title" ) );

			if( oThis.href && oThis.href != "#" )
				window.location = oThis.href;
			else if( oThis.click )
				oThis.click();
			else
				oThis.onclick();
		}

		function SystemError( msg )
		{
			var params = new Array();
			params['css'] = 'modal_error';
			params['css_title'] = 'modal_error_title';
			params['css_ok_button'] = 'modal_error_button';
			params['css_cancel_button'] = 'modal_error_button';
			params['ok_caption'] = 'Close';
			params['img_url_icon'] = VIRTUAL_DIR_ROOT + 'images/exclamation_point_icon_big.gif';

			var modal = Modal.CreateInstance( Modal.POPUP, params, null, null );
			ShowModal( modal, 'Error', msg );
		}

		function PromptOkay()
		{
			oThis = this.GetCustomData();
			zip_code = this.GetText();

			if( zip_code == null || zip_code == '' || zip_code.length <= 1 )
				return false;
			if( zip_code.length != 5 )
			{
				SystemError( 'The zip code must be 5 digits' );
				return;
			}

			oThis.setAttribute( 'already_confirmed', 'true' );
			document.getElementById( 'cart_zip_code' ).value = zip_code;
			oThis.click();
		}

		function show_validation_error( title, msg ) { SystemError( msg ); }
	//! END: Modals
	//////////////////////////////////////////////////////////////////////

	//////////////////////////////////////////////////////////////////////
	//## Misc
		function SearchFormSubmit()
		{
			var search_term = document.getElementById( 'search_term' ).value;
			window.location = VIRTUAL_DIR_ROOT + 'search/0/' + encodeURI( search_term );
			return false;
		}

		function ReplaceFullWidthLinks()
		{
			var arr_links = document.getElementsByTagName( 'a' );

			for( var i = 0; i < arr_links.length; i++ )
			{
				if( arr_links[i].href.indexOf( 'pages/full_width' ) != -1 )
				{
					arr_links[i].onclick = function()
					{
						var rect = Viewport.getRect();
						var pop_height = rect.height - 25;
						var pop_width = rect.width - 25;

						window.open( this.href, 'full_width_window', 'status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=1,scrollbars=1,width=' + pop_width + ',height=' + pop_height ); return false;
					}
				}
			}
		}

		addLoadEvent( ReplaceFullWidthLinks );
	//! END: Misc
	//////////////////////////////////////////////////////////////////////
