/* Copyright 2008 Simply Extras Ltd */
var GOSLib={day_names_long:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],day_names_short:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],month_names_long:["January","February","March","April","May","June","July","August","September","October","November","December"],month_names_short:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],included_scripts:[],include_once:function(A){if(!GOSLib.Array.in_array(A,included_scripts)){GOSLib.include(A)}},include:function(A){var C=document.getElementsByTagName("head").item(0);var B=document.createElement("script");B.setAttribute("language","javascript");B.setAttribute("type","text/javascript");B.setAttribute("src",A);C.appendChild(B);return B},arguments_to_array:function(A){var B;var C=new Array();for(B=0;B<A.length;B++){C[B]=A[B]}return C},merge:function(C){for(var A=1;A<arguments.length;A++){for(var B in arguments[A]){C[B]=arguments[A][B]}}return C},compact:function(B){for(var A in B){if(B[A]===undefined){delete B[A]}}return B},merge_methodically:function(C){for(var A=1;A<arguments.length;A++){for(var B in arguments[A]){if(typeof (arguments[A][B]=="function")){C[B]=(function(D){return function(){return D.apply(this,[this].concat(GOSLib.arguments_to_array(arguments)))}})(arguments[A][B])}else{C[B]=source[B]}}}return C},property_cycle:function(C,A,B){if(A.constructor===Array){while(A.length>1){C=C[A.shift()]}A=A[0]}var D=undefined;GOSLib.Array.each_index(B,function(F,E){if(E===C[A]){D=F;return false}return });if(D===undefined){return C[A]=B[0]}return C[A]=B[(D+1)%B.length]},Function:{partial:function(B){var A=GOSLib.arguments_to_array(arguments).slice(1);return function(){return B.apply(this,A.concat(GOSLib.arguments_to_array(arguments)))}},successorize:function(A){var B=GOSLib.arguments_to_array(arguments);return function(){var C=GOSLib.arguments_to_array(arguments);var E=true;for(var D=0;D<B.length;D++){if(!(E=B[D].apply(this,C))){return E}}return E}}},Array:{each:function(C,D,B){if(B===undefined){B=true}for(var A in C){if(B&&typeof (C[A])!="number"&&typeof (C[A])!="string"){continue}if(D(A,C[A])===false){return C}}return C},each_index:function(A,C){for(var B=0;B<A.length;B++){if(C(B,A[B])===false){return A}}return A},in_array:function(C,B){var A=false;B.each(function(E,D){if(D==C){A=true;return false}return undefined});return A},URI_encode:function(B,A){if(typeof (A)=="undefined"){A=false}var C="";B.each(function(E,D){if(A){if(typeof (E)=="number"){E=A+"["+E+"]"}else{E=A+E}}if(C.length>0){C+="&"}C+=encodeURIComponent(E)+"="+encodeURIComponent(B[E])});return C}},Hash:{URI_encode:function(C,B){if(typeof (B)=="undefined"){B=false}var D="";for(var A in C){if(B){if(typeof (parseInt(A))=="number"){A=B+"["+A+"]"}else{A=B+A}}if(D.length>0){D+="&"}D+=encodeURIComponent(A)+"="+encodeURIComponent(C[A])}return D}},Date:{get_short_year:function(A){return A.getFullYear().toString().substr(2,4)},format:function(A,E){var D;var C="";for(D=0;D<E.length;D++){var F=E.substr(D,1);if(F=="\\"){C+=E[++D];continue}var B=(function(K,J){var H=GOSLib.Date;switch(K){case"d":return A.getDate().toString().lpad(2,"0");case"D":return GOSLib.day_names_short[A.getDay()];case"j":return A.getDate().toString();case"l":return GOSLib.day_names_long[A.getDay()];case"N":return[7,1,2,3,4,5,6][A.getDay()];case"S":return GOSLib.Number.getEnding(A.getDate());case"w":return A.getDay();case"z":var I=0;for(var G=0;G<A.getMonth();G++){I+=H.last_day_of_month(H.build(A,{month:G,date:1})).getDate()}return I+A.getDate()-1;case"W":return undefined;case"F":return GOSLib.month_names_long[A.getMonth()];case"m":return(A.getMonth()+1).toString().lpad(2,"0");case"M":return GOSLib.month_names_short[A.getMonth()];case"n":return A.getMonth()+1;case"t":return H.last_day_of_month(A).getDate();case"L":return(H.build(A,{month:1,date:29}).getDate()==29?"1":"0");case"o":return undefined;case"Y":return A.getFullYear();case"y":return A.getFullYear().last(2);case"a":return(A.getHours()<12?"am":"pm");case"A":return(A.getHours()<12?"AM":"PM");case"B":return undefined;case"g":return(A.getHours()%12)+1;case"G":return A.getHours();case"h":return((A.getHours()%12)+1).toString().lpad(2,"0");case"H":return A.getHours().toString().lpad(2,"0");case"i":return A.getMinutes().toString().lpad(2,"0");case"s":return A.getSeconds().toString().lpad(2,"0");case"u":return A.getMilliseconds();case"e":return undefined;case"I":return undefined;case"O":return((A.getTimezoneOffset()>=0?"+":"-")+Math.abs(Math.floor(A.getTimezoneOffset()/60)).toString().lpad(2,"0")+(A.getTimezoneOffset()*60).toString().last(2).lpad(2,"0"));case"P":return((A.getTimezoneOffset()>=0?"+":"-")+Math.abs(Math.floor(A.getTimezoneOffset()/60)).toString().lpad(2,"0")+":"+(A.getTimezoneOffset()*60).toString().last(2).lpad(2,"0"));case"T":return undefined;case"Z":return A.getTimezoneOffset()*60;case"c":return H.format(A,"Y-m-d\\TH:i:sP");case"r":return H.format(A,"D, d M Y H:i:s O");case"U":return Math.floor(A.getTime()/1000);default:return K}})(F);if(B===undefined){return undefined}else{C+=B.toString()}}return C},fromMilliseconds:function(A){var B=new Date();B.setTime(A);return B},fromSeconds:function(B){var A=new Date();A.setTime(B*1000);return A},build:function(A,B){if((!A)||A.constructor!=Date){if(B===undefined){B=A;A=undefined}if(A===undefined){A=new Date()}}A=new Date(A);for(o in B){var C=B[o];switch(o){case"date":A.setDate(C);break;case"month":A.setMonth(C);break;case"year":A.setFullYear(C);break;case"hour":A.setHours(C);break;case"minute":A.setMinutes(C);break;case"second":A.setSeconds(C);break;case"millisecond":A.setMilliseconds(C);break;case"time":A.setTime(C);break;default:return undefined}}return A},add_hours:function(A,E){var B=GOSLib.Date;if(E===undefined){E=A;A=new Date()}if(E==0){return A}var C=(E>0?1:-1);var D=B.build(A,{hour:A.getHours()+C});if(!D||D.getDate()!=A.getDate()){D=B.build(A,{hour:(C==1?0:23)});D=B.add_days(D,C)}while(0!=(E-=C)){D=B.add_hours(D,C)}return D},add_days:function(A,E){var B=GOSLib.Date;if(E===undefined){E=A;A=new Date()}if(E==0){return A}var C=(E>0?1:-1);var D=B.build(A,{date:A.getDate()+C});if(!D||D.getMonth()!=A.getMonth()){D=B.build(A,{date:1});if(A.getMonth()+C>=0&&A.getMonth()+C<=11){D.setMonth(A.getMonth()+C)}else{D.setFullYear(A.getFullYear()+C);D.setMonth(C>0?0:11)}if(C<0){D=B.last_day_of_month(D)}}while(0!=(E-=C)){D=B.add_days(D,C)}return D},add_months:function(A,E){var B=GOSLib.Date;if(E===undefined){E=A;A=new Date()}if(E==0){return A}var C=(E>0?1:-1);var D=B.build(A,{date:1,month:A.getMonth()+C});D=B.build(D,{date:Math.min(A.getDate(),B.last_day_of_month(D).getDate())});if(!D||D.getFullYear()!=A.getFullYear()){D=B.build(A,{date:1,month:1,year:A.getFullYear()+C});D.setMonth(C>0?0:11);D=B.build(D,{date:Math.min(A.getDate(),B.last_day_of_month(D).getDate())})}while(0!=(E-=C)){D=B.add_months(D,C)}return D},add_years:function(A,B){return GOSLib.Date.build(A,{year:A.getFullYear()+B})},first_day_of_week:function(A,B){if(B===undefined){B=0}while(A.getDay()!=B){A=GOSLib.Date.add_days(A,-1)}return new Date(A)},last_day_of_month:function(A){var B=GOSLib.Date;var D=B.build(A,{date:28});var C;while(D&&D.getMonth()==A.getMonth()){D=B.add_days(C=D,1)}return C},is_weekend:function(A){return(A.getDay()==0||A.getDay()==6)},max:function(){var A=arguments[0];for(var B=1;B<arguments.length;B++){if(GOSLib.Date.cmp(arguments[B],A)>0){A=arguments[B]}}return A},min:function(){var B=arguments[0];for(var A=1;A<arguments.length;A++){if(GOSLib.Date.cmp(arguments[A],B)<0){B=arguments[A]}}return B},cmp:function(B,A){B=B.getTime();A=A.getTime();return(B>A?1:(B==A?0:-1))}},Math:{cmp:function(B,A){return(B>A?1:(B<A?-1:0))}},Number:{getEnding:function(A){if(Math.floor(A)!=A){return""}var B=GOSLib.String.last(A,2);switch(B){case"11":case"12":case"13":return"th"}switch(B.last()){case"1":return"st";case"2":return"nd";case"3":return"rd"}return"th"}},String:{repeat:function(B,A){return(A>0?B.toString()+GOSLib.String.repeat(B.toString(),A-1):"")},lpad:function(B,A,C){if(C===undefined){C=" "}return GOSLib.String.repeat(C,(A-B.toString().length)/C.length)+B.toString()},rpad:function(B,A,C){if(C===undefined){C=" "}return B.toString()+GOSLib.String.repeat(C,(A-B.toString().length)/C.length)},first:function(B,A){if(A===undefined){A=1}return B.toString().substr(0,A)},last:function(B,A){if(A===undefined){A=1}return B.toString().substr(B.toString().length-A)}},DOM:{hack_stop:function(){if(window.stop){window.stop()}else{try{document.execCommand("Stop")}catch(A){}}},hack_textContent:function(A){if(typeof (A.textContent)!="undefined"){return A.textContent}if(typeof (A.innerText)!="undefined"){return A.innerText}if(typeof (A.text)!="undefined"){return A.text}return undefined},hack_set_textContent:function(A,B){if(typeof (A.textContent)!="undefined"){return A.textContent=B}if(typeof (A.innerText)!="undefined"){return A.innerText=B}if(typeof (A.text)!="undefined"){return A.text=B}return undefined},hack_backmask:function(C,B){if(B===undefined){B=document.getElementsByTagName("body")[0]}var A=GOSLib.DOM.createElement("iframe",{scrolling:"no",frameBorder:0,style:{display:"block",position:"absolute",zIndex:2,top:(GOSLib.DOM.getAbsoluteTop(C)-GOSLib.DOM.getAbsoluteTop(B))+"px",left:(GOSLib.DOM.getAbsoluteLeft(C)-GOSLib.DOM.getAbsoluteLeft(B))+"px",width:C.clientWidth+"px",height:C.clientHeight+"px",backgroundColor:"#00ff00"}});B.appendChild(A);GOSLib.DOM.removeElement(C);C.style.position="absolute";C.style.zIndex=3;C.style.top=A.style.top;C.style.left=A.style.left;B.appendChild(C);return A},getAbsoluteTop:function(A){if(A.tagName=="BODY"){return A.offsetTop||0}return(A.offsetTop||0)+(A.offsetParent?GOSLib.DOM.getAbsoluteTop(A.offsetParent):0)},getAbsoluteLeft:function(A){if(A.tagName=="BODY"){return A.offsetLeft||0}return(A.offsetLeft||0)+(A.offsetParent?GOSLib.DOM.getAbsoluteLeft(A.offsetParent):0)},removeElement:function(A){if(A.parentNode){A.parentNode.removeChild(A)}return A},emptyElement:function(A){while(A.firstChild){A.removeChild(A.firstChild)}},createElement:function(D,A,C){var E=document.createElement(D);if(A){if(A.textContent){GOSLib.DOM.hack_set_textContent(E,A.textContent);delete A.textContent}if(A.style){GOSLib.merge(E.style,A.style);delete A.style}GOSLib.merge(E,A)}for(var B=0;C&&B<C.length;B++){if(D=="select"){GOSLib.DOM.Select.hack_add(E,C[B])}else{E.appendChild(C[B])}}return E},unescape_html:function(B){var A=document.createElement("div");A.innerHTML=B;return GOSLib.DOM.hack_textContent(A)},is_scrollbar_at_bottom:function(B){var A=B.scrollTop;GOSLib.DOM.scroll_to_bottom(B);if(B.scrollTop!=A){B.scrollTop=A;return false}return true},scroll_to_bottom:function(A){return A.scrollTop=A.scrollHeight},Select:{hack_add:function(A,C,B){if(B===undefined){B=null}if(B===null){return A.appendChild(C)}return A.add(C,B)},empty:function(A){return GOSLib.DOM.emptyElement(A)},add_option:function(A,B,D,E){if(E===undefined){E=false}var C=GOSLib.DOM.createElement("option",{value:B,textContent:D});GOSLib.DOM.Select.hack_add(A,C);if(E){C.selected=true}return C},add_options_from_XML:function(D,A,G,B){var F=GOSLib.DOM.Select;var H=undefined;var I;var E;var C;if(typeof (B)==="undefined"){B=true}I=A.getElementsByTagName("option");for(C=0;C<I.length;C++){E=I[C];if(H===undefined&&(G==E.getAttribute("value")||(B&&I.length==1))){E=F.add_option(D,E.getAttribute("value"),GOSLib.DOM.hack_textContent(E),true);H=E}else{F.add_option(D,E.getAttribute("value"),GOSLib.DOM.hack_textContent(E),false)}}return H},add_options_in_range:function(B,G,F,D){if(typeof (D)=="undefined"){D=G}var C;var E=false;var A;A=G;while(true){C=GOSLib.DOM.Select.add_option(B,A,A.toString(),A==D);if(A==D){E=C}if(G<=F){A++;if(A>F){break}}else{A--;if(A<F){break}}}return E}},get_options_from_XML:function(A,E){var C=new Array();var B;var F;var D;B=A.getElementsByTagName(E);for(D=0;D<B.length;D++){F=B[D];C[D]=new Array();C[D]["value"]=F.getAttribute("value");C[D]["text"]=GOSLib.DOM.hack_textContent(F)}return C},map:function(C,D){var B=C.childNodes;var A;for(A=0;A<B.length;A++){if(D(B[A])){GOSLib.DOM.map(B[A],D)}}return true},Form:{serialize:function(A,D){if(typeof (as_hash)=="undefined"){D=false}var B=new Array();var C="";GOSLib.DOM.map(A,function(E){if(E.nodeType!=1){return true}if(E.disabled){return false}switch(E.tagName){case"input":case"select":case"textarea":B[E.name]=E.value;break;default:break}return true});if(D){return B}return GOSLib.Array.URI_encode(B)}}}};GOSLib.merge(Function,GOSLib.Function);GOSLib.merge_methodically(Function.prototype,GOSLib.Function);GOSLib.merge(Array,GOSLib.Array);GOSLib.merge_methodically(Array.prototype,GOSLib.Array);GOSLib.merge(Date,GOSLib.Date);GOSLib.merge_methodically(Date.prototype,GOSLib.Date);GOSLib.merge(Math,GOSLib.Math);GOSLib.merge(Number,GOSLib.Number);GOSLib.merge_methodically(Number.prototype,GOSLib.Number);GOSLib.merge(String,GOSLib.String);GOSLib.merge_methodically(String.prototype,GOSLib.String);GOSLib.merge(Number,GOSLib.String);GOSLib.merge_methodically(Number.prototype,GOSLib.String);GOSLib.Flasher=function(B,D,A){var C=this;if(typeof (A)=="undefined"){A=100}if(typeof (B)=="function"){B=[B]}this.a_actions=B;this.iterations=D;this.interval=A;this._stop=false;this._iteration=0;this._a_args=GOSLib.arguments_to_array(arguments).slice(3);this._asynchronous=false;this.getIteration=function(){return parseInt(C._iteration)};this.handler=function(){var E=function(){var F=C.a_actions[C._iteration%C.a_actions.length];return F.apply(null,[C._iteration].concat(C._a_args))};if(C._stop){return false}if(C._asynchronous){setTimeout(E,0)}else{E()}C._iteration++;if(C._forever||C._iteration<D){setTimeout(C.handler,A)}return undefined};this.go=function(){setTimeout(this.handler,A)};this.stop=function(){this._stop=true}};GOSLib.merge(GOSLib.Flasher,{flash:function(C,D,B){var A=new GOSLib.Flasher(C,D,B);A._a_args=GOSLib.arguments_to_array(arguments).slice(3);A.go()}});