		
		//close htmlPOpup
		$j(window).bind('keyup',function(e) {
			if(e.keyCode == 27) {
				if($j('#blackout').length > 0) {
					$gcws.blackout('hide'); 
				}
				if($j('.popup-holder').length > 0) {
					$j('.popup-holder').remove();
				}
			}
		});
		
		var $gcws = {
			alertsResponse:null,
			alerts:function(c,t,w,h,accept) {					
					
					if(!c || typeof c == 'undefined') return false;
					if(!t || typeof t == 'undefined') t = '<h2>Information</h2>';
					if(!w || typeof w == 'undefined') w = '600px';
					if(!h || typeof h == 'undefined') h = '400px';	
					if(typeof accept == 'undefined') accept = true;	
					if(!$gcws.alertsResponse || $gcws.alertsResponse == null) $gcws.alertsResponse = '$j(\'#gcwsAlert\').fadeOut(function() { $j(this).remove()} );$gcws.blackout(\'hide\')';			
					var html_header = '<div class="gcwsAlert-header">'+t+'<a href="javascript:;" onclick="$j(\'#gcwsAlert\').fadeOut(function() { $j(this).remove()} );$gcws.blackout(\'hide\')">X</a><div class="clear"></div></div>';
					var html = '';
					var html_accept = '<div class="form" style="text-align:center">';
						html_accept += '<span class="button-wrap"><input type="button" onclick="eval($gcws.alertsResponse)" value="OK" id="gcwsAlertOK" class="btn-sp"></span></div>';
					var html_name = 'gcwsAlert';
					
					if(accept === false) {
						html_accept = '';
					}
					
					if(typeof c == 'object') {
						if(typeof c.action == 'undefined') {
							c.action = 'ajax';
						}
						
						if(typeof c.func == 'undefined') {
							c.func = 'alerts';
						}
												
						c.html_extra = html_accept;
						html = c;
					} else {
						
						if(c.substring(0,1) == '#') {					
							html = $j(c).html();
						} else {
							html += '<p>'+c+'</p>';
							html += html_accept;
						}
					}
					$gcws.blackout();								
					$gcws.htmlPopup(html_name,html,w,h,html_header);					
					
			},
				
			blackout:function(keep) {
				var winWidth = $j(document).width();
				var winHeight = $j(document).height();
				if($j('#blackout').length == 0) {
					$j(document.body).append('<div id="blackout"></div>');
					$j('#blackout').css('height',winHeight+'px');
					$j('#blackout').css('width',winWidth+'px');
					$j('#blackout').css('position','absolute');
					$j('#blackout').css('display','block');				
					$j('#blackout').css('background-color','#ffffff');
					$j('#blackout').css('opacity','0.7');
					$j('#blackout').css('-moz-opacity','0.7');
					$j('#blackout').css('khtmlopacity','0.7');
					$j('#blackout').css('filter','alpha(opacity=70)');
				} else {
					if(keep == true) {
						return true;
					} else if(keep == 'hide') {
						$j('#blackout').remove();
					} else if(keep == 'show') {
						$j('#blackout').show();
					} else if(typeof keep == 'undefined' || typeof keep == null) {
						$j('#blackout').toggle();
					}
				}			
				
			},
			
			
			htmlPopupResponse:null,			
			htmlPopup:function(name,content,iw,ih,header) {
				if(typeof name == 'undefined' ||
				   typeof name == null) {
					name = 'htmlPop';
				}
				
				var aw = $j(window).width();
				var ah = $j(window).height();
				var st = $j(document).scrollTop();
				var sl = $j(document).scrollLeft();
				
				//check fox px				
				if(iw.toString().indexOf('px') != -1) {
					var w = iw.toString().substr(0,iw.toString().indexOf('px'));
				} else {
					var w = aw * iw;
				}
				if(ih.toString().indexOf('px') != -1) {
					var h = ih.toString().substr(0,ih.toString().indexOf('px'));
				} else {
					var h = ah * ih;
				}
				
				var ch = h;
				var headh = 0;
				var theHtml = '';
				var ajaxContent = { };
				if($j('#'+name).length == 0) {
					$j(document.body).append('<div id="'+name+'" class="popup-holder"><div class="popup-html"><div class="popup-content"></div></div></div>');				
				}
				
				/* include header */
				if(typeof header != 'undefined' &&
				   typeof header != null) {
					
					if($j('#'+name+' .popup-header').length == 0) {
						if(header.substring(0,1) == '#') {
							$j('#'+name).prepend('<div class="popup-header">'+$j(header).html()+'</div>');
						} else {
							$j('#'+name).prepend('<div class="popup-header">'+header+'</div>');
						}
					}
					
					//new content height
					if($j('#'+name+' .popup-header').length == 0) {
						headh = 0;
					} else {
						headh = $j('#'+name+' .popup-header').height();
					}
					
					ch = (h-headh);
					h = parseFloat(h) + parseFloat(headh);
				}
	
				var t = ((ah - h)/2)+st;
				var l = ((aw - w)/2)+sl;

				//check if window height is less than the actual popup
				if(ah < h) {
					t = 20;	 //push it down a little bit
				}
				
				$j('#'+name).css('display','none');
				$j('#'+name).css('background-color','#ffffff');
				$j('#'+name).css('width',w+'px');
				$j('#'+name).css('height',h+'px');	
				$j('#'+name).css('position','absolute');
				$j('#'+name).css('zIndex',999);
				$j('#'+name).css('top',t+'px');
				$j('#'+name).css('left',l+'px');				
				$j('#'+name).fadeIn();

				$j('#'+name+' .popup-html').css('width',w+'px');
				$j('#'+name+' .popup-html').css('height',ch+'px');
				$j('#'+name+' .popup-html').css('overflow','auto');
				
				//check if we are getting an object to ajax
				if(typeof content == 'object') {						
					$j('#'+name+' .popup-content').html('<div style="text-align:center"><img src="/images/loading.gif" /></div>');				
					
					
					if(typeof content.timeout == 'undefined') {
						content.timeout = 600000;
					}
					
					$j.ajaxSetup({
						timeout:content.timeout,
						complete:function(a,text) {
							if(text == 'timeout') {
								alert('The operation is taking longer than usual, please try again later...');
							} else if(text == 'error') {
								alert('There has been an error while processing your request, please try again later...');
							}
						}
						
					});
					
					if(typeof content.url == 'undefined' || content.url == '') {
						alert('No URL was given');
						return false;
					}
					
					var content_data;
					var url = content.url;
					delete content.url;				
					
					if(typeof content.data == 'undefined') {
						content.data = '';
						content_data = content;
					} else {
						content_data = content.data;	
					}
							
					$j.ajax({
						type:"POST",
						url:url,
						data:content_data,
						success:function(r) {
							if(typeof content.html_extra != 'undefined') {
							  r += content.html_extra;
						  	}
						  	$j('#'+name+' .popup-content').html(r);			
						}
					});
				
					return true;
				} else if(typeof content == 'function') {
					theHtml = content();
				} else if(content.substring(0,1) == '#') {					
					theHtml = $j(content).html();
					$j(content).remove();
				} else {
					theHtml = content;
				}
				
				$j('#'+name+' .popup-content').html(theHtml);
				
			},
			
			htmlPopupCenter:function(popup) {
				
				if(typeof popup == 'undefined') {
					popup = '.popup-html';
				} else {
					if(popup.indexOf('#') == -1) {
						popup = '#' + popup;
					} 
				}
				
				var aw = $j(window).width();
				var ah = $j(window).height();
				var st = $j(document).scrollTop();
				var sl = $j(document).scrollLeft();
				var w = $j(popup).width();
				var h = $j(popup).height();
									
				var t = ((ah - h)/2)+st;
				var l = ((aw - w)/2)+sl;

				$j(popup).css('position','absolute');
				$j(popup).css('zIndex',999);
				$j(popup).css('top',t+'px');
				$j(popup).css('left',l+'px');				
				$j(popup).show();								
			},
						
			htmlPopupResize:function(popup,iw,ih) {
				
				if(typeof popup == 'undefined') {
					popup = '.popup-html';
				} else {
					if(popup.indexOf('#') == -1) {
						popup = '#' + popup;
					} 
				}
				
				//check fox px				
				if(iw.toString().indexOf('px') != -1) {
					var w = iw.toString().substr(0,iw.toString().indexOf('px'));
				} else {
					var w = aw * iw;
				}
				if(iw.toString().indexOf('px') != -1) {
					var h = ih.toString().substr(0,ih.toString().indexOf('px'));
				} else {
					var h = ah * ih;
				}
				
				var ch = h;
				var headh = 0;
				
				//new content height
				if($j(popup + ' .popup-header').length >= 1) {
					headh = $j(popup + ' .popup-header').height();
					ch = (h-headh);
					h = parseFloat(h) + parseFloat(headh);
				} else {
					headh = 0;
				} 
				
				
				$j(popup).css('width',w+'px');
				$j(popup).css('height',h+'px');	
				$j(popup + ' .popup-html').css('width',w+'px');
				$j(popup + ' .popup-html').css('height',ch+'px');
				$j(popup + ' .popup-html').css('overflow','auto');
			},
			
			windowsLoader:new Array(),		
			
			windowsLoaderAdd:function(func) {
				$gcws.windowsLoader[windowsLoader.length] = func;
			},
			
			windowsLoadFunc:function() {
				for(i=0;i<windowsLoader.length;i++) {
					eval(windowsLoader[i]);
				}
			},
			
			loadFunc:function(){ 
				window.onload = windowsLoadFunc;
			},
			
			setState:function(w) {
				if(w.value != 'US') {
					$j('#state').attr('value','99');
					$j('#state').attr('disabled',true);
					$j('#state_outside').attr('disabled',false);
				} else {
					$j('#state').attr('value','0');
					$j('#state').attr('disabled',false);
					$j('#state_outside').attr('disabled',true);
				}
					
			},
			
			popUp:function(theURL, Name, popW, popH, scroll) { 
				var winleft = (screen.width - popW) / 2;
				var winUp = ((screen.height - popH) / 2)-50;
				winProp = 'width='+popW+',height='+popH+',left='+winleft+',top='+winUp+',scrollbars='+scroll+',resizable'
				Win = window.open(theURL, Name, winProp)
				if (parseInt(navigator.appVersion) >= 4) { Win.window.focus(); }
			},
						
			checkAll:function(field,type,theclass) {
				
				if(!type || typeof type == 'undefined') {
					type = 'checkbox';
				}
				
				$j(':'+type).select();
				
				if(field.checked) {					
					if(typeof theclass != 'undefined') {
						if($j(':'+type).hasClass(theclass)) {						
							$j('.'+theclass).attr('checked',true);
						} else {
							return false;
						}
					} else {	
						$j(':'+type).attr('checked',true);						
					}
				} else {
					if(typeof theclass != 'undefined') {
						if($j(':'+type).hasClass(theclass)) {						
							$j('.'+theclass).attr('checked',false);
						} else {
							return false;
						}
					} else {	
						$j(':'+type).attr('checked',false);
					}
				}			
				
			},

			dialog:function(m) {
				if(!window.confirm(m)) { 
					return false;
				}
				return true;
			},
			
			disableButton:function(b,t) {
				$j(b).attr('disabled',true);
				$j(b).attr('value',t);
			},
			
			dismissElement:function(el) {
				
				var hide = true;
				if(document.addEventListener) {
					document.addEventListener("click",function(event) { 
						var element = event.target;
						
						for(var e = element; e; e = e.offsetParent) {
							if(e.getAttribute('id') == el) {																	
								hide = false;	
							}
						}
						
						if(hide == true) {
							if($j('#'+el).length == 1) {
								$j('#'+el).hide();
							}
						}

						
					},true);
					
				} else {
					//listen to the document on IE
					document.numclicks = 0;					
					document.onclick = function() {			
								
						var element = event.srcElement;		
						document.numclicks++;
						
						for(var e = element; e; e = e.offsetParent) {
							if(e.getAttribute('id') == el) {																	
								hide = false;	
							}
						}
						
						if(hide == true && document.numclicks > 1) {	
												
							if($j('#'+el).length == 1) {
								$j('#'+el).hide();
								document.numclicks = 0;
							}
						}
					}
				}	
				
			},
			
			findPosX:function(obj) {
				var curleft = 0;
				if(obj.offsetParent)
					while(1) 
					{
					  curleft += obj.offsetLeft;
					  if(!obj.offsetParent)
						break;
						  obj = obj.offsetParent;
						}
						else if(obj.x)
						curleft += obj.x;
						return curleft;
			},
						
			findPosY:function(obj) {
				var curtop = 0;
				if(obj.offsetParent)
					while(1)
					{
					  curtop += obj.offsetTop;
					  if(!obj.offsetParent)
						break;
					  obj = obj.offsetParent;
					}
					else if(obj.y)
					curtop += obj.y;
					return curtop;
			}
			
		}
