/* 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,f){var e;var d="";for(e=0;e<f.length;e++){var g=f.substr(e,1);if(g=="\\"){d+=f[++e];continue}var b=(function(l,k){var i=GOSLib.Date;switch(l){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 j=0;for(var h=0;h<a.getMonth();h++){j+=i.last_day_of_month(i.build(a,{month:h,date:1})).getDate()}return j+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 i.last_day_of_month(a).getDate();case"L":return(i.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 i.format(a,"Y-m-d\\TH:i:sP");case"r":return i.format(a,"D, d M Y H:i:s O");case"U":return Math.floor(a.getTime()/1000);default:return l}})(g);if(b===undefined){return undefined}else{d+=b.toString()}}return d},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 e=b.build(a,{date:28});var c;while(e&&e.getMonth()==a.getMonth()){e=b.add_days(c=e,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(d,c){d=d.getTime();c=c.getTime();return(d>c?1:(d==c?0:-1))}},Math:{cmp:function(d,c){return(d>c?1:(d<c?-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 f=document.createElement(d);if(a){if(a.textContent){GOSLib.DOM.hack_set_textContent(f,a.textContent);delete a.textContent}if(a.style){GOSLib.merge(f.style,a.style);delete a.style}GOSLib.merge(f,a)}for(var b=0;c&&b<c.length;b++){if(d=="select"){GOSLib.DOM.Select.hack_add(f,c[b])}else{f.appendChild(c[b])}}return f},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 j;var e;var c;if(typeof(b)==="undefined"){b=true}j=a.getElementsByTagName("option");for(c=0;c<j.length;c++){e=j[c];if(h===undefined&&(g==e.getAttribute("value")||(b&&j.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(f){if(f.nodeType!=1){return true}if(f.disabled){return false}switch(f.tagName){case"input":case"select":case"textarea":b[f.name]=f.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()}});
