HG=window.HG||{};HG.util={inArray:function(element,array){var i;var found=false;for(i in array){if(array[i]==element){found=true;break;}}
return found;},padAZero:function(s){s=s.toString();if(s.length==1){return'0'+s;}else{return s;}},isDescendantOf:function(node,parent){var current=node;while(current!=null&&current!=parent){current=current.parentNode;}
return current!=null;},getElementPosition:function(element){var offsetTrail=element;var offsetLeft=0;var offsetTop=0;while(offsetTrail){offsetLeft+=offsetTrail.offsetLeft;offsetTop+=offsetTrail.offsetTop;offsetTrail=offsetTrail.offsetParent;}
if(navigator.userAgent.indexOf("Mac")!=-1&&typeof document.body.leftMargin!="undefined"){offsetLeft+=document.body.leftMargin;offsetTop+=document.body.topMargin;}
return{left:offsetLeft,top:offsetTop};},inElement:function(element,x,y,paddingX,paddingY){var inElement;if(paddingX==undefined){paddingX=0;}
if(paddingY==undefined){paddingY=0;}
var pos=this.getElementPosition(element)
inElement=((x>=pos.left-paddingX)&&(y>=pos.top-paddingY)&&(x<=pos.left+element.clientWidth+paddingX)&&(y<=pos.top+element.clientHeight+paddingY));return inElement;},addToList:function(list,option){try{list.add(option,null);}catch(e){list.add(option);}},inList:function(list,value){var i;var found=false;for(i=0;i<list.options.length;i++){if(list.options[i].value==value){found=true;break;}}
return found;},convertFormToUrl:function(form,targetUrl){if(typeof(form)=='string'){form=$(form);}
var url;if(targetUrl==undefined){url=form.action+"?";}else{url=targetUrl;if(targetUrl.search(/\?/)==-1){url+='?';}else{url+='&';}}
var i;var first=true;for(i=0;i<form.elements.length;i++){var element=form.elements[i];if(element.type=='checkbox'||element.type=='radio'){if(!element.checked){continue;}}
if(element.value!=undefined){if(first){first=false;}else{url+="&";}
if(typeof(element.value)=='object'){var j;for(j in element.value){url+=element.name+"="+encodeURI(element.value[j]);}}else{url+=element.name+"="+encodeURI(element.value);}}}
return url;},toQueryString:function(object){var first=true;var result='';for(var key in object){if(first){first=false;}else{result+='&'}
result+=escape(key)+'='+escape(object[key]);}
return result;},parseQueryString:function(queryString){var pairs=queryString.split('&');var result={};for(var i=0;i<pairs.length;i++){var pair=pairs[i].split('=');if(pair.length==2){result[unescape(pair[0])]=unescape(pair[1]);}}
return result;},submitFormToPopup:function(form,name,features,replace,targetUrl){var url=this.convertFormToUrl(form,targetUrl);return window.open(url,name,features,replace);},submitFormToAJAX:function(form,targetUrl,method,callback){var postData;var url;switch(method){case'get':url=this.convertFormToUrl(form,targetUrl);break;case'post':url=targetUrl;postData=this.convertFormToQueryString(form);break;}
YAHOO.util.Connect.asyncRequest(method,url,callback,postData);},isNumeric:function(sText){var ValidChars="0123456789.";var IsNumber=true;var Char;for(i=0;i<sText.length&&IsNumber==true;i++)
{Char=sText.charAt(i);if(ValidChars.indexOf(Char)==-1)
{IsNumber=false;}}
return IsNumber;},copyObject:function(obj){var copy=(obj instanceof Array)?[]:{};for(var i in obj){var item=obj[i];switch(item instanceof Array||item instanceof Object){case true:copy[i]=this.copyObject(item);break;default:copy[i]=item;}}
return copy;},processJSON:function(expression){var script;if(typeof(expression)=='object'){script=expression.responseText;}else{script=expression;}
script="("+script+")";return eval(script);},ajaxError:function(o){alert(HG.text.getText(HG_GETTEXT+'_ajax_error')+' - '+o.statusText);},Set:function(){this.elements=[];this.elementMap={};}};HG.util.Set.prototype={contains:function(element){return this.elementMap[element]!=null;},getElements:function(){return this.elements;},size:function(){return this.elements.length;},add:function(element){if(!this.contains(element)){this.elements.push(element);this.elementMap[element]=true;}},remove:function(element){this.elementMap[element]=null;var i;for(i=0;i<this.elements.length;i++){if(this.elements[i]==element){this.elements.splice(i,1);break;}}},clear:function(){this.elements=[];this.elementMap={};}};HG.util.Bookmarks={method:'none',init:function(){if(window.external!=undefined&&(HG.browser==undefined||HG.browser.is_ie)){this.method='IE';}else if(window.sidebar!=undefined){this.method='Mozilla';}},addBookmark:function(title,url){switch(this.method){case'IE':window.external.AddFavorite(location.href,title);break;case'Mozilla':window.sidebar.addPanel(title,location.href,"");break;case'none':default:break;}},isSupported:function(){return this.method!='none';}};HG.util.Bookmarks.init();HG.util.JSTest=function(){this.enabledId='main-javascript-enabled';this.disabledId='main-javascript-disabled';};HG.util.JSTest.prototype.run=function(){$(this.disabledId).style.display='none';document.body.jstest=this;window.onload=function(){$(document.body.jstest.enabledId).style.display='block';};};HG.util.Date={monthLengths:{1:31,2:null,3:31,4:30,5:31,6:30,7:31,8:31,9:30,10:31,11:30,12:31},isLeapYear:function(datea)
{datea=parseInt(datea);if(datea%4==0)
{if(datea%100!=0)
{return true;}
else
{if(datea%400==0)
return true;else
return false;}}
return false;},getMonthLength:function(month,year,zeroBased){if(zeroBased){month++;}
var monthLength;if(month==2){monthLength=(this.isLeapYear(year))?29:28;}else{monthLength=this.monthLengths[month];}
return monthLength;}};Date.prototype.getMonthLength=function(){return HG.util.Date.getMonthLength(this.getMonth(),this.getFullYear(),true);};HG.util.Cookie={getValue:function(name,value){var value=null;if(document.cookie.length>0)
{var start=document.cookie.indexOf(name+"=");var end;if(start!=-1){start=start+name.length+1;end=document.cookie.indexOf(";",start);if(end==-1){end=document.cookie.length;}
value=unescape(document.cookie.substring(start,end));}}
return value;},setValue:function(name,value,expireDays){var cookieValue;cookieValue=name+"="+escape(value);if(expireDays){var exdate=new Date();exdate.setDate(exdate.getDate()+expireDays);cookieValue+=";expires="+exdate.toGMTString();}
cookieValue+=';path=/';document.cookie=cookieValue;}};
