var Prototype={Version:"1.5.1",Browser:{IE:!!(window.attachEvent&&!window.opera),Opera:!!window.opera,WebKit:navigator.userAgent.indexOf("AppleWebKit/")>-1,Gecko:navigator.userAgent.indexOf("Gecko")>-1&&navigator.userAgent.indexOf("KHTML")==-1},BrowserFeatures:{XPath:!!document.evaluate,ElementExtensions:!!window.HTMLElement,SpecificElementExtensions:(document.createElement("div").__proto__!==document.createElement("form").__proto__)},ScriptFragment:"<script[^>]*>([\x01-\uffff]*?)</script>",JSONFilter:/^\/\*-secure-\s*(.*)\s*\*\/\s*$/,emptyFunction:function(){
},K:function(x){
return x;
}};
var Class={create:function(){
return function(){
this.initialize.apply(this,arguments);
};
}};
var Abstract=new Object();
Object.extend=function(_2,_3){
for(var _4 in _3){
_2[_4]=_3[_4];
}
return _2;
};
Object.extend(Object,{inspect:function(_5){
try{
if(_5===undefined){
return "undefined";
}
if(_5===null){
return "null";
}
return _5.inspect?_5.inspect():_5.toString();
}
catch(e){
if(e instanceof RangeError){
return "...";
}
throw e;
}
},toJSON:function(_6){
var _7=typeof _6;
switch(_7){
case "undefined":
case "function":
case "unknown":
return;
case "boolean":
return _6.toString();
}
if(_6===null){
return "null";
}
if(_6.toJSON){
return _6.toJSON();
}
if(_6.ownerDocument===document){
return;
}
var _8=[];
for(var _9 in _6){
var _a=Object.toJSON(_6[_9]);
if(_a!==undefined){
_8.push(_9.toJSON()+": "+_a);
}
}
return "{"+_8.join(", ")+"}";
},keys:function(_b){
var _c=[];
for(var _d in _b){
_c.push(_d);
}
return _c;
},values:function(_e){
var _f=[];
for(var _10 in _e){
_f.push(_e[_10]);
}
return _f;
},clone:function(_11){
return Object.extend({},_11);
}});
Function.prototype.bind=function(){
var _12=this,args=$A(arguments),object=args.shift();
return function(){
return _12.apply(object,args.concat($A(arguments)));
};
};
Function.prototype.bindAsEventListener=function(_13){
var _14=this,args=$A(arguments),_13=args.shift();
return function(_15){
return _14.apply(_13,[_15||window.event].concat(args));
};
};
Object.extend(Number.prototype,{toColorPart:function(){
return this.toPaddedString(2,16);
},succ:function(){
return this+1;
},times:function(_16){
$R(0,this,true).each(_16);
return this;
},toPaddedString:function(_17,_18){
var _19=this.toString(_18||10);
return "0".times(_17-_19.length)+_19;
},toJSON:function(){
return isFinite(this)?this.toString():"null";
}});
Date.prototype.toJSON=function(){
return "\""+this.getFullYear()+"-"+(this.getMonth()+1).toPaddedString(2)+"-"+this.getDate().toPaddedString(2)+"T"+this.getHours().toPaddedString(2)+":"+this.getMinutes().toPaddedString(2)+":"+this.getSeconds().toPaddedString(2)+"\"";
};
var Try={these:function(){
var _1a;
for(var i=0,length=arguments.length;i<length;i++){
var _1c=arguments[i];
try{
_1a=_1c();
break;
}
catch(e){
}
}
return _1a;
}};
var PeriodicalExecuter=Class.create();
PeriodicalExecuter.prototype={initialize:function(_1d,_1e){
this.callback=_1d;
this.frequency=_1e;
this.currentlyExecuting=false;
this.registerCallback();
},registerCallback:function(){
this.timer=setInterval(this.onTimerEvent.bind(this),this.frequency*1000);
},stop:function(){
if(!this.timer){
return;
}
clearInterval(this.timer);
this.timer=null;
},onTimerEvent:function(){
if(!this.currentlyExecuting){
try{
this.currentlyExecuting=true;
this.callback(this);
}
finally{
this.currentlyExecuting=false;
}
}
}};
Object.extend(String,{interpret:function(_1f){
return _1f==null?"":String(_1f);
},specialChar:{"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r","\\":"\\\\"}});
Object.extend(String.prototype,{gsub:function(_20,_21){
var _22="",source=this,match;
_21=arguments.callee.prepareReplacement(_21);
while(source.length>0){
if(match=source.match(_20)){
_22+=source.slice(0,match.index);
_22+=String.interpret(_21(match));
source=source.slice(match.index+match[0].length);
}else{
_22+=source,source="";
}
}
return _22;
},sub:function(_23,_24,_25){
_24=this.gsub.prepareReplacement(_24);
_25=_25===undefined?1:_25;
return this.gsub(_23,function(_26){
if(--_25<0){
return _26[0];
}
return _24(_26);
});
},scan:function(_27,_28){
this.gsub(_27,_28);
return this;
},truncate:function(_29,_2a){
_29=_29||30;
_2a=_2a===undefined?"...":_2a;
return this.length>_29?this.slice(0,_29-_2a.length)+_2a:this;
},strip:function(){
return this.replace(/^\s+/,"").replace(/\s+$/,"");
},stripTags:function(){
return this.replace(/<\/?[^>]+>/gi,"");
},stripScripts:function(){
return this.replace(new RegExp(Prototype.ScriptFragment,"img"),"");
},extractScripts:function(){
var _2b=new RegExp(Prototype.ScriptFragment,"img");
var _2c=new RegExp(Prototype.ScriptFragment,"im");
return (this.match(_2b)||[]).map(function(_2d){
return (_2d.match(_2c)||["",""])[1];
});
},evalScripts:function(){
return this.extractScripts().map(function(_2e){
return eval(_2e);
});
},escapeHTML:function(){
var _2f=arguments.callee;
_2f.text.data=this;
return _2f.div.innerHTML;
},unescapeHTML:function(){
var div=document.createElement("div");
div.innerHTML=this.stripTags();
return div.childNodes[0]?(div.childNodes.length>1?$A(div.childNodes).inject("",function(_31,_32){
return _31+_32.nodeValue;
}):div.childNodes[0].nodeValue):"";
},toQueryParams:function(_33){
var _34=this.strip().match(/([^?#]*)(#.*)?$/);
if(!_34){
return {};
}
return _34[1].split(_33||"&").inject({},function(_35,_36){
if((_36=_36.split("="))[0]){
var key=decodeURIComponent(_36.shift());
var _38=_36.length>1?_36.join("="):_36[0];
if(_38!=undefined){
_38=decodeURIComponent(_38);
}
if(key in _35){
if(_35[key].constructor!=Array){
_35[key]=[_35[key]];
}
_35[key].push(_38);
}else{
_35[key]=_38;
}
}
return _35;
});
},toArray:function(){
return this.split("");
},succ:function(){
return this.slice(0,this.length-1)+String.fromCharCode(this.charCodeAt(this.length-1)+1);
},times:function(_39){
var _3a="";
for(var i=0;i<_39;i++){
_3a+=this;
}
return _3a;
},camelize:function(){
var _3c=this.split("-"),len=_3c.length;
if(len==1){
return _3c[0];
}
var _3d=this.charAt(0)=="-"?_3c[0].charAt(0).toUpperCase()+_3c[0].substring(1):_3c[0];
for(var i=1;i<len;i++){
_3d+=_3c[i].charAt(0).toUpperCase()+_3c[i].substring(1);
}
return _3d;
},capitalize:function(){
return this.charAt(0).toUpperCase()+this.substring(1).toLowerCase();
},underscore:function(){
return this.gsub(/::/,"/").gsub(/([A-Z]+)([A-Z][a-z])/,"#{1}_#{2}").gsub(/([a-z\d])([A-Z])/,"#{1}_#{2}").gsub(/-/,"_").toLowerCase();
},dasherize:function(){
return this.gsub(/_/,"-");
},inspect:function(_3f){
var _40=this.gsub(/[\x00-\x1f\\]/,function(_41){
var _42=String.specialChar[_41[0]];
return _42?_42:"\\u00"+_41[0].charCodeAt().toPaddedString(2,16);
});
if(_3f){
return "\""+_40.replace(/"/g,"\\\"")+"\"";
}
return "'"+_40.replace(/'/g,"\\'")+"'";
},toJSON:function(){
return this.inspect(true);
},unfilterJSON:function(_43){
return this.sub(_43||Prototype.JSONFilter,"#{1}");
},evalJSON:function(_44){
var _45=this.unfilterJSON();
try{
if(!_44||(/^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/.test(_45))){
return eval("("+_45+")");
}
}
catch(e){
}
throw new SyntaxError("Badly formed JSON string: "+this.inspect());
},include:function(_46){
return this.indexOf(_46)>-1;
},startsWith:function(_47){
return this.indexOf(_47)===0;
},endsWith:function(_48){
var d=this.length-_48.length;
return d>=0&&this.lastIndexOf(_48)===d;
},empty:function(){
return this=="";
},blank:function(){
return /^\s*$/.test(this);
}});
if(Prototype.Browser.WebKit||Prototype.Browser.IE){
Object.extend(String.prototype,{escapeHTML:function(){
return this.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");
},unescapeHTML:function(){
return this.replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">");
}});
}
String.prototype.gsub.prepareReplacement=function(_4a){
if(typeof _4a=="function"){
return _4a;
}
var _4b=new Template(_4a);
return function(_4c){
return _4b.evaluate(_4c);
};
};
String.prototype.parseQuery=String.prototype.toQueryParams;
Object.extend(String.prototype.escapeHTML,{div:document.createElement("div"),text:document.createTextNode("")});
with(String.prototype.escapeHTML){
div.appendChild(text);
}
var Template=Class.create();
Template.Pattern=/(^|.|\r|\n)(#\{(.*?)\})/;
Template.prototype={initialize:function(_4d,_4e){
this.template=_4d.toString();
this.pattern=_4e||Template.Pattern;
},evaluate:function(_4f){
return this.template.gsub(this.pattern,function(_50){
var _51=_50[1];
if(_51=="\\"){
return _50[2];
}
return _51+String.interpret(_4f[_50[3]]);
});
}};
var $break={},$continue=new Error("\"throw $continue\" is deprecated, use \"return\" instead");
var Enumerable={each:function(_52){
var _53=0;
try{
this._each(function(_54){
_52(_54,_53++);
});
}
catch(e){
if(e!=$break){
throw e;
}
}
return this;
},eachSlice:function(_55,_56){
var _57=-_55,slices=[],array=this.toArray();
while((_57+=_55)<array.length){
slices.push(array.slice(_57,_57+_55));
}
return slices.map(_56);
},all:function(_58){
var _59=true;
this.each(function(_5a,_5b){
_59=_59&&!!(_58||Prototype.K)(_5a,_5b);
if(!_59){
throw $break;
}
});
return _59;
},any:function(_5c){
var _5d=false;
this.each(function(_5e,_5f){
if(_5d=!!(_5c||Prototype.K)(_5e,_5f)){
throw $break;
}
});
return _5d;
},collect:function(_60){
var _61=[];
this.each(function(_62,_63){
_61.push((_60||Prototype.K)(_62,_63));
});
return _61;
},detect:function(_64){
var _65;
this.each(function(_66,_67){
if(_64(_66,_67)){
_65=_66;
throw $break;
}
});
return _65;
},findAll:function(_68){
var _69=[];
this.each(function(_6a,_6b){
if(_68(_6a,_6b)){
_69.push(_6a);
}
});
return _69;
},grep:function(_6c,_6d){
var _6e=[];
this.each(function(_6f,_70){
var _71=_6f.toString();
if(_71.match(_6c)){
_6e.push((_6d||Prototype.K)(_6f,_70));
}
});
return _6e;
},include:function(_72){
var _73=false;
this.each(function(_74){
if(_74==_72){
_73=true;
throw $break;
}
});
return _73;
},inGroupsOf:function(_75,_76){
_76=_76===undefined?null:_76;
return this.eachSlice(_75,function(_77){
while(_77.length<_75){
_77.push(_76);
}
return _77;
});
},inject:function(_78,_79){
this.each(function(_7a,_7b){
_78=_79(_78,_7a,_7b);
});
return _78;
},invoke:function(_7c){
var _7d=$A(arguments).slice(1);
return this.map(function(_7e){
return _7e[_7c].apply(_7e,_7d);
});
},max:function(_7f){
var _80;
this.each(function(_81,_82){
_81=(_7f||Prototype.K)(_81,_82);
if(_80==undefined||_81>=_80){
_80=_81;
}
});
return _80;
},min:function(_83){
var _84;
this.each(function(_85,_86){
_85=(_83||Prototype.K)(_85,_86);
if(_84==undefined||_85<_84){
_84=_85;
}
});
return _84;
},partition:function(_87){
var _88=[],falses=[];
this.each(function(_89,_8a){
((_87||Prototype.K)(_89,_8a)?_88:falses).push(_89);
});
return [_88,falses];
},pluck:function(_8b){
var _8c=[];
this.each(function(_8d,_8e){
_8c.push(_8d[_8b]);
});
return _8c;
},reject:function(_8f){
var _90=[];
this.each(function(_91,_92){
if(!_8f(_91,_92)){
_90.push(_91);
}
});
return _90;
},sortBy:function(_93){
return this.map(function(_94,_95){
return {value:_94,criteria:_93(_94,_95)};
}).sort(function(_96,_97){
var a=_96.criteria,b=_97.criteria;
return a<b?-1:a>b?1:0;
}).pluck("value");
},toArray:function(){
return this.map();
},zip:function(){
var _99=Prototype.K,args=$A(arguments);
if(typeof args.last()=="function"){
_99=args.pop();
}
var _9a=[this].concat(args).map($A);
return this.map(function(_9b,_9c){
return _99(_9a.pluck(_9c));
});
},size:function(){
return this.toArray().length;
},inspect:function(){
return "#<Enumerable:"+this.toArray().inspect()+">";
}};
Object.extend(Enumerable,{map:Enumerable.collect,find:Enumerable.detect,select:Enumerable.findAll,member:Enumerable.include,entries:Enumerable.toArray});
var $A=Array.from=function(_9d){
if(!_9d){
return [];
}
if(_9d.toArray){
return _9d.toArray();
}else{
var _9e=[];
for(var i=0,length=_9d.length;i<length;i++){
_9e.push(_9d[i]);
}
return _9e;
}
};
if(Prototype.Browser.WebKit){
$A=Array.from=function(_a0){
if(!_a0){
return [];
}
if(!(typeof _a0=="function"&&_a0=="[object NodeList]")&&_a0.toArray){
return _a0.toArray();
}else{
var _a1=[];
for(var i=0,length=_a0.length;i<length;i++){
_a1.push(_a0[i]);
}
return _a1;
}
};
}
Object.extend(Array.prototype,Enumerable);
if(!Array.prototype._reverse){
Array.prototype._reverse=Array.prototype.reverse;
}
Object.extend(Array.prototype,{_each:function(_a3){
for(var i=0,length=this.length;i<length;i++){
_a3(this[i]);
}
},clear:function(){
this.length=0;
return this;
},first:function(){
return this[0];
},last:function(){
return this[this.length-1];
},compact:function(){
return this.select(function(_a5){
return _a5!=null;
});
},flatten:function(){
return this.inject([],function(_a6,_a7){
return _a6.concat(_a7&&_a7.constructor==Array?_a7.flatten():[_a7]);
});
},without:function(){
var _a8=$A(arguments);
return this.select(function(_a9){
return !_a8.include(_a9);
});
},indexOf:function(_aa){
for(var i=0,length=this.length;i<length;i++){
if(this[i]==_aa){
return i;
}
}
return -1;
},reverse:function(_ac){
return (_ac!==false?this:this.toArray())._reverse();
},reduce:function(){
return this.length>1?this:this[0];
},uniq:function(_ad){
return this.inject([],function(_ae,_af,_b0){
if(0==_b0||(_ad?_ae.last()!=_af:!_ae.include(_af))){
_ae.push(_af);
}
return _ae;
});
},clone:function(){
return [].concat(this);
},size:function(){
return this.length;
},inspect:function(){
return "["+this.map(Object.inspect).join(", ")+"]";
},toJSON:function(){
var _b1=[];
this.each(function(_b2){
var _b3=Object.toJSON(_b2);
if(_b3!==undefined){
_b1.push(_b3);
}
});
return "["+_b1.join(", ")+"]";
}});
Array.prototype.toArray=Array.prototype.clone;
function $w(_b4){
_b4=_b4.strip();
return _b4?_b4.split(/\s+/):[];
}
if(Prototype.Browser.Opera){
Array.prototype.concat=function(){
var _b5=[];
for(var i=0,length=this.length;i<length;i++){
_b5.push(this[i]);
}
for(var i=0,length=arguments.length;i<length;i++){
if(arguments[i].constructor==Array){
for(var j=0,arrayLength=arguments[i].length;j<arrayLength;j++){
_b5.push(arguments[i][j]);
}
}else{
_b5.push(arguments[i]);
}
}
return _b5;
};
}
var Hash=function(_b8){
if(_b8 instanceof Hash){
this.merge(_b8);
}else{
Object.extend(this,_b8||{});
}
};
Object.extend(Hash,{toQueryString:function(obj){
var _ba=[];
_ba.add=arguments.callee.addPair;
this.prototype._each.call(obj,function(_bb){
if(!_bb.key){
return;
}
var _bc=_bb.value;
if(_bc&&typeof _bc=="object"){
if(_bc.constructor==Array){
_bc.each(function(_bd){
_ba.add(_bb.key,_bd);
});
}
return;
}
_ba.add(_bb.key,_bc);
});
return _ba.join("&");
},toJSON:function(_be){
var _bf=[];
this.prototype._each.call(_be,function(_c0){
var _c1=Object.toJSON(_c0.value);
if(_c1!==undefined){
_bf.push(_c0.key.toJSON()+": "+_c1);
}
});
return "{"+_bf.join(", ")+"}";
}});
Hash.toQueryString.addPair=function(key,_c3,_c4){
key=encodeURIComponent(key);
if(_c3===undefined){
this.push(key);
}else{
this.push(key+"="+(_c3==null?"":encodeURIComponent(_c3)));
}
};
Object.extend(Hash.prototype,Enumerable);
Object.extend(Hash.prototype,{_each:function(_c5){
for(var key in this){
var _c7=this[key];
if(_c7&&_c7==Hash.prototype[key]){
continue;
}
var _c8=[key,_c7];
_c8.key=key;
_c8.value=_c7;
_c5(_c8);
}
},keys:function(){
return this.pluck("key");
},values:function(){
return this.pluck("value");
},merge:function(_c9){
return $H(_c9).inject(this,function(_ca,_cb){
_ca[_cb.key]=_cb.value;
return _ca;
});
},remove:function(){
var _cc;
for(var i=0,length=arguments.length;i<length;i++){
var _ce=this[arguments[i]];
if(_ce!==undefined){
if(_cc===undefined){
_cc=_ce;
}else{
if(_cc.constructor!=Array){
_cc=[_cc];
}
_cc.push(_ce);
}
}
delete this[arguments[i]];
}
return _cc;
},toQueryString:function(){
return Hash.toQueryString(this);
},inspect:function(){
return "#<Hash:{"+this.map(function(_cf){
return _cf.map(Object.inspect).join(": ");
}).join(", ")+"}>";
},toJSON:function(){
return Hash.toJSON(this);
}});
function $H(_d0){
if(_d0 instanceof Hash){
return _d0;
}
return new Hash(_d0);
}
if(function(){
var i=0,Test=function(_d2){
this.key=_d2;
};
Test.prototype.key="foo";
for(var _d3 in new Test("bar")){
i++;
}
return i>1;
}()){
Hash.prototype._each=function(_d4){
var _d5=[];
for(var key in this){
var _d7=this[key];
if((_d7&&_d7==Hash.prototype[key])||_d5.include(key)){
continue;
}
_d5.push(key);
var _d8=[key,_d7];
_d8.key=key;
_d8.value=_d7;
_d4(_d8);
}
};
}
ObjectRange=Class.create();
Object.extend(ObjectRange.prototype,Enumerable);
Object.extend(ObjectRange.prototype,{initialize:function(_d9,end,_db){
this.start=_d9;
this.end=end;
this.exclusive=_db;
},_each:function(_dc){
var _dd=this.start;
while(this.include(_dd)){
_dc(_dd);
_dd=_dd.succ();
}
},include:function(_de){
if(_de<this.start){
return false;
}
if(this.exclusive){
return _de<this.end;
}
return _de<=this.end;
}});
var $R=function(_df,end,_e1){
return new ObjectRange(_df,end,_e1);
};
var Ajax={getTransport:function(){
return Try.these(function(){
return new XMLHttpRequest();
},function(){
return new ActiveXObject("Msxml2.XMLHTTP");
},function(){
return new ActiveXObject("Microsoft.XMLHTTP");
})||false;
},activeRequestCount:0};
Ajax.Responders={responders:[],_each:function(_e2){
this.responders._each(_e2);
},register:function(_e3){
if(!this.include(_e3)){
this.responders.push(_e3);
}
},unregister:function(_e4){
this.responders=this.responders.without(_e4);
},dispatch:function(_e5,_e6,_e7,_e8){
this.each(function(_e9){
if(typeof _e9[_e5]=="function"){
try{
_e9[_e5].apply(_e9,[_e6,_e7,_e8]);
}
catch(e){
}
}
});
}};
Object.extend(Ajax.Responders,Enumerable);
Ajax.Responders.register({onCreate:function(){
Ajax.activeRequestCount++;
},onComplete:function(){
Ajax.activeRequestCount--;
}});
Ajax.Base=function(){
};
Ajax.Base.prototype={setOptions:function(_ea){
this.options={method:"post",asynchronous:true,contentType:"application/x-www-form-urlencoded",encoding:"UTF-8",parameters:""};
Object.extend(this.options,_ea||{});
this.options.method=this.options.method.toLowerCase();
if(typeof this.options.parameters=="string"){
this.options.parameters=this.options.parameters.toQueryParams();
}
}};
Ajax.Request=Class.create();
Ajax.Request.Events=["Uninitialized","Loading","Loaded","Interactive","Complete"];
Ajax.Request.prototype=Object.extend(new Ajax.Base(),{_complete:false,initialize:function(url,_ec){
this.transport=Ajax.getTransport();
this.setOptions(_ec);
this.request(url);
},request:function(url){
this.url=url;
this.method=this.options.method;
var _ee=Object.clone(this.options.parameters);
if(!["get","post"].include(this.method)){
_ee["_method"]=this.method;
this.method="post";
}
this.parameters=_ee;
if(_ee=Hash.toQueryString(_ee)){
if(this.method=="get"){
this.url+=(this.url.include("?")?"&":"?")+_ee;
}else{
if(/Konqueror|Safari|KHTML/.test(navigator.userAgent)){
_ee+="&_=";
}
}
}
try{
if(this.options.onCreate){
this.options.onCreate(this.transport);
}
Ajax.Responders.dispatch("onCreate",this,this.transport);
this.transport.open(this.method.toUpperCase(),this.url,this.options.asynchronous);
if(this.options.asynchronous){
setTimeout(function(){
this.respondToReadyState(1);
}.bind(this),10);
}
this.transport.onreadystatechange=this.onStateChange.bind(this);
this.setRequestHeaders();
this.body=this.method=="post"?(this.options.postBody||_ee):null;
this.transport.send(this.body);
if(!this.options.asynchronous&&this.transport.overrideMimeType){
this.onStateChange();
}
}
catch(e){
this.dispatchException(e);
}
},onStateChange:function(){
var _ef=this.transport.readyState;
if(_ef>1&&!((_ef==4)&&this._complete)){
this.respondToReadyState(this.transport.readyState);
}
},setRequestHeaders:function(){
var _f0={"X-Requested-With":"XMLHttpRequest","X-Prototype-Version":Prototype.Version,"Accept":"text/javascript, text/html, application/xml, text/xml, */*"};
if(this.method=="post"){
_f0["Content-type"]=this.options.contentType+(this.options.encoding?"; charset="+this.options.encoding:"");
if(this.transport.overrideMimeType&&(navigator.userAgent.match(/Gecko\/(\d{4})/)||[0,2005])[1]<2005){
_f0["Connection"]="close";
}
}
if(typeof this.options.requestHeaders=="object"){
var _f1=this.options.requestHeaders;
if(typeof _f1.push=="function"){
for(var i=0,length=_f1.length;i<length;i+=2){
_f0[_f1[i]]=_f1[i+1];
}
}else{
$H(_f1).each(function(_f3){
_f0[_f3.key]=_f3.value;
});
}
}
for(var _f4 in _f0){
this.transport.setRequestHeader(_f4,_f0[_f4]);
}
},success:function(){
return !this.transport.status||(this.transport.status>=200&&this.transport.status<300);
},respondToReadyState:function(_f5){
var _f6=Ajax.Request.Events[_f5];
var _f7=this.transport,json=this.evalJSON();
if(_f6=="Complete"){
try{
this._complete=true;
(this.options["on"+this.transport.status]||this.options["on"+(this.success()?"Success":"Failure")]||Prototype.emptyFunction)(_f7,json);
}
catch(e){
this.dispatchException(e);
}
var _f8=this.getHeader("Content-type");
if(_f8&&_f8.strip().match(/^(text|application)\/(x-)?(java|ecma)script(;.*)?$/i)){
this.evalResponse();
}
}
try{
(this.options["on"+_f6]||Prototype.emptyFunction)(_f7,json);
Ajax.Responders.dispatch("on"+_f6,this,_f7,json);
}
catch(e){
this.dispatchException(e);
}
if(_f6=="Complete"){
this.transport.onreadystatechange=Prototype.emptyFunction;
}
},getHeader:function(_f9){
try{
return this.transport.getResponseHeader(_f9);
}
catch(e){
return null;
}
},evalJSON:function(){
try{
var _fa=this.getHeader("X-JSON");
return _fa?_fa.evalJSON():null;
}
catch(e){
return null;
}
},evalResponse:function(){
try{
return eval((this.transport.responseText||"").unfilterJSON());
}
catch(e){
this.dispatchException(e);
}
},dispatchException:function(_fb){
(this.options.onException||Prototype.emptyFunction)(this,_fb);
Ajax.Responders.dispatch("onException",this,_fb);
}});
Ajax.Updater=Class.create();
Object.extend(Object.extend(Ajax.Updater.prototype,Ajax.Request.prototype),{initialize:function(_fc,url,_fe){
this.container={success:(_fc.success||_fc),failure:(_fc.failure||(_fc.success?null:_fc))};
this.transport=Ajax.getTransport();
this.setOptions(_fe);
var _ff=this.options.onComplete||Prototype.emptyFunction;
this.options.onComplete=(function(_100,_101){
this.updateContent();
_ff(_100,_101);
}).bind(this);
this.request(url);
},updateContent:function(){
var _102=this.container[this.success()?"success":"failure"];
var _103=this.transport.responseText;
if(!this.options.evalScripts){
_103=_103.stripScripts();
}
if(_102=$(_102)){
if(this.options.insertion){
new this.options.insertion(_102,_103);
}else{
_102.update(_103);
}
}
if(this.success()){
if(this.onComplete){
setTimeout(this.onComplete.bind(this),10);
}
}
}});
Ajax.PeriodicalUpdater=Class.create();
Ajax.PeriodicalUpdater.prototype=Object.extend(new Ajax.Base(),{initialize:function(_104,url,_106){
this.setOptions(_106);
this.onComplete=this.options.onComplete;
this.frequency=(this.options.frequency||2);
this.decay=(this.options.decay||1);
this.updater={};
this.container=_104;
this.url=url;
this.start();
},start:function(){
this.options.onComplete=this.updateComplete.bind(this);
this.onTimerEvent();
},stop:function(){
this.updater.options.onComplete=undefined;
clearTimeout(this.timer);
(this.onComplete||Prototype.emptyFunction).apply(this,arguments);
},updateComplete:function(_107){
if(this.options.decay){
this.decay=(_107.responseText==this.lastText?this.decay*this.options.decay:1);
this.lastText=_107.responseText;
}
this.timer=setTimeout(this.onTimerEvent.bind(this),this.decay*this.frequency*1000);
},onTimerEvent:function(){
this.updater=new Ajax.Updater(this.container,this.url,this.options);
}});
function $(_108){
if(arguments.length>1){
for(var i=0,elements=[],length=arguments.length;i<length;i++){
elements.push($(arguments[i]));
}
return elements;
}
if(typeof _108=="string"){
_108=document.getElementById(_108);
}
return Element.extend(_108);
}
if(Prototype.BrowserFeatures.XPath){
document._getElementsByXPath=function(_10a,_10b){
var _10c=[];
var _10d=document.evaluate(_10a,$(_10b)||document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
for(var i=0,length=_10d.snapshotLength;i<length;i++){
_10c.push(_10d.snapshotItem(i));
}
return _10c;
};
document.getElementsByClassName=function(_10f,_110){
var q=".//*[contains(concat(' ', @class, ' '), ' "+_10f+" ')]";
return document._getElementsByXPath(q,_110);
};
}else{
document.getElementsByClassName=function(_112,_113){
var _114=($(_113)||document.body).getElementsByTagName("*");
var _115=[],child;
for(var i=0,length=_114.length;i<length;i++){
child=_114[i];
if(Element.hasClassName(child,_112)){
_115.push(Element.extend(child));
}
}
return _115;
};
}
if(!window.Element){
var Element={};
}
Element.extend=function(_117){
var F=Prototype.BrowserFeatures;
if(!_117||!_117.tagName||_117.nodeType==3||_117._extended||F.SpecificElementExtensions||_117==window){
return _117;
}
var _119={},tagName=_117.tagName,cache=Element.extend.cache,T=Element.Methods.ByTag;
if(!F.ElementExtensions){
Object.extend(_119,Element.Methods),Object.extend(_119,Element.Methods.Simulated);
}
if(T[tagName]){
Object.extend(_119,T[tagName]);
}
for(var _11a in _119){
var _11b=_119[_11a];
if(typeof _11b=="function"&&!(_11a in _117)){
_117[_11a]=cache.findOrStore(_11b);
}
}
_117._extended=Prototype.emptyFunction;
return _117;
};
Element.extend.cache={findOrStore:function(_11c){
return this[_11c]=this[_11c]||function(){
return _11c.apply(null,[this].concat($A(arguments)));
};
}};
Element.Methods={visible:function(_11d){
return $(_11d).style.display!="none";
},toggle:function(_11e){
_11e=$(_11e);
Element[Element.visible(_11e)?"hide":"show"](_11e);
return _11e;
},hide:function(_11f){
$(_11f).style.display="none";
return _11f;
},show:function(_120){
$(_120).style.display="";
return _120;
},remove:function(_121){
_121=$(_121);
_121.parentNode.removeChild(_121);
return _121;
},update:function(_122,html){
html=typeof html=="undefined"?"":html.toString();
$(_122).innerHTML=html.stripScripts();
setTimeout(function(){
html.evalScripts();
},10);
return _122;
},replace:function(_124,html){
_124=$(_124);
html=typeof html=="undefined"?"":html.toString();
if(_124.outerHTML){
_124.outerHTML=html.stripScripts();
}else{
var _126=_124.ownerDocument.createRange();
_126.selectNodeContents(_124);
_124.parentNode.replaceChild(_126.createContextualFragment(html.stripScripts()),_124);
}
setTimeout(function(){
html.evalScripts();
},10);
return _124;
},inspect:function(_127){
_127=$(_127);
var _128="<"+_127.tagName.toLowerCase();
$H({"id":"id","className":"class"}).each(function(pair){
var _12a=pair.first(),attribute=pair.last();
var _12b=(_127[_12a]||"").toString();
if(_12b){
_128+=" "+attribute+"="+_12b.inspect(true);
}
});
return _128+">";
},recursivelyCollect:function(_12c,_12d){
_12c=$(_12c);
var _12e=[];
while(_12c=_12c[_12d]){
if(_12c.nodeType==1){
_12e.push(Element.extend(_12c));
}
}
return _12e;
},ancestors:function(_12f){
return $(_12f).recursivelyCollect("parentNode");
},descendants:function(_130){
return $A($(_130).getElementsByTagName("*")).each(Element.extend);
},firstDescendant:function(_131){
_131=$(_131).firstChild;
while(_131&&_131.nodeType!=1){
_131=_131.nextSibling;
}
return $(_131);
},immediateDescendants:function(_132){
if(!(_132=$(_132).firstChild)){
return [];
}
while(_132&&_132.nodeType!=1){
_132=_132.nextSibling;
}
if(_132){
return [_132].concat($(_132).nextSiblings());
}
return [];
},previousSiblings:function(_133){
return $(_133).recursivelyCollect("previousSibling");
},nextSiblings:function(_134){
return $(_134).recursivelyCollect("nextSibling");
},siblings:function(_135){
_135=$(_135);
return _135.previousSiblings().reverse().concat(_135.nextSiblings());
},match:function(_136,_137){
if(typeof _137=="string"){
_137=new Selector(_137);
}
return _137.match($(_136));
},up:function(_138,_139,_13a){
_138=$(_138);
if(arguments.length==1){
return $(_138.parentNode);
}
var _13b=_138.ancestors();
return _139?Selector.findElement(_13b,_139,_13a):_13b[_13a||0];
},down:function(_13c,_13d,_13e){
_13c=$(_13c);
if(arguments.length==1){
return _13c.firstDescendant();
}
var _13f=_13c.descendants();
return _13d?Selector.findElement(_13f,_13d,_13e):_13f[_13e||0];
},previous:function(_140,_141,_142){
_140=$(_140);
if(arguments.length==1){
return $(Selector.handlers.previousElementSibling(_140));
}
var _143=_140.previousSiblings();
return _141?Selector.findElement(_143,_141,_142):_143[_142||0];
},next:function(_144,_145,_146){
_144=$(_144);
if(arguments.length==1){
return $(Selector.handlers.nextElementSibling(_144));
}
var _147=_144.nextSiblings();
return _145?Selector.findElement(_147,_145,_146):_147[_146||0];
},getElementsBySelector:function(){
var args=$A(arguments),element=$(args.shift());
return Selector.findChildElements(element,args);
},getElementsByClassName:function(_149,_14a){
return document.getElementsByClassName(_14a,_149);
},readAttribute:function(_14b,name){
_14b=$(_14b);
if(Prototype.Browser.IE){
if(!_14b.attributes){
return null;
}
var t=Element._attributeTranslations;
if(t.values[name]){
return t.values[name](_14b,name);
}
if(t.names[name]){
name=t.names[name];
}
var _14e=_14b.attributes[name];
return _14e?_14e.nodeValue:null;
}
return _14b.getAttribute(name);
},getHeight:function(_14f){
return $(_14f).getDimensions().height;
},getWidth:function(_150){
return $(_150).getDimensions().width;
},classNames:function(_151){
return new Element.ClassNames(_151);
},hasClassName:function(_152,_153){
if(!(_152=$(_152))){
return;
}
var _154=_152.className;
if(_154.length==0){
return false;
}
if(_154==_153||_154.match(new RegExp("(^|\\s)"+_153+"(\\s|$)"))){
return true;
}
return false;
},addClassName:function(_155,_156){
if(!(_155=$(_155))){
return;
}
Element.classNames(_155).add(_156);
return _155;
},removeClassName:function(_157,_158){
if(!(_157=$(_157))){
return;
}
Element.classNames(_157).remove(_158);
return _157;
},toggleClassName:function(_159,_15a){
if(!(_159=$(_159))){
return;
}
Element.classNames(_159)[_159.hasClassName(_15a)?"remove":"add"](_15a);
return _159;
},observe:function(){
Event.observe.apply(Event,arguments);
return $A(arguments).first();
},stopObserving:function(){
Event.stopObserving.apply(Event,arguments);
return $A(arguments).first();
},cleanWhitespace:function(_15b){
_15b=$(_15b);
var node=_15b.firstChild;
while(node){
var _15d=node.nextSibling;
if(node.nodeType==3&&!/\S/.test(node.nodeValue)){
_15b.removeChild(node);
}
node=_15d;
}
return _15b;
},empty:function(_15e){
return $(_15e).innerHTML.blank();
},descendantOf:function(_15f,_160){
_15f=$(_15f),_160=$(_160);
while(_15f=_15f.parentNode){
if(_15f==_160){
return true;
}
}
return false;
},scrollTo:function(_161){
_161=$(_161);
var pos=Position.cumulativeOffset(_161);
window.scrollTo(pos[0],pos[1]);
return _161;
},getStyle:function(_163,_164){
_163=$(_163);
_164=_164=="float"?"cssFloat":_164.camelize();
var _165=_163.style[_164];
if(!_165){
var css=document.defaultView.getComputedStyle(_163,null);
_165=css?css[_164]:null;
}
if(_164=="opacity"){
return _165?parseFloat(_165):1;
}
return _165=="auto"?null:_165;
},getOpacity:function(_167){
return $(_167).getStyle("opacity");
},setStyle:function(_168,_169,_16a){
_168=$(_168);
var _16b=_168.style;
for(var _16c in _169){
if(_16c=="opacity"){
_168.setOpacity(_169[_16c]);
}else{
_16b[(_16c=="float"||_16c=="cssFloat")?(_16b.styleFloat===undefined?"cssFloat":"styleFloat"):(_16a?_16c:_16c.camelize())]=_169[_16c];
}
}
return _168;
},setOpacity:function(_16d,_16e){
_16d=$(_16d);
_16d.style.opacity=(_16e==1||_16e==="")?"":(_16e<0.00001)?0:_16e;
return _16d;
},getDimensions:function(_16f){
_16f=$(_16f);
var _170=$(_16f).getStyle("display");
if(_170!="none"&&_170!=null){
return {width:_16f.offsetWidth,height:_16f.offsetHeight};
}
var els=_16f.style;
var _172=els.visibility;
var _173=els.position;
var _174=els.display;
els.visibility="hidden";
els.position="absolute";
els.display="block";
var _175=_16f.clientWidth;
var _176=_16f.clientHeight;
els.display=_174;
els.position=_173;
els.visibility=_172;
return {width:_175,height:_176};
},makePositioned:function(_177){
_177=$(_177);
var pos=Element.getStyle(_177,"position");
if(pos=="static"||!pos){
_177._madePositioned=true;
_177.style.position="relative";
if(window.opera){
_177.style.top=0;
_177.style.left=0;
}
}
return _177;
},undoPositioned:function(_179){
_179=$(_179);
if(_179._madePositioned){
_179._madePositioned=undefined;
_179.style.position=_179.style.top=_179.style.left=_179.style.bottom=_179.style.right="";
}
return _179;
},makeClipping:function(_17a){
_17a=$(_17a);
if(_17a._overflow){
return _17a;
}
_17a._overflow=_17a.style.overflow||"auto";
if((Element.getStyle(_17a,"overflow")||"visible")!="hidden"){
_17a.style.overflow="hidden";
}
return _17a;
},undoClipping:function(_17b){
_17b=$(_17b);
if(!_17b._overflow){
return _17b;
}
_17b.style.overflow=_17b._overflow=="auto"?"":_17b._overflow;
_17b._overflow=null;
return _17b;
}};
Object.extend(Element.Methods,{childOf:Element.Methods.descendantOf,childElements:Element.Methods.immediateDescendants});
if(Prototype.Browser.Opera){
Element.Methods._getStyle=Element.Methods.getStyle;
Element.Methods.getStyle=function(_17c,_17d){
switch(_17d){
case "left":
case "top":
case "right":
case "bottom":
if(Element._getStyle(_17c,"position")=="static"){
return null;
}
default:
return Element._getStyle(_17c,_17d);
}
};
}else{
if(Prototype.Browser.IE){
Element.Methods.getStyle=function(_17e,_17f){
_17e=$(_17e);
_17f=(_17f=="float"||_17f=="cssFloat")?"styleFloat":_17f.camelize();
var _180=_17e.style[_17f];
if(!_180&&_17e.currentStyle){
_180=_17e.currentStyle[_17f];
}
if(_17f=="opacity"){
if(_180=(_17e.getStyle("filter")||"").match(/alpha\(opacity=(.*)\)/)){
if(_180[1]){
return parseFloat(_180[1])/100;
}
}
return 1;
}
if(_180=="auto"){
if((_17f=="width"||_17f=="height")&&(_17e.getStyle("display")!="none")){
return _17e["offset"+_17f.capitalize()]+"px";
}
return null;
}
return _180;
};
Element.Methods.setOpacity=function(_181,_182){
_181=$(_181);
var _183=_181.getStyle("filter"),style=_181.style;
if(_182==1||_182===""){
style.filter=_183.replace(/alpha\([^\)]*\)/gi,"");
return _181;
}else{
if(_182<0.00001){
_182=0;
}
}
style.filter=_183.replace(/alpha\([^\)]*\)/gi,"")+"alpha(opacity="+(_182*100)+")";
return _181;
};
Element.Methods.update=function(_184,html){
_184=$(_184);
html=typeof html=="undefined"?"":html.toString();
var _186=_184.tagName.toUpperCase();
if(["THEAD","TBODY","TR","TD"].include(_186)){
var div=document.createElement("div");
switch(_186){
case "THEAD":
case "TBODY":
div.innerHTML="<table><tbody>"+html.stripScripts()+"</tbody></table>";
depth=2;
break;
case "TR":
div.innerHTML="<table><tbody><tr>"+html.stripScripts()+"</tr></tbody></table>";
depth=3;
break;
case "TD":
div.innerHTML="<table><tbody><tr><td>"+html.stripScripts()+"</td></tr></tbody></table>";
depth=4;
}
$A(_184.childNodes).each(function(node){
_184.removeChild(node);
});
depth.times(function(){
div=div.firstChild;
});
$A(div.childNodes).each(function(node){
_184.appendChild(node);
});
}else{
_184.innerHTML=html.stripScripts();
}
setTimeout(function(){
html.evalScripts();
},10);
return _184;
};
}else{
if(Prototype.Browser.Gecko){
Element.Methods.setOpacity=function(_18a,_18b){
_18a=$(_18a);
_18a.style.opacity=(_18b==1)?0.999999:(_18b==="")?"":(_18b<0.00001)?0:_18b;
return _18a;
};
}
}
}
Element._attributeTranslations={names:{colspan:"colSpan",rowspan:"rowSpan",valign:"vAlign",datetime:"dateTime",accesskey:"accessKey",tabindex:"tabIndex",enctype:"encType",maxlength:"maxLength",readonly:"readOnly",longdesc:"longDesc"},values:{_getAttr:function(_18c,_18d){
return _18c.getAttribute(_18d,2);
},_flag:function(_18e,_18f){
return $(_18e).hasAttribute(_18f)?_18f:null;
},style:function(_190){
return _190.style.cssText.toLowerCase();
},title:function(_191){
var node=_191.getAttributeNode("title");
return node.specified?node.nodeValue:null;
}}};
(function(){
Object.extend(this,{href:this._getAttr,src:this._getAttr,type:this._getAttr,disabled:this._flag,checked:this._flag,readonly:this._flag,multiple:this._flag});
}).call(Element._attributeTranslations.values);
Element.Methods.Simulated={hasAttribute:function(_193,_194){
var t=Element._attributeTranslations,node;
_194=t.names[_194]||_194;
node=$(_193).getAttributeNode(_194);
return node&&node.specified;
}};
Element.Methods.ByTag={};
Object.extend(Element,Element.Methods);
if(!Prototype.BrowserFeatures.ElementExtensions&&document.createElement("div").__proto__){
window.HTMLElement={};
window.HTMLElement.prototype=document.createElement("div").__proto__;
Prototype.BrowserFeatures.ElementExtensions=true;
}
Element.hasAttribute=function(_196,_197){
if(_196.hasAttribute){
return _196.hasAttribute(_197);
}
return Element.Methods.Simulated.hasAttribute(_196,_197);
};
Element.addMethods=function(_198){
var F=Prototype.BrowserFeatures,T=Element.Methods.ByTag;
if(!_198){
Object.extend(Form,Form.Methods);
Object.extend(Form.Element,Form.Element.Methods);
Object.extend(Element.Methods.ByTag,{"FORM":Object.clone(Form.Methods),"INPUT":Object.clone(Form.Element.Methods),"SELECT":Object.clone(Form.Element.Methods),"TEXTAREA":Object.clone(Form.Element.Methods)});
}
if(arguments.length==2){
var _19a=_198;
_198=arguments[1];
}
if(!_19a){
Object.extend(Element.Methods,_198||{});
}else{
if(_19a.constructor==Array){
_19a.each(extend);
}else{
extend(_19a);
}
}
function extend(_19b){
_19b=_19b.toUpperCase();
if(!Element.Methods.ByTag[_19b]){
Element.Methods.ByTag[_19b]={};
}
Object.extend(Element.Methods.ByTag[_19b],_198);
}
function copy(_19c,_19d,_19e){
_19e=_19e||false;
var _19f=Element.extend.cache;
for(var _1a0 in _19c){
var _1a1=_19c[_1a0];
if(!_19e||!(_1a0 in _19d)){
_19d[_1a0]=_19f.findOrStore(_1a1);
}
}
}
function findDOMClass(_1a2){
var _1a3;
var _1a4={"OPTGROUP":"OptGroup","TEXTAREA":"TextArea","P":"Paragraph","FIELDSET":"FieldSet","UL":"UList","OL":"OList","DL":"DList","DIR":"Directory","H1":"Heading","H2":"Heading","H3":"Heading","H4":"Heading","H5":"Heading","H6":"Heading","Q":"Quote","INS":"Mod","DEL":"Mod","A":"Anchor","IMG":"Image","CAPTION":"TableCaption","COL":"TableCol","COLGROUP":"TableCol","THEAD":"TableSection","TFOOT":"TableSection","TBODY":"TableSection","TR":"TableRow","TH":"TableCell","TD":"TableCell","FRAMESET":"FrameSet","IFRAME":"IFrame"};
if(_1a4[_1a2]){
_1a3="HTML"+_1a4[_1a2]+"Element";
}
if(window[_1a3]){
return window[_1a3];
}
_1a3="HTML"+_1a2+"Element";
if(window[_1a3]){
return window[_1a3];
}
_1a3="HTML"+_1a2.capitalize()+"Element";
if(window[_1a3]){
return window[_1a3];
}
window[_1a3]={};
window[_1a3].prototype=document.createElement(_1a2).__proto__;
return window[_1a3];
}
if(F.ElementExtensions){
copy(Element.Methods,HTMLElement.prototype);
copy(Element.Methods.Simulated,HTMLElement.prototype,true);
}
if(F.SpecificElementExtensions){
for(var tag in Element.Methods.ByTag){
var _1a6=findDOMClass(tag);
if(typeof _1a6=="undefined"){
continue;
}
copy(T[tag],_1a6.prototype);
}
}
Object.extend(Element,Element.Methods);
delete Element.ByTag;
};
var Toggle={display:Element.toggle};
Abstract.Insertion=function(_1a7){
this.adjacency=_1a7;
};
Abstract.Insertion.prototype={initialize:function(_1a8,_1a9){
this.element=$(_1a8);
this.content=_1a9.stripScripts();
if(this.adjacency&&this.element.insertAdjacentHTML){
try{
this.element.insertAdjacentHTML(this.adjacency,this.content);
}
catch(e){
var _1aa=this.element.tagName.toUpperCase();
if(["TBODY","TR"].include(_1aa)){
this.insertContent(this.contentFromAnonymousTable());
}else{
throw e;
}
}
}else{
this.range=this.element.ownerDocument.createRange();
if(this.initializeRange){
this.initializeRange();
}
this.insertContent([this.range.createContextualFragment(this.content)]);
}
setTimeout(function(){
_1a9.evalScripts();
},10);
},contentFromAnonymousTable:function(){
var div=document.createElement("div");
div.innerHTML="<table><tbody>"+this.content+"</tbody></table>";
return $A(div.childNodes[0].childNodes[0].childNodes);
}};
var Insertion=new Object();
Insertion.Before=Class.create();
Insertion.Before.prototype=Object.extend(new Abstract.Insertion("beforeBegin"),{initializeRange:function(){
this.range.setStartBefore(this.element);
},insertContent:function(_1ac){
_1ac.each((function(_1ad){
this.element.parentNode.insertBefore(_1ad,this.element);
}).bind(this));
}});
Insertion.Top=Class.create();
Insertion.Top.prototype=Object.extend(new Abstract.Insertion("afterBegin"),{initializeRange:function(){
this.range.selectNodeContents(this.element);
this.range.collapse(true);
},insertContent:function(_1ae){
_1ae.reverse(false).each((function(_1af){
this.element.insertBefore(_1af,this.element.firstChild);
}).bind(this));
}});
Insertion.Bottom=Class.create();
Insertion.Bottom.prototype=Object.extend(new Abstract.Insertion("beforeEnd"),{initializeRange:function(){
this.range.selectNodeContents(this.element);
this.range.collapse(this.element);
},insertContent:function(_1b0){
_1b0.each((function(_1b1){
this.element.appendChild(_1b1);
}).bind(this));
}});
Insertion.After=Class.create();
Insertion.After.prototype=Object.extend(new Abstract.Insertion("afterEnd"),{initializeRange:function(){
this.range.setStartAfter(this.element);
},insertContent:function(_1b2){
_1b2.each((function(_1b3){
this.element.parentNode.insertBefore(_1b3,this.element.nextSibling);
}).bind(this));
}});
Element.ClassNames=Class.create();
Element.ClassNames.prototype={initialize:function(_1b4){
this.element=$(_1b4);
},_each:function(_1b5){
this.element.className.split(/\s+/).select(function(name){
return name.length>0;
})._each(_1b5);
},set:function(_1b7){
this.element.className=_1b7;
},add:function(_1b8){
if(this.include(_1b8)){
return;
}
this.set($A(this).concat(_1b8).join(" "));
},remove:function(_1b9){
if(!this.include(_1b9)){
return;
}
this.set($A(this).without(_1b9).join(" "));
},toString:function(){
return $A(this).join(" ");
}};
Object.extend(Element.ClassNames.prototype,Enumerable);
var Selector=Class.create();
Selector.prototype={initialize:function(_1ba){
this.expression=_1ba.strip();
this.compileMatcher();
},compileMatcher:function(){
if(Prototype.BrowserFeatures.XPath&&!(/\[[\w-]*?:/).test(this.expression)){
return this.compileXPathMatcher();
}
var e=this.expression,ps=Selector.patterns,h=Selector.handlers,c=Selector.criteria,le,p,m;
if(Selector._cache[e]){
this.matcher=Selector._cache[e];
return;
}
this.matcher=["this.matcher = function(root) {","var r = root, h = Selector.handlers, c = false, n;"];
while(e&&le!=e&&(/\S/).test(e)){
le=e;
for(var i in ps){
p=ps[i];
if(m=e.match(p)){
this.matcher.push(typeof c[i]=="function"?c[i](m):new Template(c[i]).evaluate(m));
e=e.replace(m[0],"");
break;
}
}
}
this.matcher.push("return h.unique(n);\n}");
eval(this.matcher.join("\n"));
Selector._cache[this.expression]=this.matcher;
},compileXPathMatcher:function(){
var e=this.expression,ps=Selector.patterns,x=Selector.xpath,le,m;
if(Selector._cache[e]){
this.xpath=Selector._cache[e];
return;
}
this.matcher=[".//*"];
while(e&&le!=e&&(/\S/).test(e)){
le=e;
for(var i in ps){
if(m=e.match(ps[i])){
this.matcher.push(typeof x[i]=="function"?x[i](m):new Template(x[i]).evaluate(m));
e=e.replace(m[0],"");
break;
}
}
}
this.xpath=this.matcher.join("");
Selector._cache[this.expression]=this.xpath;
},findElements:function(root){
root=root||document;
if(this.xpath){
return document._getElementsByXPath(this.xpath,root);
}
return this.matcher(root);
},match:function(_1c0){
return this.findElements(document).include(_1c0);
},toString:function(){
return this.expression;
},inspect:function(){
return "#<Selector:"+this.expression.inspect()+">";
}};
Object.extend(Selector,{_cache:{},xpath:{descendant:"//*",child:"/*",adjacent:"/following-sibling::*[1]",laterSibling:"/following-sibling::*",tagName:function(m){
if(m[1]=="*"){
return "";
}
return "[local-name()='"+m[1].toLowerCase()+"' or local-name()='"+m[1].toUpperCase()+"']";
},className:"[contains(concat(' ', @class, ' '), ' #{1} ')]",id:"[@id='#{1}']",attrPresence:"[@#{1}]",attr:function(m){
m[3]=m[5]||m[6];
return new Template(Selector.xpath.operators[m[2]]).evaluate(m);
},pseudo:function(m){
var h=Selector.xpath.pseudos[m[1]];
if(!h){
return "";
}
if(typeof h==="function"){
return h(m);
}
return new Template(Selector.xpath.pseudos[m[1]]).evaluate(m);
},operators:{"=":"[@#{1}='#{3}']","!=":"[@#{1}!='#{3}']","^=":"[starts-with(@#{1}, '#{3}')]","$=":"[substring(@#{1}, (string-length(@#{1}) - string-length('#{3}') + 1))='#{3}']","*=":"[contains(@#{1}, '#{3}')]","~=":"[contains(concat(' ', @#{1}, ' '), ' #{3} ')]","|=":"[contains(concat('-', @#{1}, '-'), '-#{3}-')]"},pseudos:{"first-child":"[not(preceding-sibling::*)]","last-child":"[not(following-sibling::*)]","only-child":"[not(preceding-sibling::* or following-sibling::*)]","empty":"[count(*) = 0 and (count(text()) = 0 or translate(text(), ' \t\r\n', '') = '')]","checked":"[@checked]","disabled":"[@disabled]","enabled":"[not(@disabled)]","not":function(m){
var e=m[6],p=Selector.patterns,x=Selector.xpath,le,m,v;
var _1c7=[];
while(e&&le!=e&&(/\S/).test(e)){
le=e;
for(var i in p){
if(m=e.match(p[i])){
v=typeof x[i]=="function"?x[i](m):new Template(x[i]).evaluate(m);
_1c7.push("("+v.substring(1,v.length-1)+")");
e=e.replace(m[0],"");
break;
}
}
}
return "[not("+_1c7.join(" and ")+")]";
},"nth-child":function(m){
return Selector.xpath.pseudos.nth("(count(./preceding-sibling::*) + 1) ",m);
},"nth-last-child":function(m){
return Selector.xpath.pseudos.nth("(count(./following-sibling::*) + 1) ",m);
},"nth-of-type":function(m){
return Selector.xpath.pseudos.nth("position() ",m);
},"nth-last-of-type":function(m){
return Selector.xpath.pseudos.nth("(last() + 1 - position()) ",m);
},"first-of-type":function(m){
m[6]="1";
return Selector.xpath.pseudos["nth-of-type"](m);
},"last-of-type":function(m){
m[6]="1";
return Selector.xpath.pseudos["nth-last-of-type"](m);
},"only-of-type":function(m){
var p=Selector.xpath.pseudos;
return p["first-of-type"](m)+p["last-of-type"](m);
},nth:function(_1d1,m){
var mm,formula=m[6],predicate;
if(formula=="even"){
formula="2n+0";
}
if(formula=="odd"){
formula="2n+1";
}
if(mm=formula.match(/^(\d+)$/)){
return "["+_1d1+"= "+mm[1]+"]";
}
if(mm=formula.match(/^(-?\d*)?n(([+-])(\d+))?/)){
if(mm[1]=="-"){
mm[1]=-1;
}
var a=mm[1]?Number(mm[1]):1;
var b=mm[2]?Number(mm[2]):0;
predicate="[((#{fragment} - #{b}) mod #{a} = 0) and "+"((#{fragment} - #{b}) div #{a} >= 0)]";
return new Template(predicate).evaluate({fragment:_1d1,a:a,b:b});
}
}}},criteria:{tagName:"n = h.tagName(n, r, \"#{1}\", c);   c = false;",className:"n = h.className(n, r, \"#{1}\", c); c = false;",id:"n = h.id(n, r, \"#{1}\", c);        c = false;",attrPresence:"n = h.attrPresence(n, r, \"#{1}\"); c = false;",attr:function(m){
m[3]=(m[5]||m[6]);
return new Template("n = h.attr(n, r, \"#{1}\", \"#{3}\", \"#{2}\"); c = false;").evaluate(m);
},pseudo:function(m){
if(m[6]){
m[6]=m[6].replace(/"/g,"\\\"");
}
return new Template("n = h.pseudo(n, \"#{1}\", \"#{6}\", r, c); c = false;").evaluate(m);
},descendant:"c = \"descendant\";",child:"c = \"child\";",adjacent:"c = \"adjacent\";",laterSibling:"c = \"laterSibling\";"},patterns:{laterSibling:/^\s*~\s*/,child:/^\s*>\s*/,adjacent:/^\s*\+\s*/,descendant:/^\s/,tagName:/^\s*(\*|[\w\-]+)(\b|$)?/,id:/^#([\w\-\*]+)(\b|$)/,className:/^\.([\w\-\*]+)(\b|$)/,pseudo:/^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\((.*?)\))?(\b|$|\s|(?=:))/,attrPresence:/^\[([\w]+)\]/,attr:/\[((?:[\w-]*:)?[\w-]+)\s*(?:([!^$*~|]?=)\s*((['"])([^\]]*?)\4|([^'"][^\]]*?)))?\]/},handlers:{concat:function(a,b){
for(var i=0,node;node=b[i];i++){
a.push(node);
}
return a;
},mark:function(_1db){
for(var i=0,node;node=_1db[i];i++){
node._counted=true;
}
return _1db;
},unmark:function(_1dd){
for(var i=0,node;node=_1dd[i];i++){
node._counted=undefined;
}
return _1dd;
},index:function(_1df,_1e0,_1e1){
_1df._counted=true;
if(_1e0){
for(var _1e2=_1df.childNodes,i=_1e2.length-1,j=1;i>=0;i--){
node=_1e2[i];
if(node.nodeType==1&&(!_1e1||node._counted)){
node.nodeIndex=j++;
}
}
}else{
for(var i=0,j=1,_1e2=_1df.childNodes;node=_1e2[i];i++){
if(node.nodeType==1&&(!_1e1||node._counted)){
node.nodeIndex=j++;
}
}
}
},unique:function(_1e4){
if(_1e4.length==0){
return _1e4;
}
var _1e5=[],n;
for(var i=0,l=_1e4.length;i<l;i++){
if(!(n=_1e4[i])._counted){
n._counted=true;
_1e5.push(Element.extend(n));
}
}
return Selector.handlers.unmark(_1e5);
},descendant:function(_1e7){
var h=Selector.handlers;
for(var i=0,results=[],node;node=_1e7[i];i++){
h.concat(results,node.getElementsByTagName("*"));
}
return results;
},child:function(_1ea){
var h=Selector.handlers;
for(var i=0,results=[],node;node=_1ea[i];i++){
for(var j=0,children=[],child;child=node.childNodes[j];j++){
if(child.nodeType==1&&child.tagName!="!"){
results.push(child);
}
}
}
return results;
},adjacent:function(_1ee){
for(var i=0,results=[],node;node=_1ee[i];i++){
var next=this.nextElementSibling(node);
if(next){
results.push(next);
}
}
return results;
},laterSibling:function(_1f1){
var h=Selector.handlers;
for(var i=0,results=[],node;node=_1f1[i];i++){
h.concat(results,Element.nextSiblings(node));
}
return results;
},nextElementSibling:function(node){
while(node=node.nextSibling){
if(node.nodeType==1){
return node;
}
}
return null;
},previousElementSibling:function(node){
while(node=node.previousSibling){
if(node.nodeType==1){
return node;
}
}
return null;
},tagName:function(_1f6,root,_1f8,_1f9){
_1f8=_1f8.toUpperCase();
var _1fa=[],h=Selector.handlers;
if(_1f6){
if(_1f9){
if(_1f9=="descendant"){
for(var i=0,node;node=_1f6[i];i++){
h.concat(_1fa,node.getElementsByTagName(_1f8));
}
return _1fa;
}else{
_1f6=this[_1f9](_1f6);
}
if(_1f8=="*"){
return _1f6;
}
}
for(var i=0,node;node=_1f6[i];i++){
if(node.tagName.toUpperCase()==_1f8){
_1fa.push(node);
}
}
return _1fa;
}else{
return root.getElementsByTagName(_1f8);
}
},id:function(_1fc,root,id,_1ff){
var _200=$(id),h=Selector.handlers;
if(!_1fc&&root==document){
return _200?[_200]:[];
}
if(_1fc){
if(_1ff){
if(_1ff=="child"){
for(var i=0,node;node=_1fc[i];i++){
if(_200.parentNode==node){
return [_200];
}
}
}else{
if(_1ff=="descendant"){
for(var i=0,node;node=_1fc[i];i++){
if(Element.descendantOf(_200,node)){
return [_200];
}
}
}else{
if(_1ff=="adjacent"){
for(var i=0,node;node=_1fc[i];i++){
if(Selector.handlers.previousElementSibling(_200)==node){
return [_200];
}
}
}else{
_1fc=h[_1ff](_1fc);
}
}
}
}
for(var i=0,node;node=_1fc[i];i++){
if(node==_200){
return [_200];
}
}
return [];
}
return (_200&&Element.descendantOf(_200,root))?[_200]:[];
},className:function(_202,root,_204,_205){
if(_202&&_205){
_202=this[_205](_202);
}
return Selector.handlers.byClassName(_202,root,_204);
},byClassName:function(_206,root,_208){
if(!_206){
_206=Selector.handlers.descendant([root]);
}
var _209=" "+_208+" ";
for(var i=0,results=[],node,nodeClassName;node=_206[i];i++){
nodeClassName=node.className;
if(nodeClassName.length==0){
continue;
}
if(nodeClassName==_208||(" "+nodeClassName+" ").include(_209)){
results.push(node);
}
}
return results;
},attrPresence:function(_20b,root,attr){
var _20e=[];
for(var i=0,node;node=_20b[i];i++){
if(Element.hasAttribute(node,attr)){
_20e.push(node);
}
}
return _20e;
},attr:function(_210,root,attr,_213,_214){
if(!_210){
_210=root.getElementsByTagName("*");
}
var _215=Selector.operators[_214],results=[];
for(var i=0,node;node=_210[i];i++){
var _217=Element.readAttribute(node,attr);
if(_217===null){
continue;
}
if(_215(_217,_213)){
results.push(node);
}
}
return results;
},pseudo:function(_218,name,_21a,root,_21c){
if(_218&&_21c){
_218=this[_21c](_218);
}
if(!_218){
_218=root.getElementsByTagName("*");
}
return Selector.pseudos[name](_218,_21a,root);
}},pseudos:{"first-child":function(_21d,_21e,root){
for(var i=0,results=[],node;node=_21d[i];i++){
if(Selector.handlers.previousElementSibling(node)){
continue;
}
results.push(node);
}
return results;
},"last-child":function(_221,_222,root){
for(var i=0,results=[],node;node=_221[i];i++){
if(Selector.handlers.nextElementSibling(node)){
continue;
}
results.push(node);
}
return results;
},"only-child":function(_225,_226,root){
var h=Selector.handlers;
for(var i=0,results=[],node;node=_225[i];i++){
if(!h.previousElementSibling(node)&&!h.nextElementSibling(node)){
results.push(node);
}
}
return results;
},"nth-child":function(_22a,_22b,root){
return Selector.pseudos.nth(_22a,_22b,root);
},"nth-last-child":function(_22d,_22e,root){
return Selector.pseudos.nth(_22d,_22e,root,true);
},"nth-of-type":function(_230,_231,root){
return Selector.pseudos.nth(_230,_231,root,false,true);
},"nth-last-of-type":function(_233,_234,root){
return Selector.pseudos.nth(_233,_234,root,true,true);
},"first-of-type":function(_236,_237,root){
return Selector.pseudos.nth(_236,"1",root,false,true);
},"last-of-type":function(_239,_23a,root){
return Selector.pseudos.nth(_239,"1",root,true,true);
},"only-of-type":function(_23c,_23d,root){
var p=Selector.pseudos;
return p["last-of-type"](p["first-of-type"](_23c,_23d,root),_23d,root);
},getIndices:function(a,b,_242){
if(a==0){
return b>0?[b]:[];
}
return $R(1,_242).inject([],function(memo,i){
if(0==(i-b)%a&&(i-b)/a>=0){
memo.push(i);
}
return memo;
});
},nth:function(_245,_246,root,_248,_249){
if(_245.length==0){
return [];
}
if(_246=="even"){
_246="2n+0";
}
if(_246=="odd"){
_246="2n+1";
}
var h=Selector.handlers,results=[],indexed=[],m;
h.mark(_245);
for(var i=0,node;node=_245[i];i++){
if(!node.parentNode._counted){
h.index(node.parentNode,_248,_249);
indexed.push(node.parentNode);
}
}
if(_246.match(/^\d+$/)){
_246=Number(_246);
for(var i=0,node;node=_245[i];i++){
if(node.nodeIndex==_246){
results.push(node);
}
}
}else{
if(m=_246.match(/^(-?\d*)?n(([+-])(\d+))?/)){
if(m[1]=="-"){
m[1]=-1;
}
var a=m[1]?Number(m[1]):1;
var b=m[2]?Number(m[2]):0;
var _24e=Selector.pseudos.getIndices(a,b,_245.length);
for(var i=0,node,l=_24e.length;node=_245[i];i++){
for(var j=0;j<l;j++){
if(node.nodeIndex==_24e[j]){
results.push(node);
}
}
}
}
}
h.unmark(_245);
h.unmark(indexed);
return results;
},"empty":function(_250,_251,root){
for(var i=0,results=[],node;node=_250[i];i++){
if(node.tagName=="!"||(node.firstChild&&!node.innerHTML.match(/^\s*$/))){
continue;
}
results.push(node);
}
return results;
},"not":function(_254,_255,root){
var h=Selector.handlers,selectorType,m;
var _258=new Selector(_255).findElements(root);
h.mark(_258);
for(var i=0,results=[],node;node=_254[i];i++){
if(!node._counted){
results.push(node);
}
}
h.unmark(_258);
return results;
},"enabled":function(_25a,_25b,root){
for(var i=0,results=[],node;node=_25a[i];i++){
if(!node.disabled){
results.push(node);
}
}
return results;
},"disabled":function(_25e,_25f,root){
for(var i=0,results=[],node;node=_25e[i];i++){
if(node.disabled){
results.push(node);
}
}
return results;
},"checked":function(_262,_263,root){
for(var i=0,results=[],node;node=_262[i];i++){
if(node.checked){
results.push(node);
}
}
return results;
}},operators:{"=":function(nv,v){
return nv==v;
},"!=":function(nv,v){
return nv!=v;
},"^=":function(nv,v){
return nv.startsWith(v);
},"$=":function(nv,v){
return nv.endsWith(v);
},"*=":function(nv,v){
return nv.include(v);
},"~=":function(nv,v){
return (" "+nv+" ").include(" "+v+" ");
},"|=":function(nv,v){
return ("-"+nv.toUpperCase()+"-").include("-"+v.toUpperCase()+"-");
}},matchElements:function(_274,_275){
var _276=new Selector(_275).findElements(),h=Selector.handlers;
h.mark(_276);
for(var i=0,results=[],element;element=_274[i];i++){
if(element._counted){
results.push(element);
}
}
h.unmark(_276);
return results;
},findElement:function(_278,_279,_27a){
if(typeof _279=="number"){
_27a=_279;
_279=false;
}
return Selector.matchElements(_278,_279||"*")[_27a||0];
},findChildElements:function(_27b,_27c){
var _27d=_27c.join(","),_27c=[];
_27d.scan(/(([\w#:.~>+()\s-]+|\*|\[.*?\])+)\s*(,|$)/,function(m){
_27c.push(m[1].strip());
});
var _27f=[],h=Selector.handlers;
for(var i=0,l=_27c.length,selector;i<l;i++){
selector=new Selector(_27c[i].strip());
h.concat(_27f,selector.findElements(_27b));
}
return (l>1)?h.unique(_27f):_27f;
}});
function $$(){
return Selector.findChildElements(document,$A(arguments));
}
var Form={reset:function(form){
$(form).reset();
return form;
},serializeElements:function(_282,_283){
var data=_282.inject({},function(_285,_286){
if(!_286.disabled&&_286.name){
var key=_286.name,value=$(_286).getValue();
if(value!=null){
if(key in _285){
if(_285[key].constructor!=Array){
_285[key]=[_285[key]];
}
_285[key].push(value);
}else{
_285[key]=value;
}
}
}
return _285;
});
return _283?data:Hash.toQueryString(data);
}};
Form.Methods={serialize:function(form,_289){
return Form.serializeElements(Form.getElements(form),_289);
},getElements:function(form){
return $A($(form).getElementsByTagName("*")).inject([],function(_28b,_28c){
if(Form.Element.Serializers[_28c.tagName.toLowerCase()]){
_28b.push(Element.extend(_28c));
}
return _28b;
});
},getInputs:function(form,_28e,name){
form=$(form);
var _290=form.getElementsByTagName("input");
if(!_28e&&!name){
return $A(_290).map(Element.extend);
}
for(var i=0,matchingInputs=[],length=_290.length;i<length;i++){
var _292=_290[i];
if((_28e&&_292.type!=_28e)||(name&&_292.name!=name)){
continue;
}
matchingInputs.push(Element.extend(_292));
}
return matchingInputs;
},disable:function(form){
form=$(form);
Form.getElements(form).invoke("disable");
return form;
},enable:function(form){
form=$(form);
Form.getElements(form).invoke("enable");
return form;
},findFirstElement:function(form){
return $(form).getElements().find(function(_296){
return _296.type!="hidden"&&!_296.disabled&&["input","select","textarea"].include(_296.tagName.toLowerCase());
});
},focusFirstElement:function(form){
form=$(form);
form.findFirstElement().activate();
return form;
},request:function(form,_299){
form=$(form),_299=Object.clone(_299||{});
var _29a=_299.parameters;
_299.parameters=form.serialize(true);
if(_29a){
if(typeof _29a=="string"){
_29a=_29a.toQueryParams();
}
Object.extend(_299.parameters,_29a);
}
if(form.hasAttribute("method")&&!_299.method){
_299.method=form.method;
}
return new Ajax.Request(form.readAttribute("action"),_299);
}};
Form.Element={focus:function(_29b){
$(_29b).focus();
return _29b;
},select:function(_29c){
$(_29c).select();
return _29c;
}};
Form.Element.Methods={serialize:function(_29d){
_29d=$(_29d);
if(!_29d.disabled&&_29d.name){
var _29e=_29d.getValue();
if(_29e!=undefined){
var pair={};
pair[_29d.name]=_29e;
return Hash.toQueryString(pair);
}
}
return "";
},getValue:function(_2a0){
_2a0=$(_2a0);
var _2a1=_2a0.tagName.toLowerCase();
return Form.Element.Serializers[_2a1](_2a0);
},clear:function(_2a2){
$(_2a2).value="";
return _2a2;
},present:function(_2a3){
return $(_2a3).value!="";
},activate:function(_2a4){
_2a4=$(_2a4);
try{
_2a4.focus();
if(_2a4.select&&(_2a4.tagName.toLowerCase()!="input"||!["button","reset","submit"].include(_2a4.type))){
_2a4.select();
}
}
catch(e){
}
return _2a4;
},disable:function(_2a5){
_2a5=$(_2a5);
_2a5.blur();
_2a5.disabled=true;
return _2a5;
},enable:function(_2a6){
_2a6=$(_2a6);
_2a6.disabled=false;
return _2a6;
}};
var Field=Form.Element;
var $F=Form.Element.Methods.getValue;
Form.Element.Serializers={input:function(_2a7){
switch(_2a7.type.toLowerCase()){
case "checkbox":
case "radio":
return Form.Element.Serializers.inputSelector(_2a7);
default:
return Form.Element.Serializers.textarea(_2a7);
}
},inputSelector:function(_2a8){
return _2a8.checked?_2a8.value:null;
},textarea:function(_2a9){
return _2a9.value;
},select:function(_2aa){
return this[_2aa.type=="select-one"?"selectOne":"selectMany"](_2aa);
},selectOne:function(_2ab){
var _2ac=_2ab.selectedIndex;
return _2ac>=0?this.optionValue(_2ab.options[_2ac]):null;
},selectMany:function(_2ad){
var _2ae,length=_2ad.length;
if(!length){
return null;
}
for(var i=0,_2ae=[];i<length;i++){
var opt=_2ad.options[i];
if(opt.selected){
_2ae.push(this.optionValue(opt));
}
}
return _2ae;
},optionValue:function(opt){
return Element.extend(opt).hasAttribute("value")?opt.value:opt.text;
}};
Abstract.TimedObserver=function(){
};
Abstract.TimedObserver.prototype={initialize:function(_2b2,_2b3,_2b4){
this.frequency=_2b3;
this.element=$(_2b2);
this.callback=_2b4;
this.lastValue=this.getValue();
this.registerCallback();
},registerCallback:function(){
setInterval(this.onTimerEvent.bind(this),this.frequency*1000);
},onTimerEvent:function(){
var _2b5=this.getValue();
var _2b6=("string"==typeof this.lastValue&&"string"==typeof _2b5?this.lastValue!=_2b5:String(this.lastValue)!=String(_2b5));
if(_2b6){
this.callback(this.element,_2b5);
this.lastValue=_2b5;
}
}};
Form.Element.Observer=Class.create();
Form.Element.Observer.prototype=Object.extend(new Abstract.TimedObserver(),{getValue:function(){
return Form.Element.getValue(this.element);
}});
Form.Observer=Class.create();
Form.Observer.prototype=Object.extend(new Abstract.TimedObserver(),{getValue:function(){
return Form.serialize(this.element);
}});
Abstract.EventObserver=function(){
};
Abstract.EventObserver.prototype={initialize:function(_2b7,_2b8){
this.element=$(_2b7);
this.callback=_2b8;
this.lastValue=this.getValue();
if(this.element.tagName.toLowerCase()=="form"){
this.registerFormCallbacks();
}else{
this.registerCallback(this.element);
}
},onElementEvent:function(){
var _2b9=this.getValue();
if(this.lastValue!=_2b9){
this.callback(this.element,_2b9);
this.lastValue=_2b9;
}
},registerFormCallbacks:function(){
Form.getElements(this.element).each(this.registerCallback.bind(this));
},registerCallback:function(_2ba){
if(_2ba.type){
switch(_2ba.type.toLowerCase()){
case "checkbox":
case "radio":
Event.observe(_2ba,"click",this.onElementEvent.bind(this));
break;
default:
Event.observe(_2ba,"change",this.onElementEvent.bind(this));
break;
}
}
}};
Form.Element.EventObserver=Class.create();
Form.Element.EventObserver.prototype=Object.extend(new Abstract.EventObserver(),{getValue:function(){
return Form.Element.getValue(this.element);
}});
Form.EventObserver=Class.create();
Form.EventObserver.prototype=Object.extend(new Abstract.EventObserver(),{getValue:function(){
return Form.serialize(this.element);
}});
if(!window.Event){
var Event=new Object();
}
Object.extend(Event,{KEY_BACKSPACE:8,KEY_TAB:9,KEY_RETURN:13,KEY_ESC:27,KEY_LEFT:37,KEY_UP:38,KEY_RIGHT:39,KEY_DOWN:40,KEY_DELETE:46,KEY_HOME:36,KEY_END:35,KEY_PAGEUP:33,KEY_PAGEDOWN:34,element:function(_2bb){
return $(_2bb.target||_2bb.srcElement);
},isLeftClick:function(_2bc){
return (((_2bc.which)&&(_2bc.which==1))||((_2bc.button)&&(_2bc.button==1)));
},pointerX:function(_2bd){
return _2bd.pageX||(_2bd.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft));
},pointerY:function(_2be){
return _2be.pageY||(_2be.clientY+(document.documentElement.scrollTop||document.body.scrollTop));
},stop:function(_2bf){
if(_2bf.preventDefault){
_2bf.preventDefault();
_2bf.stopPropagation();
}else{
_2bf.returnValue=false;
_2bf.cancelBubble=true;
}
},findElement:function(_2c0,_2c1){
var _2c2=Event.element(_2c0);
while(_2c2.parentNode&&(!_2c2.tagName||(_2c2.tagName.toUpperCase()!=_2c1.toUpperCase()))){
_2c2=_2c2.parentNode;
}
return _2c2;
},observers:false,_observeAndCache:function(_2c3,name,_2c5,_2c6){
if(!this.observers){
this.observers=[];
}
if(_2c3.addEventListener){
this.observers.push([_2c3,name,_2c5,_2c6]);
_2c3.addEventListener(name,_2c5,_2c6);
}else{
if(_2c3.attachEvent){
this.observers.push([_2c3,name,_2c5,_2c6]);
_2c3.attachEvent("on"+name,_2c5);
}
}
},unloadCache:function(){
if(!Event.observers){
return;
}
for(var i=0,length=Event.observers.length;i<length;i++){
Event.stopObserving.apply(this,Event.observers[i]);
Event.observers[i][0]=null;
}
Event.observers=false;
},observe:function(_2c8,name,_2ca,_2cb){
_2c8=$(_2c8);
_2cb=_2cb||false;
if(name=="keypress"&&(Prototype.Browser.WebKit||_2c8.attachEvent)){
name="keydown";
}
Event._observeAndCache(_2c8,name,_2ca,_2cb);
},stopObserving:function(_2cc,name,_2ce,_2cf){
_2cc=$(_2cc);
_2cf=_2cf||false;
if(name=="keypress"&&(Prototype.Browser.WebKit||_2cc.attachEvent)){
name="keydown";
}
if(_2cc.removeEventListener){
_2cc.removeEventListener(name,_2ce,_2cf);
}else{
if(_2cc.detachEvent){
try{
_2cc.detachEvent("on"+name,_2ce);
}
catch(e){
}
}
}
}});
if(Prototype.Browser.IE){
Event.observe(window,"unload",Event.unloadCache,false);
}
var Position={includeScrollOffsets:false,prepare:function(){
this.deltaX=window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0;
this.deltaY=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0;
},realOffset:function(_2d0){
var _2d1=0,valueL=0;
do{
_2d1+=_2d0.scrollTop||0;
valueL+=_2d0.scrollLeft||0;
_2d0=_2d0.parentNode;
}while(_2d0);
return [valueL,_2d1];
},cumulativeOffset:function(_2d2){
var _2d3=0,valueL=0;
do{
_2d3+=_2d2.offsetTop||0;
valueL+=_2d2.offsetLeft||0;
_2d2=_2d2.offsetParent;
}while(_2d2);
return [valueL,_2d3];
},positionedOffset:function(_2d4){
var _2d5=0,valueL=0;
do{
_2d5+=_2d4.offsetTop||0;
valueL+=_2d4.offsetLeft||0;
_2d4=_2d4.offsetParent;
if(_2d4){
if(_2d4.tagName=="BODY"){
break;
}
var p=Element.getStyle(_2d4,"position");
if(p=="relative"||p=="absolute"){
break;
}
}
}while(_2d4);
return [valueL,_2d5];
},offsetParent:function(_2d7){
if(_2d7.offsetParent){
return _2d7.offsetParent;
}
if(_2d7==document.body){
return _2d7;
}
while((_2d7=_2d7.parentNode)&&_2d7!=document.body){
if(Element.getStyle(_2d7,"position")!="static"){
return _2d7;
}
}
return document.body;
},within:function(_2d8,x,y){
if(this.includeScrollOffsets){
return this.withinIncludingScrolloffsets(_2d8,x,y);
}
this.xcomp=x;
this.ycomp=y;
this.offset=this.cumulativeOffset(_2d8);
return (y>=this.offset[1]&&y<this.offset[1]+_2d8.offsetHeight&&x>=this.offset[0]&&x<this.offset[0]+_2d8.offsetWidth);
},withinIncludingScrolloffsets:function(_2db,x,y){
var _2de=this.realOffset(_2db);
this.xcomp=x+_2de[0]-this.deltaX;
this.ycomp=y+_2de[1]-this.deltaY;
this.offset=this.cumulativeOffset(_2db);
return (this.ycomp>=this.offset[1]&&this.ycomp<this.offset[1]+_2db.offsetHeight&&this.xcomp>=this.offset[0]&&this.xcomp<this.offset[0]+_2db.offsetWidth);
},overlap:function(mode,_2e0){
if(!mode){
return 0;
}
if(mode=="vertical"){
return ((this.offset[1]+_2e0.offsetHeight)-this.ycomp)/_2e0.offsetHeight;
}
if(mode=="horizontal"){
return ((this.offset[0]+_2e0.offsetWidth)-this.xcomp)/_2e0.offsetWidth;
}
},page:function(_2e1){
var _2e2=0,valueL=0;
var _2e3=_2e1;
do{
_2e2+=_2e3.offsetTop||0;
valueL+=_2e3.offsetLeft||0;
if(_2e3.offsetParent==document.body){
if(Element.getStyle(_2e3,"position")=="absolute"){
break;
}
}
}while(_2e3=_2e3.offsetParent);
_2e3=_2e1;
do{
if(!window.opera||_2e3.tagName=="BODY"){
_2e2-=_2e3.scrollTop||0;
valueL-=_2e3.scrollLeft||0;
}
}while(_2e3=_2e3.parentNode);
return [valueL,_2e2];
},clone:function(_2e4,_2e5){
var _2e6=Object.extend({setLeft:true,setTop:true,setWidth:true,setHeight:true,offsetTop:0,offsetLeft:0},arguments[2]||{});
_2e4=$(_2e4);
var p=Position.page(_2e4);
_2e5=$(_2e5);
var _2e8=[0,0];
var _2e9=null;
if(Element.getStyle(_2e5,"position")=="absolute"){
_2e9=Position.offsetParent(_2e5);
_2e8=Position.page(_2e9);
}
if(_2e9==document.body){
_2e8[0]-=document.body.offsetLeft;
_2e8[1]-=document.body.offsetTop;
}
if(_2e6.setLeft){
_2e5.style.left=(p[0]-_2e8[0]+_2e6.offsetLeft)+"px";
}
if(_2e6.setTop){
_2e5.style.top=(p[1]-_2e8[1]+_2e6.offsetTop)+"px";
}
if(_2e6.setWidth){
_2e5.style.width=_2e4.offsetWidth+"px";
}
if(_2e6.setHeight){
_2e5.style.height=_2e4.offsetHeight+"px";
}
},absolutize:function(_2ea){
_2ea=$(_2ea);
if(_2ea.style.position=="absolute"){
return;
}
Position.prepare();
var _2eb=Position.positionedOffset(_2ea);
var top=_2eb[1];
var left=_2eb[0];
var _2ee=_2ea.clientWidth;
var _2ef=_2ea.clientHeight;
_2ea._originalLeft=left-parseFloat(_2ea.style.left||0);
_2ea._originalTop=top-parseFloat(_2ea.style.top||0);
_2ea._originalWidth=_2ea.style.width;
_2ea._originalHeight=_2ea.style.height;
_2ea.style.position="absolute";
_2ea.style.top=top+"px";
_2ea.style.left=left+"px";
_2ea.style.width=_2ee+"px";
_2ea.style.height=_2ef+"px";
},relativize:function(_2f0){
_2f0=$(_2f0);
if(_2f0.style.position=="relative"){
return;
}
Position.prepare();
_2f0.style.position="relative";
var top=parseFloat(_2f0.style.top||0)-(_2f0._originalTop||0);
var left=parseFloat(_2f0.style.left||0)-(_2f0._originalLeft||0);
_2f0.style.top=top+"px";
_2f0.style.left=left+"px";
_2f0.style.height=_2f0._originalHeight;
_2f0.style.width=_2f0._originalWidth;
}};
if(Prototype.Browser.WebKit){
Position.cumulativeOffset=function(_2f3){
var _2f4=0,valueL=0;
do{
_2f4+=_2f3.offsetTop||0;
valueL+=_2f3.offsetLeft||0;
if(_2f3.offsetParent==document.body){
if(Element.getStyle(_2f3,"position")=="absolute"){
break;
}
}
_2f3=_2f3.offsetParent;
}while(_2f3);
return [valueL,_2f4];
};
}
Element.addMethods();


// script.aculo.us builder.js v1.7.0, Fri Jan 19 19:16:36 CET 2007

// Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
//
// script.aculo.us is freely distributable under the terms of an MIT-style license.
// For details, see the script.aculo.us web site: http://script.aculo.us/

var Builder = {
  NODEMAP: {
    AREA: 'map',
    CAPTION: 'table',
    COL: 'table',
    COLGROUP: 'table',
    LEGEND: 'fieldset',
    OPTGROUP: 'select',
    OPTION: 'select',
    PARAM: 'object',
    TBODY: 'table',
    TD: 'table',
    TFOOT: 'table',
    TH: 'table',
    THEAD: 'table',
    TR: 'table'
  },
  // note: For Firefox < 1.5, OPTION and OPTGROUP tags are currently broken,
  //       due to a Firefox bug
  node: function(elementName) {
    elementName = elementName.toUpperCase();
    
    // try innerHTML approach
    var parentTag = this.NODEMAP[elementName] || 'div';
    var parentElement = document.createElement(parentTag);
    try { // prevent IE "feature": http://dev.rubyonrails.org/ticket/2707
      parentElement.innerHTML = "<" + elementName + "></" + elementName + ">";
    } catch(e) {}
    var element = parentElement.firstChild || null;
      
    // see if browser added wrapping tags
    if(element && (element.tagName.toUpperCase() != elementName))
      element = element.getElementsByTagName(elementName)[0];
    
    // fallback to createElement approach
    if(!element) element = document.createElement(elementName);
    
    // abort if nothing could be created
    if(!element) return;

    // attributes (or text)
    if(arguments[1])
      if(this._isStringOrNumber(arguments[1]) ||
        (arguments[1] instanceof Array)) {
          this._children(element, arguments[1]);
        } else {
          var attrs = this._attributes(arguments[1]);
          if(attrs.length) {
            try { // prevent IE "feature": http://dev.rubyonrails.org/ticket/2707
              parentElement.innerHTML = "<" +elementName + " " +
                attrs + "></" + elementName + ">";
            } catch(e) {}
            element = parentElement.firstChild || null;
            // workaround firefox 1.0.X bug
            if(!element) {
              element = document.createElement(elementName);
              for(attr in arguments[1]) 
                element[attr == 'class' ? 'className' : attr] = arguments[1][attr];
            }
            if(element.tagName.toUpperCase() != elementName)
              element = parentElement.getElementsByTagName(elementName)[0];
            }
        } 

    // text, or array of children
    if(arguments[2])
      this._children(element, arguments[2]);

     return element;
  },
  _text: function(text) {
     return document.createTextNode(text);
  },

  ATTR_MAP: {
    'className': 'class',
    'htmlFor': 'for'
  },

  _attributes: function(attributes) {
    var attrs = [];
    for(attribute in attributes)
      attrs.push((attribute in this.ATTR_MAP ? this.ATTR_MAP[attribute] : attribute) +
          '="' + attributes[attribute].toString().escapeHTML() + '"');
    return attrs.join(" ");
  },
  _children: function(element, children) {
    if(typeof children=='object') { // array can hold nodes and text
      children.flatten().each( function(e) {
        if(typeof e=='object')
          element.appendChild(e)
        else
          if(Builder._isStringOrNumber(e))
            element.appendChild(Builder._text(e));
      });
    } else
      if(Builder._isStringOrNumber(children)) 
         element.appendChild(Builder._text(children));
  },
  _isStringOrNumber: function(param) {
    return(typeof param=='string' || typeof param=='number');
  },
  build: function(html) {
    var element = this.node('div');
    $(element).update(html.strip());
    return element.down();
  },
  dump: function(scope) { 
    if(typeof scope != 'object' && typeof scope != 'function') scope = window; //global scope 
  
    var tags = ("A ABBR ACRONYM ADDRESS APPLET AREA B BASE BASEFONT BDO BIG BLOCKQUOTE BODY " +
      "BR BUTTON CAPTION CENTER CITE CODE COL COLGROUP DD DEL DFN DIR DIV DL DT EM FIELDSET " +
      "FONT FORM FRAME FRAMESET H1 H2 H3 H4 H5 H6 HEAD HR HTML I IFRAME IMG INPUT INS ISINDEX "+
      "KBD LABEL LEGEND LI LINK MAP MENU META NOFRAMES NOSCRIPT OBJECT OL OPTGROUP OPTION P "+
      "PARAM PRE Q S SAMP SCRIPT SELECT SMALL SPAN STRIKE STRONG STYLE SUB SUP TABLE TBODY TD "+
      "TEXTAREA TFOOT TH THEAD TITLE TR TT U UL VAR").split(/\s+/);
  
    tags.each( function(tag){ 
      scope[tag] = function() { 
        return Builder.node.apply(Builder, [tag].concat($A(arguments)));  
      } 
    });
  }
}

// script.aculo.us effects.js v1.7.0, Fri Jan 19 19:16:36 CET 2007

// Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
// Contributors:
//  Justin Palmer (http://encytemedia.com/)
//  Mark Pilgrim (http://diveintomark.org/)
//  Martin Bialasinki
// 
// script.aculo.us is freely distributable under the terms of an MIT-style license.
// For details, see the script.aculo.us web site: http://script.aculo.us/ 

// converts rgb() and #xxx to #xxxxxx format,  
// returns self (or first argument) if not convertable  
String.prototype.parseColor = function() {  
  var color = '#';
  if(this.slice(0,4) == 'rgb(') {  
    var cols = this.slice(4,this.length-1).split(',');  
    var i=0; do { color += parseInt(cols[i]).toColorPart() } while (++i<3);  
  } else {  
    if(this.slice(0,1) == '#') {  
      if(this.length==4) for(var i=1;i<4;i++) color += (this.charAt(i) + this.charAt(i)).toLowerCase();  
      if(this.length==7) color = this.toLowerCase();  
    }  
  }  
  return(color.length==7 ? color : (arguments[0] || this));  
}

/*--------------------------------------------------------------------------*/

Element.collectTextNodes = function(element) {  
  return $A($(element).childNodes).collect( function(node) {
    return (node.nodeType==3 ? node.nodeValue : 
      (node.hasChildNodes() ? Element.collectTextNodes(node) : ''));
  }).flatten().join('');
}

Element.collectTextNodesIgnoreClass = function(element, className) {  
  return $A($(element).childNodes).collect( function(node) {
    return (node.nodeType==3 ? node.nodeValue : 
      ((node.hasChildNodes() && !Element.hasClassName(node,className)) ? 
        Element.collectTextNodesIgnoreClass(node, className) : ''));
  }).flatten().join('');
}

Element.setContentZoom = function(element, percent) {
  element = $(element);  
  element.setStyle({fontSize: (percent/100) + 'em'});   
  if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0);
  return element;
}

Element.getOpacity = function(element){
  return $(element).getStyle('opacity');
}

Element.setOpacity = function(element, value){
  //return $(element).setStyle({opacity:value});
    element = $(element);
    if (Prototype.Browser.IE) {
	    var filter = element.getStyle('filter'), style = element.style;
	    if (value == 1 || value === '') {
	      style.filter = filter.replace(/alpha\([^\)]*\)/gi,'');
	      return element;
	    } else if (value < 0.00001) value = 0;
	    style.filter = filter.replace(/alpha\([^\)]*\)/gi, '') +
	      'alpha(opacity=' + (value * 100) + ')';
  	}
  	else
  	{
	    element.style.opacity = (value == 1) ? 0.999999 :
	      (value === '') ? '' : (value < 0.00001) ? 0 : value;	  	
  	}
    return element;
}

Element.getInlineOpacity = function(element){
  return $(element).style.opacity || '';
}

Element.forceRerendering = function(element) {
  try {
    element = $(element);
    var n = document.createTextNode(' ');
    element.appendChild(n);
    element.removeChild(n);
  } catch(e) { }
};

/*--------------------------------------------------------------------------*/

Array.prototype.call = function() {
  var args = arguments;
  this.each(function(f){ f.apply(this, args) });
}

/*--------------------------------------------------------------------------*/

var Effect = {
  _elementDoesNotExistError: {
    name: 'ElementDoesNotExistError',
    message: 'The specified DOM element does not exist, but is required for this effect to operate'
  },
  tagifyText: function(element) {
    if(typeof Builder == 'undefined')
      throw("Effect.tagifyText requires including script.aculo.us' builder.js library");
      
    var tagifyStyle = 'position:relative';
    if(/MSIE/.test(navigator.userAgent) && !window.opera) tagifyStyle += ';zoom:1';
    
    element = $(element);
    $A(element.childNodes).each( function(child) {
      if(child.nodeType==3) {
        child.nodeValue.toArray().each( function(character) {
          element.insertBefore(
            Builder.node('span',{style: tagifyStyle},
              character == ' ' ? String.fromCharCode(160) : character), 
              child);
        });
        Element.remove(child);
      }
    });
  },
  multiple: function(element, effect) {
    var elements;
    if(((typeof element == 'object') || 
        (typeof element == 'function')) && 
       (element.length))
      elements = element;
    else
      elements = $(element).childNodes;
      
    var options = Object.extend({
      speed: 0.1,
      delay: 0.0
    }, arguments[2] || {});
    var masterDelay = options.delay;

    $A(elements).each( function(element, index) {
      new effect(element, Object.extend(options, { delay: index * options.speed + masterDelay }));
    });
  },
  PAIRS: {
    'slide':  ['SlideDown','SlideUp'],
    'blind':  ['BlindDown','BlindUp'],
    'appear': ['Appear','Fade']
  },
  toggle: function(element, effect) {
    element = $(element);
    effect = (effect || 'appear').toLowerCase();
    var options = Object.extend({
      queue: { position:'end', scope:(element.id || 'global'), limit: 1 }
    }, arguments[2] || {});
    Effect[element.visible() ? 
      Effect.PAIRS[effect][1] : Effect.PAIRS[effect][0]](element, options);
  }
};

var Effect2 = Effect; // deprecated

/* ------------- transitions ------------- */

Effect.Transitions = {
  linear: Prototype.K,
  sinoidal: function(pos) {
    return (-Math.cos(pos*Math.PI)/2) + 0.5;
  },
  reverse: function(pos) {
    return 1-pos;
  },
  flicker: function(pos) {
    return ((-Math.cos(pos*Math.PI)/4) + 0.75) + Math.random()/4;
  },
  wobble: function(pos) {
    return (-Math.cos(pos*Math.PI*(9*pos))/2) + 0.5;
  },
  pulse: function(pos, pulses) { 
    pulses = pulses || 5; 
    return (
      Math.round((pos % (1/pulses)) * pulses) == 0 ? 
            ((pos * pulses * 2) - Math.floor(pos * pulses * 2)) : 
        1 - ((pos * pulses * 2) - Math.floor(pos * pulses * 2))
      );
  },
  none: function(pos) {
    return 0;
  },
  full: function(pos) {
    return 1;
  }
};

/* ------------- core effects ------------- */

Effect.ScopedQueue = Class.create();
Object.extend(Object.extend(Effect.ScopedQueue.prototype, Enumerable), {
  initialize: function() {
    this.effects  = [];
    this.interval = null;
  },
  _each: function(iterator) {
    this.effects._each(iterator);
  },
  add: function(effect) {
    var timestamp = new Date().getTime();
    
    var position = (typeof effect.options.queue == 'string') ? 
      effect.options.queue : effect.options.queue.position;
    
    switch(position) {
      case 'front':
        // move unstarted effects after this effect  
        this.effects.findAll(function(e){ return e.state=='idle' }).each( function(e) {
            e.startOn  += effect.finishOn;
            e.finishOn += effect.finishOn;
          });
        break;
      case 'with-last':
        timestamp = this.effects.pluck('startOn').max() || timestamp;
        break;
      case 'end':
        // start effect after last queued effect has finished
        timestamp = this.effects.pluck('finishOn').max() || timestamp;
        break;
    }
    
    effect.startOn  += timestamp;
    effect.finishOn += timestamp;

    if(!effect.options.queue.limit || (this.effects.length < effect.options.queue.limit))
      this.effects.push(effect);
    
    if(!this.interval) 
      this.interval = setInterval(this.loop.bind(this), 15);
  },
  remove: function(effect) {
    this.effects = this.effects.reject(function(e) { return e==effect });
    if(this.effects.length == 0) {
      clearInterval(this.interval);
      this.interval = null;
    }
  },
  loop: function() {
    var timePos = new Date().getTime();
    for(var i=0, len=this.effects.length;i<len;i++) 
      if(this.effects[i]) this.effects[i].loop(timePos);
  }
});

Effect.Queues = {
  instances: $H(),
  get: function(queueName) {
    if(typeof queueName != 'string') return queueName;
    
    if(!this.instances[queueName])
      this.instances[queueName] = new Effect.ScopedQueue();
      
    return this.instances[queueName];
  }
}
Effect.Queue = Effect.Queues.get('global');

Effect.DefaultOptions = {
  transition: Effect.Transitions.sinoidal,
  duration:   1.0,   // seconds
  fps:        60.0,  // max. 60fps due to Effect.Queue implementation
  sync:       false, // true for combining
  from:       0.0,
  to:         1.0,
  delay:      0.0,
  queue:      'parallel'
}

Effect.Base = function() {};
Effect.Base.prototype = {
  position: null,
  start: function(options) {
    this.options      = Object.extend(Object.extend({},Effect.DefaultOptions), options || {});
    this.currentFrame = 0;
    this.state        = 'idle';
    this.startOn      = this.options.delay*1000;
    this.finishOn     = this.startOn + (this.options.duration*1000);
    this.event('beforeStart');
    if(!this.options.sync)
      Effect.Queues.get(typeof this.options.queue == 'string' ? 
        'global' : this.options.queue.scope).add(this);
  },
  loop: function(timePos) {
    if(timePos >= this.startOn) {
      if(timePos >= this.finishOn) {
        this.render(1.0);
        this.cancel();
        this.event('beforeFinish');
        if(this.finish) this.finish(); 
        this.event('afterFinish');
        return;  
      }
      var pos   = (timePos - this.startOn) / (this.finishOn - this.startOn);
      var frame = Math.round(pos * this.options.fps * this.options.duration);
      if(frame > this.currentFrame) {
        this.render(pos);
        this.currentFrame = frame;
      }
    }
  },
  render: function(pos) {
    if(this.state == 'idle') {
      this.state = 'running';
      this.event('beforeSetup');
      if(this.setup) this.setup();
      this.event('afterSetup');
    }
    if(this.state == 'running') {
      if(this.options.transition) pos = this.options.transition(pos);
      pos *= (this.options.to-this.options.from);
      pos += this.options.from;
      this.position = pos;
      this.event('beforeUpdate');
      if(this.update) this.update(pos);
      this.event('afterUpdate');
    }
  },
  cancel: function() {
    if(!this.options.sync)
      Effect.Queues.get(typeof this.options.queue == 'string' ? 
        'global' : this.options.queue.scope).remove(this);
    this.state = 'finished';
  },
  event: function(eventName) {
    if(this.options[eventName + 'Internal']) this.options[eventName + 'Internal'](this);
    if(this.options[eventName]) this.options[eventName](this);
  },
  inspect: function() {
    var data = $H();
    for(property in this)
      if(typeof this[property] != 'function') data[property] = this[property];
    return '#<Effect:' + data.inspect() + ',options:' + $H(this.options).inspect() + '>';
  }
}

Effect.Parallel = Class.create();
Object.extend(Object.extend(Effect.Parallel.prototype, Effect.Base.prototype), {
  initialize: function(effects) {
    this.effects = effects || [];
    this.start(arguments[1]);
  },
  update: function(position) {
    this.effects.invoke('render', position);
  },
  finish: function(position) {
    this.effects.each( function(effect) {
      effect.render(1.0);
      effect.cancel();
      effect.event('beforeFinish');
      if(effect.finish) effect.finish(position);
      effect.event('afterFinish');
    });
  }
});

Effect.Event = Class.create();
Object.extend(Object.extend(Effect.Event.prototype, Effect.Base.prototype), {
  initialize: function() {
    var options = Object.extend({
      duration: 0
    }, arguments[0] || {});
    this.start(options);
  },
  update: Prototype.emptyFunction
});

Effect.Opacity = Class.create();
Object.extend(Object.extend(Effect.Opacity.prototype, Effect.Base.prototype), {
  initialize: function(element) {
    this.element = $(element);
    if(!this.element) throw(Effect._elementDoesNotExistError);
    // make this work on IE on elements without 'layout'
    if(/MSIE/.test(navigator.userAgent) && !window.opera && (!this.element.currentStyle.hasLayout))
      this.element.setStyle({zoom: 1});
    var options = Object.extend({
      from: this.element.getOpacity() || 0.0,
      to:   1.0
    }, arguments[1] || {});
    this.start(options);
  },
  update: function(position) {
    this.element.setOpacity(position);
  }
});

Effect.Move = Class.create();
Object.extend(Object.extend(Effect.Move.prototype, Effect.Base.prototype), {
  initialize: function(element) {
    this.element = $(element);
    if(!this.element) throw(Effect._elementDoesNotExistError);
    var options = Object.extend({
      x:    0,
      y:    0,
      mode: 'relative'
    }, arguments[1] || {});
    this.start(options);
  },
  setup: function() {
    // Bug in Opera: Opera returns the "real" position of a static element or
    // relative element that does not have top/left explicitly set.
    // ==> Always set top and left for position relative elements in your stylesheets 
    // (to 0 if you do not need them) 
    this.element.makePositioned();
    this.originalLeft = parseFloat(this.element.getStyle('left') || '0');
    this.originalTop  = parseFloat(this.element.getStyle('top')  || '0');
    if(this.options.mode == 'absolute') {
      // absolute movement, so we need to calc deltaX and deltaY
      this.options.x = this.options.x - this.originalLeft;
      this.options.y = this.options.y - this.originalTop;
    }
  },
  update: function(position) {
    this.element.setStyle({
      left: Math.round(this.options.x  * position + this.originalLeft) + 'px',
      top:  Math.round(this.options.y  * position + this.originalTop)  + 'px'
    });
  }
});

// for backwards compatibility
Effect.MoveBy = function(element, toTop, toLeft) {
  return new Effect.Move(element, 
    Object.extend({ x: toLeft, y: toTop }, arguments[3] || {}));
};

Effect.Scale = Class.create();
Object.extend(Object.extend(Effect.Scale.prototype, Effect.Base.prototype), {
  initialize: function(element, percent) {
    this.element = $(element);
    if(!this.element) throw(Effect._elementDoesNotExistError);
    var options = Object.extend({
      scaleX: true,
      scaleY: true,
      scaleContent: true,
      scaleFromCenter: false,
      scaleMode: 'box',        // 'box' or 'contents' or {} with provided values
      scaleFrom: 100.0,
      scaleTo:   percent
    }, arguments[2] || {});
    this.start(options);
  },
  setup: function() {
    this.restoreAfterFinish = this.options.restoreAfterFinish || false;
    this.elementPositioning = this.element.getStyle('position');
    
    this.originalStyle = {};
    ['top','left','width','height','fontSize'].each( function(k) {
      this.originalStyle[k] = this.element.style[k];
    }.bind(this));
      
    this.originalTop  = this.element.offsetTop;
    this.originalLeft = this.element.offsetLeft;
    
    var fontSize = this.element.getStyle('font-size') || '100%';
    ['em','px','%','pt'].each( function(fontSizeType) {
      if(fontSize.indexOf(fontSizeType)>0) {
        this.fontSize     = parseFloat(fontSize);
        this.fontSizeType = fontSizeType;
      }
    }.bind(this));
    
    this.factor = (this.options.scaleTo - this.options.scaleFrom)/100;
    
    this.dims = null;
    if(this.options.scaleMode=='box')
      this.dims = [this.element.offsetHeight, this.element.offsetWidth];
    if(/^content/.test(this.options.scaleMode))
      this.dims = [this.element.scrollHeight, this.element.scrollWidth];
    if(!this.dims)
      this.dims = [this.options.scaleMode.originalHeight,
                   this.options.scaleMode.originalWidth];
  },
  update: function(position) {
    var currentScale = (this.options.scaleFrom/100.0) + (this.factor * position);
    if(this.options.scaleContent && this.fontSize)
      this.element.setStyle({fontSize: this.fontSize * currentScale + this.fontSizeType });
    this.setDimensions(this.dims[0] * currentScale, this.dims[1] * currentScale);
  },
  finish: function(position) {
    if(this.restoreAfterFinish) this.element.setStyle(this.originalStyle);
  },
  setDimensions: function(height, width) {
    var d = {};
    if(this.options.scaleX) d.width = Math.round(width) + 'px';
    if(this.options.scaleY) d.height = Math.round(height) + 'px';
    if(this.options.scaleFromCenter) {
      var topd  = (height - this.dims[0])/2;
      var leftd = (width  - this.dims[1])/2;
      if(this.elementPositioning == 'absolute') {
        if(this.options.scaleY) d.top = this.originalTop-topd + 'px';
        if(this.options.scaleX) d.left = this.originalLeft-leftd + 'px';
      } else {
        if(this.options.scaleY) d.top = -topd + 'px';
        if(this.options.scaleX) d.left = -leftd + 'px';
      }
    }
    this.element.setStyle(d);
  }
});

Effect.Highlight = Class.create();
Object.extend(Object.extend(Effect.Highlight.prototype, Effect.Base.prototype), {
  initialize: function(element) {
    this.element = $(element);
    if(!this.element) throw(Effect._elementDoesNotExistError);
    var options = Object.extend({ startcolor: '#ffff99' }, arguments[1] || {});
    this.start(options);
  },
  setup: function() {
    // Prevent executing on elements not in the layout flow
    if(this.element.getStyle('display')=='none') { this.cancel(); return; }
    // Disable background image during the effect
    this.oldStyle = {};
    if (!this.options.keepBackgroundImage) {
      this.oldStyle.backgroundImage = this.element.getStyle('background-image');
      this.element.setStyle({backgroundImage: 'none'});
    }
    if(!this.options.endcolor)
      this.options.endcolor = this.element.getStyle('background-color').parseColor('#ffffff');
    if(!this.options.restorecolor)
      this.options.restorecolor = this.element.getStyle('background-color');
    // init color calculations
    this._base  = $R(0,2).map(function(i){ return parseInt(this.options.startcolor.slice(i*2+1,i*2+3),16) }.bind(this));
    this._delta = $R(0,2).map(function(i){ return parseInt(this.options.endcolor.slice(i*2+1,i*2+3),16)-this._base[i] }.bind(this));
  },
  update: function(position) {
    this.element.setStyle({backgroundColor: $R(0,2).inject('#',function(m,v,i){
      return m+(Math.round(this._base[i]+(this._delta[i]*position)).toColorPart()); }.bind(this)) });
  },
  finish: function() {
    this.element.setStyle(Object.extend(this.oldStyle, {
      backgroundColor: this.options.restorecolor
    }));
  }
});

Effect.ScrollTo = Class.create();
Object.extend(Object.extend(Effect.ScrollTo.prototype, Effect.Base.prototype), {
  initialize: function(element) {
    this.element = $(element);
    this.start(arguments[1] || {});
  },
  setup: function() {
    Position.prepare();
    var offsets = Position.cumulativeOffset(this.element);
    if(this.options.offset) offsets[1] += this.options.offset;
    var max = window.innerHeight ? 
      window.height - window.innerHeight :
      document.body.scrollHeight - 
        (document.documentElement.clientHeight ? 
          document.documentElement.clientHeight : document.body.clientHeight);
    this.scrollStart = Position.deltaY;
    this.delta = (offsets[1] > max ? max : offsets[1]) - this.scrollStart;
  },
  update: function(position) {
    Position.prepare();
    window.scrollTo(Position.deltaX, 
      this.scrollStart + (position*this.delta));
  }
});

/* ------------- combination effects ------------- */

Effect.Fade = function(element) {
  element = $(element);
  var oldOpacity = element.getInlineOpacity();
  var options = Object.extend({
  from: element.getOpacity() || 1.0,
  to:   0.0,
  afterFinishInternal: function(effect) { 
    if(effect.options.to!=0) return;
    effect.element.hide().setStyle({opacity: oldOpacity}); 
  }}, arguments[1] || {});
  return new Effect.Opacity(element,options);
}

Effect.Appear = function(element) {
  element = $(element);
  var options = Object.extend({
  from: (element.getStyle('display') == 'none' ? 0.0 : element.getOpacity() || 0.0),
  to:   1.0,
  // force Safari to render floated elements properly
  afterFinishInternal: function(effect) {
    effect.element.forceRerendering();
  },
  beforeSetup: function(effect) {
    effect.element.setOpacity(effect.options.from).show(); 
  }}, arguments[1] || {});
  return new Effect.Opacity(element,options);
}

Effect.Puff = function(element) {
  element = $(element);
  var oldStyle = { 
    opacity: element.getInlineOpacity(), 
    position: element.getStyle('position'),
    top:  element.style.top,
    left: element.style.left,
    width: element.style.width,
    height: element.style.height
  };
  return new Effect.Parallel(
   [ new Effect.Scale(element, 200, 
      { sync: true, scaleFromCenter: true, scaleContent: true, restoreAfterFinish: true }), 
     new Effect.Opacity(element, { sync: true, to: 0.0 } ) ], 
     Object.extend({ duration: 1.0, 
      beforeSetupInternal: function(effect) {
        Position.absolutize(effect.effects[0].element)
      },
      afterFinishInternal: function(effect) {
         effect.effects[0].element.hide().setStyle(oldStyle); }
     }, arguments[1] || {})
   );
}

Effect.BlindUp = function(element) {
  element = $(element);
  element.makeClipping();
  return new Effect.Scale(element, 0,
    Object.extend({ scaleContent: false, 
      scaleX: false, 
      restoreAfterFinish: true,
      afterFinishInternal: function(effect) {
        effect.element.hide().undoClipping();
      } 
    }, arguments[1] || {})
  );
}

Effect.BlindDown = function(element) {
  element = $(element);
  var elementDimensions = element.getDimensions();
  return new Effect.Scale(element, 100, Object.extend({ 
    scaleContent: false, 
    scaleX: false,
    scaleFrom: 0,
    scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
    restoreAfterFinish: true,
    afterSetup: function(effect) {
      effect.element.makeClipping().setStyle({height: '0px'}).show(); 
    },  
    afterFinishInternal: function(effect) {
      effect.element.undoClipping();
    }
  }, arguments[1] || {}));
}

Effect.SwitchOff = function(element) {
  element = $(element);
  var oldOpacity = element.getInlineOpacity();
  return new Effect.Appear(element, Object.extend({
    duration: 0.4,
    from: 0,
    transition: Effect.Transitions.flicker,
    afterFinishInternal: function(effect) {
      new Effect.Scale(effect.element, 1, { 
        duration: 0.3, scaleFromCenter: true,
        scaleX: false, scaleContent: false, restoreAfterFinish: true,
        beforeSetup: function(effect) { 
          effect.element.makePositioned().makeClipping();
        },
        afterFinishInternal: function(effect) {
          effect.element.hide().undoClipping().undoPositioned().setStyle({opacity: oldOpacity});
        }
      })
    }
  }, arguments[1] || {}));
}

Effect.DropOut = function(element) {
  element = $(element);
  var oldStyle = {
    top: element.getStyle('top'),
    left: element.getStyle('left'),
    opacity: element.getInlineOpacity() };
  return new Effect.Parallel(
    [ new Effect.Move(element, {x: 0, y: 100, sync: true }), 
      new Effect.Opacity(element, { sync: true, to: 0.0 }) ],
    Object.extend(
      { duration: 0.5,
        beforeSetup: function(effect) {
          effect.effects[0].element.makePositioned(); 
        },
        afterFinishInternal: function(effect) {
          effect.effects[0].element.hide().undoPositioned().setStyle(oldStyle);
        } 
      }, arguments[1] || {}));
}

Effect.Shake = function(element) {
  element = $(element);
  var oldStyle = {
    top: element.getStyle('top'),
    left: element.getStyle('left') };
    return new Effect.Move(element, 
      { x:  20, y: 0, duration: 0.05, afterFinishInternal: function(effect) {
    new Effect.Move(effect.element,
      { x: -40, y: 0, duration: 0.1,  afterFinishInternal: function(effect) {
    new Effect.Move(effect.element,
      { x:  40, y: 0, duration: 0.1,  afterFinishInternal: function(effect) {
    new Effect.Move(effect.element,
      { x: -40, y: 0, duration: 0.1,  afterFinishInternal: function(effect) {
    new Effect.Move(effect.element,
      { x:  40, y: 0, duration: 0.1,  afterFinishInternal: function(effect) {
    new Effect.Move(effect.element,
      { x: -20, y: 0, duration: 0.05, afterFinishInternal: function(effect) {
        effect.element.undoPositioned().setStyle(oldStyle);
  }}) }}) }}) }}) }}) }});
}

Effect.SlideDown = function(element) {
  element = $(element).cleanWhitespace();
  // SlideDown need to have the content of the element wrapped in a container element with fixed height!
  var oldInnerBottom = element.down().getStyle('bottom');
  var elementDimensions = element.getDimensions();
  return new Effect.Scale(element, 100, Object.extend({ 
    scaleContent: false, 
    scaleX: false, 
    scaleFrom: window.opera ? 0 : 1,
    scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
    restoreAfterFinish: true,
    afterSetup: function(effect) {
      effect.element.makePositioned();
      effect.element.down().makePositioned();
      if(window.opera) effect.element.setStyle({top: ''});
      effect.element.makeClipping().setStyle({height: '0px'}).show(); 
    },
    afterUpdateInternal: function(effect) {
      effect.element.down().setStyle({bottom:
        (effect.dims[0] - effect.element.clientHeight) + 'px' }); 
    },
    afterFinishInternal: function(effect) {
      effect.element.undoClipping().undoPositioned();
      effect.element.down().undoPositioned().setStyle({bottom: oldInnerBottom}); }
    }, arguments[1] || {})
  );
}

Effect.SlideUp = function(element) {
  element = $(element).cleanWhitespace();
  var oldInnerBottom = element.down().getStyle('bottom');
  return new Effect.Scale(element, window.opera ? 0 : 1,
   Object.extend({ scaleContent: false, 
    scaleX: false, 
    scaleMode: 'box',
    scaleFrom: 100,
    restoreAfterFinish: true,
    beforeStartInternal: function(effect) {
      effect.element.makePositioned();
      effect.element.down().makePositioned();
      if(window.opera) effect.element.setStyle({top: ''});
      effect.element.makeClipping().show();
    },  
    afterUpdateInternal: function(effect) {
      effect.element.down().setStyle({bottom:
        (effect.dims[0] - effect.element.clientHeight) + 'px' });
    },
    afterFinishInternal: function(effect) {
      effect.element.hide().undoClipping().undoPositioned().setStyle({bottom: oldInnerBottom});
      effect.element.down().undoPositioned();
    }
   }, arguments[1] || {})
  );
}

// Bug in opera makes the TD containing this element expand for a instance after finish 
Effect.Squish = function(element) {
  return new Effect.Scale(element, window.opera ? 1 : 0, { 
    restoreAfterFinish: true,
    beforeSetup: function(effect) {
      effect.element.makeClipping(); 
    },  
    afterFinishInternal: function(effect) {
      effect.element.hide().undoClipping(); 
    }
  });
}

Effect.Grow = function(element) {
  element = $(element);
  var options = Object.extend({
    direction: 'center',
    moveTransition: Effect.Transitions.sinoidal,
    scaleTransition: Effect.Transitions.sinoidal,
    opacityTransition: Effect.Transitions.full
  }, arguments[1] || {});
  var oldStyle = {
    top: element.style.top,
    left: element.style.left,
    height: element.style.height,
    width: element.style.width,
    opacity: element.getInlineOpacity() };

  var dims = element.getDimensions();    
  var initialMoveX, initialMoveY;
  var moveX, moveY;
  
  switch (options.direction) {
    case 'top-left':
      initialMoveX = initialMoveY = moveX = moveY = 0; 
      break;
    case 'top-right':
      initialMoveX = dims.width;
      initialMoveY = moveY = 0;
      moveX = -dims.width;
      break;
    case 'bottom-left':
      initialMoveX = moveX = 0;
      initialMoveY = dims.height;
      moveY = -dims.height;
      break;
    case 'bottom-right':
      initialMoveX = dims.width;
      initialMoveY = dims.height;
      moveX = -dims.width;
      moveY = -dims.height;
      break;
    case 'center':
      initialMoveX = dims.width / 2;
      initialMoveY = dims.height / 2;
      moveX = -dims.width / 2;
      moveY = -dims.height / 2;
      break;
  }
  
  return new Effect.Move(element, {
    x: initialMoveX,
    y: initialMoveY,
    duration: 0.01, 
    beforeSetup: function(effect) {
      effect.element.hide().makeClipping().makePositioned();
    },
    afterFinishInternal: function(effect) {
      new Effect.Parallel(
        [ new Effect.Opacity(effect.element, { sync: true, to: 1.0, from: 0.0, transition: options.opacityTransition }),
          new Effect.Move(effect.element, { x: moveX, y: moveY, sync: true, transition: options.moveTransition }),
          new Effect.Scale(effect.element, 100, {
            scaleMode: { originalHeight: dims.height, originalWidth: dims.width }, 
            sync: true, scaleFrom: window.opera ? 1 : 0, transition: options.scaleTransition, restoreAfterFinish: true})
        ], Object.extend({
             beforeSetup: function(effect) {
               effect.effects[0].element.setStyle({height: '0px'}).show(); 
             },
             afterFinishInternal: function(effect) {
               effect.effects[0].element.undoClipping().undoPositioned().setStyle(oldStyle); 
             }
           }, options)
      )
    }
  });
}

Effect.Shrink = function(element) {
  element = $(element);
  var options = Object.extend({
    direction: 'center',
    moveTransition: Effect.Transitions.sinoidal,
    scaleTransition: Effect.Transitions.sinoidal,
    opacityTransition: Effect.Transitions.none
  }, arguments[1] || {});
  var oldStyle = {
    top: element.style.top,
    left: element.style.left,
    height: element.style.height,
    width: element.style.width,
    opacity: element.getInlineOpacity() };

  var dims = element.getDimensions();
  var moveX, moveY;
  
  switch (options.direction) {
    case 'top-left':
      moveX = moveY = 0;
      break;
    case 'top-right':
      moveX = dims.width;
      moveY = 0;
      break;
    case 'bottom-left':
      moveX = 0;
      moveY = dims.height;
      break;
    case 'bottom-right':
      moveX = dims.width;
      moveY = dims.height;
      break;
    case 'center':  
      moveX = dims.width / 2;
      moveY = dims.height / 2;
      break;
  }
  
  return new Effect.Parallel(
    [ new Effect.Opacity(element, { sync: true, to: 0.0, from: 1.0, transition: options.opacityTransition }),
      new Effect.Scale(element, window.opera ? 1 : 0, { sync: true, transition: options.scaleTransition, restoreAfterFinish: true}),
      new Effect.Move(element, { x: moveX, y: moveY, sync: true, transition: options.moveTransition })
    ], Object.extend({            
         beforeStartInternal: function(effect) {
           effect.effects[0].element.makePositioned().makeClipping(); 
         },
         afterFinishInternal: function(effect) {
           effect.effects[0].element.hide().undoClipping().undoPositioned().setStyle(oldStyle); }
       }, options)
  );
}

Effect.Pulsate = function(element) {
  element = $(element);
  var options    = arguments[1] || {};
  var oldOpacity = element.getInlineOpacity();
  var transition = options.transition || Effect.Transitions.sinoidal;
  var reverser   = function(pos){ return transition(1-Effect.Transitions.pulse(pos, options.pulses)) };
  reverser.bind(transition);
  return new Effect.Opacity(element, 
    Object.extend(Object.extend({  duration: 2.0, from: 0,
      afterFinishInternal: function(effect) { effect.element.setStyle({opacity: oldOpacity}); }
    }, options), {transition: reverser}));
}

Effect.Fold = function(element) {
  element = $(element);
  var oldStyle = {
    top: element.style.top,
    left: element.style.left,
    width: element.style.width,
    height: element.style.height };
  element.makeClipping();
  return new Effect.Scale(element, 5, Object.extend({   
    scaleContent: false,
    scaleX: false,
    afterFinishInternal: function(effect) {
    new Effect.Scale(element, 1, { 
      scaleContent: false, 
      scaleY: false,
      afterFinishInternal: function(effect) {
        effect.element.hide().undoClipping().setStyle(oldStyle);
      } });
  }}, arguments[1] || {}));
};

Effect.Morph = Class.create();
Object.extend(Object.extend(Effect.Morph.prototype, Effect.Base.prototype), {
  initialize: function(element) {
    this.element = $(element);
    if(!this.element) throw(Effect._elementDoesNotExistError);
    var options = Object.extend({
      style: {}
    }, arguments[1] || {});
    if (typeof options.style == 'string') {
      if(options.style.indexOf(':') == -1) {
        var cssText = '', selector = '.' + options.style;
        $A(document.styleSheets).reverse().each(function(styleSheet) {
          if (styleSheet.cssRules) cssRules = styleSheet.cssRules;
          else if (styleSheet.rules) cssRules = styleSheet.rules;
          $A(cssRules).reverse().each(function(rule) {
            if (selector == rule.selectorText) {
              cssText = rule.style.cssText;
              throw $break;
            }
          });
          if (cssText) throw $break;
        });
        this.style = cssText.parseStyle();
        options.afterFinishInternal = function(effect){
          effect.element.addClassName(effect.options.style);
          effect.transforms.each(function(transform) {
            if(transform.style != 'opacity')
              effect.element.style[transform.style.camelize()] = '';
          });
        }
      } else this.style = options.style.parseStyle();
    } else this.style = $H(options.style)
    this.start(options);
  },
  setup: function(){
    function parseColor(color){
      if(!color || ['rgba(0, 0, 0, 0)','transparent'].include(color)) color = '#ffffff';
      color = color.parseColor();
      return $R(0,2).map(function(i){
        return parseInt( color.slice(i*2+1,i*2+3), 16 ) 
      });
    }
    this.transforms = this.style.map(function(pair){
      var property = pair[0].underscore().dasherize(), value = pair[1], unit = null;

      if(value.parseColor('#zzzzzz') != '#zzzzzz') {
        value = value.parseColor();
        unit  = 'color';
      } else if(property == 'opacity') {
        value = parseFloat(value);
        if(/MSIE/.test(navigator.userAgent) && !window.opera && (!this.element.currentStyle.hasLayout))
          this.element.setStyle({zoom: 1});
      } else if(Element.CSS_LENGTH.test(value)) 
        var components = value.match(/^([\+\-]?[0-9\.]+)(.*)$/),
          value = parseFloat(components[1]), unit = (components.length == 3) ? components[2] : null;

      var originalValue = this.element.getStyle(property);
      return $H({ 
        style: property, 
        originalValue: unit=='color' ? parseColor(originalValue) : parseFloat(originalValue || 0), 
        targetValue: unit=='color' ? parseColor(value) : value,
        unit: unit
      });
    }.bind(this)).reject(function(transform){
      return (
        (transform.originalValue == transform.targetValue) ||
        (
          transform.unit != 'color' &&
          (isNaN(transform.originalValue) || isNaN(transform.targetValue))
        )
      )
    });
  },
  update: function(position) {
    var style = $H(), value = null;
    this.transforms.each(function(transform){
      value = transform.unit=='color' ?
        $R(0,2).inject('#',function(m,v,i){
          return m+(Math.round(transform.originalValue[i]+
            (transform.targetValue[i] - transform.originalValue[i])*position)).toColorPart() }) : 
        transform.originalValue + Math.round(
          ((transform.targetValue - transform.originalValue) * position) * 1000)/1000 + transform.unit;
      style[transform.style] = value;
    });
    this.element.setStyle(style);
  }
});

Effect.Transform = Class.create();
Object.extend(Effect.Transform.prototype, {
  initialize: function(tracks){
    this.tracks  = [];
    this.options = arguments[1] || {};
    this.addTracks(tracks);
  },
  addTracks: function(tracks){
    tracks.each(function(track){
      var data = $H(track).values().first();
      this.tracks.push($H({
        ids:     $H(track).keys().first(),
        effect:  Effect.Morph,
        options: { style: data }
      }));
    }.bind(this));
    return this;
  },
  play: function(){
    return new Effect.Parallel(
      this.tracks.map(function(track){
        var elements = [$(track.ids) || $$(track.ids)].flatten();
        return elements.map(function(e){ return new track.effect(e, Object.extend({ sync:true }, track.options)) });
      }).flatten(),
      this.options
    );
  }
});

Element.CSS_PROPERTIES = $w(
  'backgroundColor backgroundPosition borderBottomColor borderBottomStyle ' + 
  'borderBottomWidth borderLeftColor borderLeftStyle borderLeftWidth ' +
  'borderRightColor borderRightStyle borderRightWidth borderSpacing ' +
  'borderTopColor borderTopStyle borderTopWidth bottom clip color ' +
  'fontSize fontWeight height left letterSpacing lineHeight ' +
  'marginBottom marginLeft marginRight marginTop markerOffset maxHeight '+
  'maxWidth minHeight minWidth opacity outlineColor outlineOffset ' +
  'outlineWidth paddingBottom paddingLeft paddingRight paddingTop ' +
  'right textIndent top width wordSpacing zIndex');
  
Element.CSS_LENGTH = /^(([\+\-]?[0-9\.]+)(em|ex|px|in|cm|mm|pt|pc|\%))|0$/;

String.prototype.parseStyle = function(){
  var element = Element.extend(document.createElement('div'));
  element.innerHTML = '<div style="' + this + '"></div>';
  var style = element.down().style, styleRules = $H();
  
  Element.CSS_PROPERTIES.each(function(property){
    if(style[property]) styleRules[property] = style[property]; 
  });
  if(/MSIE/.test(navigator.userAgent) && !window.opera && this.indexOf('opacity') > -1) {
    styleRules.opacity = this.match(/opacity:\s*((?:0|1)?(?:\.\d*)?)/)[1];
  }
  return styleRules;
};

Element.morph = function(element, style) {
  new Effect.Morph(element, Object.extend({ style: style }, arguments[2] || {}));
  return element;
};

['setOpacity','getOpacity','getInlineOpacity','forceRerendering','setContentZoom',
 'collectTextNodes','collectTextNodesIgnoreClass','morph'].each( 
  function(f) { Element.Methods[f] = Element[f]; }
);

Element.Methods.visualEffect = function(element, effect, options) {
  s = effect.gsub(/_/, '-').camelize();
  effect_class = s.charAt(0).toUpperCase() + s.substring(1);
  new Effect[effect_class](element, options);
  return $(element);
};

Element.addMethods();
var agt=navigator.userAgent.toLowerCase();
var is_major=parseInt(navigator.appVersion);
var is_minor=parseFloat(navigator.appVersion);
var is_nav=((agt.indexOf("mozilla")!=-1)&&(agt.indexOf("spoofer")==-1)&&(agt.indexOf("compatible")==-1)&&(agt.indexOf("opera")==-1)&&(agt.indexOf("webtv")==-1)&&(agt.indexOf("hotjava")==-1));
var is_nav2=(is_nav&&(is_major==2));
var is_nav3=(is_nav&&(is_major==3));
var is_nav4=(is_nav&&(is_major==4));
var is_nav4up=(is_nav&&(is_major>=4));
var is_navonly=(is_nav&&((agt.indexOf(";nav")!=-1)||(agt.indexOf("; nav")!=-1)));
var is_nav6=(is_nav&&(is_major==5));
var is_nav6up=(is_nav&&(is_major>=5));
var is_gecko=(agt.indexOf("gecko")!=-1);
var is_ie=((agt.indexOf("msie")!=-1)&&(agt.indexOf("opera")==-1));
var ie=((agt.indexOf("msie")!=-1)&&(agt.indexOf("opera")==-1));
var is_ie3=(is_ie&&(is_major<4));
var is_ie4=(is_ie&&(is_major==4)&&(agt.indexOf("msie 4")!=-1));
var is_ie4up=(is_ie&&(is_major>=4));
var is_ie5=(is_ie&&(is_major==4)&&(agt.indexOf("msie 5.0")!=-1));
var is_ie5_5=(is_ie&&(is_major==4)&&(agt.indexOf("msie 5.5")!=-1));
var is_ie5up=(is_ie&&!is_ie3&&!is_ie4);
var is_ie5_5up=(is_ie&&!is_ie3&&!is_ie4&&!is_ie5);
var is_ie6=(is_ie&&(is_major==4)&&(agt.indexOf("msie 6.")!=-1));
var is_ie6up=(is_ie&&!is_ie3&&!is_ie4&&!is_ie5&&!is_ie5_5);
var is_ie7=(is_ie&&(is_major==4)&&(agt.indexOf("msie 7.")!=-1));
var is_aol=(agt.indexOf("aol")!=-1);
var is_aol3=(is_aol&&is_ie3);
var is_aol4=(is_aol&&is_ie4);
var is_aol5=(agt.indexOf("aol 5")!=-1);
var is_aol6=(agt.indexOf("aol 6")!=-1);
var is_opera=(agt.indexOf("opera")!=-1);
var is_opera2=(agt.indexOf("opera 2")!=-1||agt.indexOf("opera/2")!=-1);
var is_opera3=(agt.indexOf("opera 3")!=-1||agt.indexOf("opera/3")!=-1);
var is_opera4=(agt.indexOf("opera 4")!=-1||agt.indexOf("opera/4")!=-1);
var is_opera5=(agt.indexOf("opera 5")!=-1||agt.indexOf("opera/5")!=-1);
var is_opera5up=(is_opera&&!is_opera2&&!is_opera3&&!is_opera4);
var is_webtv=(agt.indexOf("webtv")!=-1);
var is_TVNavigator=((agt.indexOf("navio")!=-1)||(agt.indexOf("navio_aoltv")!=-1));
var is_AOLTV=is_TVNavigator;
var is_hotjava=(agt.indexOf("hotjava")!=-1);
var is_hotjava3=(is_hotjava&&(is_major==3));
var is_hotjava3up=(is_hotjava&&(is_major>=3));


var grab1=new Image(32,32);
grab1.src="images/cursor/hand32.cur";
var grab2=new Image(32,32);
grab2.src="images/cursor/grab32.cur";
function setCookie(_1,_2,_3,_4,_5,_6){
document.cookie=_1+"="+escape(_2)+((_3)?"; expires="+_3.toGMTString():"")+((_4)?"; path="+_4:"")+((_5)?"; domain="+_5:"")+((_6)?"; secure":"");
}
function getCookie(_7){
var dc=document.cookie;
var _9=_7+"=";
var _a=dc.indexOf("; "+_9);
if(_a==-1){
_a=dc.indexOf(_9);
if(_a!=0){
return null;
}
}else{
_a+=2;
}
var _b=document.cookie.indexOf(";",_a);
if(_b==-1){
_b=dc.length;
}
return unescape(dc.substring(_a+_9.length,_b));
}
function deleteCookie(_c,_d,_e){
if(getCookie(_c)){
document.cookie=_c+"="+((_d)?"; path="+_d:"")+((_e)?"; domain="+_e:"")+"; expires=Thu, 01-Jan-70 00:00:01 GMT";
}
}
function newWindowFixed(_f,_10,w,h){
return window.open(_f,_10,"toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no,width="+w+",height="+h+",left="+((window.screen.availWidth-(w+4))/2)+",top="+((window.screen.availHeight-(h+50))/2));
}
function getOffset(obj,_14){
var _15=0;
while(obj!=null){
_15+=obj["offset"+(_14?"Left":"Top")];
obj=obj.offsetParent;
}
return _15;
}
function getPageSize(){
var _16,yScroll;
if(window.innerHeight&&window.scrollMaxY){
_16=document.body.scrollWidth;
yScroll=window.innerHeight+window.scrollMaxY;
}else{
if(document.body.scrollHeight>document.body.offsetHeight){
_16=document.body.scrollWidth;
yScroll=document.body.scrollHeight;
}else{
_16=document.body.offsetWidth;
yScroll=document.body.offsetHeight;
}
}
this.xS=_16;
this.yS=yScroll;
var _17,windowHeight;
if(self.innerHeight){
_17=self.innerWidth;
windowHeight=self.innerHeight;
}else{
if(document.documentElement&&document.documentElement.clientHeight){
_17=document.documentElement.clientWidth;
windowHeight=document.documentElement.clientHeight;
}else{
if(document.body){
_17=document.body.clientWidth;
windowHeight=document.body.clientHeight;
}
}
}
this.wW=_17;
this.wH=windowHeight;
if(yScroll<windowHeight){
pageHeight=windowHeight;
}else{
pageHeight=yScroll;
}
if(_16<_17){
pageWidth=_17;
}else{
pageWidth=_16;
}
var _18=new Array(pageWidth,pageHeight,_17,windowHeight);
return _18;
}
function parseUri(_19){
var _1a=["source","protocol","authority","domain","port","path","directoryPath","fileName","query","anchor"];
var _1b=new RegExp("^(?:([^:/?#.]+):)?(?://)?(([^:/?#]*)(?::(\\d*))?)?((/(?:[^?#](?![^?#/]*\\.[^?#/.]+(?:[\\?#]|$)))*/?)?([^?#/]*))?(?:\\?([^#]*))?(?:#(.*))?").exec(_19);
var uri={};
for(var i=0;i<10;i++){
uri[_1a[i]]=(_1b[i]?_1b[i]:"");
}
if(uri.directoryPath.length>0){
uri.directoryPath=uri.directoryPath.replace(/\/?$/,"/");
}
return uri;
}
window.dhtmlHistory={initialize:function(){
if(this.isInternetExplorer()==false){
return;
}
if(historyStorage.hasKey("DhtmlHistory_pageLoaded")==false){
this.fireOnNewListener=false;
this.firstLoad=true;
historyStorage.put("DhtmlHistory_pageLoaded",true);
}else{
this.fireOnNewListener=true;
this.firstLoad=false;
}
},addListener:function(_1e){
this.listener=_1e;
if(this.fireOnNewListener==true){
this.fireHistoryEvent(this.currentLocation);
this.fireOnNewListener=false;
}
},add:function(_1f,_20){
var _21=this;
var _22=function(){
if(_21.currentWaitTime>0){
_21.currentWaitTime=_21.currentWaitTime-_21.WAIT_TIME;
}
_1f=_21.removeHash(_1f);
var _23=document.getElementById(_1f);
if(_23!=undefined||_23!=null){
var _24="Exception: History locations can not have "+"the same value as _any_ id's "+"that might be in the document, "+"due to a bug in Internet "+"Explorer; please ask the "+"developer to choose a history "+"location that does not match "+"any HTML id's in this "+"document. The following ID "+"is already taken and can not "+"be a location: "+_1f;
throw _24;
}
historyStorage.put(_1f,_20);
_21.ignoreLocationChange=true;
this.ieAtomicLocationChange=true;
_21.currentLocation=_1f;
window.location.hash=_1f;
if(_21.isInternetExplorer()){
_21.iframe.src="/blank.html?"+_1f;
}
this.ieAtomicLocationChange=false;
};
window.setTimeout(_22,this.currentWaitTime);
this.currentWaitTime=this.currentWaitTime+this.WAIT_TIME;
},isFirstLoad:function(){
if(this.firstLoad==true){
return true;
}else{
return false;
}
},isInternational:function(){
return false;
},getVersion:function(){
return "0.03";
},getCurrentLocation:function(){
var _25=this.removeHash(window.location.hash);
return _25;
},currentLocation:null,listener:null,iframe:null,ignoreLocationChange:null,WAIT_TIME:200,currentWaitTime:0,fireOnNewListener:null,firstLoad:null,ieAtomicLocationChange:null,create:function(){
var _26=this.getCurrentLocation();
this.currentLocation=_26;
if(this.isInternetExplorer()){
document.write("<iframe style='border: 0px; width: 1px; "+"height: 1px; position: absolute; bottom: 0px; "+"right: 0px; visibility: visible;' "+"name='DhtmlHistoryFrame' id='DhtmlHistoryFrame' "+"src='/blank.html?"+_26+"'>"+"</iframe>");
this.WAIT_TIME=400;
}
var _27=this;
window.onunload=function(){
_27.firstLoad=null;
};
if(this.isInternetExplorer()==false){
if(historyStorage.hasKey("DhtmlHistory_pageLoaded")==false){
this.ignoreLocationChange=true;
this.firstLoad=true;
historyStorage.put("DhtmlHistory_pageLoaded",true);
}else{
this.ignoreLocationChange=false;
this.fireOnNewListener=true;
}
}else{
this.ignoreLocationChange=true;
}
if(this.isInternetExplorer()){
this.iframe=document.getElementById("DhtmlHistoryFrame");
}
var _27=this;
var _28=function(){
_27.checkLocation();
};
setInterval(_28,100);
},fireHistoryEvent:function(_29){
var _2a=historyStorage.get(_29);
if(typeof (this.listener)=="function"){
this.listener(_29,_2a);
}
},checkLocation:function(){
if(this.isInternetExplorer()==false&&this.ignoreLocationChange==true){
this.ignoreLocationChange=false;
return;
}
if(this.isInternetExplorer()==false&&this.ieAtomicLocationChange==true){
return;
}
var _2b=this.getCurrentLocation();
if(_2b==this.currentLocation){
return;
}
this.ieAtomicLocationChange=true;
if(this.isInternetExplorer()&&this.getIFrameHash()!=_2b){
this.iframe.src="/blank.html?"+_2b;
}else{
if(this.isInternetExplorer()){
return;
}
}
this.currentLocation=_2b;
this.ieAtomicLocationChange=false;
this.fireHistoryEvent(_2b);
},getIFrameHash:function(){
var _2c=document.getElementById("DhtmlHistoryFrame");
var doc=_2c.contentWindow.document;
var _2e=new String(doc.location.search);
if(_2e.length==1&&_2e.charAt(0)=="?"){
_2e="";
}else{
if(_2e.length>=2&&_2e.charAt(0)=="?"){
_2e=_2e.substring(1);
}
}
return _2e;
},removeHash:function(_2f){
if(_2f==null||_2f==undefined){
return null;
}else{
if(_2f==""){
return "";
}else{
if(_2f.length==1&&_2f.charAt(0)=="#"){
return "";
}else{
if(_2f.length>1&&_2f.charAt(0)=="#"){
return _2f.substring(1);
}else{
return _2f;
}
}
}
}
},iframeLoaded:function(_30){
if(this.ignoreLocationChange==true){
this.ignoreLocationChange=false;
return;
}
var _31=new String(_30.search);
if(_31.length==1&&_31.charAt(0)=="?"){
_31="";
}else{
if(_31.length>=2&&_31.charAt(0)=="?"){
_31=_31.substring(1);
}
}
if(this.pageLoadEvent!=true){
window.location.hash=_31;
}
this.fireHistoryEvent(_31);
},isInternetExplorer:function(){
var _32=navigator.userAgent.toLowerCase();
if(document.all&&_32.indexOf("msie")!=-1){
return true;
}else{
return false;
}
}};
window.historyStorage={debugging:false,storageHash:new Object(),hashLoaded:false,put:function(key,_34){
this.assertValidKey(key);
if(this.hasKey(key)){
this.remove(key);
}
this.storageHash[key]=_34;
this.saveHashTable();
},get:function(key){
this.assertValidKey(key);
this.loadHashTable();
var _36=this.storageHash[key];
if(_36==undefined){
return null;
}else{
return _36;
}
},remove:function(key){
this.assertValidKey(key);
this.loadHashTable();
delete this.storageHash[key];
this.saveHashTable();
},reset:function(){
this.storageField.value="";
this.storageHash=new Object();
},hasKey:function(key){
this.assertValidKey(key);
this.loadHashTable();
if(typeof this.storageHash[key]=="undefined"){
return false;
}else{
return true;
}
},isValidKey:function(key){
if(typeof key!="string"){
key=key.toString();
}
var _3a=/^[a-zA-Z0-9_ \!\@\#\$\%\^\&\*\(\)\+\=\:\;\,\.\/\?\|\\\~\{\}\[\]]*$/;
return _3a.test(key);
},storageField:null,init:function(){
var _3b="position: absolute; top: -1000px; left: -1000px;";
if(this.debugging==true){
_3b="width: 30em; height: 30em;";
}
var _3c="<form id='historyStorageForm' "+"method='GET' "+"style='"+_3b+"'>"+"<textarea id='historyStorageField' "+"style='"+_3b+"'"+"left: -1000px;' "+"name='historyStorageField'></textarea>"+"</form>";
document.write(_3c);
this.storageField=document.getElementById("historyStorageField");
},assertValidKey:function(key){
if(this.isValidKey(key)==false){
throw "Please provide a valid key for "+"window.historyStorage, key= "+key;
}
},loadHashTable:function(){
if(this.hashLoaded==false){
var _3e=this.storageField.value;
if(_3e!=""&&_3e!=null){
this.storageHash=eval("("+_3e+")");
}
this.hashLoaded=true;
}
},saveHashTable:function(){
this.loadHashTable();
var _3f=JSON.stringify(this.storageHash);
this.storageField.value=_3f;
}};
Array.prototype.______array="______array";
var JSON={org:"http://www.JSON.org",copyright:"(c)2005 JSON.org",license:"http://www.crockford.com/JSON/license.html",stringify:function(arg){
var c,i,l,s="",v;
switch(typeof arg){
case "object":
if(arg){
if(arg.______array=="______array"){
for(i=0;i<arg.length;++i){
v=this.stringify(arg[i]);
if(s){
s+=",";
}
s+=v;
}
return "["+s+"]";
}else{
if(typeof arg.toString!="undefined"){
for(i in arg){
v=arg[i];
if(typeof v!="undefined"&&typeof v!="function"){
v=this.stringify(v);
if(s){
s+=",";
}
s+=this.stringify(i)+":"+v;
}
}
return "{"+s+"}";
}
}
}
return "null";
case "number":
return isFinite(arg)?String(arg):"null";
case "string":
l=arg.length;
s="\"";
for(i=0;i<l;i+=1){
c=arg.charAt(i);
if(c>=" "){
if(c=="\\"||c=="\""){
s+="\\";
}
s+=c;
}else{
switch(c){
case "\b":
s+="\\b";
break;
case "\f":
s+="\\f";
break;
case "\n":
s+="\\n";
break;
case "\r":
s+="\\r";
break;
case "\t":
s+="\\t";
break;
default:
c=c.charCodeAt();
s+="\\u00"+Math.floor(c/16).toString(16)+(c%16).toString(16);
}
}
}
return s+"\"";
case "boolean":
return String(arg);
default:
return "null";
}
},parse:function(_42){
var at=0;
var ch=" ";
function error(m){
throw {name:"JSONError",message:m,at:at-1,text:_42};
}
function next(){
ch=_42.charAt(at);
at+=1;
return ch;
}
function white(){
while(ch!=""&&ch<=" "){
next();
}
}
function str(){
var i,s="",t,u;
if(ch=="\""){
outer:
while(next()){
if(ch=="\""){
next();
return s;
}else{
if(ch=="\\"){
switch(next()){
case "b":
s+="\b";
break;
case "f":
s+="\f";
break;
case "n":
s+="\n";
break;
case "r":
s+="\r";
break;
case "t":
s+="\t";
break;
case "u":
u=0;
for(i=0;i<4;i+=1){
t=parseInt(next(),16);
if(!isFinite(t)){
break outer;
}
u=u*16+t;
}
s+=String.fromCharCode(u);
break;
default:
s+=ch;
}
}else{
s+=ch;
}
}
}
}
error("Bad string");
}
function arr(){
var a=[];
if(ch=="["){
next();
white();
if(ch=="]"){
next();
return a;
}
while(ch){
a.push(val());
white();
if(ch=="]"){
next();
return a;
}else{
if(ch!=","){
break;
}
}
next();
white();
}
}
error("Bad array");
}
function obj(){
var k,o={};
if(ch=="{"){
next();
white();
if(ch=="}"){
next();
return o;
}
while(ch){
k=str();
white();
if(ch!=":"){
break;
}
next();
o[k]=val();
white();
if(ch=="}"){
next();
return o;
}else{
if(ch!=","){
break;
}
}
next();
white();
}
}
error("Bad object");
}
function num(){
var n="",v;
if(ch=="-"){
n="-";
next();
}
while(ch>="0"&&ch<="9"){
n+=ch;
next();
}
if(ch=="."){
n+=".";
while(next()&&ch>="0"&&ch<="9"){
n+=ch;
}
}
if(ch=="e"||ch=="E"){
n+="e";
next();
if(ch=="-"||ch=="+"){
n+=ch;
next();
}
while(ch>="0"&&ch<="9"){
n+=ch;
next();
}
}
v=+n;
if(!isFinite(v)){
error("Bad number");
}else{
return v;
}
}
function word(){
switch(ch){
case "t":
if(next()=="r"&&next()=="u"&&next()=="e"){
next();
return true;
}
break;
case "f":
if(next()=="a"&&next()=="l"&&next()=="s"&&next()=="e"){
next();
return false;
}
break;
case "n":
if(next()=="u"&&next()=="l"&&next()=="l"){
next();
return null;
}
break;
}
error("Syntax error");
}
function val(){
white();
switch(ch){
case "{":
return obj();
case "[":
return arr();
case "\"":
return str();
case "-":
return num();
default:
return ch>="0"&&ch<="9"?num():word();
}
}
return val();
}};
window.historyStorage.init();
window.dhtmlHistory.create();


var Drag={enable:true,obj:null,init:function(o,_2,_3,_4,_5,_6,_7,_8,_9,_a){
o.onmousedown=Drag.start;
o.hmode=_7?false:true;
o.vmode=_8?false:true;
o.root=_2&&_2!=null?_2:o;
if(o.hmode&&isNaN(parseInt(o.root.style.left))){
o.root.style.left="0px";
}
if(o.vmode&&isNaN(parseInt(o.root.style.top))){
o.root.style.top="0px";
}
if(!o.hmode&&isNaN(parseInt(o.root.style.right))){
o.root.style.right="0px";
}
if(!o.vmode&&isNaN(parseInt(o.root.style.bottom))){
o.root.style.bottom="0px";
}
o.minX=typeof _3!="undefined"?_3:null;
o.minY=typeof _5!="undefined"?_5:null;
o.maxX=typeof _4!="undefined"?_4:null;
o.maxY=typeof _6!="undefined"?_6:null;
o.xMapper=_9?_9:null;
o.yMapper=_a?_a:null;
o.root.onDragStart=new Function();
o.root.onDragEnd=new Function();
o.root.onDrag=new Function();
},start:function(e){
var o=Drag.obj=this;
e=Drag.fixE(e);
if(ie){
if(e.button!=1){
return;
}
}else{
if(e.button!=0){
return;
}
}
var y=parseInt(o.root.offsetTop);
var x=parseInt(o.root.offsetLeft);
o.root.onDragStart(e,x,y);
o.lastMouseX=e.clientX;
o.lastMouseY=e.clientY;
document.onmousemove=Drag.drag;
document.onmouseup=Drag.end;
return false;
},drag:function(e){
e=Drag.fixE(e);
var o=Drag.obj;
var ey=e.clientY;
var ex=e.clientX;
var y=parseInt(o.root.offsetTop);
var x=parseInt(o.root.offsetLeft);
var nx,ny;
nx=x+(ex-o.lastMouseX);
ny=y+(ey-o.lastMouseY);
Drag.obj.root.style.left=nx+"px";
Drag.obj.root.style.top=ny+"px";
Drag.obj.lastMouseX=ex;
Drag.obj.lastMouseY=ey;
Drag.obj.root.onDrag(e,nx,ny);
return false;
},end:function(){
document.onmousemove=null;
document.onmouseup=null;
Drag.obj.root.onDragEnd(parseInt(Drag.obj.root.style[Drag.obj.hmode?"left":"right"]),parseInt(Drag.obj.root.style[Drag.obj.vmode?"top":"bottom"]));
Drag.obj=null;
},fixE:function(evt){
var e=evt?evt:window.event;
return e;
}};
var Drag2={obj:null,init:function(o,_19,_1a,_1b,_1c,_1d,_1e,_1f,_20,_21){
o.onmousedown=Drag2.start;
o.hmode=_1e?false:true;
o.vmode=_1f?false:true;
o.root=_19&&_19!=null?_19:o;
if(o.hmode&&isNaN(parseInt(o.root.style.left))){
o.root.style.left="0px";
}
if(o.vmode&&isNaN(parseInt(o.root.style.top))){
o.root.style.top="0px";
}
if(!o.hmode&&isNaN(parseInt(o.root.style.right))){
o.root.style.right="0px";
}
if(!o.vmode&&isNaN(parseInt(o.root.style.bottom))){
o.root.style.bottom="0px";
}
o.minX=typeof _1a!="undefined"?_1a:null;
o.minY=typeof _1c!="undefined"?_1c:null;
o.maxX=typeof _1b!="undefined"?_1b:null;
o.maxY=typeof _1d!="undefined"?_1d:null;
o.xMapper=_20?_20:null;
o.yMapper=_21?_21:null;
o.root.onDragStart=new Function();
o.root.onDragEnd=new Function();
o.root.onDrag=new Function();
},start:function(e){
var o=Drag2.obj=this;
e=Drag2.fixE(e);
var y=parseInt(o.vmode?o.root.style.top:o.root.style.bottom);
var x=parseInt(o.hmode?o.root.style.left:o.root.style.right);
o.root.onDragStart(e,x,y);
o.lastMouseX=e.clientX;
o.lastMouseY=e.clientY;
if(o.hmode){
if(o.minX!=null){
o.minMouseX=e.clientX-x+o.minX;
}
if(o.maxX!=null){
o.maxMouseX=o.minMouseX+o.maxX-o.minX;
}
}else{
if(o.minX!=null){
o.maxMouseX=-o.minX+e.clientX+x;
}
if(o.maxX!=null){
o.minMouseX=-o.maxX+e.clientX+x;
}
}
if(o.vmode){
if(o.minY!=null){
o.minMouseY=e.clientY-y+o.minY;
}
if(o.maxY!=null){
o.maxMouseY=o.minMouseY+o.maxY-o.minY;
}
}else{
if(o.minY!=null){
o.maxMouseY=-o.minY+e.clientY+y;
}
if(o.maxY!=null){
o.minMouseY=-o.maxY+e.clientY+y;
}
}
document.onmousemove=Drag2.drag;
document.onmouseup=Drag2.end;
return false;
},drag:function(e){
e=Drag2.fixE(e);
var o=Drag2.obj;
var ey=e.clientY;
var ex=e.clientX;
var y=parseInt(o.vmode?o.root.style.top:o.root.style.bottom);
var x=parseInt(o.hmode?o.root.style.left:o.root.style.right);
var nx,ny;
if(o.minX!=null){
ex=o.hmode?Math.max(ex,o.minMouseX):Math.min(ex,o.maxMouseX);
}
if(o.maxX!=null){
ex=o.hmode?Math.min(ex,o.maxMouseX):Math.max(ex,o.minMouseX);
}
if(o.minY!=null){
ey=o.vmode?Math.max(ey,o.minMouseY):Math.min(ey,o.maxMouseY);
}
if(o.maxY!=null){
ey=o.vmode?Math.min(ey,o.maxMouseY):Math.max(ey,o.minMouseY);
}
nx=x+((ex-o.lastMouseX)*(o.hmode?1:-1));
ny=y+((ey-o.lastMouseY)*(o.vmode?1:-1));
if(o.xMapper){
nx=o.xMapper(y);
}else{
if(o.yMapper){
ny=o.yMapper(x);
}
}
Drag2.obj.root.style[o.hmode?"left":"right"]=nx+"px";
Drag2.obj.root.style[o.vmode?"top":"bottom"]=ny+"px";
Drag2.obj.lastMouseX=ex;
Drag2.obj.lastMouseY=ey;
Drag2.obj.root.onDrag(e,nx,ny);
return false;
},end:function(){
document.onmousemove=null;
document.onmouseup=null;
Drag2.obj.root.onDragEnd(parseInt(Drag2.obj.root.style[Drag2.obj.hmode?"left":"right"]),parseInt(Drag2.obj.root.style[Drag2.obj.vmode?"top":"bottom"]));
Drag2.obj=null;
},fixE:function(e){
if(typeof e=="undefined"){
e=window.event;
}
if(typeof e.layerX=="undefined"){
e.layerX=e.offsetX;
}
if(typeof e.layerY=="undefined"){
e.layerY=e.offsetY;
}
return e;
}};


function numConvert(b){
var _2=new Array("","K","M","B");
var _3=0;
var _4=b;
var _5=b+"";
if(!_5.indexOf("0")){
return b;
}
while(true){
if((_4/1000)>=1){
_4=_4/1000;
_3++;
}else{
break;
}
}
_4=_4+""+_2[_3];
return _4;
}
function NumberFormat(_6,_7){
this.VERSION="Number Format v1.5.4";
this.COMMA=",";
this.PERIOD=".";
this.DASH="-";
this.LEFT_PAREN="(";
this.RIGHT_PAREN=")";
this.LEFT_OUTSIDE=0;
this.LEFT_INSIDE=1;
this.RIGHT_INSIDE=2;
this.RIGHT_OUTSIDE=3;
this.LEFT_DASH=0;
this.RIGHT_DASH=1;
this.PARENTHESIS=2;
this.NO_ROUNDING=-1;
this.num;
this.numOriginal;
this.hasSeparators=false;
this.separatorValue;
this.inputDecimalValue;
this.decimalValue;
this.negativeFormat;
this.negativeRed;
this.hasCurrency;
this.currencyPosition;
this.currencyValue;
this.places;
this.roundToPlaces;
this.truncate;
this.setNumber=setNumberNF;
this.toUnformatted=toUnformattedNF;
this.setInputDecimal=setInputDecimalNF;
this.setSeparators=setSeparatorsNF;
this.setCommas=setCommasNF;
this.setNegativeFormat=setNegativeFormatNF;
this.setNegativeRed=setNegativeRedNF;
this.setCurrency=setCurrencyNF;
this.setCurrencyPrefix=setCurrencyPrefixNF;
this.setCurrencyValue=setCurrencyValueNF;
this.setCurrencyPosition=setCurrencyPositionNF;
this.setPlaces=setPlacesNF;
this.toFormatted=toFormattedNF;
this.toPercentage=toPercentageNF;
this.getOriginal=getOriginalNF;
this.moveDecimalRight=moveDecimalRightNF;
this.moveDecimalLeft=moveDecimalLeftNF;
this.getRounded=getRoundedNF;
this.preserveZeros=preserveZerosNF;
this.justNumber=justNumberNF;
this.expandExponential=expandExponentialNF;
this.getZeros=getZerosNF;
this.moveDecimalAsString=moveDecimalAsStringNF;
this.moveDecimal=moveDecimalNF;
this.addSeparators=addSeparatorsNF;
if(_7==null){
this.setNumber(_6,this.PERIOD);
}else{
this.setNumber(_6,_7);
}
this.setCommas(true);
this.setNegativeFormat(this.LEFT_DASH);
this.setNegativeRed(false);
this.setCurrency(false);
this.setCurrencyPrefix("$");
this.setPlaces(0);
}
function setInputDecimalNF(_8){
this.inputDecimalValue=_8;
}
function setNumberNF(_9,_a){
if(_a!=null){
this.setInputDecimal(_a);
}
this.numOriginal=_9;
this.num=this.justNumber(_9);
}
function toUnformattedNF(){
return (this.num);
}
function getOriginalNF(){
return (this.numOriginal);
}
function setNegativeFormatNF(_b){
this.negativeFormat=_b;
}
function setNegativeRedNF(_c){
this.negativeRed=_c;
}
function setSeparatorsNF(_d,_e,_f){
this.hasSeparators=_d;
if(_e==null){
_e=this.COMMA;
}
if(_f==null){
_f=this.PERIOD;
}
if(_e==_f){
this.decimalValue=(_f==this.PERIOD)?this.COMMA:this.PERIOD;
}else{
this.decimalValue=_f;
}
this.separatorValue=_e;
}
function setCommasNF(isC){
this.setSeparators(isC,this.COMMA,this.PERIOD);
}
function setCurrencyNF(isC){
this.hasCurrency=isC;
}
function setCurrencyValueNF(val){
this.currencyValue=val;
}
function setCurrencyPrefixNF(cp){
this.setCurrencyValue(cp);
this.setCurrencyPosition(this.LEFT_OUTSIDE);
}
function setCurrencyPositionNF(cp){
this.currencyPosition=cp;
}
function setPlacesNF(p,tr){
this.roundToPlaces=!(p==this.NO_ROUNDING);
this.truncate=(tr!=null&&tr);
this.places=(p<0)?0:p;
}
function addSeparatorsNF(_17,inD,_19,sep){
_17+="";
var _1b=_17.indexOf(inD);
var _1c="";
if(_1b!=-1){
_1c=_19+_17.substring(_1b+1,_17.length);
_17=_17.substring(0,_1b);
}
var rgx=/(\d+)(\d{3})/;
while(rgx.test(_17)){
_17=_17.replace(rgx,"$1"+sep+"$2");
}
return _17+_1c;
}
function toFormattedNF(){
var pos;
var _1f=this.num;
var _20;
var _21=new Array(2);
if(this.roundToPlaces){
_1f=this.getRounded(_1f);
_20=this.preserveZeros(Math.abs(_1f));
}else{
_20=this.expandExponential(Math.abs(_1f));
}
if(this.hasSeparators){
_20=this.addSeparators(_20,this.PERIOD,this.decimalValue,this.separatorValue);
}else{
_20=_20.replace(new RegExp("\\"+this.PERIOD),this.decimalValue);
}
var c0="";
var n0="";
var c1="";
var n1="";
var n2="";
var c2="";
var n3="";
var c3="";
var _2a=(this.negativeFormat==this.PARENTHESIS)?this.LEFT_PAREN:this.DASH;
var _2b=(this.negativeFormat==this.PARENTHESIS)?this.RIGHT_PAREN:this.DASH;
if(this.currencyPosition==this.LEFT_OUTSIDE){
if(_1f<0){
if(this.negativeFormat==this.LEFT_DASH||this.negativeFormat==this.PARENTHESIS){
n1=_2a;
}
if(this.negativeFormat==this.RIGHT_DASH||this.negativeFormat==this.PARENTHESIS){
n2=_2b;
}
}
if(this.hasCurrency){
c0=this.currencyValue;
}
}else{
if(this.currencyPosition==this.LEFT_INSIDE){
if(_1f<0){
if(this.negativeFormat==this.LEFT_DASH||this.negativeFormat==this.PARENTHESIS){
n0=_2a;
}
if(this.negativeFormat==this.RIGHT_DASH||this.negativeFormat==this.PARENTHESIS){
n3=_2b;
}
}
if(this.hasCurrency){
c1=this.currencyValue;
}
}else{
if(this.currencyPosition==this.RIGHT_INSIDE){
if(_1f<0){
if(this.negativeFormat==this.LEFT_DASH||this.negativeFormat==this.PARENTHESIS){
n0=_2a;
}
if(this.negativeFormat==this.RIGHT_DASH||this.negativeFormat==this.PARENTHESIS){
n3=_2b;
}
}
if(this.hasCurrency){
c2=this.currencyValue;
}
}else{
if(this.currencyPosition==this.RIGHT_OUTSIDE){
if(_1f<0){
if(this.negativeFormat==this.LEFT_DASH||this.negativeFormat==this.PARENTHESIS){
n1=_2a;
}
if(this.negativeFormat==this.RIGHT_DASH||this.negativeFormat==this.PARENTHESIS){
n2=_2b;
}
}
if(this.hasCurrency){
c3=this.currencyValue;
}
}
}
}
}
_20=c0+n0+c1+n1+_20+n2+c2+n3+c3;
if(this.negativeRed&&_1f<0){
_20="<font color=\"red\">"+_20+"</font>";
}
return (_20);
}
function toPercentageNF(){
nNum=this.num*100;
nNum=this.getRounded(nNum);
return nNum+"%";
}
function getZerosNF(_2c){
var _2d="";
var i;
for(i=0;i<_2c;i++){
_2d+="0";
}
return _2d;
}
function expandExponentialNF(_2f){
if(isNaN(_2f)){
return _2f;
}
var _30=parseFloat(_2f)+"";
var _31=_30.toLowerCase().indexOf("e");
if(_31!=-1){
var _32=_30.toLowerCase().indexOf("+");
var _33=_30.toLowerCase().indexOf("-",_31);
var _34=_30.substring(0,_31);
if(_33!=-1){
var _35=_30.substring(_33+1,_30.length);
_34=this.moveDecimalAsString(_34,true,parseInt(_35));
}else{
if(_32==-1){
_32=_31;
}
var _35=_30.substring(_32+1,_30.length);
_34=this.moveDecimalAsString(_34,false,parseInt(_35));
}
_30=_34;
}
return _30;
}
function moveDecimalRightNF(val,_37){
var _38="";
if(_37==null){
_38=this.moveDecimal(val,false);
}else{
_38=this.moveDecimal(val,false,_37);
}
return _38;
}
function moveDecimalLeftNF(val,_3a){
var _3b="";
if(_3a==null){
_3b=this.moveDecimal(val,true);
}else{
_3b=this.moveDecimal(val,true,_3a);
}
return _3b;
}
function moveDecimalAsStringNF(val,_3d,_3e){
var _3f=(arguments.length<3)?this.places:_3e;
if(_3f<=0){
return val;
}
var _40=val+"";
var _41=this.getZeros(_3f);
var re1=new RegExp("([0-9.]+)");
if(_3d){
_40=_40.replace(re1,_41+"$1");
var re2=new RegExp("(-?)([0-9]*)([0-9]{"+_3f+"})(\\.?)");
_40=_40.replace(re2,"$1$2.$3");
}else{
var _44=re1.exec(_40);
if(_44!=null){
_40=_40.substring(0,_44.index)+_44[1]+_41+_40.substring(_44.index+_44[0].length);
}
var re2=new RegExp("(-?)([0-9]*)(\\.?)([0-9]{"+_3f+"})");
_40=_40.replace(re2,"$1$2$4.");
}
_40=_40.replace(/\.$/,"");
return _40;
}
function moveDecimalNF(val,_46,_47){
var _48="";
if(_47==null){
_48=this.moveDecimalAsString(val,_46);
}else{
_48=this.moveDecimalAsString(val,_46,_47);
}
return parseFloat(_48);
}
function getRoundedNF(val){
val=this.moveDecimalRight(val);
if(this.truncate){
val=val>=0?Math.floor(val):Math.ceil(val);
}else{
val=Math.round(val);
}
val=this.moveDecimalLeft(val);
return val;
}
function preserveZerosNF(val){
var i;
val=this.expandExponential(val);
if(this.places<=0){
return val;
}
var _4c=val.indexOf(".");
if(_4c==-1){
val+=".";
for(i=0;i<this.places;i++){
val+="0";
}
}else{
var _4d=(val.length-1)-_4c;
var _4e=this.places-_4d;
for(i=0;i<_4e;i++){
val+="0";
}
}
return val;
}
function justNumberNF(val){
newVal=val+"";
var _50=false;
if(newVal.indexOf("%")!=-1){
newVal=newVal.replace(/\%/g,"");
_50=true;
}
var re=new RegExp("[^\\"+this.inputDecimalValue+"\\d\\-\\+\\(\\)eE]","g");
newVal=newVal.replace(re,"");
var _52=new RegExp("["+this.inputDecimalValue+"]","g");
var _53=_52.exec(newVal);
if(_53!=null){
var _54=newVal.substring(_53.index+_53[0].length);
newVal=newVal.substring(0,_53.index)+this.PERIOD+_54.replace(_52,"");
}
if(newVal.charAt(newVal.length-1)==this.DASH){
newVal=newVal.substring(0,newVal.length-1);
newVal="-"+newVal;
}else{
if(newVal.charAt(0)==this.LEFT_PAREN&&newVal.charAt(newVal.length-1)==this.RIGHT_PAREN){
newVal=newVal.substring(1,newVal.length-1);
newVal="-"+newVal;
}
}
newVal=parseFloat(newVal);
if(!isFinite(newVal)){
newVal=0;
}
if(_50){
newVal=this.moveDecimalLeft(newVal,2);
}
return newVal;
}
function Slider(_55,p){
if(_55!=null&&typeof (_55)=="object"&&_55.tagName.toLowerCase()=="div"){
this.container=_55;
}
if(p!=null){
this.p=p;
}
this.p.height=this.p.height-2;
}
Slider.prototype.__getOffset=function(obj,_58){
var _59=0;
while(obj!=null){
_59+=obj["offset"+(_58?"Left":"Top")];
obj=obj.offsetParent;
}
return _59;
};
Slider.prototype.__getEvt=function(evt){
var e=evt?evt:window.event;
var src=((ie)?e.srcElement:e.target);
return [e,src];
};
Slider.prototype.initSlider=function(){
if(this.container==null||this.p==null){
return false;
}
if(this.p.min_val==null||this.p.max_val==null||this.p.width==null){
return false;
}
if(this.p.min_val>=this.p.max_val){
return false;
}
this.marginX=10;
if(this.p.marginX!=null&&!isNaN(this.p.marginX)){
this.marginX=this.p.marginX;
}
if(isNaN(this.p.factor)){
this.p.factor=1;
}
if(this.p.rounding==null){
this.p.rounding=true;
}
if(this.p.interval==null){
this.p.interval=1;
}
this.p.margin=parseInt(this.p.max_val)-parseInt(this.p.min_val);
this.p.marginx=Math.ceil((this.p.margin)/this.p.interval);
this.p.val_per_px=Math.ceil(this.p.margin/this.p.width);
if(this.p.num_of_grid==null||this.p.num_of_grid>=this.p.margin){
if(this.p.width>=(this.p.marginx)){
if(this.p.interval>this.p.margin){
this.p.interval=this.p.margin;
}
this.p.num_of_grid=Math.ceil(this.p.margin/this.p.interval);
this.p.grid_val=this.p.interval;
}else{
this.p.num_of_grid=this.p.width;
this.p.grid_val=Math.ceil((this.p.margin/this.p.width));
}
}else{
this.p.num_of_grid=this.p.num_of_grid;
this.p.grid_val=Math.ceil(this.p.margin/this.p.num_of_grid);
}
this.p.grid_width_val=this.p.width/this.p.num_of_grid;
this.p.grid_width=Math.ceil(this.p.grid_width_val);
if((this.p.grid_width*this.p.num_of_grid)>this.p.width){
this.p.num_of_grid=this.p.width;
this.p.grid_val=Math.ceil((this.p.margin/this.p.width))*((this.p.margin+1)/this.p.num_of_grid);
this.p.grid_width_val=this.p.width/this.p.num_of_grid;
this.p.grid_width=Math.ceil(this.p.grid_width_val);
}
this.div=document.createElement("div");
this.div.style.position="absolute";
this.div.style.width=this.p.width+"px";
this.div.style.zIndex="20000";
if(this.p.height==null){
this.p.height=16;
}
this.div.style.height=this.p.height+"px";
if(this.p.init_val1==null){
this.p.init_val1=this.p.min_val*this.p.factor;
this.val1=this.p.init_val1;
}else{
if(this.p.init_val1<this.p.min_val||this.p.init_val1>this.p.max_val){
this.p.init_val1=this.p.min_val*this.p.factor;
this.val1=this.p.init_val1;
}else{
this.p.init_val1=this.p.init_val1*this.p.factor;
this.val1=this.p.init_val1;
}
}
if(this.p.init_val2==null){
this.p.init_val2=this.p.max_val*this.p.factor;
this.val2=this.p.init_val2;
}else{
if(this.p.init_val2<this.p.min_val||this.p.init_val2>this.p.max_val){
this.p.init_val2=this.p.max_val*this.p.factor;
this.val2=this.p.init_val2;
}else{
this.p.init_val2=this.p.init_val2*this.p.factor;
this.val2=this.p.init_val2;
}
}
this.tricker=document.createElement("span");
this.tricker.style.width="100%";
this.tricker.style.align="center";
this.tricker.className="dragtricker2";
document.body.appendChild(this.div);
this.div.appendChild(this.tricker);
this.tricker.innerHTML="<table width='100%'><tr><td style='color:#654A00' class='generalDesc' align='right'>"+this.getDisplayValue1(this.val1)+"&nbsp;to&nbsp;"+this.getDisplayValue2(this.val2)+"</td></tr></table>";
this.div.style.left=this.__getOffset(this.container,true)+"px";
this.div.style.top=this.__getOffset(this.container,false)+"px";
this.grid_tbl=document.createElement("table");
this.div.appendChild(this.grid_tbl);
this.grid_tbl.style.border="0";
this.grid_tbl.style.borderLeft="1px #999999 solid";
this.grid_tbl.cellPadding=0;
this.grid_tbl.cellSpacing=0;
this.grid_tbl.style.width=(this.p.num_of_grid*this.p.grid_width)+"px";
this.grid_tbl.style.height=(this.p.height)+"px";
this.grid_tbody=document.createElement("tbody");
this.grid_tbl.appendChild(this.grid_tbody);
this.grid_tbl.border="2";
this.grid_tr=document.createElement("tr");
this.grid_tbody.appendChild(this.grid_tr);
for(var i=0;i<1;i++){
var gtd=document.createElement("td");
this.grid_tr.appendChild(gtd);
gtd.vAlign="bottom";
gtd.innerHTML="&nbsp;";
gtd.style.fontSize="1px";
gtd.style.borderLeft="0px #999999 solid";
}
this.dragger_icon=null;
var src=sBasePath+"images/slider/pointer1.gif";
if(this.p.icon!=null){
src=this.p.icon;
}
this.dragger_icon=new Image(10,10);
this.dragger_icon.src=src;
this.dragger1=document.createElement("div");
this.dragger1.style.zIndex="20000";
this.dragger1.code=1;
document.body.appendChild(this.dragger1);
this.dragger1.style.position="absolute";
this.dragger1.style.height=(this.p.height+10+1)+"px";
this.dragger1.style.width="10px";
var htm="<table width=\"100%\" height=\""+(this.p.height+10+1)+"\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td valign=\"bottom\"><img src=\""+sBasePath+"images/slider_pointer.gif\"></td></tr></table>";
this.dragger1.innerHTML=htm;
var l=this.__getOffset(this.div,true)-5;
var l2=this.__getOffset(this.div,true)+this.div.offsetWidth-5;
var t=this.__getOffset(this.div,false);
this.dragger1.style.left=l+"px";
if(ie){
this.dragger1.style.top=(t-2)+"px";
}else{
this.dragger1.style.top=(t+3)+"px";
}
this.dragger1.style.cursor="pointer";
this.drag1=Drag2;
this.drag1.init(this.dragger1,null,l,l2-2,t,t);
this.dragger1.onDragStart=this.onDragStartEvt.bind(this);
this.dragger1.onDrag=this.onDragEvt.bind(this);
this.dragger1.onDragEnd=this.onDragEndEvt.bind(this);
var htm="<table width=\"100%\" height=\""+(this.p.height+10+1)+"\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td valign=\"bottom\"><img src=\""+sBasePath+"images/slider_pointer.gif\"></td></tr></table>";
this.dragger2=document.createElement("div");
this.dragger2.style.zIndex="20000";
this.dragger2.code=2;
document.body.appendChild(this.dragger2);
this.dragger2.style.position="absolute";
this.dragger2.style.height=(this.p.height+10+1)+"px";
this.dragger2.style.width="10px";
this.dragger2.innerHTML=htm;
this.dragger2.style.left=l2+"px";
if(ie){
this.dragger2.style.top=(t-2)+"px";
}else{
this.dragger2.style.top=(t+3)+"px";
}
this.dragger2.style.cursor="pointer";
this.drag2=Drag2;
this.drag2.init(this.dragger2,null,l+2,l2,t,t);
this.dragger2.onDragStart=this.onDragStartEvt.bind(this);
this.dragger2.onDrag=this.onDragEvt.bind(this);
this.dragger2.onDragEnd=this.onDragEndEvt.bind(this);
this.dragger1_tricker=document.createElement("div");
this.dragger1_tricker.style.zIndex="20000";
this.dragger1_tricker.style.display="none";
this.dragger1_tricker.style.backgroundColor="#ffffff";
if(ie){
this.dragger1_tricker.style.border="1px #000000 solid";
}
this.dragger1_tricker.className="dragtricker";
this.div.appendChild(this.dragger1_tricker);
this.dragger2_tricker=document.createElement("div");
this.dragger2_tricker.style.zIndex="20000";
this.dragger2_tricker.style.backgroundColor="#ffffff";
this.dragger2_tricker.style.display="none";
if(ie){
this.dragger2_tricker.style.border="1px #000000 solid";
}
this.dragger2_tricker.className="dragtricker";
this.div.appendChild(this.dragger2_tricker);
this.dragger1_tricker.style.position="absolute";
this.dragger2_tricker.style.position="absolute";
this.setDisplayValue2(this.p.init_val2);
this.setDisplayValue1(this.p.init_val1);
this.margin_shad=document.createElement("div");
this.margin_shad.style.zIndex="19999";
document.body.appendChild(this.margin_shad);
this.margin_shad.style.position="absolute";
if(ie){
this.margin_shad.style.top=(t+this.tricker.offsetHeight)+"px";
}else{
this.margin_shad.style.top=(t+20)+"px";
}
var w=l2-l;
this.margin_shad.style.width=w+"px";
this.margin_shad.style.backgroundColor="#FFDB63";
this.margin_shad.style.height=(this.p.height-2)+"px";
this.margin_shad.style.left=(l+5)+"px";
this.margin_shad.style.overflow="hidden";
this.margin_shad.className="mshad";
if(this.p.margin_shad==null||false==this.p.margin_shad){
this.margin_shad.style.display="none";
}
this.setVal1(this.val1/this.p.factor);
this.setVal2(this.val2/this.p.factor);
this.dragger2_tricker.style.left=(this.div.offsetWidth-this.dragger2_tricker.offsetWidth)+"px";
this.dragger2_tricker.style.top=this.dragger2.offsetHeight+"px";
this.dragger1_tricker.style.top=this.dragger1.offsetHeight+"px";
};
Slider.prototype.getDisplayValue1=function(val){
if(this.p.rounding){
return numConvert(val);
}else{
return new NumberFormat(val).toFormatted();
}
};
Slider.prototype.setDisplayValue1=function(val){
if(this.p.rounding){
this.dragger1_tricker.innerHTML=numConvert(val);
}else{
this.dragger1_tricker.innerHTML=new NumberFormat(val).toFormatted();
}
};
Slider.prototype.getDisplayValue2=function(val){
var _68="";
if((val/this.p.factor)==this.p.max_val){
_68="+";
}
if(this.p.rounding){
return numConvert(val)+_68;
}else{
return (new NumberFormat(val).toFormatted())+_68;
}
};
Slider.prototype.setDisplayValue2=function(val){
var _6a="";
if((val/this.p.factor)==this.p.max_val){
_6a="+";
}
if(this.p.rounding){
this.dragger2_tricker.innerHTML=numConvert(val)+_6a;
}else{
this.dragger2_tricker.innerHTML=(new NumberFormat(val).toFormatted())+_6a;
}
};
Slider.prototype.setGridValue=function(_6b){
for(var i=0;i<this.grid_tr.childNodes.length;i++){
if(_6b[i]!=null&&!isNaN(parseInt(_6b[i]))){
this.grid_tr.childNodes[i].childNodes[0].style.visibility="visible";
var val=parseInt(this.grid_tbl.offsetHeight)*(_6b[i]/100);
if(val==0){
val=1;
}
this.grid_tr.childNodes[i].childNodes[0].style.height=val+"px";
}else{
this.grid_tr.childNodes[i].childNodes[0].style.visibility="hidden";
}
}
};
Slider.prototype.onDragStartEvt=function(e,x,y){
evt=this.__getEvt(e);
obj=evt[1];
while(obj!=null){
if(obj.tagName=="DIV"&&obj.code!=null){
break;
}
obj=obj.offsetParent;
}
this.current_obj=obj;
switch(this.current_obj.code){
case 1:
case "1":
this.dragger1.style.zIndex="100000";
this.dragger2.style.zIndex="90000";
break;
case 2:
case "2":
this.dragger2.style.zIndex="100000";
this.dragger1.style.zIndex="90000";
break;
}
};
Slider.prototype.onDragEvt=function(e,x,y){
var t=this.__getOffset(this.div,false);
var cl=this.__getOffset(this.current_obj,true);
var l1=this.__getOffset(this.div,true)-5;
var l2=this.__getOffset(this.div,true)+this.div.offsetWidth-5;
var m=((cl+4)-this.__getOffset(this.div,true));
var v=(((cl+4)-this.__getOffset(this.div,true))/this.div.offsetWidth)*100;
v=Math.ceil(Math.ceil(v)/100*this.p.num_of_grid);
v=(v*this.p.grid_val)+this.p.min_val;
if(v>this.p.max_val){
v=this.p.max_val;
}
if(v<this.p.min_val){
v=this.p.min_val;
}
switch(this.current_obj.code){
case 1:
case "1":
this.val1=Math.ceil(v);
if(this.p.factor!=null){
this.val1=this.val1*this.p.factor;
}
if(this.margin_shad.style.display!="none"){
cl2=this.__getOffset(this.dragger2,true);
var w=cl2-cl;
this.margin_shad.style.width=w+"px";
this.margin_shad.style.left=(cl+5)+"px";
}
break;
case 2:
case "2":
this.val2=Math.ceil(v);
if(this.p.factor!=null){
this.val2=this.val2*this.p.factor;
}
if(this.margin_shad.style.display!="none"){
cl2=this.__getOffset(this.dragger1,true);
var w=cl-cl2;
this.margin_shad.style.width=w+"px";
this.margin_shad.style.left=(cl2+5)+"px";
}
break;
}
if(this.p.drag_func!=null&&typeof (this.p.drag_func)=="function"){
this.p.drag_func(this);
}else{
this.tricker.innerHTML="<table width='100%'><tr><td style='color:#654A00' class='generalDesc' align='right'>"+this.getDisplayValue1(this.val1)+"&nbsp;to&nbsp;"+this.getDisplayValue2(this.val2)+"</td></tr></table>";
this.dragger2_tricker.style.left=(this.div.offsetWidth-this.dragger2_tricker.offsetWidth)+"px";
}
if(ie){
this.dragger2.style.top=(t+this.tricker.offsetHeight-6)+"px";
this.dragger1.style.top=(t+this.tricker.offsetHeight-6)+"px";
}else{
this.dragger2.style.top=(t+20-6)+"px";
this.dragger1.style.top=(t+20-6)+"px";
}
return;
};
Slider.prototype.onDragEndEvt=function(x,y){
if(this.current_obj!=null){
switch(this.current_obj.code){
case 1:
case "1":
this.dragger2.minX=this.__getOffset(this.dragger1,true)+this.marginX;
break;
case 2:
case "2":
this.dragger1.maxX=this.__getOffset(this.dragger2,true)-this.marginX;
break;
}
this.current_obj=null;
}
if(this.p.drag_end_func!=null&&typeof (this.p.drag_end_func)=="function"){
this.p.drag_end_func(this);
}
};
Slider.prototype.setVal1=function(val){
if(val<this.min_val||val>this.max_val||val*this.p.factor>this.val2){
return false;
}
this.val1=Math.ceil(val);
if(this.p.factor!=null){
this.val1=this.val1*this.p.factor;
}
this.setDisplayValue1(this.val1);
var d_l=this.__getOffset(this.div,true)-5;
var p=(val-this.p.min_val)/(this.p.max_val-this.p.min_val);
var pos=this.div.offsetWidth*p+d_l;
this.dragger1.style.left=pos+"px";
var cl=this.__getOffset(this.dragger1,true);
if(this.margin_shad.style.display!="none"){
cl2=this.__getOffset(this.dragger2,true);
var w=cl2-cl;
this.margin_shad.style.width=w+"px";
this.margin_shad.style.left=(cl+5)+"px";
}
this.dragger2.minX=this.__getOffset(this.dragger1,true)+2;
};
Slider.prototype.setVal2=function(val){
if(val<this.min_val||val>this.max_val||val*this.p.factor<this.val1){
return false;
}
this.val2=Math.ceil(val);
if(this.p.factor!=null){
this.val2=this.val2*this.p.factor;
}
this.setDisplayValue2(this.val2);
var d_l=this.__getOffset(this.div,true)-5;
var p=(val-this.p.min_val)/(this.p.max_val-this.p.min_val);
var pos=this.div.offsetWidth*p+d_l;
this.dragger2.style.left=pos+"px";
var cl=this.__getOffset(this.dragger2,true);
if(this.margin_shad.style.display!="none"){
cl2=this.__getOffset(this.dragger1,true);
var w=cl-cl2;
this.margin_shad.style.width=w+"px";
this.margin_shad.style.left=(cl2+5)+"px";
}
this.dragger1.maxX=this.__getOffset(this.dragger2,true)-this.marginX;
};
Slider.prototype.relocateElement=function(p,pl,pt){
var _8c=this.__getOffset(this.container,true);
var _8d=this.__getOffset(this.container,false);
if(pl!=null){
_8c=_8c-pl;
}
if(pt!=null){
_8d=_8d-pt;
}
if(p!=null&&p.left!=null){
_8c=_8c+parseInt(p.left);
}
this.div.style.left=_8c+"px";
this.div.style.top=_8d+"px";
var t=this.__getOffset(this.div,false);
var d_l=this.__getOffset(this.div,true)-5;
var p=((this.val1/this.p.factor)-this.p.min_val)/(this.p.max_val-this.p.min_val);
var pos=this.div.offsetWidth*p+d_l;
this.dragger1.style.left=pos+"px";
if(ie){
this.dragger1.style.top=(t+this.tricker.offsetHeight-6)+"px";
}else{
this.dragger1.style.top=(t+20-6)+"px";
}
var p=((this.val2/this.p.factor)-this.p.min_val)/(this.p.max_val-this.p.min_val);
var pos=this.div.offsetWidth*p+d_l;
this.dragger2.style.left=pos+"px";
if(ie){
this.dragger2.style.top=(t+this.tricker.offsetHeight-6)+"px";
}else{
this.dragger2.style.top=(t+20-6)+"px";
}
var cl=this.__getOffset(this.dragger2,true);
if(this.margin_shad.style.display!="none"){
cl2=this.__getOffset(this.dragger1,true);
var w=cl-cl2;
this.margin_shad.style.width=w+"px";
this.margin_shad.style.left=(cl2+5)+"px";
if(ie){
this.margin_shad.style.top=(t+this.tricker.offsetHeight)+"px";
}else{
this.margin_shad.style.top=(t+20)+"px";
}
}
this.dragger1.minX=this.__getOffset(this.div,true)-5;
this.dragger1.maxX=this.__getOffset(this.dragger2,true)-this.marginX;
this.dragger2.minX=this.__getOffset(this.dragger1,true)+this.marginX;
this.dragger2.maxX=this.__getOffset(this.div,true)+this.div.offsetWidth-5;
};
Slider.prototype.setDisplay=function(_93){
if(this.div==null){
return false;
}
if(_93){
this.div.style.display="";
if(this.dragger1!=null){
this.dragger1.style.display="";
}
if(this.dragger2!=null){
this.dragger2.style.display="";
}
if(this.margin_shad!=null){
this.margin_shad.style.display="";
}
}else{
this.div.style.display="none";
if(this.dragger1!=null){
this.dragger1.style.display="none";
}
if(this.dragger2!=null){
this.dragger2.style.display="none";
}
if(this.margin_shad!=null){
this.margin_shad.style.display="none";
}
}
};
Slider.prototype.setWidth=function(w){
this.p.width=parseInt(w);
this.div.style.width=this.p.width+"px";
this.p.val_per_px=Math.ceil(this.p.margin/this.p.width);
if(this.p.num_of_grid==null||this.p.num_of_grid>=this.p.margin){
if(this.p.width>=(this.p.marginx)){
if(this.p.interval>this.p.margin){
this.p.interval=this.p.margin;
}
this.p.num_of_grid=Math.ceil(this.p.margin/this.p.interval);
this.p.grid_val=this.p.interval;
}else{
this.p.num_of_grid=this.p.width;
this.p.grid_val=Math.ceil((this.p.margin/this.p.width));
}
}else{
this.p.num_of_grid=this.p.num_of_grid;
this.p.grid_val=Math.ceil(this.p.margin/this.p.num_of_grid);
}
this.p.grid_width_val=this.p.width/this.p.num_of_grid;
this.p.grid_width=Math.ceil(this.p.grid_width_val);
if((this.p.grid_width*this.p.num_of_grid)>this.p.width){
this.p.num_of_grid=this.p.width;
this.p.grid_val=Math.ceil((this.p.margin/this.p.width))*((this.p.margin+1)/this.p.num_of_grid);
this.p.grid_width_val=this.p.width/this.p.num_of_grid;
this.p.grid_width=Math.ceil(this.p.grid_width_val);
}
this.grid_tbl.style.width=(this.p.num_of_grid*this.p.grid_width)+"px";
while(this.grid_tr.childNodes.length>0){
this.grid_tr.removeChild(this.grid_tr.childNodes[0]);
}
for(var i=0;i<1;i++){
var gtd=document.createElement("td");
this.grid_tr.appendChild(gtd);
gtd.style.width="5%";
gtd.vAlign="bottom";
gtd.innerHTML="&nbsp;";
gtd.style.fontSize="1px";
gtd.style.borderLeft="1px #999999 solid";
}
this.div.style.width=this.p.width+"px";
};
Slider.prototype.setzIndex=function(val){
this.div.style.zIndex=val;
this.dragger1.style.zIndex=val;
this.dragger2.style.zIndex=val;
this.margin_shad.style.zIndex=(val-1);
};


var ToolbarController = Class.create();
ToolbarController.prototype = {
	initialize : function(container)
	{
		this.container = container;
		this.container.innerHTML = "";
		this.items = [];
		this.location = parseUri(window.location.href);
	},
	getOffset : function(obj, bool)
	{
		var total=0;
		while(obj!=null)
		{
			total+=obj["offset"+(bool?"Left":"Top")];

			obj=obj.offsetParent;
		}
		return total;
	},
	addItem : function(item)
	{
			var tmp = new item(this);
			if
				(
					this.location.directoryPath.indexOf('living_in_hk/directory/') != "-1" ||
					this.location.directoryPath.indexOf('living_in_hk/featured_article/') != "-1" ||
					this.location.directoryPath.indexOf('living_in_hk/goods_and_services/') != "-1"
				)
			{
				if (tmp.id == 'homes_and_living')
				{
					var img = sBasePath+"images/home/menu_living_on.gif";
					tmp.default_img = img;
					tmp.mouseout_img = img;
				}
			}
			else if (tmp.id == 'contact_us' && this.location.directoryPath.indexOf('company/') != "-1")
			{
				var img = sBasePath+"images/home/menu_about_on.gif";
				tmp.default_img = img;
				tmp.mouseout_img = img;
			}
			else
			{
				if(this.location.directoryPath.indexOf(tmp.id) != "-1")
				{
					tmp.default_img = tmp.on_img;
					tmp.mouseout_img = tmp.on_img;
				}
			}

			tmp.img = document.createElement("IMG");
			tmp.img.src = tmp.default_img;
			if (tmp.img_width)
			{
				tmp.img.width = tmp.img_width;
				tmp.img.height = 30;
			}
			tmp.img.className = "toobar_item";
			//Event.observe(tmp.img, "click", tmp.onClickListener.bindAsEventListener(tmp));
			tmp.img.onclick = tmp.onClickListener.bindAsEventListener(tmp);
			//Event.observe(tmp.img, "mouseover", tmp.onMouseoverListener.bindAsEventListener(tmp));
			tmp.img.onmouseover = tmp.onMouseoverListener.bindAsEventListener(tmp);
			//Event.observe(tmp.img, "mouseout", tmp.onMouseoutListener.bindAsEventListener(tmp));
			tmp.img.onmouseout = tmp.onMouseoutListener.bindAsEventListener(tmp);
			if(tmp.img_title != null)
				tmp.img.title = tmp.img_title;
			//Event.observe(tmp.img, "dblclick", tmp.onDblClickListener.bindAsEventListener(tmp));
			this.container.appendChild(tmp.img);
			
			// if (tmp instanceof MyPageToolbarItem)
			// {
				// // var toolbar_width = this.container.offsetWidth;
				// // var total_img_width = 0;
				// // for (var i=0; i < this.items.length; i++) // "My Page" not included yet
				// // {
					// // total_img_width += this.items[i].img.width + 16;
				// // }
				// // var my_page_margin = toolbar_width - total_img_width - 72 - 8 - 16;
				// tmp.img.style.marginLeft = '35px';
			// }
			
			this.items.push(tmp);
			
			if(typeof(tmp.postInitialize) == "function")
			{
				tmp.postInitialize();
			}
		//}
	},
	checkItemCompletness : function(obj)
	{
		if(obj.id == null)
			return false;
		if(obj.name == null)
			return false;
		if(obj.default_img == null)
			return false;
		if(obj.on_img == null)
			return false;
		if(obj.off_img == null)
			return false;
		if(obj.mouseover_img == null)
			return false;
		if(obj.mouseout_img == null)
			return false;
		if(typeof(obj.getResource) != "function")
			return false;
		if(typeof(obj.onClickListener) != "function")
			return false;
		if(typeof(obj.onMouseoverListener) != "function")
			return false;
		if(typeof(obj.onMouseoutListener) != "function")
			return false;
		if(typeof(obj.onDblClickListener) != "function")
			return false;
		return true;
	},
	showSelect: function() {
		try{
		if(!is_ie || is_ie7)
			return;

		/*for(var i=0; i<this.items.length; i++)
		{
			if(	this.items[i].div != null && this.items[i].div.tagName == "DIV" && this.items[i].div.style.display != "none")
				return;
		}*/

		selects = document.getElementsByTagName("select");
		for (var i = 0; i < selects.length; i++) {
			if($(selects[i]).readAttribute("no_hide") != "true")
				selects[i].style.visibility = "visible";
		}
		}
		catch(e){}
	},
	hideSelect: function (){
		try{
		if(!is_ie || is_ie7)
			return;

		selects = document.getElementsByTagName("select");
		for (var i = 0; i < selects.length; i++) {
			if($(selects[i]).readAttribute("no_hide") != "true")
			{
				selects[i].style.visibility = "hidden";
			}
		}
		}
		catch(e){}
	},
	itemClickListner : function()
	{

	},
	closeOthers : function(obj)
	{
		for(var i=0; i<this.items.length; i++)
		{
			if(	this.items[i] != obj )
				this.items[i].close();
		}
	},
	searchItem : function(id)
	{
		for(var i=0; i<this.items.length; i++)
		{
			if(	this.items[i].id == id )
				return this.items[i];
		}
		return null;
	}
}

var DEFAULT_TOOLBAR_ITEM = [];

var PropertySearchToolbarItem = Class.create();
PropertySearchToolbarItem.prototype = {
	id : "property_search", //*
	name : "Property Search", //*
	img : null,
	default_img : sBasePath+"images/home/menu_property_off.gif", //*
	on_img : sBasePath+"images/home/menu_property_on.gif", //*
	off_img : sBasePath+"images/home/menu_property_off.gif", //*
	mouseover_img : sBasePath+"images/home/menu_property_over.gif", //*
	mouseout_img : sBasePath+"images/home/menu_property_off.gif", //*
	img_width: 144,
	img_title : "Click to start property search.",
	default_keyword : "",
	setHTML : function()
	{
		this.htm = "";
	},
	initialize : function(controller)
	{
		this.current_form_status = null;
		var mode = 2;
		this.div = document.createElement("DIV");
		if($("property_search_toolbar_html") != null)
		{
			this.div  = $("property_search_toolbar_html");
			mode = 1;
		}
		else
		{
			this.setHTML();
			this.div.innerHTML = this.htm;
		}

		this.controller = controller;

		this.first_load = true;
		if(mode == 1)
		{
			var opt = null;
			if(typeof(sDistrictList) != "undefined")
			{
				/*for(var i=0; i<sDistrictList.length; i++)
				{
					if(sDistrictList[i][0] == 0)
					{
						//htm += '          <option value="'+sDistrictList[i][0]+'_'+sDistrictList[i][1]+'" style="background-color:#DDDDDD">--'+unescape(sDistrictList[i][2])+' District--</option>';
						opt = document.createElement("OPTION");
						opt.innerHTML = '--'+unescape(sDistrictList[i][2])+' District--';
						opt.style.backgroundColor = "#DDDDDD";
						opt.value = sDistrictList[i][0]+'_'+sDistrictList[i][1];
						$("ps_location").appendChild(opt);

						opt = document.createElement("OPTION");
						opt.innerHTML = '--'+unescape(sDistrictList[i][2])+' District--';
						opt.style.backgroundColor = "#DDDDDD";
						opt.value = sDistrictList[i][0]+'_'+sDistrictList[i][1];
						$("ps_location2").appendChild(opt);
					}
					else
					{
						//htm += '          <option value="'+sDistrictList[i][0]+'" style="padding-left:10px;">'+unescape(sDistrictList[i][2])+'</option>';
						opt = document.createElement("OPTION");
						opt.innerHTML = unescape(sDistrictList[i][2]);
						opt.value = sDistrictList[i][0];
						$("ps_location").appendChild(opt);

						opt = document.createElement("OPTION");
						opt.innerHTML = unescape(sDistrictList[i][2]);
						opt.value = sDistrictList[i][0];
						$("ps_location2").appendChild(opt);
					}
					opt = null;
				}*/
			}
			opt = null;
		}

		this.initializeAction();
	},
	initializeAction : function ()
	{
		this.form = this.div.getElementsByTagName("FORM")[0];
	},
	locationListSelectListener : function(evt)
	{
		try{
			Event.element(evt).blur();
		}catch(e){}
	},
	locationListBlurListener : function(evt)
	{
		//Event.observe(this.div, "mouseover", this.menu_over_listener);
	},
	locationListFocusListener : function(evt)
	{
		//Event.stopObserving(document, "mousemove", this.mouse_move_listener);

	},
	mouseMoveListener : function(evt)
	{
		var x = Event.pointerX(evt);
		var y = Event.pointerY(evt);

		if(
			!(x > this.menu_left && x < this.menu_left2 && y > this.menu_top && y < this.menu_top2)
			&&
			!(x > this.img_left && x < this.img_left2 && y > this.img_top && y < this.img_top2)
		)
		{
			this.closeMenu();
			//Event.stopObserving(document, "mousemove", this.mouse_move_listener);
			//Event.observe(this.div, "mouseover", this.menu_over_listener);
		}
	},
	setFormValue : function(pair)
	{


			switch(pair.key)
			{
				case "street":
					if(pair.value != "" && pair.value != "undefined")
						this.form.street.value = pair.value;
					else
						this.form.street.value = "";
					break;
				case "bid":
					if(pair.value != "" && pair.value != "undefined")
						this.form.bid.value = pair.value;
					else
						this.form.bid.value = "";
					break;				
				case "sl":
					if(pair.value == "1")
					{
						this.form.sl.value = "1";
					}
					else
					{
						this.form.sl.value = "0";
					}
					break;
				case "sch_type":
					if(pair.value == "1")
					{
						$("ps_rent_radio").checked = true;
						$("ps_buy_radio").checked = false;
						this.changeRentSale($("ps_rent_radio"));
					}
					else if(pair.value == "2")
					{
						$("ps_rent_radio").checked = false;
						$("ps_buy_radio").checked = true;
						this.changeRentSale($("ps_buy_radio"));
					}
					break;
				case "sale_with_lease":
					if($("ps_buy_radio").checked)
						$("ps_sale_with_lease").checked = true;
					break;
				case "location":
					var vals = [];
					try{
						vals = pair.value.split(",");
					}catch(e){}

					if(vals.length >= 1)
					{
						var selected_val = false;
						for(var i=0; i<this.form.location.options.length; i++)
						{
							if(	this.form.location.options[i].value == vals[0])
							{
								this.form.location.options[i].selected = "true";
								selected_val = true;
								break;
							}
						}
						if(!selected_val)
						{
							this.form.location.options[0].selected = "true";
						}
					}
					if(vals.length >= 2)
					{
						var selected_val = false;
						for(var i=0; i<this.form.location2.options.length; i++)
						{
							if(	this.form.location2.options[i].value == vals[1])
							{
								this.form.location2.options[i].selected = "true";
								selected_val = true;
								break;
							}
						}
						if(!selected_val)
						{
							this.form.location2.options[0].selected = "true";
						}
					}
					break;
				case "pr_from":
					$("ps_pr_from_value").value = parseInt(pair.value);

					/*for(var i=0; i<this.pr_result_mask.length; i++)
					{
						if(this.pr_result_mask[i] >= parseInt($("ps_pr_from_value").value))
						{
							this.pr_slider.setVal1(i);
							break;
						}
					}
					this.onPrDrag(this.pr_slider);		*/
					break;
				case "pr_to":
					$("ps_pr_to_value").value = parseInt(pair.value);
					/*for(var i=0; i<this.pr_result_mask.length; i++)
					{
						if(this.pr_result_mask[i] >= parseInt($("ps_pr_to_value").value))
						{
							this.pr_slider.setVal2(i);
							break;
						}
					}
					this.onPrDrag(this.pr_slider);		*/
					break;
				case "rt_from":
					$("ps_rt_from_value").value = parseInt(pair.value);

					/*for(var i=0; i<this.rt_result_mask.length; i++)
					{
						if(this.rt_result_mask[i] >= parseInt($("ps_rt_from_value").value))
						{
							this.rt_slider.setVal1(i);
							break;
						}
					}
					this.onRtDrag(this.rt_slider);	*/
					break;
				case "rt_to":
					$("ps_rt_to_value").value = parseInt(pair.value);
					/*for(var i=0; i<this.rt_result_mask.length; i++)
					{
						if(this.rt_result_mask[i] >= parseInt($("ps_rt_to_value").value))
						{
							this.rt_slider.setVal2(i);
							break;
						}
					}
					this.onRtDrag(this.rt_slider);	*/
					break;
				case "size_from":
					for(var i=0; i<this.form.size_from.options.length; i++)
					{
						if(this.form.size_from.options[i].value == pair.value)
						{
							this.form.size_from.options[i].selected = "true";
							break;
						}
					}
					break;
				case "size_to":
					for(var i=0; i<this.form.size_to.options.length; i++)
					{
						if(this.form.size_to.options[i].value == pair.value)
						{
							this.form.size_to.options[i].selected = "true";
							break;
						}
					}
					break;
				case "br_from":
					for(var i=0; i<this.form.br_from.options.length; i++)
					{
						if(this.form.br_from.options[i].value == pair.value)
						{
							this.form.br_from.options[i].selected = "true";
							break;
						}
					}
					break;
				case "br_to":
					for(var i=0; i<this.form.br_to.options.length; i++)
					{
						if(this.form.br_to.options[i].value == pair.value)
						{
							this.form.br_to.options[i].selected = "true";
							break;
						}
					}
					break;
				case "keywords":
					if(typeof(pair.value) != "undefined")
					{
						this.form.keywords.value = pair.value;
						this.default_keyword = pair.value;
					}
					else
					{
						this.form.keywords.value = "";
						this.default_keyword = "";
					}
					break;
				case "lchk1":
					this.form.lchk1.checked = true;
					break;
				case "lchk2":
					this.form.lchk2.checked = true;
					break;
				case "lchk3":
					this.form.lchk3.checked = true;
					break;
				case "lchk4":
					this.form.lchk4.checked = true;
					break;
				case "lchk5":
					this.form.lchk5.checked = true;
					break;
				case "lchk6":
					this.form.lchk6.checked = true;
					break;
				case "fchk":
					for(var i=0; i<this.form.fchk.length; i++)
					{
						if(	this.form.fchk[i].value == pair.value )
						{
							this.form.fchk[i].checked = true;
						}
					}
					break;
				case "fchk5":
					this.form.fchk5.checked = true;
					break;
				case "fchk6":
					this.form.fchk6.checked = true;
					break;
				case "fchk7":
					this.form.fchk7.checked = true;
					break;
				case "fchk8":
					this.form.fchk8.checked = true;
					break;
				case "fchk9":
					this.form.fchk9.checked = true;
					break;
				case "fchk10":
					this.form.fchk10.checked = true;
					break;
				case "page":
					this.form.page.value = pair.value;
					break;
				case "rec_per_page":
					this.form.rec_per_page.value = pair.value;
					break;
				case "sort_by":
					this.form.sort_by.value = pair.value;
					break;
				case "mode":
					this.form.mode.value = pair.value;
					break;
			}
	},
	setResource : function(obj)
	{
		if(this.first_load)
		{
			this.initializeAction();
			this.first_load = false;
		}
		var h = $H(obj);
		h.each(this.setFormValue.bind(this));


	},
	submitSearch : function(evt)
	{
		this.current_form_status = null;
		var url = parseUri(window.location.href);
		if(url.directoryPath.indexOf("property_search") != -1 && controller != null && typeof(controller.use_ajax) != "undefined" && controller.use_ajax && typeof(controller.makeResultRequest) == "function")
		//if(false)
		{
			this.default_keyword = this.form.keywords.value;
			this.form.sl.value = 0;
			this.form.max_page.value = 0;
			this.form.page.value = 1;
			var form_serialize = $(this.form).serialize();
			controller.tagItemClickAction(controller.result_in_list);
			var url = "xml/getResult.php?"+form_serialize;
			controller.history_key = "";
			controller.history_val = form_serialize;
			controller.form_obj = form_serialize;
			controller.makeResultRequest(url);
			controller.map_point_loaded = false;
			this.close();
			return;
		}
		else
		{
			this.form.sl.value = 0;
			this.form.max_page.value = 0;
			this.form.page.value = 1;
			this.form.submit();
		}
	},
	resetSearch : function(evt)
	{
		this.form.reset();
		$("ps_pr_from_value").value = 0;
		$("ps_pr_to_value").value = 100000000;
		$("ps_rt_from_value").value = 0;
		$("ps_rt_to_value").value = 180000;
	},
	fchkFeatureClickListener : function(evt)
	{
		var ele = Event.element(evt);
		if(this.current_fchk == ele)
			ele.checked = false;
		else
			this.current_fchk = ele;
	},
	changeRentSaleListener : function(evt)
	{
		var ele = Event.element(evt);
		this.changeRentSale(ele);

	},
	getSearchType : function()
	{
		if($("ps_rent_radio").checked)
			return $("ps_rent_radio").value;
		else if($("ps_buy_radio").checked)
			return $("ps_buy_radio").value;
		else
			return "0";

	},
	changeRentSale : function (obj)
	{
		return;

	},
	onPrDrag : function(obj)
	{
		this.pr_slider.tricker.innerHTML = "<table width='100%'><tr><td class='general_text' align='right'>"+this.pr_display_mask[obj.val1]+"&nbsp;to&nbsp;"+this.pr_display_mask[obj.val2]+"</td></tr></table>";
		this.pr_slider.dragger2_tricker.style.left = (this.pr_slider.div.offsetWidth-this.pr_slider.dragger2_tricker.offsetWidth)+"px";
	},
	setPr : function(obj)
	{
		this.min_sale = this.pr_result_mask[obj.val1];
		$("ps_pr_from_value").value = this.min_sale;
		this.max_sale = this.pr_result_mask[obj.val2];
		$("ps_pr_to_value").value = this.max_sale;
	},
	setRt : function(obj)
	{
		this.min_rent = this.rt_result_mask[obj.val1];
		$("ps_rt_from_value").value = this.min_rent;
		this.max_rent = this.rt_result_mask[obj.val2];
		$("ps_rt_to_value").value = this.max_rent;
	},
	onRtDrag : function(obj)
	{
		this.rt_slider.tricker.innerHTML = "<table width='100%'><tr><td class='general_text' align='right'>"+this.rt_display_mask[obj.val1]+"&nbsp;to&nbsp;"+this.rt_display_mask[obj.val2]+"</td></tr></table>";
		this.rt_slider.dragger2_tricker.style.left = (this.rt_slider.div.offsetWidth-this.rt_slider.dragger2_tricker.offsetWidth)+"px";
	},
	close : function()
	{
		this.closeMenu();
		this.img.src = this.mouseout_img;
	},
	open : function()
	{

	},
	getResource : function()
	{

	},
	closeMenu : function()
	{
		try{

		return;
		}catch(e){}
	},
	onClickListener : function(evt)
	{
		//Effect.Pulsate(this.img, {pulses:1, duration:0.4});
		/*if(this.div.style.display == "none")
			this.openSearchFormAction();*/
		var url = parseUri(window.location.href);
		window.location.href = ((sBasePath=="")?"property_search/":sBasePath+"property_search/")+"form.php?"+((url.directoryPath.indexOf("property_search") != -1)?url.query:"");
	},
	onDblClickListener : function(evt)
	{

	},
	openSearchFormAction : function()
	{
		if(this.first_load)
		{
			this.initializeAction();
			this.first_load = false;
		}
		this.controller.closeOthers(this);
		this.controller.hideSelect();
		this.img.src = this.mouseover_img;
		//this.img.title = "Click to open property search form.";
		var left = this.controller.getOffset($("main_panel"), true);
		var top = this.controller.getOffset($("main_panel"), false);

		this.div.style.left = left+"px";
		this.div.style.top = top+"px";
		this.div.style.display = "";
		//this.open_effect = Effect.Appear(this.div, {duration:0.6,afterFinish:this.sliderDownFinish.bind(this)});
		this.sliderDownFinish();
		//alert($("property_search_form_tbl1").offsetHeight+" "+$("property_search_form_tbl2").offsetHeight);
	},
	onMouseoverListener : function(evt)
	{
		this.controller.closeOthers(this);
		this.img.src = this.mouseover_img;
		//this.openSearchFormAction();
	},
	sliderDownFinish : function()
	{
		try{
			this.form.keywords.value = "";
		}catch(e)
		{}
		this.current_form_status = $(this.form).serialize();

		$("property_search_form_tbl1").style.height = $("property_search_form_tbl2").offsetHeight+"px";

		if($("ps_rent_radio").checked)
		{
			this.changeRentSale($("ps_rent_radio"));
		}
		else if($("ps_buy_radio").checked)
		{
			this.changeRentSale($("ps_buy_radio"));
		}
	},
	onMouseoutListener : function(evt)
	{
		this.img.src = this.mouseout_img;
	},
	menuOverListener : function(evt)
	{
		//this.img.src = this.mouseover_img;
		/*this.menu_left = this.controller.getOffset(this.div, true);
		this.menu_top = this.controller.getOffset(this.div, false);
		this.menu_left2 = this.menu_left+this.div.offsetWidth;
		this.menu_top2 = this.menu_top+this.div.offsetHeight;

		this.img_left = this.controller.getOffset(this.img, true);
		this.img_top = this.controller.getOffset(this.img, false);
		this.img_left2 = this.img_left+this.img.offsetWidth;
		this.img_top2 = this.img_top+this.img.offsetHeight+2;

		Event.stopObserving(document, "mousemove", this.mouse_move_listener);
		Event.stopObserving(this.div, "mouseover", this.menu_over_listener);
		Event.observe(document, "mousemove", this.mouse_move_listener);		*/
	}
}
DEFAULT_TOOLBAR_ITEM.push(PropertySearchToolbarItem);

var ServicedApartmentsToolbarItem = Class.create();
ServicedApartmentsToolbarItem.prototype = {
	id : "serviced_apartments", //*
	name : "Serviced Apartments", //*
	img : null,
	default_img : sBasePath+"images/home/menu_serviced_apt_off.gif", //*
	on_img : sBasePath+"images/home/menu_serviced_apt_on.gif", //*
	off_img : sBasePath+"images/home/menu_serviced_apt_off.gif", //*
	mouseover_img : sBasePath+"images/home/menu_serviced_apt_over.gif", //*
	mouseout_img : sBasePath+"images/home/menu_serviced_apt_off.gif", //*
	img_width: 167,
	img_title : "Click to start serviced apartment search.",
	default_keyword : "",
	setHTML : function ()
	{
		this.htm = '<form method="get" action="'+sBasePath+'serviced_apartments/search.php" name="sa_search_form" id="sa_search_form"><table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="F6F6EC" class="general_tbl">';
		this.htm += '  <tr>';
		this.htm += '    <td align="left" valign="top" class="general_td2"><table id="serviced_apartments_form_tbl1" width="100%" border="0" cellspacing="0" cellpadding="2" style="height:100%" class="general_tbl">';

		this.htm += '      <tr>';
		this.htm += '        <td colspan="2"><select name="location" id="sa_location" no_hide="true">';
		this.htm += '          <option value="" selected>All Locations</option>';
		if(typeof(sDistrictList) != "undefined")
		{
			for(var i=0; i<sDistrictList.length; i++)
			{
				if(sDistrictList[i][0] == 0)
				{
					this.htm += '          <option value="'+sDistrictList[i][0]+'_'+sDistrictList[i][1]+'" style="background-color:#DDDDDD">--'+unescape(sDistrictList[i][2])+' District--</option>';
				}
				else
				{
					this.htm += '          <option value="'+sDistrictList[i][0]+'" style="padding-left:10px;">'+unescape(sDistrictList[i][2])+'</option>';
				}
			}
		}
		this.htm += '        </select>        </td>';
		this.htm += '        </tr>';

		this.htm += '      <tr style="height:10px">';
		this.htm += '        <td colspan="2"></td>';
		this.htm += '      </tr>';
		this.htm += '      <tr>';
		this.htm += '        <td colspan="2" vAlign="top" style="height:35px" id="sa_price_range">Price Range (HK$)&nbsp;<div id="sa_slider"></div><input type="hidden" name="rt_from" id="sa_from_value" value="0"><input type="hidden" name="rt_to" id="sa_to_value" value="150000"></td>';
		this.htm += '      </tr>';
		this.htm += '      <tr style="height:10px">';
		this.htm += '        <td colspan="2"></td>';
		this.htm += '      </tr>';
		this.htm += '      <tr>';
		this.htm += '        <td>Size (sq.ft.) </td>';
		this.htm += '        <td>Bedrooms</td>';
		this.htm += '      </tr>';
		this.htm += '      <tr>';
		this.htm += '        <td><select name="size_from" id="sa_size_from" no_hide="true">';
		this.htm += '        <option value="0" selected>0</option>';
		this.htm += '        <option value="200">200</option>';
		this.htm += '        <option value="400">400</option>';
		this.htm += '        <option value="600">600</option>';
		this.htm += '        <option value="800">800</option>';
		this.htm += '        <option value="1000">1000</option>';
		this.htm += '        <option value="1500">1500</option>';
		this.htm += '        <option value="2000">2000</option>';
		this.htm += '        </select>';
		this.htm += '          to';
		this.htm += '          <select name="size_to" id="sa_size_to" no_hide="true">';
		this.htm += '        <option value="0">0</option>';
		this.htm += '        <option value="200">200</option>';
		this.htm += '        <option value="400">400</option>';
		this.htm += '        <option value="600">600</option>';
		this.htm += '        <option value="800">800</option>';
		this.htm += '        <option value="1000">1000</option>';
		this.htm += '        <option value="1500">1500</option>';
		this.htm += '        <option value="2000" selected>2000+</option>';
		this.htm += '          </select></td>';
		this.htm += '        <td><select name="br_from" id="sa_br_from" no_hide="true">';
		this.htm += '        <option value="0" selected>Studio</option>';
		this.htm += '        <option value="1">1</option>';
		this.htm += '        <option value="2">2</option>';
		this.htm += '        <option value="3">3</option>';
		this.htm += '        <option value="4">4</option>';
		this.htm += '        <option value="5">5+</option>';
		this.htm += '        </select>';
		this.htm += '          to';
		this.htm += '          <select name="br_to" id="sa_br_to" no_hide="true">';
		this.htm += '        <option value="0">Studio</option>';
		this.htm += '        <option value="1">1</option>';
		this.htm += '        <option value="2">2</option>';
		this.htm += '        <option value="3">3</option>';
		this.htm += '        <option value="4">4</option>';
		this.htm += '        <option value="5" selected>5+</option>';
		this.htm += '          </select></td>';
		this.htm += '      </tr>';
		this.htm += '    </table></td>';
		this.htm += '    <td width="50%" align="left" valign="top" class="general_td2"><table id="serviced_apartments_form_tbl2" width="100%" border="0" cellspacing="0" cellpadding="2" class="general_tbl">';
		this.htm += '      <tr>';
		this.htm += '        <td colspan="2">Features (Optional) </td>';
		this.htm += '        </tr>';
		this.htm += '      <tr>';
		this.htm += '        <td width="50%"><input type="checkbox" name="fchk5" value="fchk5">Gymnasium</td>';
		this.htm += '        <td width="50%"><input type="checkbox" name="fchk7" value="fchk7">Tennis Court</td>';
		this.htm += '      </tr>';
		this.htm += '      <tr>';
		this.htm += '        <td><input type="checkbox" name="fchk6" value="fchk6">Swimming Pool</td>';
		this.htm += '        <td><input type="checkbox" name="fchk8" value="fchk8">Children\'s Playground</td>';
		this.htm += '      </tr>';
		this.htm += '      <tr>';
		this.htm += '        <td><input type="checkbox" name="fchk9" value="fchk9">Shuttle Bus</td>';
		this.htm += '        <td><input type="checkbox" name="fchk10" value="fchk10">Carpark</td>';
		this.htm += '      </tr>';
		this.htm += '      <tr>';
		this.htm += '        <td colspan="2">Building Age (optional)</td>';
		this.htm += '        </tr>';
		this.htm += '      <tr>';
		this.htm += '        <td colspan="2"><select id="sa_building_age" name="age" no_hide="true">';
		this.htm += '        <option value="0" selected>No Preference</option>';
		this.htm += '		<option value="20">Within 20 years</option>';
		this.htm += '		<option value="15">Within 15 years</option>';
		this.htm += '		<option value="10">Within 10 years</option>';
		this.htm += '		<option value="5">Within 5 years</option>';
		this.htm += '		<option value="3">Within 3 years</option>';
		this.htm += '		<option value="2">Within 2 years</option>';
		this.htm += '		<option value="1">Within 1 year</option></select>';
		this.htm += '		</td>';
		this.htm += '        </tr>';
		this.htm += '    </table></td>';
		this.htm += '  </tr>';
		this.htm += '  <tr>';
		this.htm += '    <td colspan="2" align="right" valign="middle" class="general_td2"><img src="'+sBasePath+'images/property/btn_close_off.gif" width="39" height="17">&nbsp;&nbsp;<img src="'+sBasePath+'images/property/btn_reset_off.gif" width="39" height="17">&nbsp;&nbsp;<img src="'+sBasePath+'images/property/btn_search_off.gif" width="47" height="17">&nbsp;&nbsp;</td>';
		this.htm += '  </tr>';
		this.htm += '</table>';
		this.htm += '<input type="hidden" name="sch_type" id="sa_sch_type" value="1"><input type="hidden" name="is_serv_apart" id="sa_is_serv_apart" value="1"><input type="hidden" name="page" id="sa_page" value="1"><input type="hidden" name="rec_per_page" id="sa_rec_per_page" value="5"><input type="hidden" name="sort" id="sa_sort" value="3"><input type="hidden" name="action" id="sa_action" value="1"><input type="hidden" name="mode" id="sa_display_mode" value="1"><input type="hidden" name="max_page" id="sa_max_page" value="0">';
		this.htm += '</form>';
	},

	initialize : function(controller)
	{
		/*this.current_form_status = null;
		this.controller = controller;
		var mode = 2;
		this.div = document.createElement("DIV");
		if($("serviced_apartment_toolbar_html") != null)
		{
			this.div = $("serviced_apartment_toolbar_html");
			mode = 1;
		}
		else
		{
			this.setHTML();
			this.div.innerHTML = this.htm;
		}

		this.div.style.width = $("main_panel").offsetWidth+"px";
		this.div.style.zIndex = "10000";
		this.div.style.backgroundColor = "#F6F6EC";
		this.div.style.position = "absolute";
		document.body.appendChild(this.div);

		this.div.style.display = "none";	*/

		this.current_form_status = null;
		var mode = 2;
		this.div = document.createElement("DIV");
		if($("serviced_apartment_toolbar_html") != null)
		{
			this.div  = $("serviced_apartment_toolbar_html");
			mode = 1;
		}
		else
		{
			this.setHTML();
			this.div.innerHTML = this.htm;
		}

		this.controller = controller;

		this.first_load = true;

		if(mode == 1)
		{
			/*var opt = null;
			if(typeof(sDistrictList) != "undefined")
			{
				for(var i=0; i<sDistrictList.length; i++)
				{
					if(sDistrictList[i][0] == 0)
					{
						opt = document.createElement("OPTION");
						opt.innerHTML = '--'+unescape(sDistrictList[i][2])+' District--';
						opt.style.backgroundColor = "#DDDDDD";
						opt.value = sDistrictList[i][0]+'_'+sDistrictList[i][1];
						$("sa_location").appendChild(opt);
					}
					else
					{
						opt = document.createElement("OPTION");
						opt.innerHTML = unescape(sDistrictList[i][2]);
						opt.value = sDistrictList[i][0];
						$("sa_location").appendChild(opt);
					}
					opt = null;
				}
			}
			opt = null;*/
		}

		this.first_load = true;
		//this.initializeAction();
	},
	initializeAction : function()
	{
		this.form = this.div.getElementsByTagName("FORM")[0];
		/*this.div.style.display = "";
		this.form = this.div.getElementsByTagName("FORM")[0];

		var imgs = this.div.getElementsByTagName("IMG");
		for(var i=0; i<imgs.length; i++)
		{
			if(imgs[i].src.indexOf("btn_close_off.gif") != -1)
			{
				Event.observe(imgs[i], "click", this.closeMenu.bindAsEventListener(this));
				imgs[i].style.cursor = "pointer";
			}
			if(imgs[i].src.indexOf("btn_search_off.gif") != -1)
			{
				Event.observe(imgs[i], "click", this.submitSearch.bindAsEventListener(this));
				imgs[i].style.cursor = "pointer";
			}
			if(imgs[i].src.indexOf("btn_reset_off.gif") != -1)
			{
				Event.observe(imgs[i], "click", this.resetSearch.bindAsEventListener(this));
				imgs[i].style.cursor = "pointer";
			}
		}

		this.sa_slider = null;
		var l = this.controller.getOffset($("sa_price_range"), true);
		var t = this.controller.getOffset($("sa_price_range"), false);
		$("sa_slider").style.position = "absolute";
		$("sa_slider").style.left = (l+5)+"px";
		$("sa_slider").style.top = (t-2)+"px";
		var mnr = 0; var mxr = 180;

		this.sa_result_mask = new Array(0,5000,10000,15000,20000,25000,30000,35000,40000,45000,50000,55000,60000,65000,70000,75000,80000,85000,90000,95000,100000,110000,120000,130000,140000,150000);
		this.sa_display_mask = new Array("0","5K","10K","15K","20K","25K","30K","35K","40K","45K","50K","55K","60K","65K","70K","75K","80K","85K","90K","95K","100K","110K","120K","130K","140K","150K");
		var cnt = 0;
		for(var rc = 0; rc <= 150; rc=rc+3)
		{
			this.sa_result_mask[cnt] = rc*1000;
			this.sa_display_mask[cnt] = (rc)+"K";
			cnt++;
		}
		this.sa_slider = new Slider($("sa_slider"), {"rounding":true,"min_val":0,"max_val":(this.sa_result_mask.length-1),"width":($("sa_price_range").offsetWidth-10) ,"height":10,"interval":1,"margin_shad":true, "factor":1, "background_image":"", "drag_func":this.onSaDrag.bind(this), "drag_end_func":this.setSa.bind(this)});
		this.sa_slider.initSlider();
		this.onSaDrag(this.sa_slider);

		this.sa_slider.setDisplay(0);

		this.div.style.display = "none";

		this.mouse_move_listener = this.mouseMoveListener.bindAsEventListener(this);
		this.menu_over_listener = this.menuOverListener.bindAsEventListener(this);
		//Event.observe(this.div, "mouseover", this.menu_over_listener);

		Event.observe($("sa_location"), "focus", this.locationListFocusListener.bindAsEventListener(this));
		Event.observe($("sa_location"), "blur", this.locationListBlurListener.bindAsEventListener(this));
		Event.observe($("sa_location"), "change", this.locationListSelectListener.bindAsEventListener(this));
		*/
		//this.img.title = "Click to open serviced apartment search form.";
	},
	locationListSelectListener : function(evt)
	{
		$("sa_location").blur();
	},
	locationListBlurListener : function(evt)
	{
		//Event.observe(this.div, "mouseover", this.menu_over_listener);
	},
	locationListFocusListener : function(evt)
	{
		//Event.stopObserving(document, "mousemove", this.mouse_move_listener);

	},
	getSearchType : function()
	{
		return 1;
	},
	mouseMoveListener : function(evt)
	{
		var x = Event.pointerX(evt);
		var y = Event.pointerY(evt);

		if(
			!(x > this.menu_left && x < this.menu_left2 && y > this.menu_top && y < this.menu_top2)
			&&
			!(x > this.img_left && x < this.img_left2 && y > this.img_top && y < this.img_top2)
		)
		{
			this.closeMenu();
			//Event.stopObserving(document, "mousemove", this.mouse_move_listener);
			//Event.observe(this.div, "mouseover", this.menu_over_listener);
		}
	},
	submitSearch : function(evt)
	{
		this.current_form_status = null;
		var url = parseUri(window.location.href);

		if(url.directoryPath.indexOf("serviced_apartments") != -1 && controller != null && typeof(controller.use_ajax) != "undefined" && controller.use_ajax && typeof(controller.makeResultRequest) == "function")
		//if(false)
		{
			//this.default_keyword = this.form.keywords.value;
			this.form.sl.value = 0;
			this.form.max_page.value = 0;
			this.form.page.value = 1;
			var form_serialize = $(this.form).serialize();
			controller.tagItemClickAction(controller.result_in_list);
			var url = "xml/getResult.php?"+form_serialize;

			controller.history_key = "";
			controller.history_val = form_serialize;
			controller.makeResultRequest(url);
			controller.map_point_loaded = false;
			this.close();
			return;
		}
		else
		{
			this.form.sl.value = 0;
			this.form.max_page.value = 0;
			this.form.page.value = 1;
			this.form.submit();
		}
		/*this.form.max_page.value = 0;
		this.form.page.value = 1;
		this.form.submit();*/
	},
	resetSearch : function(evt)
	{
		this.form.reset();
		//alert($("sa_from_value").value+" "+$("sa_to_value").value);
		$("sa_from_value").value = 0;
		$("sa_to_value").value = 150000;
		for(var i=0; i<this.sa_result_mask.length; i++)
		{
			if(this.sa_result_mask[i] == parseInt($("sa_from_value").value))
			{
				this.sa_slider.setVal1(i);
				break;
			}
		}
		for(var i=0; i<this.sa_result_mask.length; i++)
		{
			if(this.sa_result_mask[i] == parseInt($("sa_to_value").value))
			{
				this.sa_slider.setVal2(i);
				break;
			}
		}
		this.onSaDrag(this.sa_slider);
	},
	onSaDrag : function(obj)
	{
		this.sa_slider.tricker.innerHTML = "<table width='100%'><tr><td class='general_text' align='right'>"+this.sa_display_mask[obj.val1]+"&nbsp;to&nbsp;"+this.sa_display_mask[obj.val2]+"</td></tr></table>";
		this.sa_slider.dragger2_tricker.style.left = (this.sa_slider.div.offsetWidth-this.sa_slider.dragger2_tricker.offsetWidth)+"px";
	},
	setSa : function(obj)
	{
		this.min_sale = this.sa_result_mask[obj.val1];
		$("sa_from_value").value = this.min_sale;
		this.max_sale = this.sa_result_mask[obj.val2];
		$("sa_to_value").value = this.max_sale;
	},
	close : function()
	{
		this.closeMenu();
		this.img.src = this.mouseout_img;

	},
	open : function()
	{

	},
	getResource : function()
	{

	},
	setFormValue : function(pair)
	{

			switch(pair.key)
			{
				case "street":
					if(pair.value != "")
						this.form.street.value = pair.value;
					break;
				case "bid":
					if(pair.value != "")
						this.form.bid.value = pair.value;
					break;					
				case "sl":
					if(pair.value == "1")
					{
						this.form.sl.value = "1";
					}
					break;
				case "location":
					var vals = [];
					try{
						vals = pair.value.split(",");
					}catch(e){}
					if(vals.length >= 1)
					{
						var selected_val = false;
						for(var i=0; i<this.form.location.options.length; i++)
						{
							if(	this.form.location.options[i].value == vals[0])
							{
								this.form.location.options[i].selected = "true";
								selected_val = true;
								break;
							}
						}
						if(!selected_val)
						{
							this.form.location.options[0].selected = "true";
						}
					}
					if(vals.length >= 2)
					{
						var selected_val = false;
						for(var i=0; i<this.form.location2.options.length; i++)
						{
							if(	this.form.location2.options[i].value == vals[1])
							{
								this.form.location2.options[i].selected = "true";
								selected_val = true;
								break;
							}
						}
						if(!selected_val)
						{
							this.form.location2.options[0].selected = "true";
						}
					}
					break;
				case "rt_from":
					$("sa_from_value").value = parseInt(pair.value);

					/*for(var i=0; i<this.sa_result_mask.length; i++)
					{
						if(this.sa_result_mask[i] >= parseInt($("sa_from_value").value))
						{
							this.sa_slider.setVal1(i);
							break;
						}
					}
					this.onSaDrag(this.sa_slider);	*/
					break;
				case "rt_to":
					$("sa_to_value").value = parseInt(pair.value);
					/*for(var i=0; i<this.sa_result_mask.length; i++)
					{
						if(this.sa_result_mask[i] >= parseInt($("sa_to_value").value))
						{
							this.sa_slider.setVal2(i);
							break;
						}
					}
					this.onSaDrag(this.sa_slider);	*/
					break;
				case "size_from":
					for(var i=0; i<this.form.size_from.options.length; i++)
					{
						if(this.form.size_from.options[i].value == pair.value)
						{
							this.form.size_from.options[i].selected = "true";
							break;
						}
					}
					break;
				case "size_to":
					for(var i=0; i<this.form.size_to.options.length; i++)
					{
						if(this.form.size_to.options[i].value == pair.value)
						{
							this.form.size_to.options[i].selected = "true";
							break;
						}
					}
					break;
				case "br_from":
					for(var i=0; i<this.form.br_from.options.length; i++)
					{
						if(this.form.br_from.options[i].value == pair.value)
						{
							this.form.br_from.options[i].selected = "true";
							break;
						}
					}
					break;
				case "br_to":
					for(var i=0; i<this.form.br_to.options.length; i++)
					{
						if(this.form.br_to.options[i].value == pair.value)
						{
							this.form.br_to.options[i].selected = "true";
							break;
						}
					}
					break;
				case "keywords":
					if(pair.value != "" && typeof(pair.value) != "undefined")
					{
						this.form.keywords.value = pair.value;
						this.default_keyword = pair.value;
					}
					break;
				case "fchk5":
					this.form.fchk5.checked = true;
					break;
				case "fchk6":
					this.form.fchk6.checked = true;
					break;
				case "fchk7":
					this.form.fchk7.checked = true;
					break;
				case "fchk8":
					this.form.fchk8.checked = true;
					break;
				case "fchk9":
					this.form.fchk9.checked = true;
					break;
				case "fchk10":
					this.form.fchk10.checked = true;
					break;
				case "page":
					this.form.page.value = pair.value;
					break;
				case "rec_per_page":
					this.form.rec_per_page.value = pair.value;
					break;
				case "sort":
					this.form.sort.value = pair.value;
					break;
				case "mode":
					this.form.mode.value = pair.value;
					break;
				case "age":
					for(var i=0; i<this.form.age.options.length; i++)
					{
						if(this.form.age.options[i].value == pair.value)
						{
							this.form.age.options[i].selected = "true";
							break;
						}
					}
					break;
			}
	},
	setResource : function(obj)
	{
		if(this.first_load)
		{
			this.initializeAction();
			this.first_load = false;
		}
		var h = $H(obj);
		h.each(this.setFormValue.bind(this));
	},
	closeMenu : function()
	{
		try{

		var tmp_form_status = $(this.form).serialize();
		if(this.current_form_status != null && this.current_form_status  != tmp_form_status)
		{
			this.resetSearch();
			var h = $H(this.current_form_status.toQueryParams());
			h.each(this.setFormValue.bind(this));
		}

		if(this.div != null)
			this.div.style.display = "none";
		if(this.open_effect != null)
			this.open_effect.cancel();
		if(this.img != null)
			this.img.src = this.mouseout_img;
		if(this.sa_slider != null)
			this.sa_slider.setDisplay(0);
		this.controller.showSelect();
		//this.form.keywords.value = this.default_keyword;
		}catch(e){}
	},
	onClickListener : function(evt)
	{
		//Effect.Pulsate(this.img, {pulses:1, duration:0.4});
		//if(this.div.style.display == "none")
		//	this.openSearchFormAction();
		var url = parseUri(window.location.href);
		window.location.href = ((sBasePath=="")?"serviced_apartments/":sBasePath+"serviced_apartments/")+"form.php?"+((url.directoryPath.indexOf("serviced_apartments") != -1)?url.query:"");
	},
	onDblClickListener : function(evt)
	{

	},
	openSearchFormAction : function()
	{
		if(this.div.style.display != "none")
			return;
		if(this.first_load)
		{
			this.initializeAction();
			this.first_load = false;
		}
		this.controller.closeOthers(this);
		this.controller.hideSelect();
		this.img.src = this.mouseover_img;
		//this.img.title = "Click to open serviced apartment search form.";
		var left = this.controller.getOffset($("main_panel"), true);
		var top = this.controller.getOffset($("main_panel"), false);

		this.div.style.left = left+"px";
		this.div.style.top = top+"px";
		this.div.style.display = "";

		//this.div.style.display = "none";

		//this.open_effect = Effect.Appear(this.div, {duration:0.4,afterFinish:this.sliderDownFinish.bind(this)});
		this.sliderDownFinish();
	},
	onMouseoverListener : function(evt)
	{
		this.controller.closeOthers(this);
		this.img.src = this.mouseover_img;
		//this.openSearchFormAction();
	},
	sliderDownFinish : function()
	{
		try{
			//this.form.keywords.value = "";
		}catch(e)
		{}
		this.current_form_status = $(this.form).serialize();
		$("serviced_apartments_form_tbl1").style.height = ($("serviced_apartments_form_tbl2").offsetHeight+2)+"px";

		this.sa_slider.setDisplay(1);
		$("sa_slider").style.left = ($("sa_price_range").offsetLeft+24)+"px";
		$("sa_slider").style.top = ($("sa_price_range").offsetTop+12)+"px";
		this.sa_slider.relocateElement();
	},
	onMouseoutListener : function(evt)
	{
		//if(this.div.style.display == "none")
		this.img.src = this.mouseout_img;
	},
	menuOverListener : function(evt)
	{
		this.menu_left = this.controller.getOffset(this.div, true);
		this.menu_top = this.controller.getOffset(this.div, false);
		this.menu_left2 = this.menu_left+this.div.offsetWidth;
		this.menu_top2 = this.menu_top+this.div.offsetHeight;

		this.img_left = this.controller.getOffset(this.img, true);
		this.img_top = this.controller.getOffset(this.img, false);
		this.img_left2 = this.img_left+this.img.offsetWidth;
		this.img_top2 = this.img_top+this.img.offsetHeight+2;
		try{
			Event.stopObserving(document, "mousemove", this.mouse_move_listener);
			Event.stopObserving(this.div, "mouseover", this.menu_over_listener);
			Event.observe(document, "mousemove", this.mouse_move_listener);
		}catch(e){}
	}
}
DEFAULT_TOOLBAR_ITEM.push(ServicedApartmentsToolbarItem);

var AgentSelectionsToolbarItem = Class.create();
AgentSelectionsToolbarItem.prototype = {
	id : "agent", //*
	name : "Agent Selections", //*
	img : null,
	default_img : sBasePath+"images/home/menu_agents_off.gif", //*
	on_img : sBasePath+"images/home/menu_agents_on.gif", //*
	off_img : sBasePath+"images/home/menu_agents_off.gif", //*
	mouseover_img : sBasePath+"images/home/menu_agents_over.gif", //*
	mouseout_img : sBasePath+"images/home/menu_agents_off.gif", //*
	initialize : function(controller)
	{
		this.controller = controller;
		return;
		var htm = '<table border="0" cellpadding="2" cellspacing="0" bgcolor="F6F6EC" class="general_tbl">';
		/*htm += '  <tr>';
		htm += '    <td class="general_text company_item" style="padding-right:12px;padding-left:5px" id="mypage_item2">Clipboard</td>';
		htm += '    <td align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/resources/arrow.gif" style="display:none" id="mypage_item2_indicator"></td>';
		htm += '  </tr>';	*/
		/*htm += '  <tr>';
		htm += '    <td class="general_text company_item" style="padding-right:12px;padding-left:5px" id="mypage_item1">Login</td>';
		htm += '    <td style="width:13px" align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/resources/arrow.gif" style="display:none" id="mypage_item1_indicator"></td>';
		htm += '  </tr>';*/
		htm += '  <tr>';
		htm += '    <td class="general_text company_item" style="padding-right:12px;padding-left:5px" id="mypage_item4">My Profile</td>';
		htm += '    <td style="width:13px" align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/resources/arrow.gif" style="display:none" id="mypage_item4_indicator"></td>';
		htm += '  </tr>';
		htm += '  <tr>';
		htm += '    <td class="general_text company_item" style="padding-right:12px;padding-left:5px" id="mypage_item2">My Property</td>';
		htm += '    <td style="width:13px" align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/resources/arrow.gif" style="display:none" id="mypage_item2_indicator"></td>';
		htm += '  </tr>';
		htm += '  <tr>';
		htm += '    <td class="general_text company_item" style="padding-right:12px;padding-left:5px" id="mypage_item3">After Sale Service</td>';
		htm += '    <td style="width:13px" align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/resources/arrow.gif" style="display:none" id="mypage_item3_indicator"></td>';
		htm += '  </tr>';
		htm += '  <tr style="display:none" id="mypage_logout">';
		htm += '    <td class="general_text company_item" style="padding-right:12px;padding-left:5px" id="mypage_item5">Logout</td>';
		htm += '    <td style="width:13px" align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/resources/arrow.gif" style="display:none" id="mypage_item5_indicator"></td>';
		htm += '  </tr>';
		htm += '  <tr>';
		htm += '    <td colspan="2" style="height:10px"></td>';
		htm += '  </tr>';
		htm += '</table>';
		this.div = document.createElement("DIV");
		this.div.style.display = "none";
		this.div.style.padding = "5px";
		this.div.style.backgroundColor = "F6F6EC";
		this.div.style.position = "absolute";
		this.div.style.zIndex = "10000";
		this.div.innerHTML = htm;
		Event.observe(this.div, "mouseover", this.menuOverListener.bindAsEventListener(this),true);
		//Event.observe(this.div, "mouseout", this.menuOutListener.bindAsEventListener(this),true);
		document.body.appendChild(this.div);
		this.div_over = false;
		this.mouse_move_listener = this.mouseMoveListener.bindAsEventListener(this);

		var mypage_arr = [2,3,4,5];
		for(var i=0; i < mypage_arr.length; i++)
		{
			Event.observe($("mypage_item"+mypage_arr[i]), "click", this.itemClickListener.bindAsEventListener(this));
			Event.observe($("mypage_item"+mypage_arr[i]), "mouseover", this.itemMouseoverListener.bindAsEventListener(this));
			Event.observe($("mypage_item"+mypage_arr[i]), "mouseout", this.itemMouseoutListener.bindAsEventListener(this));
			$("mypage_item"+mypage_arr[i]).style.cursor = "pointer";
		}
		/*Event.observe($("mypage_item1"), "click", this.itemClickListener.bindAsEventListener(this));
		Event.observe($("mypage_item1"), "mouseover", this.itemMouseoverListener.bindAsEventListener(this));
		Event.observe($("mypage_item1"), "mouseout", this.itemMouseoutListener.bindAsEventListener(this));
		$("mypage_item1").style.cursor = "pointer";*/

		/*Event.observe($("tools_item2"), "click", this.itemClickListener.bindAsEventListener(this));
		Event.observe($("tools_item2"), "mouseover", this.itemMouseoverListener.bindAsEventListener(this));
		Event.observe($("tools_item2"), "mouseout", this.itemMouseoutListener.bindAsEventListener(this));
		$("tools_item2").style.cursor = "pointer";*/
		if(typeof(IS_LOGIN) != "undefined" && typeof(IS_PRISM_LOGIN) != "undefined")
		{
			if(IS_LOGIN || IS_PRISM_LOGIN)
				this.showLogout();
		}
	},
	hideLogout : function()
	{
		$("mypage_logout").style.display = "none";
	},
	showLogout : function()
	{
		$("mypage_logout").style.display = "";
	},
	itemMouseoverListener : function(evt)
	{
		try{
		var ele = Event.element(evt);
		$(ele.id+"_indicator").style.display = "";
		}catch(e){}
	},
	itemMouseoutListener : function(evt)
	{
		try{
		var ele = Event.element(evt);
		$(ele.id+"_indicator").style.display = "none";
		}catch(e){}
	},
	itemClickListener : function(evt)
	{
		var ele = Event.element(evt);
		if($(ele).readAttribute("url") != null)
		{
			var url = sBasePath+$(ele).readAttribute("url");
			if(window.location.href != url)
				window.location.href = url;
		}
	},
	close : function()
	{
		this.img.src = this.mouseout_img;
		// if(this.open_effect != null)
			// this.open_effect.cancel();
		// this.div.style.display = "none";
		// try{
		// Event.stopObserving(document, "mousemove", this.mouse_move_listener);
		// }catch(e){}
	},
	open : function()
	{

	},

	getResource : function()
	{

	},
	mouseMoveListener : function(evt)
	{
		var x = Event.pointerX(evt);
		var y = Event.pointerY(evt);

		if(
			// !(x > this.menu_left && x < this.menu_left2 && y > this.menu_top && y < this.menu_top2)
			// &&
			!(x > this.img_left && x < this.img_left2 && y > this.img_top && y < this.img_top2)
		)
		{
			this.img.src = this.mouseout_img;
			// this.div.style.display = "none";
			try{
			Event.stopObserving(document, "mousemove", this.mouse_move_listener);
			}catch(e){}
		}

	},
	onClickListener : function(evt)
	{
		//Effect.Pulsate(this.img, {pulses:1, duration:0.4});
		// var url = parseUri(window.location.href);
		
		window.location.href = ((sBasePath=="")?"agent/":sBasePath+"agent/");
	},
	onDblClickListener : function(evt)
	{

	},
	onMouseoverListener : function(evt)
	{
		this.img.src = this.mouseover_img;
		this.controller.closeOthers(this);
		// var left = this.controller.getOffset(this.img, true);
		// var top = this.controller.getOffset(this.img, false);
		// this.div.style.left = (left)+"px";
		// this.div.style.top = (top+this.img.offsetHeight)+"px";
		// this.div.style.display = "";
		//this.open_effect = Effect.Appear(this.div, {duration:0.4});
	},
	onMouseoutListener : function(evt)
	{
		this.img.src = this.mouseout_img;
	},
	menuOverListener : function(evt)
	{
		// this.menu_left = this.controller.getOffset(this.div, true);
		// this.menu_top = this.controller.getOffset(this.div, false);
		// this.menu_left2 = this.menu_left+this.div.offsetWidth;
		// this.menu_top2 = this.menu_top+this.div.offsetHeight;

		this.img_left = this.controller.getOffset(this.img, true);
		this.img_top = this.controller.getOffset(this.img, false);
		this.img_left2 = this.img_left+this.img.offsetWidth;
		this.img_top2 = this.img_top+this.img.offsetHeight+2;
		//alert(this.img_left+" "+this.img_left2+" "+this.img_top+" "+this.img_top2);
		try{
		Event.stopObserving(document, "mousemove", this.mouse_move_listener);
		Event.observe(document, "mousemove", this.mouse_move_listener);
		}catch(e){}
	},
	menuOutListener : function(evt)
	{

	}
}
DEFAULT_TOOLBAR_ITEM.push(AgentSelectionsToolbarItem);

var OverseasToolbarItem = Class.create();
OverseasToolbarItem.prototype = {
	id : "overseas", //*
	name : "Overseas", //*
	img : null,
	default_img : sBasePath+"images/home/menu_overseas_off.gif", //*
	on_img : sBasePath+"images/home/menu_overseas_on.gif", //*
	off_img : sBasePath+"images/home/menu_overseas_off.gif", //*
	mouseover_img : sBasePath+"images/home/menu_overseas_over.gif", //*
	mouseout_img : sBasePath+"images/home/menu_overseas_off.gif", //*
	initialize : function(controller)
	{
		this.controller = controller;
	},
	close : function()
	{

	},
	open : function()
	{

	},
	getResource : function()
	{

	},
	onClickListener : function(evt)
	{
		Effect.Pulsate(this.img, {pulses:1, duration:0.4});
		window.location.href = sRelativePath+"overseas/";
	},
	onDblClickListener : function(evt)
	{

	},
	onMouseoverListener : function(evt)
	{
		this.img.src = this.mouseover_img;
		this.controller.closeOthers(this);
	},
	onMouseoutListener : function(evt)
	{
		this.img.src = this.mouseout_img;
	}
}
//DEFAULT_TOOLBAR_ITEM.push(OverseasToolbarItem);

var LivingInHKToolbarItem = Class.create();
LivingInHKToolbarItem.prototype = {
	id : "living_in_hk", //*
	name : "Living in HK", //*
	img : null,
	default_img : sBasePath+"images/home/menu_living_in_hk_off.gif", //*
	on_img : sBasePath+"images/home/menu_living_in_hk_on.gif", //*
	off_img : sBasePath+"images/home/menu_living_in_hk_off.gif", //*
	mouseover_img : sBasePath+"images/home/menu_living_in_hk_over.gif", //*
	mouseout_img : sBasePath+"images/home/menu_living_in_hk_off.gif", //*
	img_width: 106,
	initialize : function(controller)
	{
		this.controller = controller;
		var htm = '<table border="0" cellpadding="2" cellspacing="0" bgcolor="F6F6EC" class="general_tbl">';
		// htm += '  <tr>';
		// htm += '    <td class="general_text" style="padding-right:12px;padding-left:5px" id="living_in_hk_item8" url="living_in_hk/">Overview&nbsp;&nbsp;&nbsp;</td>';
		// htm += '    <td style="width:13px" align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/resources/arrow.gif" style="display:none" id="living_in_hk_item8_indicator"></td>';
		// htm += '  </tr>';	
		// htm += '  <tr>';
		// htm += '    <td class="general_text" style="padding-right:12px;padding-left:5px" id="living_in_hk_item1" url="living_in_hk/directory/index.htm"><a href="'+sBasePath+'living_in_hk/directory/index.htm"></a>Directory&nbsp;&nbsp;&nbsp;</td>';
		// htm += '    <td style="width:13px" align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/living_in_hk/arrow.gif" style="display:none" id="living_in_hk_item1_indicator"></td>';
		// htm += '  </tr>';
		// htm += '  <tr>';
		// htm += '    <td class="general_text" style="padding-right:12px;padding-left:5px" id="living_in_hk_item2" url="living_in_hk/featured_article/article_list.htm"><a href="'+sBasePath+'living_in_hk/featured_article/article_list.htm"></a>Featured&nbsp;Articles&nbsp;&nbsp;&nbsp;</td>';
		// htm += '    <td style="width:13px" align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/living_in_hk/arrow.gif" style="display:none" id="living_in_hk_item2_indicator"></td>';
		// htm += '  </tr>';
		// htm += '  <tr>';
		// htm += '    <td class="general_text" style="padding-right:12px;padding-left:5px" id="living_in_hk_item3" url="living_in_hk/goods_and_services/index.htm"><a href="'+sBasePath+'living_in_hk/goods_and_services/index.htm"></a>Goods&nbsp;&&nbsp;Services&nbsp;&nbsp;&nbsp;</td>';
		// htm += '    <td style="width:13px" align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/living_in_hk/arrow.gif" style="display:none" id="living_in_hk_item3_indicator"></td>';
		// htm += '  </tr>';
		htm += '  <tr>';
		htm += '    <td class="general_text" style="padding-right:12px;padding-left:5px" id="living_in_hk_item4" url="living_in_hk/housing_districts/overview.htm"><a href="'+sBasePath+'living_in_hk/housing_districts/overview.htm"></a>Housing&nbsp;Districts&nbsp;&nbsp;&nbsp;</td>';
		htm += '    <td style="width:13px" align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/living_in_hk/arrow.gif" style="display:none" id="living_in_hk_item4_indicator"></td>';
		htm += '  </tr>';
		htm += '  <tr>';
		htm += '    <td class="general_text" style="padding-right:12px;padding-left:5px" id="living_in_hk_item5" url="living_in_hk/useful_info.php"><a href="'+sBasePath+'living_in_hk/useful_info.php"></a>Useful&nbsp;Information&nbsp;&nbsp;&nbsp;</td>';
		htm += '    <td style="width:13px" align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/living_in_hk/arrow.gif" style="display:none" id="living_in_hk_item6_indicator"></td>';
		htm += '  </tr>';
		htm += '  <tr>';
		htm += '    <td class="general_text" style="padding-right:12px;padding-left:5px" id="living_in_hk_item7" url="living_in_hk/renting_guide.php"><a href="'+sBasePath+'living_in_hk/renting_guide.php"></a>Renting&nbsp;Guide&nbsp;&nbsp;&nbsp;</td>';
		htm += '    <td style="width:13px" align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/living_in_hk/arrow.gif" style="display:none" id="living_in_hk_item7_indicator"></td>';
		htm += '  </tr>';

		/*htm += '  <tr>';
		htm += '    <td class="general_text" style="padding-right:12px;padding-left:5px" id="living_in_hk_item2" url="living_in_hk/whats_on.php">What\'s On</td>';
		htm += '    <td style="width:13px" align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/living_in_hk/arrow.gif" style="display:none" id="living_in_hk_item2_indicator"></td>';
		htm += '  </tr>';
		htm += '  <tr>';
		htm += '    <td class="general_text" style="padding-right:12px;padding-left:5px" id="living_in_hk_item3" url="living_in_hk/useful_information.php">Useful Information</td>';
		htm += '    <td style="width:13px" align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/living_in_hk/arrow.gif" style="display:none" id="living_in_hk_item3_indicator"></td>';
		htm += '  </tr>';*/
		htm += '  <tr>';
		htm += '    <td colspan="2" style="height:10px"></td>';
		htm += '  </tr>';
		htm += '</table>';
		this.div = document.createElement("DIV");
		this.div.style.display = "none";
		this.div.style.padding = "5px";
		this.div.style.backgroundColor = "F6F6EC";
		this.div.style.position = "absolute";
		this.div.style.zIndex = "10000";
		this.div.innerHTML = htm;

		document.body.appendChild(this.div);
		this.first_load = false;
		this.initializeAction();		
	},
	imgOnload : function ()
	{
			var left = this.controller.getOffset(this.img, true);
			var top = this.controller.getOffset(this.img, false);
	},
	postInitialize : function()
	{
		if(this.img != null)
		{
			this.img.onload = this.imgOnload.bindAsEventListener(this);
		}
	},
	initializeAction : function ()
	{
		Event.observe(this.div, "mouseover", this.menuOverListener.bindAsEventListener(this),true);
		this.div_over = false;
		this.mouse_move_listener = this.mouseMoveListener.bindAsEventListener(this);

		//this.tag_item = document.getElementsByClassName("company_item");
		//this.tmp_arr = [1,2,3];
		this.tmp_arr = [1,2,3,4,5,6,7,8,9];
		for(var i=0; i<this.tmp_arr.length; i++)
		{
			var obj = $("living_in_hk_item"+this.tmp_arr[i]);
			if(obj == null)
				continue;

			if(obj.id != null && obj.id.indexOf("living_in_hk_item") != -1)
			{
				Event.observe(obj, "click", this.itemClickListener.bindAsEventListener(this));
				Event.observe(obj, "mouseover", this.itemMouseoverListener.bindAsEventListener(this));
				Event.observe(obj, "mouseout", this.itemMouseoutListener.bindAsEventListener(this));
				obj.style.cursor = "pointer";
			}
		}
	},
	itemMouseoverListener : function(evt)
	{
		try{
		var ele = Event.element(evt);
		$(ele.id+"_indicator").style.display = "";
		}catch(e){}
	},
	itemMouseoutListener : function(evt)
	{
		try{
		var ele = Event.element(evt);
		$(ele.id+"_indicator").style.display = "none";
		}catch(e){}
	},
	itemClickListener : function(evt)
	{
		var ele = Event.element(evt);
		if($(ele).readAttribute("url") != null)
		{
			var url = sBasePath+$(ele).readAttribute("url");
			if(window.location.href != url)
				window.location.href = url;
		}
	},
	close : function()
	{


		this.img.src = this.mouseout_img;
		this.div.style.display = "none";
		//this.controller.showSelect();
		if(this.open_effect != null)
			this.open_effect.cancel();
		try{
		Event.stopObserving(document, "mousemove", this.mouse_move_listener);
		}catch(e){}

	},
	open : function()
	{

	},

	getResource : function()
	{

	},
	mouseMoveListener : function(evt)
	{

		var x = Event.pointerX(evt);
		var y = Event.pointerY(evt);

		if(
			!(x > this.menu_left && x < this.menu_left2 && y > this.menu_top && y < this.menu_top2)
			&&
			!(x > this.img_left && x < this.img_left2 && y > this.img_top && y < this.img_top2)
		)
		{
			/*this.img.src = this.mouseout_img;
			this.div.style.display = "none";
			Event.stopObserving(document, "mousemove", this.mouse_move_listener);*/
			this.close();
		}

	},
	onClickListener : function(evt)
	{
		//Effect.Pulsate(this.img, {pulses:1, duration:0.4});
		// window.location.href = sRelativePath+"living_in_hk/";
		Effect.Pulsate(this.img, {pulses:1, duration:0.4});
	},
	onDblClickListener : function(evt)
	{

	},
	onMouseoverListener : function(evt)
	{
		if(this.first_load)
		{
			this.initializeAction();
			this.first_load = false;
		}
		this.img.src = this.mouseover_img;
		this.controller.closeOthers(this);
		var left = this.controller.getOffset(this.img, true);
		var top = this.controller.getOffset(this.img, false);
		this.div.style.left = (left)+"px";
		this.div.style.top = (top+this.img.offsetHeight)+"px";

		//this.controller.hideSelect();

		this.div.style.display = "";
		//this.open_effect = Effect.Appear(this.div, {duration:0.4});
	},
	onMouseoutListener : function(evt)
	{
	},
	menuOverListener : function(evt)
	{
		this.menu_left = this.controller.getOffset(this.div, true);
		this.menu_top = this.controller.getOffset(this.div, false);
		this.menu_left2 = this.menu_left+this.div.offsetWidth;
		this.menu_top2 = this.menu_top+this.div.offsetHeight;

		this.img_left = this.controller.getOffset(this.img, true);
		this.img_top = this.controller.getOffset(this.img, false);
		this.img_left2 = this.img_left+this.img.offsetWidth;
		this.img_top2 = this.img_top+this.img.offsetHeight+2;
		//alert(this.img_left+" "+this.img_left2+" "+this.img_top+" "+this.img_top2);
		try{
		Event.stopObserving(document, "mousemove", this.mouse_move_listener);
		Event.observe(document, "mousemove", this.mouse_move_listener);
		}catch(e){}
	},
	menuOutListener : function(evt)
	{

	}
}
DEFAULT_TOOLBAR_ITEM.push(LivingInHKToolbarItem);

var ResourcesToolbarItem = Class.create();
ResourcesToolbarItem.prototype = {
	id : "resources", //*
	name : "Resources", //*
	img : null,
	//default_img : sBasePath+"images/home/menu_r234234esources_off.gif", //*
	default_img : sBasePath+"images/home/menu_resources_off.gif", //*
	on_img : sBasePath+"images/home/menu_resources_on.gif", //*
	off_img : sBasePath+"images/home/menu_resources_off.gif", //*
	mouseover_img : sBasePath+"images/home/menu_resources_over.gif", //*
	mouseout_img : sBasePath+"images/home/menu_resources_off.gif", //*
	initialize : function(controller)
	{
		this.controller = controller;
		var htm = '<table border="0" cellpadding="2" cellspacing="0" bgcolor="F6F6EC" class="general_tbl">';
		htm += '  <tr>';
		htm += '    <td class="general_text" style="padding-right:12px;padding-left:5px" id="resources_item1" url="resources/index.php"><a href="'+sBasePath+'resources/index.php"></a>Directory&nbsp;&nbsp;&nbsp;</td>';
		htm += '    <td style="width:13px" align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/resources/arrow.gif" style="display:none" id="resources_item1_indicator"></td>';
		htm += '  </tr>';
		htm += '  <tr>';
		htm += '    <td class="general_text" style="padding-right:12px;padding-left:5px" id="resources_item2" url="resources/category.php?id=38&cname=Business%20and%20Financial%20Services"><a href="'+sBasePath+'resources/category.php?id=38&cname=Business%20and%20Financial%20Services"></a>Business&nbsp;&&nbsp;Financial&nbsp;Services&nbsp;&nbsp;&nbsp;</td>';
		htm += '    <td style="width:13px" align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/resources/arrow.gif" style="display:none" id="resources_item2_indicator"></td>';
		htm += '  </tr>';
		htm += '  <tr>';
		htm += '    <td class="general_text" style="padding-right:12px;padding-left:5px" id="resources_item3" url="resources/directory.php?category=12">Domestic&nbsp;Helpers&nbsp;&nbsp;&nbsp;</td>';
		htm += '    <td style="width:13px" align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/resources/arrow.gif" style="display:none" id="resources_item3_indicator"></td>';
		htm += '  </tr>';
		htm += '  <tr>';
		htm += '    <td class="general_text" style="padding-right:12px;padding-left:5px" id="resources_item4" url="resources/category.php?id=81&cname=Essentials"><a href="'+sBasePath+'resources/category.php?id=81&cname=Essentials"></a>Essentials&nbsp;&nbsp;&nbsp;</td>';
		htm += '    <td style="width:13px" align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/resources/arrow.gif" style="display:none" id="resources_item4_indicator"></td>';
		htm += '  </tr>';
		htm += '  <tr>';
		htm += '    <td class="general_text" style="padding-right:12px;padding-left:5px" id="resources_item5" url="resources/directory.php?category=13"><a href="'+sBasePath+'resources/directory.php?category=13"></a>Moving&nbsp;Company&nbsp;&nbsp;&nbsp;</td>';
		htm += '    <td style="width:13px" align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/resources/arrow.gif" style="display:none" id="resources_item5_indicator"></td>';
		htm += '  </tr>';
		htm += '  <tr>';
		htm += '    <td class="general_text" style="padding-right:12px;padding-left:5px" id="resources_item6" url="resources/directory.php?category=9"><a href="'+sBasePath+'resources/directory.php?category=9"></a>International&nbsp;Schools&nbsp;&nbsp;&nbsp;</td>';
		htm += '    <td style="width:13px" align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/resources/arrow.gif" style="display:none" id="resources_item6_indicator"></td>';
		htm += '  </tr>';
		htm += '  <tr>';
		htm += '    <td class="general_text" style="padding-right:12px;padding-left:5px" id="resources_item7" url="resources/renting_guide.php"><a href="'+sBasePath+'resources/renting_guide.php"></a>Renting&nbsp;Guide&nbsp;&nbsp;&nbsp;</td>';
		htm += '    <td style="width:13px" align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/resources/arrow.gif" style="display:none" id="resources_item7_indicator"></td>';
		htm += '  </tr>';
		htm += '  <tr>';
		htm += '    <td class="general_text" style="padding-right:12px;padding-left:5px" id="resources_item8" url="resources/housing_districts.php"><a href="'+sBasePath+'resources/housing_districts.php"></a>Housing&nbsp;Districts&nbsp;&nbsp;&nbsp;</td>';
		htm += '    <td style="width:13px" align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/resources/arrow.gif" style="display:none" id="resources_item8_indicator"></td>';
		htm += '  </tr>';
		htm += '  <tr>';
		htm += '    <td class="general_text" style="padding-right:12px;padding-left:5px" id="resources_item9" url="resources/useful_info.php"><a href="'+sBasePath+'resources/category.php?id=10&cname=Home%20Furnishings"></a>Useful Information&nbsp;&nbsp;&nbsp;</td>';
		htm += '    <td style="width:13px" align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/resources/arrow.gif" style="display:none" id="resources_item9_indicator"></td>';
		htm += '  </tr>';
		/*htm += '  <tr>';
		htm += '    <td class="general_text" style="padding-right:12px;padding-left:5px" id="resources_item2" url="resources/whats_on.php">What\'s On</td>';
		htm += '    <td style="width:13px" align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/resources/arrow.gif" style="display:none" id="resources_item2_indicator"></td>';
		htm += '  </tr>';
		htm += '  <tr>';
		htm += '    <td class="general_text" style="padding-right:12px;padding-left:5px" id="resources_item3" url="resources/useful_information.php">Useful Information</td>';
		htm += '    <td style="width:13px" align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/resources/arrow.gif" style="display:none" id="resources_item3_indicator"></td>';
		htm += '  </tr>';*/
		htm += '  <tr>';
		htm += '    <td colspan="2" style="height:10px"></td>';
		htm += '  </tr>';
		htm += '</table>';
		this.div = document.createElement("DIV");
		this.div.style.display = "none";
		this.div.style.padding = "5px";
		this.div.style.backgroundColor = "F6F6EC";
		this.div.style.position = "absolute";
		this.div.style.zIndex = "10000";
		this.div.innerHTML = htm;

		this.new_div = document.createElement("div");
		this.new_div.style.width = "19px";
		this.new_div.style.height = "7px";
		this.new_div.style.position = "absolute";
		this.new_div.style.display = "none";
		this.new_div.innerHTML = "<img src='"+sBasePath+"images/new.gif' width='19px' height='7px'>";

		document.body.appendChild(this.div);
		document.body.appendChild(this.new_div);
		this.first_load = false;
		this.initializeAction();

	},
	imgOnload : function ()
	{
			var left = this.controller.getOffset(this.img, true);
			var top = this.controller.getOffset(this.img, false);
			this.new_div.style.display = "";
			this.new_div.style.left = (left+this.img.offsetWidth-23)+"px";
			this.new_div.style.top = (top+3)+"px";
	},
	postInitialize : function()
	{
		if(this.img != null)
		{
			/*var left = this.controller.getOffset(this.img, true);
			var top = this.controller.getOffset(this.img, false);
			this.new_div.style.display = "";
			this.new_div.style.left = (left+this.img.offsetWidth-23)+"px";
			this.new_div.style.top = (top+3)+"px";*/
			this.img.onload = this.imgOnload.bindAsEventListener(this);
		}
	},
	initializeAction : function ()
	{
		Event.observe(this.div, "mouseover", this.menuOverListener.bindAsEventListener(this),true);
		this.div_over = false;
		this.mouse_move_listener = this.mouseMoveListener.bindAsEventListener(this);

		//this.tag_item = document.getElementsByClassName("company_item");
		//this.tmp_arr = [1,2,3];
		this.tmp_arr = [1,2,3,4,5,6,7,8,9];
		for(var i=0; i<this.tmp_arr.length; i++)
		{
			var obj = $("resources_item"+this.tmp_arr[i]);
			if(obj == null)
				continue;

			if(obj.id != null && obj.id.indexOf("resources_item") != -1)
			{
				Event.observe(obj, "click", this.itemClickListener.bindAsEventListener(this));
				Event.observe(obj, "mouseover", this.itemMouseoverListener.bindAsEventListener(this));
				Event.observe(obj, "mouseout", this.itemMouseoutListener.bindAsEventListener(this));
				obj.style.cursor = "pointer";
			}
		}
	},
	itemMouseoverListener : function(evt)
	{
		try{
		var ele = Event.element(evt);
		$(ele.id+"_indicator").style.display = "";
		}catch(e){}
	},
	itemMouseoutListener : function(evt)
	{
		try{
		var ele = Event.element(evt);
		$(ele.id+"_indicator").style.display = "none";
		}catch(e){}
	},
	itemClickListener : function(evt)
	{
		var ele = Event.element(evt);
		if($(ele).readAttribute("url") != null)
		{
			var url = sBasePath+$(ele).readAttribute("url");
			if(window.location.href != url)
				window.location.href = url;
		}
	},
	close : function()
	{


		this.img.src = this.mouseout_img;
		this.div.style.display = "none";
		//this.controller.showSelect();
		if(this.open_effect != null)
			this.open_effect.cancel();
		try{
		Event.stopObserving(document, "mousemove", this.mouse_move_listener);
		}catch(e){}

	},
	open : function()
	{

	},

	getResource : function()
	{

	},
	mouseMoveListener : function(evt)
	{

		var x = Event.pointerX(evt);
		var y = Event.pointerY(evt);

		if(
			!(x > this.menu_left && x < this.menu_left2 && y > this.menu_top && y < this.menu_top2)
			&&
			!(x > this.img_left && x < this.img_left2 && y > this.img_top && y < this.img_top2)
		)
		{
			/*this.img.src = this.mouseout_img;
			this.div.style.display = "none";
			Event.stopObserving(document, "mousemove", this.mouse_move_listener);*/
			this.close();
		}

	},
	onClickListener : function(evt)
	{
		//Effect.Pulsate(this.img, {pulses:1, duration:0.4});
	},
	onDblClickListener : function(evt)
	{

	},
	onMouseoverListener : function(evt)
	{
		if(this.first_load)
		{
			this.initializeAction();
			this.first_load = false;
		}
		this.img.src = this.mouseover_img;
		this.controller.closeOthers(this);
		var left = this.controller.getOffset(this.img, true);
		var top = this.controller.getOffset(this.img, false);
		this.div.style.left = (left)+"px";
		this.div.style.top = (top+this.img.offsetHeight)+"px";

		//this.controller.hideSelect();

		this.div.style.display = "";
		//this.open_effect = Effect.Appear(this.div, {duration:0.4});
	},
	onMouseoutListener : function(evt)
	{
	},
	menuOverListener : function(evt)
	{
		this.menu_left = this.controller.getOffset(this.div, true);
		this.menu_top = this.controller.getOffset(this.div, false);
		this.menu_left2 = this.menu_left+this.div.offsetWidth;
		this.menu_top2 = this.menu_top+this.div.offsetHeight;

		this.img_left = this.controller.getOffset(this.img, true);
		this.img_top = this.controller.getOffset(this.img, false);
		this.img_left2 = this.img_left+this.img.offsetWidth;
		this.img_top2 = this.img_top+this.img.offsetHeight+2;
		//alert(this.img_left+" "+this.img_left2+" "+this.img_top+" "+this.img_top2);
		try{
		Event.stopObserving(document, "mousemove", this.mouse_move_listener);
		Event.observe(document, "mousemove", this.mouse_move_listener);
		}catch(e){}
	},
	menuOutListener : function(evt)
	{

	}
}
//DEFAULT_TOOLBAR_ITEM.push(ResourcesToolbarItem);

// var ExploreHKToolbarItem = Class.create();
// ExploreHKToolbarItem.prototype = {
	// id : "explore_hong_kong", 
	// name : "Explore Hong Kong", 
	// img : null,
// /*	default_img : sBasePath+"images/menu_explore_hk.jpg", 
	// on_img : sBasePath+"images/menu_explore_hk.jpg", 
	// off_img : sBasePath+"images/menu_explore_hk.jpg",
	// mouseover_img : sBasePath+"images/menu_explore_hk.jpg", 
	// mouseout_img : sBasePath+"images/menu_explore_hk.jpg", */
        // default_img : sBasePath+"images/home/menu_explore_hk_off.gif", 
        // on_img : sBasePath+"images/home/menu_explore_hk_on.gif", 
        // off_img : sBasePath+"images/home/menu_explore_hk_off.gif", 
        // mouseover_img : sBasePath+"images/home/menu_explore_hk_over.gif",
        // mouseout_img : sBasePath+"images/home/menu_explore_hk_off.gif",
	// initialize : function(controller)
	// {
		// this.controller = controller;
		// var htm = '<table border="0" cellpadding="2" cellspacing="0" bgcolor="F6F6EC" class="general_tbl">';
		// htm += '  <tr>';
		// htm += '    <td class="general_text company_item" style="padding-right:12px;padding-left:5px" id="explorehk_item1">Explore&nbsp;Hong&nbsp;Kong&nbsp;&nbsp;&nbsp;</td>';
		// htm += '    <td align="center" valign="middle" width="15px"><img align="absmiddle" src="'+sBasePath+'images/resources/arrow.gif" style="display:none" id="tools_item1_indicator"></td>';
		// htm += '  </tr>';

		// htm += '  <tr>';
		// htm += '    <td colspan="2" style="height:10px"></td>';
		// htm += '  </tr>';
		// htm += '</table>';
		// this.div = document.createElement("DIV");
		// this.div.style.display = "none";
		// this.div.style.padding = "5px";
		// this.div.style.backgroundColor = "F6F6EC";
		// this.div.style.position = "absolute";
		// this.div.style.zIndex = "10000";
		// this.div.innerHTML = htm;
		// Event.observe(this.div, "mouseover", this.menuOverListener.bindAsEventListener(this),true);
		// //Event.observe(this.div, "mouseout", this.menuOutListener.bindAsEventListener(this),true);
		// document.body.appendChild(this.div);
		// this.div_over = false;
		// this.mouse_move_listener = this.mouseMoveListener.bindAsEventListener(this);

		// Event.observe($("explorehk_item1"), "click", this.itemClickListener.bindAsEventListener(this));
		// Event.observe($("explorehk_item1"), "mouseover", this.itemMouseoverListener.bindAsEventListener(this));
		// Event.observe($("explorehk_item1"), "mouseout", this.itemMouseoutListener.bindAsEventListener(this));
		// $("explorehk_item1").style.cursor = "pointer";

// /*		Event.observe($("tools_item2"), "click", this.itemClickListener.bindAsEventListener(this));
		// Event.observe($("tools_item2"), "mouseover", this.itemMouseoverListener.bindAsEventListener(this));
		// Event.observe($("tools_item2"), "mouseout", this.itemMouseoutListener.bindAsEventListener(this));
		// $("tools_item2").style.cursor = "pointer";*/
	// },
	// itemMouseoverListener : function(evt)
	// {
		// try{
		// //var ele = Event.element(evt);
		// //$(ele.id+"_indicator").style.display = "";
		// }catch(e){}
	// },
	// itemMouseoutListener : function(evt)
	// {
		// try{
		// //var ele = Event.element(evt);
		// //$(ele.id+"_indicator").style.display = "none";
		// }catch(e){}
	// },
	// itemClickListener : function(evt)
	// {
		// var ele = Event.element(evt);

		// switch(ele)
		// {
			// case $("explorehk_item1"):
				// var url = sBasePath+"explore_hong_kong/";
				// if(window.location.href != url)
					// window.location.href = url;
				// //newWindowFixed("http://www.hongkonghomes.com/hong_kong_property/eng/mortgage_calc/index1.php", "",670,700);
				// break;
			// /*case $("tools_item2"):
				// var url = sBasePath+"tools/clipboard.php";
				// if(window.location.href != url)
					// window.location.href = url;
				// break;*/
		// }
	// },
	// close : function()
	// {
		// this.img.src = this.mouseout_img;
		// if(this.open_effect != null)
			// this.open_effect.cancel();
		// this.div.style.display = "none";
		// try{
		// Event.stopObserving(document, "mousemove", this.mouse_move_listener);
		// }catch(e){}
	// },
	// open : function()
	// {

	// },

	// getResource : function()
	// {

	// },
	// mouseMoveListener : function(evt)
	// {
// /*		var x = Event.pointerX(evt);
		// var y = Event.pointerY(evt);

		// if(
			// !(x > this.menu_left && x < this.menu_left2 && y > this.menu_top && y < this.menu_top2)
			// &&
			// !(x > this.img_left && x < this.img_left2 && y > this.img_top && y < this.img_top2)
		// )
		// {
			// this.img.src = this.mouseout_img;
			// //this.div.style.display = "none";
			// try{
			// //Event.stopObserving(document, "mousemove", this.mouse_move_listener);
			// }catch(e){}
		// }*/

	// },
	// onClickListener : function(evt)
	// {
		// //Effect.Pulsate(this.img, {pulses:1, duration:0.4});
				// var url = sBasePath+"explore_hong_kong/";
				// if(window.location.href != url)
					// window.location.href = url;		
	// },
	// onDblClickListener : function(evt)
	// {

	// },
	// onMouseoverListener : function(evt)
	// {
		// this.img.src = this.mouseover_img;
		// this.controller.closeOthers(this);
		// /*var left = this.controller.getOffset(this.img, true);
		// var top = this.controller.getOffset(this.img, false);
		// this.div.style.left = (left)+"px";
		// this.div.style.top = (top+this.img.offsetHeight)+"px";
		// this.div.style.display = "";*/
		// //this.open_effect = Effect.Appear(this.div, {duration:0.4});
	// },
	// onMouseoutListener : function(evt)
	// {
		 // this.img.src = this.mouseout_img;
	// },
	// menuOverListener : function(evt)
	// {
		// this.menu_left = this.controller.getOffset(this.div, true);
		// this.menu_top = this.controller.getOffset(this.div, false);
		// this.menu_left2 = this.menu_left+this.div.offsetWidth;
		// this.menu_top2 = this.menu_top+this.div.offsetHeight;

		// this.img_left = this.controller.getOffset(this.img, true);
		// this.img_top = this.controller.getOffset(this.img, false);
		// this.img_left2 = this.img_left+this.img.offsetWidth;
		// this.img_top2 = this.img_top+this.img.offsetHeight+2;
		// //alert(this.img_left+" "+this.img_left2+" "+this.img_top+" "+this.img_top2);
		// try{
		// Event.stopObserving(document, "mousemove", this.mouse_move_listener);
		// Event.observe(document, "mousemove", this.mouse_move_listener);
		// }catch(e){}
	// },
	// menuOutListener : function(evt)
	// {
		
	// }
// }
// DEFAULT_TOOLBAR_ITEM.push(ExploreHKToolbarItem);

var HomesAndLivingToolbarItem = Class.create();
HomesAndLivingToolbarItem.prototype = {
	id : "homes_and_living", //*
	name : "Homes and Living", //*
	img : null,
	default_img : sBasePath+"images/home/menu_living_off.gif", //*
	on_img : sBasePath+"images/home/menu_living_on.gif", //*
	off_img : sBasePath+"images/home/menu_living_off.gif", //*
	mouseover_img : sBasePath+"images/home/menu_living_over.gif", //*
	mouseout_img : sBasePath+"images/home/menu_living_off.gif", //*
	initialize : function(controller)
	{
		this.controller = controller;
		var htm = '<table border="0" cellpadding="2" cellspacing="0" bgcolor="F6F6EC" class="general_tbl">';
		htm += '  <tr>';
		htm += '    <td class="general_text" style="padding-right:12px;padding-left:5px" id="homes_and_living_item8" url="homes_and_living/">Introduction&nbsp;&nbsp;&nbsp;</td>';
		htm += '    <td style="width:13px" align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/resources/arrow.gif" style="display:none" id="homes_and_living_item8_indicator"></td>';
		htm += '  </tr>';
		htm += '  <tr>';
		htm += '    <td class="general_text" style="padding-right:12px;padding-left:5px" id="homes_and_living_item1" url="living_in_hk/directory/index.htm"><a href="'+sBasePath+'living_in_hk/directory/index.htm"></a>Directory&nbsp;&nbsp;&nbsp;</td>';
		htm += '    <td style="width:13px" align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/living_in_hk/arrow.gif" style="display:none" id="homes_and_living_item1_indicator"></td>';
		htm += '  </tr>';
		htm += '  <tr>';
		htm += '    <td class="general_text" style="padding-right:12px;padding-left:5px" id="homes_and_living_item2" url="living_in_hk/featured_article/article_list.htm"><a href="'+sBasePath+'living_in_hk/featured_article/article_list.htm"></a>Featured&nbsp;Articles&nbsp;&nbsp;&nbsp;</td>';
		htm += '    <td style="width:13px" align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/living_in_hk/arrow.gif" style="display:none" id="homes_and_living_item2_indicator"></td>';
		htm += '  </tr>';
		htm += '  <tr>';
		htm += '    <td class="general_text" style="padding-right:12px;padding-left:5px" id="homes_and_living_item3" url="living_in_hk/goods_and_services/index.htm"><a href="'+sBasePath+'living_in_hk/goods_and_services/index.htm"></a>Goods&nbsp;&&nbsp;Services&nbsp;&nbsp;&nbsp;</td>';
		htm += '    <td style="width:13px" align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/living_in_hk/arrow.gif" style="display:none" id="homes_and_living_item3_indicator"></td>';
		htm += '  </tr>';
		// htm += '  <tr>';
		// htm += '    <td class="general_text" style="padding-right:12px;padding-left:5px" id="living_in_hk_item4" url="living_in_hk/housing_districts/overview.htm"><a href="'+sBasePath+'living_in_hk/housing_districts/overview.htm"></a>Housing&nbsp;Districts&nbsp;&nbsp;&nbsp;</td>';
		// htm += '    <td style="width:13px" align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/living_in_hk/arrow.gif" style="display:none" id="living_in_hk_item4_indicator"></td>';
		// htm += '  </tr>';
		// htm += '  <tr>';
		// htm += '    <td class="general_text" style="padding-right:12px;padding-left:5px" id="living_in_hk_item5" url="living_in_hk/useful_info.php"><a href="'+sBasePath+'living_in_hk/useful_info.php"></a>Useful&nbsp;Information&nbsp;&nbsp;&nbsp;</td>';
		// htm += '    <td style="width:13px" align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/living_in_hk/arrow.gif" style="display:none" id="living_in_hk_item6_indicator"></td>';
		// htm += '  </tr>';
		// htm += '  <tr>';
		// htm += '    <td class="general_text" style="padding-right:12px;padding-left:5px" id="living_in_hk_item7" url="living_in_hk/renting_guide.php"><a href="'+sBasePath+'living_in_hk/renting_guide.php"></a>Renting&nbsp;Guide&nbsp;&nbsp;&nbsp;</td>';
		// htm += '    <td style="width:13px" align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/living_in_hk/arrow.gif" style="display:none" id="living_in_hk_item7_indicator"></td>';
		// htm += '  </tr>';

		/*htm += '  <tr>';
		htm += '    <td class="general_text" style="padding-right:12px;padding-left:5px" id="living_in_hk_item2" url="living_in_hk/whats_on.php">What\'s On</td>';
		htm += '    <td style="width:13px" align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/living_in_hk/arrow.gif" style="display:none" id="living_in_hk_item2_indicator"></td>';
		htm += '  </tr>';
		htm += '  <tr>';
		htm += '    <td class="general_text" style="padding-right:12px;padding-left:5px" id="living_in_hk_item3" url="living_in_hk/useful_information.php">Useful Information</td>';
		htm += '    <td style="width:13px" align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/living_in_hk/arrow.gif" style="display:none" id="living_in_hk_item3_indicator"></td>';
		htm += '  </tr>';*/
		htm += '  <tr>';
		htm += '    <td colspan="2" style="height:10px"></td>';
		htm += '  </tr>';
		htm += '</table>';
		this.div = document.createElement("DIV");
		this.div.style.display = "none";
		this.div.style.padding = "5px";
		this.div.style.backgroundColor = "F6F6EC";
		this.div.style.position = "absolute";
		this.div.style.zIndex = "10000";
		this.div.innerHTML = htm;

		document.body.appendChild(this.div);
		this.first_load = false;
		this.initializeAction();		
	},
	imgOnload : function ()
	{
			var left = this.controller.getOffset(this.img, true);
			var top = this.controller.getOffset(this.img, false);
	},
	postInitialize : function()
	{
		if(this.img != null)
		{
			this.img.onload = this.imgOnload.bindAsEventListener(this);
		}
	},
	initializeAction : function ()
	{
		Event.observe(this.div, "mouseover", this.menuOverListener.bindAsEventListener(this),true);
		this.div_over = false;
		this.mouse_move_listener = this.mouseMoveListener.bindAsEventListener(this);

		//this.tag_item = document.getElementsByClassName("company_item");
		//this.tmp_arr = [1,2,3];
		this.tmp_arr = [1,2,3,4,5,6,7,8,9];
		for(var i=0; i<this.tmp_arr.length; i++)
		{
			var obj = $("homes_and_living_item"+this.tmp_arr[i]);
			if(obj == null)
				continue;

			if(obj.id != null && obj.id.indexOf("homes_and_living_item") != -1)
			{
				Event.observe(obj, "click", this.itemClickListener.bindAsEventListener(this));
				Event.observe(obj, "mouseover", this.itemMouseoverListener.bindAsEventListener(this));
				Event.observe(obj, "mouseout", this.itemMouseoutListener.bindAsEventListener(this));
				obj.style.cursor = "pointer";
			}
		}
	},
	itemMouseoverListener : function(evt)
	{
		try{
		var ele = Event.element(evt);
		$(ele.id+"_indicator").style.display = "";
		}catch(e){}
	},
	itemMouseoutListener : function(evt)
	{
		try{
		var ele = Event.element(evt);
		$(ele.id+"_indicator").style.display = "none";
		}catch(e){}
	},
	itemClickListener : function(evt)
	{
		var ele = Event.element(evt);
		if($(ele).readAttribute("url") != null)
		{
			var url = sBasePath+$(ele).readAttribute("url");
			if(window.location.href != url)
				window.location.href = url;
		}
	},
	close : function()
	{


		this.img.src = this.mouseout_img;
		this.div.style.display = "none";
		//this.controller.showSelect();
		if(this.open_effect != null)
			this.open_effect.cancel();
		try{
		Event.stopObserving(document, "mousemove", this.mouse_move_listener);
		}catch(e){}

	},
	open : function()
	{

	},

	getResource : function()
	{

	},
	mouseMoveListener : function(evt)
	{

		var x = Event.pointerX(evt);
		var y = Event.pointerY(evt);

		if(
			!(x > this.menu_left && x < this.menu_left2 && y > this.menu_top && y < this.menu_top2)
			&&
			!(x > this.img_left && x < this.img_left2 && y > this.img_top && y < this.img_top2)
		)
		{
			/*this.img.src = this.mouseout_img;
			this.div.style.display = "none";
			Event.stopObserving(document, "mousemove", this.mouse_move_listener);*/
			this.close();
		}

	},
	onClickListener : function(evt)
	{
		//Effect.Pulsate(this.img, {pulses:1, duration:0.4});
		window.location.href = sRelativePath+"homes_and_living/";
	},
	onDblClickListener : function(evt)
	{

	},
	onMouseoverListener : function(evt)
	{
		if(this.first_load)
		{
			this.initializeAction();
			this.first_load = false;
		}
		this.img.src = this.mouseover_img;
		this.controller.closeOthers(this);
		var left = this.controller.getOffset(this.img, true);
		var top = this.controller.getOffset(this.img, false);
		this.div.style.left = (left)+"px";
		this.div.style.top = (top+this.img.offsetHeight)+"px";

		//this.controller.hideSelect();

		this.div.style.display = "";
		//this.open_effect = Effect.Appear(this.div, {duration:0.4});
	},
	onMouseoutListener : function(evt)
	{
	},
	menuOverListener : function(evt)
	{
		this.menu_left = this.controller.getOffset(this.div, true);
		this.menu_top = this.controller.getOffset(this.div, false);
		this.menu_left2 = this.menu_left+this.div.offsetWidth;
		this.menu_top2 = this.menu_top+this.div.offsetHeight;

		this.img_left = this.controller.getOffset(this.img, true);
		this.img_top = this.controller.getOffset(this.img, false);
		this.img_left2 = this.img_left+this.img.offsetWidth;
		this.img_top2 = this.img_top+this.img.offsetHeight+2;
		//alert(this.img_left+" "+this.img_left2+" "+this.img_top+" "+this.img_top2);
		try{
		Event.stopObserving(document, "mousemove", this.mouse_move_listener);
		Event.observe(document, "mousemove", this.mouse_move_listener);
		}catch(e){}
	},
	menuOutListener : function(evt)
	{

	}
}
DEFAULT_TOOLBAR_ITEM.push(HomesAndLivingToolbarItem);

var ToolsToolbarItem = Class.create();
ToolsToolbarItem.prototype = {
	id : "tools", //*
	name : "Tools", //*
	img : null,
	default_img : sBasePath+"images/home/menu_tools_off.gif", //*
	on_img : sBasePath+"images/home/menu_tools_on.gif", //*
	off_img : sBasePath+"images/home/menu_tools_off.gif", //*
	mouseover_img : sBasePath+"images/home/menu_tools_over.gif", //*
	mouseout_img : sBasePath+"images/home/menu_tools_off.gif", //*
	initialize : function(controller)
	{
		this.controller = controller;
		var htm = '<table border="0" cellpadding="2" cellspacing="0" bgcolor="F6F6EC" class="general_tbl">';
		htm += '  <tr>';
		htm += '    <td class="general_text company_item" style="padding-right:12px;padding-left:5px" id="tools_item1">Mortgage&nbsp;Calculator&nbsp;&nbsp;&nbsp;</td>';
		htm += '    <td align="center" valign="middle" width="15px"><img align="absmiddle" src="'+sBasePath+'images/resources/arrow.gif" style="display:none" id="tools_item1_indicator"></td>';
		htm += '  </tr>';
		/*htm += '  <tr>';
		htm += '    <td class="general_text company_item" style="padding-right:12px;padding-left:5px" id="tools_item1">Property Comparison</td>';
		htm += '    <td style="width:13px" align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/resources/arrow.gif" style="display:none" id="tools_item1_indicator"></td>';
		htm += '  </tr>';*/
		htm += '  <tr>';
		htm += '    <td colspan="2" style="height:10px"></td>';
		htm += '  </tr>';
		htm += '</table>';
		this.div = document.createElement("DIV");
		this.div.style.display = "none";
		this.div.style.padding = "5px";
		this.div.style.backgroundColor = "F6F6EC";
		this.div.style.position = "absolute";
		this.div.style.zIndex = "10000";
		this.div.innerHTML = htm;
		Event.observe(this.div, "mouseover", this.menuOverListener.bindAsEventListener(this),true);
		//Event.observe(this.div, "mouseout", this.menuOutListener.bindAsEventListener(this),true);
		document.body.appendChild(this.div);
		this.div_over = false;
		this.mouse_move_listener = this.mouseMoveListener.bindAsEventListener(this);

		Event.observe($("tools_item1"), "click", this.itemClickListener.bindAsEventListener(this));
		Event.observe($("tools_item1"), "mouseover", this.itemMouseoverListener.bindAsEventListener(this));
		Event.observe($("tools_item1"), "mouseout", this.itemMouseoutListener.bindAsEventListener(this));
		$("tools_item1").style.cursor = "pointer";

/*		Event.observe($("tools_item2"), "click", this.itemClickListener.bindAsEventListener(this));
		Event.observe($("tools_item2"), "mouseover", this.itemMouseoverListener.bindAsEventListener(this));
		Event.observe($("tools_item2"), "mouseout", this.itemMouseoutListener.bindAsEventListener(this));
		$("tools_item2").style.cursor = "pointer";*/
	},
	itemMouseoverListener : function(evt)
	{
		try{
		var ele = Event.element(evt);
		$(ele.id+"_indicator").style.display = "";
		}catch(e){}
	},
	itemMouseoutListener : function(evt)
	{
		try{
		var ele = Event.element(evt);
		$(ele.id+"_indicator").style.display = "none";
		}catch(e){}
	},
	itemClickListener : function(evt)
	{
		var ele = Event.element(evt);

		switch(ele)
		{
			case $("tools_item1"):
				/*var url = sBasePath+"tools/mortgage_cal.php";
				if(window.location.href != url)
					window.location.href = url;*/
				newWindowFixed("http://www.hongkonghomes.com/hong_kong_property/eng/mortgage_calc/index1.php", "",670,700);
				break;
			/*case $("tools_item2"):
				var url = sBasePath+"tools/clipboard.php";
				if(window.location.href != url)
					window.location.href = url;
				break;*/
		}
	},
	close : function()
	{
		this.img.src = this.mouseout_img;
		if(this.open_effect != null)
			this.open_effect.cancel();
		this.div.style.display = "none";
		try{
		Event.stopObserving(document, "mousemove", this.mouse_move_listener);
		}catch(e){}
	},
	open : function()
	{

	},

	getResource : function()
	{

	},
	mouseMoveListener : function(evt)
	{
		var x = Event.pointerX(evt);
		var y = Event.pointerY(evt);

		if(
			!(x > this.menu_left && x < this.menu_left2 && y > this.menu_top && y < this.menu_top2)
			&&
			!(x > this.img_left && x < this.img_left2 && y > this.img_top && y < this.img_top2)
		)
		{
			this.img.src = this.mouseout_img;
			this.div.style.display = "none";
			try{
			Event.stopObserving(document, "mousemove", this.mouse_move_listener);
			}catch(e){}
		}

	},
	onClickListener : function(evt)
	{
		Effect.Pulsate(this.img, {pulses:1, duration:0.4});
	},
	onDblClickListener : function(evt)
	{

	},
	onMouseoverListener : function(evt)
	{
		this.img.src = this.mouseover_img;
		this.controller.closeOthers(this);
		var left = this.controller.getOffset(this.img, true);
		var top = this.controller.getOffset(this.img, false);
		this.div.style.left = (left)+"px";
		this.div.style.top = (top+this.img.offsetHeight)+"px";
		this.div.style.display = "";
		//this.open_effect = Effect.Appear(this.div, {duration:0.4});
	},
	onMouseoutListener : function(evt)
	{
	},
	menuOverListener : function(evt)
	{
		this.menu_left = this.controller.getOffset(this.div, true);
		this.menu_top = this.controller.getOffset(this.div, false);
		this.menu_left2 = this.menu_left+this.div.offsetWidth;
		this.menu_top2 = this.menu_top+this.div.offsetHeight;

		this.img_left = this.controller.getOffset(this.img, true);
		this.img_top = this.controller.getOffset(this.img, false);
		this.img_left2 = this.img_left+this.img.offsetWidth;
		this.img_top2 = this.img_top+this.img.offsetHeight+2;
		//alert(this.img_left+" "+this.img_left2+" "+this.img_top+" "+this.img_top2);
		try{
		Event.stopObserving(document, "mousemove", this.mouse_move_listener);
		Event.observe(document, "mousemove", this.mouse_move_listener);
		}catch(e){}
	},
	menuOutListener : function(evt)
	{

	}
}
// DEFAULT_TOOLBAR_ITEM.push(ToolsToolbarItem);

var MyPageToolbarItem = Class.create();
MyPageToolbarItem.prototype = {
	id : "my_page", //*
	name : "My Page", //*
	img : null,
	default_img : sBasePath+"images/home/menu_my_page_off.gif", //*
	on_img : sBasePath+"images/home/menu_my_page_on.gif", //*
	off_img : sBasePath+"images/home/menu_my_page_off.gif", //*
	mouseover_img : sBasePath+"images/home/menu_my_page_over.gif", //*
	mouseout_img : sBasePath+"images/home/menu_my_page_off.gif", //*
	initialize : function(controller)
	{
		this.controller = controller;
		return;
		var htm = '<table border="0" cellpadding="2" cellspacing="0" bgcolor="F6F6EC" class="general_tbl">';
		/*htm += '  <tr>';
		htm += '    <td class="general_text company_item" style="padding-right:12px;padding-left:5px" id="mypage_item2">Clipboard</td>';
		htm += '    <td align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/resources/arrow.gif" style="display:none" id="mypage_item2_indicator"></td>';
		htm += '  </tr>';	*/
		/*htm += '  <tr>';
		htm += '    <td class="general_text company_item" style="padding-right:12px;padding-left:5px" id="mypage_item1">Login</td>';
		htm += '    <td style="width:13px" align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/resources/arrow.gif" style="display:none" id="mypage_item1_indicator"></td>';
		htm += '  </tr>';*/
		htm += '  <tr>';
		htm += '    <td class="general_text company_item" style="padding-right:12px;padding-left:5px" id="mypage_item4">My Profile</td>';
		htm += '    <td style="width:13px" align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/resources/arrow.gif" style="display:none" id="mypage_item4_indicator"></td>';
		htm += '  </tr>';
		htm += '  <tr>';
		htm += '    <td class="general_text company_item" style="padding-right:12px;padding-left:5px" id="mypage_item2">My Property</td>';
		htm += '    <td style="width:13px" align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/resources/arrow.gif" style="display:none" id="mypage_item2_indicator"></td>';
		htm += '  </tr>';
		htm += '  <tr>';
		htm += '    <td class="general_text company_item" style="padding-right:12px;padding-left:5px" id="mypage_item3">After Sale Service</td>';
		htm += '    <td style="width:13px" align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/resources/arrow.gif" style="display:none" id="mypage_item3_indicator"></td>';
		htm += '  </tr>';
		htm += '  <tr style="display:none" id="mypage_logout">';
		htm += '    <td class="general_text company_item" style="padding-right:12px;padding-left:5px" id="mypage_item5">Logout</td>';
		htm += '    <td style="width:13px" align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/resources/arrow.gif" style="display:none" id="mypage_item5_indicator"></td>';
		htm += '  </tr>';
		htm += '  <tr>';
		htm += '    <td colspan="2" style="height:10px"></td>';
		htm += '  </tr>';
		htm += '</table>';
		this.div = document.createElement("DIV");
		this.div.style.display = "none";
		this.div.style.padding = "5px";
		this.div.style.backgroundColor = "F6F6EC";
		this.div.style.position = "absolute";
		this.div.style.zIndex = "10000";
		this.div.innerHTML = htm;
		Event.observe(this.div, "mouseover", this.menuOverListener.bindAsEventListener(this),true);
		//Event.observe(this.div, "mouseout", this.menuOutListener.bindAsEventListener(this),true);
		document.body.appendChild(this.div);
		this.div_over = false;
		this.mouse_move_listener = this.mouseMoveListener.bindAsEventListener(this);

		var mypage_arr = [2,3,4,5];
		for(var i=0; i < mypage_arr.length; i++)
		{
			Event.observe($("mypage_item"+mypage_arr[i]), "click", this.itemClickListener.bindAsEventListener(this));
			Event.observe($("mypage_item"+mypage_arr[i]), "mouseover", this.itemMouseoverListener.bindAsEventListener(this));
			Event.observe($("mypage_item"+mypage_arr[i]), "mouseout", this.itemMouseoutListener.bindAsEventListener(this));
			$("mypage_item"+mypage_arr[i]).style.cursor = "pointer";
		}
		/*Event.observe($("mypage_item1"), "click", this.itemClickListener.bindAsEventListener(this));
		Event.observe($("mypage_item1"), "mouseover", this.itemMouseoverListener.bindAsEventListener(this));
		Event.observe($("mypage_item1"), "mouseout", this.itemMouseoutListener.bindAsEventListener(this));
		$("mypage_item1").style.cursor = "pointer";*/

		/*Event.observe($("tools_item2"), "click", this.itemClickListener.bindAsEventListener(this));
		Event.observe($("tools_item2"), "mouseover", this.itemMouseoverListener.bindAsEventListener(this));
		Event.observe($("tools_item2"), "mouseout", this.itemMouseoutListener.bindAsEventListener(this));
		$("tools_item2").style.cursor = "pointer";*/
		if(typeof(IS_LOGIN) != "undefined" && typeof(IS_PRISM_LOGIN) != "undefined")
		{
			if(IS_LOGIN || IS_PRISM_LOGIN)
				this.showLogout();
		}
	},
	hideLogout : function()
	{
		$("mypage_logout").style.display = "none";
	},
	showLogout : function()
	{
		$("mypage_logout").style.display = "";
	},
	itemMouseoverListener : function(evt)
	{
		try{
		var ele = Event.element(evt);
		$(ele.id+"_indicator").style.display = "";
		}catch(e){}
	},
	itemMouseoutListener : function(evt)
	{
		try{
		var ele = Event.element(evt);
		$(ele.id+"_indicator").style.display = "none";
		}catch(e){}
	},
	itemClickListener : function(evt)
	{
		var ele = Event.element(evt);

		switch(ele)
		{
			case $("mypage_item1"):
				var url = sBasePath+"my_page/login.php";
				if(window.location.href != url)
					window.location.href = url;
				break;
			case $("mypage_item2"):
				var url = sBasePath+"my_page/my_property.php";
				if(window.location.href != url)
					window.location.href = url;
				break;
			case $("mypage_item3"):
				var url = sBasePath+"my_page/after_sale_service.php";
				if(window.location.href != url)
					window.location.href = url;
				break;
			case $("mypage_item4"):
				var url = sBasePath+"my_page/my_profile.php";
				if(window.location.href != url)
					window.location.href = url;
				break;
			case $("mypage_item5"):
				var url = sBasePath+"my_page/logout.php";
				if(window.location.href != url)
					window.location.href = url;
				break;
		}
	},
	close : function()
	{
		this.img.src = this.mouseout_img;
		// if(this.open_effect != null)
			// this.open_effect.cancel();
		// this.div.style.display = "none";
		// try{
		// Event.stopObserving(document, "mousemove", this.mouse_move_listener);
		// }catch(e){}
	},
	open : function()
	{

	},

	getResource : function()
	{

	},
	mouseMoveListener : function(evt)
	{
		var x = Event.pointerX(evt);
		var y = Event.pointerY(evt);

		if(
			// !(x > this.menu_left && x < this.menu_left2 && y > this.menu_top && y < this.menu_top2)
			// &&
			!(x > this.img_left && x < this.img_left2 && y > this.img_top && y < this.img_top2)
		)
		{
			this.img.src = this.mouseout_img;
			// this.div.style.display = "none";
			try{
			Event.stopObserving(document, "mousemove", this.mouse_move_listener);
			}catch(e){}
		}

	},
	onClickListener : function(evt)
	{
		//Effect.Pulsate(this.img, {pulses:1, duration:0.4});
		// var url = parseUri(window.location.href);
		
		window.location.href = ((sBasePath=="")?"my_page/":sBasePath+"my_page/")+"my_page.php";
	},
	onDblClickListener : function(evt)
	{

	},
	onMouseoverListener : function(evt)
	{
		this.img.src = this.mouseover_img;
		this.controller.closeOthers(this);
		// var left = this.controller.getOffset(this.img, true);
		// var top = this.controller.getOffset(this.img, false);
		// this.div.style.left = (left)+"px";
		// this.div.style.top = (top+this.img.offsetHeight)+"px";
		// this.div.style.display = "";
		//this.open_effect = Effect.Appear(this.div, {duration:0.4});
	},
	onMouseoutListener : function(evt)
	{
		this.img.src = this.mouseout_img;
	},
	menuOverListener : function(evt)
	{
		// this.menu_left = this.controller.getOffset(this.div, true);
		// this.menu_top = this.controller.getOffset(this.div, false);
		// this.menu_left2 = this.menu_left+this.div.offsetWidth;
		// this.menu_top2 = this.menu_top+this.div.offsetHeight;

		this.img_left = this.controller.getOffset(this.img, true);
		this.img_top = this.controller.getOffset(this.img, false);
		this.img_left2 = this.img_left+this.img.offsetWidth;
		this.img_top2 = this.img_top+this.img.offsetHeight+2;
		//alert(this.img_left+" "+this.img_left2+" "+this.img_top+" "+this.img_top2);
		try{
		Event.stopObserving(document, "mousemove", this.mouse_move_listener);
		Event.observe(document, "mousemove", this.mouse_move_listener);
		}catch(e){}
	},
	menuOutListener : function(evt)
	{

	}
}
DEFAULT_TOOLBAR_ITEM.push(MyPageToolbarItem); // put my_page to last

var CompanyToolbarItem = Class.create();
CompanyToolbarItem.prototype = {
	id : "company", //*
	name : "Company", //*
	img : null,
	default_img : sBasePath+"images/home/menu_company_off.gif", //*
	on_img : sBasePath+"images/home/menu_company_on.gif", //*
	off_img : sBasePath+"images/home/menu_company_off.gif", //*
	mouseover_img : sBasePath+"images/home/menu_company_over.gif", //*
	mouseout_img : sBasePath+"images/home/menu_company_off.gif", //*
	initialize : function(controller)
	{
		this.controller = controller;
		var htm = '<table border="0" cellpadding="2" cellspacing="0" bgcolor="F6F6EC" class="general_tbl">';
		htm += '  <tr>';
		htm += '    <td class="general_text company_item" style="padding-right:12px;padding-left:5px" id="company_item1" url="company/about_us.php">About us</td>';
		htm += '    <td align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/resources/arrow.gif" style="display:none" id="company_item1_indicator"></td>';
		htm += '  </tr>';
		// htm += '  <tr>';
		// htm += '    <td class="general_text company_item" style="padding-right:12px;padding-left:5px" id="company_item2" url="company/events_activities.php">Events & Activities</td>';
		// htm += '    <td style="width:13px" align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/resources/arrow.gif" style="display:none" id="company_item2_indicator"></td>';
		// htm += '  </tr>';
		// htm += '  <tr>';
		// htm += '    <td class="general_text company_item" style="padding-right:12px;padding-left:5px" id="company_item3" url="company/news_analyses.php">News & Analyses</td>';
		// htm += '    <td style="width:13px" align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/resources/arrow.gif" style="display:none" id="company_item3_indicator"></td>';
		// htm += '  </tr>';
		// htm += '  <tr>';
		// htm += '    <td class="general_text company_item" style="padding-right:12px;padding-left:5px" id="company_item4" url="company/newsletters.php">Newsletters</td>';
		// htm += '    <td style="width:13px" align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/resources/arrow.gif" style="display:none" id="company_item4_indicator"></td>';
		// htm += '  </tr>';
		htm += '  <tr>';
		htm += '    <td class="general_text company_item" style="padding-right:12px;padding-left:5px" id="company_item5" url="company/careers.php">Careers</td>';
		htm += '    <td style="width:13px" align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/resources/arrow.gif" style="display:none" id="company_item5_indicator"></td>';
		htm += '  </tr>';
		htm += '  <tr>';
		htm += '    <td colspan="2" style="height:10px"></td>';
		htm += '  </tr>';
		htm += '</table>';
		this.div = document.createElement("DIV");
		this.div.style.display = "none";
		this.div.style.padding = "5px";
		this.div.style.backgroundColor = "F6F6EC";
		this.div.style.position = "absolute";
		this.div.style.zIndex = "10000";
		this.div.innerHTML = htm;

		//Event.observe(this.div, "mouseout", this.menuOutListener.bindAsEventListener(this),true);
		document.body.appendChild(this.div);

		this.first_load = false;
		this.initializeAction();
	},
	initializeAction : function ()
	{
		Event.observe(this.div, "mouseover", this.menuOverListener.bindAsEventListener(this),true);
		this.div_over = false;
		this.mouse_move_listener = this.mouseMoveListener.bindAsEventListener(this);

		//this.tag_item = document.getElementsByClassName("company_item");
		this.tmp_arr = [1,2,3,4,5];
		for(var i=0; i<this.tmp_arr.length; i++)
		{
			var obj = $("company_item"+this.tmp_arr[i]);
			if(obj == null)
				continue;

			if(obj.id != null && obj.id.indexOf("company_item") != -1)
			{
				Event.observe(obj, "click", this.itemClickListener.bindAsEventListener(this));
				Event.observe(obj, "mouseover", this.itemMouseoverListener.bindAsEventListener(this));
				Event.observe(obj, "mouseout", this.itemMouseoutListener.bindAsEventListener(this));
				obj.style.cursor = "pointer";
			}
		}
	},
	itemMouseoverListener : function(evt)
	{
		try{
		var ele = Event.element(evt);
		$(ele.id+"_indicator").style.display = "";
		}catch(e){}
	},
	itemMouseoutListener : function(evt)
	{
		try{
		var ele = Event.element(evt);
		$(ele.id+"_indicator").style.display = "none";
		}catch(e){}
	},
	itemClickListener : function(evt)
	{
		var ele = Event.element(evt);
		if($(ele).readAttribute("url") != null)
		{
			var url = sBasePath+$(ele).readAttribute("url");
			if(window.location.href != url)
				window.location.href = url;
		}
	},
	close : function()
	{
		this.img.src = this.mouseout_img;
		if(this.open_effect != null)
			this.open_effect.cancel();
		this.div.style.display = "none";
		try{
		Event.stopObserving(document, "mousemove", this.mouse_move_listener);
		}catch(e){}
	},
	open : function()
	{

	},

	getResource : function()
	{

	},
	mouseMoveListener : function(evt)
	{

		var x = Event.pointerX(evt);
		var y = Event.pointerY(evt);

		if(
			!(x > this.menu_left && x < this.menu_left2 && y > this.menu_top && y < this.menu_top2)
			&&
			!(x > this.img_left && x < this.img_left2 && y > this.img_top && y < this.img_top2)
		)
		{
			this.img.src = this.mouseout_img;
			this.div.style.display = "none";
			try{
			Event.stopObserving(document, "mousemove", this.mouse_move_listener);
			}catch(e){}
		}

	},
	onClickListener : function(evt)
	{
		Effect.Pulsate(this.img, {pulses:1, duration:0.4});
	},
	onDblClickListener : function(evt)
	{

	},
	onMouseoverListener : function(evt)
	{
		if(this.first_load)
		{
			this.initializeAction();
			this.first_load = false;
		}
		this.img.src = this.mouseover_img;
		this.controller.closeOthers(this);
		var left = this.controller.getOffset(this.img, true);
		var top = this.controller.getOffset(this.img, false);
		this.div.style.left = (left)+"px";
		this.div.style.top = (top+this.img.offsetHeight)+"px";
		this.div.style.display = "";
		//this.open_effect = Effect.Appear(this.div, {duration:0.4});
	},
	onMouseoutListener : function(evt)
	{
	},
	menuOverListener : function(evt)
	{
		this.menu_left = this.controller.getOffset(this.div, true);
		this.menu_top = this.controller.getOffset(this.div, false);
		this.menu_left2 = this.menu_left+this.div.offsetWidth;
		this.menu_top2 = this.menu_top+this.div.offsetHeight;

		this.img_left = this.controller.getOffset(this.img, true);
		this.img_top = this.controller.getOffset(this.img, false);
		this.img_left2 = this.img_left+this.img.offsetWidth;
		this.img_top2 = this.img_top+this.img.offsetHeight+2;
		//alert(this.img_left+" "+this.img_left2+" "+this.img_top+" "+this.img_top2);
		try{
		Event.stopObserving(document, "mousemove", this.mouse_move_listener);
		Event.observe(document, "mousemove", this.mouse_move_listener);
		}catch(e){}
	},
	menuOutListener : function(evt)
	{

	}
}
// DEFAULT_TOOLBAR_ITEM.push(CompanyToolbarItem);

/*
var ContactUsToolbarItem = Class.create();
ContactUsToolbarItem.prototype = {
	id : "contact_us", //*
	name : "Contact Us", //*
	img : null,
	default_img : sBasePath+"images/home/menu_contact_off.gif", //*
	on_img : sBasePath+"images/home/menu_contact_on.gif", //*
	off_img : sBasePath+"images/home/menu_contact_off.gif", //*
	mouseover_img : sBasePath+"images/home/menu_contact_over.gif", //*
	mouseout_img : sBasePath+"images/home/menu_contact_off.gif", //*
	initialize : function(controller)
	{
		this.controller = controller;
	},
	close : function()
	{

	},
	open : function()
	{

	},
	getResource : function()
	{

	},
	onClickListener : function(evt)
	{
		//Effect.Pulsate(this.img, {pulses:1, duration:0.4});
		window.location.href = sRelativePath+"contact_us/";
	},
	onDblClickListener : function(evt)
	{

	},
	onMouseoverListener : function(evt)
	{
		this.img.src = this.mouseover_img;
		this.controller.closeOthers(this);
	},
	onMouseoutListener : function(evt)
	{
		this.img.src = this.mouseout_img;
	}
}
DEFAULT_TOOLBAR_ITEM.push(ContactUsToolbarItem);
*/

var ContactUsToolbarItem = Class.create();
ContactUsToolbarItem.prototype = {
	id : "contact_us", //*
	name : "Contact Us", //*
	img : null,
	default_img : sBasePath+"images/home/menu_about_off.gif", //*
	on_img : sBasePath+"images/home/menu_about_on.gif", //*
	off_img : sBasePath+"images/home/menu_about_off.gif", //*
	mouseover_img : sBasePath+"images/home/menu_about_over.gif", //*
	mouseout_img : sBasePath+"images/home/menu_about_off.gif", //*
	initialize : function(controller)
	{
		this.controller = controller;
		var htm = '<table border="0" cellpadding="2" cellspacing="0" bgcolor="F6F6EC" class="general_tbl">';
		htm += '  <tr>';
		htm += '    <td class="general_text company_item" style="padding-right:12px;padding-left:5px" id="contact_us_item1" url="company/about_us.php">About us</td>';
		htm += '    <td align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/resources/arrow.gif" style="display:none" id="contact_us_item1_indicator"></td>';
		htm += '  </tr>';
		htm += '  <tr>';
		htm += '    <td class="general_text" style="padding-right:12px;padding-left:5px" id="contact_us_item2" url="contact_us/index.php">Contact Us&nbsp;&nbsp;&nbsp;</td>';
		htm += '    <td style="width:13px" align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/resources/arrow.gif" style="display:none" id="contact_us_item2_indicator"></td>';
		htm += '  </tr>';
		htm += '  <tr>';
		htm += '    <td class="general_text company_item" style="padding-right:12px;padding-left:5px" id="contact_us_item3" url="company/careers.php">Careers</td>';
		htm += '    <td style="width:13px" align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/resources/arrow.gif" style="display:none" id="contact_us_item3_indicator"></td>';
		htm += '  </tr>';
		htm += '  <tr>';
		htm += '    <td class="general_text" style="padding-right:12px;padding-left:5px" id="contact_us_item4" url="contact_us/list_your_premises.php">List Your Premises&nbsp;&nbsp;&nbsp;</td>';
		htm += '    <td style="width:13px" align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/resources/arrow.gif" style="display:none" id="contact_us_item4_indicator"></td>';
		htm += '  </tr>';
		/*htm += '  <tr>';
		htm += '    <td class="general_text" style="padding-right:12px;padding-left:5px" id="resources_item2" url="resources/whats_on.php">What\'s On</td>';
		htm += '    <td style="width:13px" align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/resources/arrow.gif" style="display:none" id="resources_item2_indicator"></td>';
		htm += '  </tr>';
		htm += '  <tr>';
		htm += '    <td class="general_text" style="padding-right:12px;padding-left:5px" id="resources_item3" url="resources/useful_information.php">Useful Information</td>';
		htm += '    <td style="width:13px" align="center" valign="middle"><img align="absmiddle" src="'+sBasePath+'images/resources/arrow.gif" style="display:none" id="resources_item3_indicator"></td>';
		htm += '  </tr>';*/
		htm += '  <tr>';
		htm += '    <td colspan="2" style="height:10px"></td>';
		htm += '  </tr>';
		htm += '</table>';
		this.div = document.createElement("DIV");
		this.div.style.display = "none";
		this.div.style.padding = "5px";
		this.div.style.backgroundColor = "F6F6EC";
		this.div.style.position = "absolute";
		this.div.style.zIndex = "10000";
		this.div.innerHTML = htm;

		//Event.observe(this.div, "mouseout", this.menuOutListener.bindAsEventListener(this),true);
		document.body.appendChild(this.div);

		this.first_load = false;
		this.initializeAction();
	},
	initializeAction : function ()
	{
		Event.observe(this.div, "mouseover", this.menuOverListener.bindAsEventListener(this),true);
		this.div_over = false;
		this.mouse_move_listener = this.mouseMoveListener.bindAsEventListener(this);

		//this.tag_item = document.getElementsByClassName("company_item");
		//this.tmp_arr = [1,2,3];
		this.tmp_arr = [1,2, 3, 4];
		for(var i=0; i<this.tmp_arr.length; i++)
		{
			var obj = $("contact_us_item"+this.tmp_arr[i]);
			if(obj == null)
				continue;

			if(obj.id != null && obj.id.indexOf("contact_us_item") != -1)
			{
				Event.observe(obj, "click", this.itemClickListener.bindAsEventListener(this));
				Event.observe(obj, "mouseover", this.itemMouseoverListener.bindAsEventListener(this));
				Event.observe(obj, "mouseout", this.itemMouseoutListener.bindAsEventListener(this));
				obj.style.cursor = "pointer";
			}
		}
	},
	itemMouseoverListener : function(evt)
	{
		try{
		var ele = Event.element(evt);
		$(ele.id+"_indicator").style.display = "";
		}catch(e){}
	},
	itemMouseoutListener : function(evt)
	{
		try{
		var ele = Event.element(evt);
		$(ele.id+"_indicator").style.display = "none";
		}catch(e){}
	},
	itemClickListener : function(evt)
	{
		var ele = Event.element(evt);
		if($(ele).readAttribute("url") != null)
		{
			var url = sBasePath+$(ele).readAttribute("url");
			if(window.location.href != url)
				window.location.href = url;
		}
	},
	close : function()
	{


		this.img.src = this.mouseout_img;
		this.div.style.display = "none";
		//this.controller.showSelect();
		if(this.open_effect != null)
			this.open_effect.cancel();
		try{
		Event.stopObserving(document, "mousemove", this.mouse_move_listener);
		}catch(e){}
	},
	open : function()
	{

	},

	getResource : function()
	{

	},
	mouseMoveListener : function(evt)
	{

		var x = Event.pointerX(evt);
		var y = Event.pointerY(evt);

		if(
			!(x > this.menu_left && x < this.menu_left2 && y > this.menu_top && y < this.menu_top2)
			&&
			!(x > this.img_left && x < this.img_left2 && y > this.img_top && y < this.img_top2)
		)
		{
			/*this.img.src = this.mouseout_img;
			this.div.style.display = "none";
			Event.stopObserving(document, "mousemove", this.mouse_move_listener);*/
			this.close();
		}

	},
	onClickListener : function(evt)
	{
		//Effect.Pulsate(this.img, {pulses:1, duration:0.4});
		Effect.Pulsate(this.img, {pulses:1, duration:0.4});
	},
	onDblClickListener : function(evt)
	{

	},
	onMouseoverListener : function(evt)
	{
		if(this.first_load)
		{
			this.initializeAction();
			this.first_load = false;
		}
		this.img.src = this.mouseover_img;
		this.controller.closeOthers(this);
		var left = this.controller.getOffset(this.img, true);
		var top = this.controller.getOffset(this.img, false);
		this.div.style.left = (left)+"px";
		this.div.style.top = (top+this.img.offsetHeight)+"px";

		//this.controller.hideSelect();

		this.div.style.display = "";
		//this.open_effect = Effect.Appear(this.div, {duration:0.4});
	},
	onMouseoutListener : function(evt)
	{
	},
	menuOverListener : function(evt)
	{
		this.menu_left = this.controller.getOffset(this.div, true);
		this.menu_top = this.controller.getOffset(this.div, false);
		this.menu_left2 = this.menu_left+this.div.offsetWidth;
		this.menu_top2 = this.menu_top+this.div.offsetHeight;

		this.img_left = this.controller.getOffset(this.img, true);
		this.img_top = this.controller.getOffset(this.img, false);
		this.img_left2 = this.img_left+this.img.offsetWidth;
		this.img_top2 = this.img_top+this.img.offsetHeight+2;
		//alert(this.img_left+" "+this.img_left2+" "+this.img_top+" "+this.img_top2);
		try{
		Event.stopObserving(document, "mousemove", this.mouse_move_listener);
		Event.observe(document, "mousemove", this.mouse_move_listener);
		}catch(e){}
	},
	menuOutListener : function(evt)
	{

	}
}
DEFAULT_TOOLBAR_ITEM.push(ContactUsToolbarItem);

// DEFAULT_TOOLBAR_ITEM.push(MyPageToolbarItem);


Effect.ReSize = Class.create();
Object.extend(Object.extend(Effect.ReSize.prototype, Effect.Base.prototype), {
  initialize: function(element) {
    this.element = element;
    if(!this.element) throw(Effect._elementDoesNotExistError);
    var options = Object.extend({ amount: 100, direction: 'vert', toSize:null }, arguments[1] || {});
    if( options.direction == 'vert' )
      this.originalSize = options.originalSize || parseInt(this.element.style.height);
    else
      this.originalSize = options.originalSize || parseInt(this.element.style.width);

    if( options.toSize != null )
      options.amount = options.toSize - this.originalSize;

    this.start(options);
  },
  setup: function() {
    // Prevent executing on elements not in the layout flow
    if(this.element.getStyle('display')=='none') { this.cancel(); return; }
  },
  update: function(position) {
    if( this.options.direction ==  'vert' ){
      this.element.setStyle({height: this.originalSize+(this.options.amount*position)+'px'});
    } else {
      this.element.setStyle({width: this.originalSize+(this.options.amount*position)+'px'});
    }
  },
  finish: function(){
    if( this.options.direction ==  'vert' ){
      this.element.setStyle({height: this.originalSize+this.options.amount+'px'});
    } else {
      this.element.setStyle({width: this.originalSize+this.options.amount+'px'});
    }
  }
});

String.prototype.toQueryParams = function(separator) {
  var match = this.strip().match(/([^?#]*)(#.*)?$/);
  if (!match) return {};

  return match[1].split(separator || '&').inject({}, function(hash, pair) {
    if ((pair = pair.split('='))[0]) {
      var name = decodeURIComponent(pair[0].replace(/\+/g," "));
      var value = pair[1] ? decodeURIComponent(pair[1].replace(/\+/g," ")) : undefined;

      if (hash[name] !== undefined) {
        if (hash[name].constructor != Array)
          hash[name] = [hash[name]];
        if (value) hash[name].push(value);
      }
      else hash[name] = value;
    }
    return hash;
  });
};



function fitScreen ()
{
        //alert("x");
        if(typeof(toolbar) != "undefined" && toolbar != null && typeof(toolbar.closeOthers) == "function")
                toolbar.closeOthers(null);
        var s = getPageSize();
        var padding = parseInt((s[0]-950)/2);
        //alert(padding);
        if(padding > 0)
        {
                document.body.style.marginLeft = padding+"px";
        }
        else
        {
                document.body.style.marginLeft = "15px";
        }


        var today = new Date();
        var expire_date = new Date(today.getTime()+3600000*24*100);
        setCookie("screen_padding", padding, expire_date, "/");

}
var fitScreenAction = fitScreen.bind(null);
//Event.observe(window, "load", fitScreen);
Event.observe(window, "resize", fitScreenAction);


