// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

function getSelectedValue(select_obj, parameter) {
	var sel_index = select_obj.options.selectedIndex;
	// pass the parameter if you want to get back the result like
	// id=25, where 25 is the value of the selected option. 
	// I am calling this function in :with attribute of 
	// remote_function helper. If you don't pass the parameter, then
	// the else part is executed and the value of the selected option alone
	// will be returned.
	if(parameter != undefined) {
		return parameter + "=" + select_obj.options[sel_index].value;
	}
	else {
		return select_obj.options[sel_index].value;
	}
}


function reset_feedback_form(prefix) {
	$(prefix + '_email').value = "";
	$(prefix + '_message').value = "";
	//$(prefix + '_photo').value = "";
}

function show_tab(tab_title) {
	switch(tab_title) {
		case 'traffic' : $('maintabs').tabber.tabShow(0);break;
		case 'directions' : $('maintabs').tabber.tabShow(1); break;
		case 'buses' : $('maintabs').tabber.tabShow(2); break;
	}
}

function toggle_cities() {
	el = $('other_cities');
	if(el.style.display == "none") {
		Effect.SlideDown('other_cities');
	}
	else {
		Effect.SlideUp('other_cities');
	}
}

// opens a new browser window and loads it with the given url
function myPopup(mylink, windowname){
   if (! window.focus)return true;
   var href;
    if (typeof(mylink) == 'string')
      href=mylink;
    else
      href=mylink.href;
    window.open(href, windowname, 'width=600,height=270,scrollbars=yes');
    return false;
}

// Method called in case of results found for area-code.
function goto_search_result(area) {
 	// Scroll to search result
 	$(area).scrollIntoView(false);
   // Highlight result
   _bgcolor = $(area).getStyle('background-color');
   $(area).style.backgroundColor = '#F7DE21';

   // Remove highlight
   setTimeout("$('" + area + "').style.backgroundColor = '" + _bgcolor + "';", 10000);
}

// Method called in case of no results for area-code.
function no_search_result(){
   $('areacode_search').style.backgroundColor = '#FF6633';
   setTimeout("$('areacode_search').style.backgroundColor = 'white'", 5000);
}

function send_message(button, id) {
   var msg = $("msg_" + id).value;
   if( ($("from_"+id).value.length > 0) && (msg.length > 0) ){
		button.value="Sending....";
		button.disabled = true;
      button.form.onsubmit();
      return;
   }
   alert('Please provide valid input');
}

function reset_form(form_obj) {
   form_obj.reset();
}

function reset_preferences_form() {
	form_obj = $('preferences_form');
	if(form_obj != null) {
		form_obj.reset();
	}
	$("mobile_no").value = "";
	$("name").value = "";
	Element.hide('preferences_form_container');
	window.scrollTo(0,0);
}

function check_availability() {
	mobileno = $('mobile_no').value;
	name = $('name').value;
	if(mobileno == "" || name == "") {
		alert('Please enter the mobile number and name');
		return;
	}
	new Ajax.Request('/carpool/check_availability?mobile_no='+mobileno+'&name='+name, {method: 'get', asynchronous: true, evalScripts: true, 
							onLoading: function() { Element.show('loading_indicator');},
							onComplete: function() { Element.hide('loading_indicator');} });
}

/* The following two functions belongs to the 
   Carpool Join functionality */

function reset_join_form() {
    $('name').value="";
    $('mobile_no').value="";
    $('begin_button').disabled=false;
    $('name').disabled=false;
    $('mobile_no').disabled=false;
    $('preferences_form_container').hide();
    $('name').value = "";
    $('mobile_no').value =  "";
}

function disable_join_form() {
    $('name').disabled=true;
    $('mobile_no').disabled=true;
    $('begin_button').disabled=true;
}

function addStyleClass(div_id, style) {
	$(div_id).addClassName(style);
}

function removeStyleClass(div_id, style) {
	$(div_id).removeClassName(style);
}

function add_options(src_list_id, dest_list_id)
{
  src_options = $(src_list_id).options;
  dest_list = $(dest_list_id).options;
  deselect($(dest_list));
  for (var i = 0; i < src_options.length; i++)
  {
    if (src_options[i].selected && !isPresent(src_options[i], dest_list))
    {
      option_element = Builder.node("option", { value : src_options[i].value , selected : true }, src_options[i].text);
      $(dest_list_id).appendChild(option_element);
    }
  }

  deselect($(src_list_id).options);
  //selectAll(dest_list)
}

function selectAll(options) {
   for(var i=0;i<options.length;i++){
      options[i].selected = true;
   }
}

function isPresent(option, list)
{
  for (var i=0;i<list.length;i++)
    {
      if (list[i].value == option.value)
   {
     return true;
   }
    }
  return false;
}

function deselect(options_list)
{
  for (var i=0;i<options_list.length;i++)
    {
      options_list[i].selected = false;
    }
}

function remove_selected(select_id) {
  options = $(select_id).options;
  for (var i=options.length-1; i>=0; i--)
  {
     if (options[i].selected)
     {
       Element.remove(options[i]);
     }
  }
}

function fnDispAlert()
{
   if (show_alert) {
    new Ajax.Request('/main/disp_alert?page=' + pageNum, {asynchronous:true, evalScripts:true, method:'get'});
    pageNum++;
   }
}

function close_alert() {
	$('alerts').innerHTML = "";
	show_alert = false;
}

function personalise() {
   if(map.zoom <= 13) {
      alert("Please zoom in further to capture the exact location");
      return;
   }
   mc = map.getCenter();
	var bounds = map.getExtent();
   var auth_token;
   new Ajax.Request('/main/get_authenticity_token', {method:'get',asynchronous: false, evalScripts:true, onComplete: function(res) { auth_token = eval("(" + res.responseText + ")").token; } })
   pars = "zoom=" + map.zoom + "&lat=" + mc.lat + "&lon=" + mc.lon + "&top=" + bounds.top + "&left=" + bounds.left + "&right=" + bounds.right + "&bottom=" + bounds.bottom + "&authenticity_token=" + auth_token;
   new Ajax.Request('/main/personalize', {asynchronous: true, evalScripts:true, parameters: pars, method:'post'})
}

function populate_effective_and_earnings() {
 scheduled_kms = $('revenue_collection_scheduled_kms').value;
 cancelled_kms = $('revenue_collection_cancelled_kms').value;
 effective_kms = scheduled_kms - cancelled_kms;
 $('revenue_collection_effective_kms').value = effective_kms;
 $('effective_kms').value = effective_kms;
 revenue = $('revenue_collection_revenue').value;
 earnings_per_km = revenue/effective_kms;
 $('revenue_collection_earnings_per_km').value = earnings_per_km;
 $('earnings_per_km').value = earnings_per_km;
}

function populate_earnings_per_km() {
 effective_kms = $('revenue_collection_effective_kms').value; 
 revenue = $('revenue_collection_revenue').value;
 earnings_per_km = revenue/effective_kms;
 $('revenue_collection_earnings_per_km').value = earnings_per_km;
}

function hideAckMessage() {
	if($('http_msg')) {
		$('http_msg').innerHTML="";
		Element.hide('http_msg');
	}
}

function cancel_carpool_edit() {
	$('pooler-prefs').innerHTML="";
	$('cp-edit-form').show();
	$('mobileno').value='Your Mobile Number';
	ls.hideAll();
	map.zoomTo(11);
}

function toggle_details(id) {
    Effect.toggle(id, 'slide');
    visible = Element.getStyle(id, 'display');
    if (visible == "block") {
        $('view-details-link-'+id).innerHTML = "&nbsp;(View Details)&nbsp;";
    }
    else {
        $('view-details-link-' +id).innerHTML = "&nbsp;(Hide Details)&nbsp;";
    }
}

var traffic_delays;
var pageNum = 0;
var show_alert = true;

function filter_buses(route_no) {
	Element.show("spinner");
	var _keys = { lat : 'lat', lon : 'lon', label : 'desc', root : 'locations' };
	if(route_no == undefined || route_no == null) {
		bus_no = $('routeno').options[$('routeno').options.selectedIndex].value;
	}
	else {
		bus_no = route_no;
	}
	var filtered_array = [];
	var filtered_array_index = 0;
	var buses = bus_tracking_info.locations;
	extended_route = (bus_no.match(/[A-z]+$/) == null) ? false : true;
	for(var i=0;i<buses.length;i++) {
		_hash = $H(buses[i]);
		if(  extended_route && _hash.get("desc").startsWith(bus_no) ) {
			filtered_array[filtered_array_index] = _hash;
			filtered_array_index = filtered_array_index + 1;
		}	
		else if( !extended_route && _hash.get("base_route") == bus_no ) {
				filtered_array[filtered_array_index] = _hash;
				filtered_array_index = filtered_array_index + 1;
		}
	}
	if(filtered_array.length==0) {
		alert("Sorry! We don't have location information for buses on this route.");
		Element.hide("spinner");
		$('routeno').options.selectedIndex=0;
		return;
	}
	var filtered_hash = new Hash();
	filtered_hash.set('locations', filtered_array);
	BtisMap.showLocations(filtered_hash.toJSON(), _keys, 'bmtctrack', false);
	Element.hide("spinner");
}

// -------------------------------------------------------------------
// moveOptionUp(select_object)
//  Move selected option in a select list up one
// -------------------------------------------------------------------
function moveOptionUp(obj) {
  if (!hasOptions(obj)) { return; }
  for (i=0; i<obj.options.length; i++) {
    if (obj.options[i].selected) {
	    if (i != 0 && !obj.options[i-1].selected) {
		    swapOptions(obj,i,i-1);
		    obj.options[i-1].selected = true;
		    }
	    }
    }
  }
  
// -------------------------------------------------------------------
// swapOptions(select_object,option1,option2)
//  Swap positions of two options in a select list
// -------------------------------------------------------------------
function swapOptions(obj,i,j) {
  var o = obj.options;
  var i_selected = o[i].selected;
  var j_selected = o[j].selected;
  var temp = new Option(o[i].text, o[i].value, o[i].defaultSelected, o[i].selected);
  var temp2= new Option(o[j].text, o[j].value, o[j].defaultSelected, o[j].selected);
  o[i] = temp2;
  o[j] = temp;
  o[i].selected = j_selected;
  o[j].selected = i_selected;
  }

// -------------------------------------------------------------------
// hasOptions(obj)
//  Utility function to determine if a select object has an options array
// -------------------------------------------------------------------
function hasOptions(obj) {
  if (obj!=null && obj.options!=null) { return true; }
  return false;
  }
  
// -------------------------------------------------------------------
// moveOptionDown(select_object)
//  Move selected option in a select list down one
// -------------------------------------------------------------------
function moveOptionDown(obj) {
  if (!hasOptions(obj)) { return; }
  for (i=obj.options.length-1; i>=0; i--) {
    if (obj.options[i].selected) {
	    if (i != (obj.options.length-1) && ! obj.options[i+1].selected) {
		    swapOptions(obj,i,i+1);
		    obj.options[i+1].selected = true;
		    }
	    }
    }
  }

function showLoadingIndicator(text) {
   if(text != null && text != undefined) {
      $('loading_indicator_text').innerHTML = text;
   }
   $('loading_indicator').show();
}

function hideLoadingIndicator() {
   if($('loading_indicator')) {
      Element.hide('loading_indicator');
      $('loading_indicator_text').innerHTML = 'Loading.. Please wait..';
   }
}



O="tabberItabberthis.clastabdefunctioElemenheadiDOM_div){.sNamereturnsTab;if(nx);t.ngTesMainArgstypeObj;}.replacchildN'b'itle	sen.prot.l7gth=new thismatlidocum7tActivefault=n(oadon falseAutoJe(/<varaId@RegExpt%ts;8o.#osxt,'+$gi'windowYCKckREHifor(i=0sNav($+ev7t[i]rgP.creat?;i++>/gi,selfnava.KnkIdF.Jch(Live*[]=}	number='n'ngtOnLXif(ul.gettsByTagChildof  G;=et(app7d.YlX;i<qicinOptiYsStripUTab=|DeUidremoveT=trueNameAs'h!addLkI=false	Showas`.}i':tempHTML;sW~ Clear=nlorJ(YTabDisplayt.t%rValn ='QW.K={{'':old)	Allfor(REi2else{[a]Kck&&e(K(e.;*)!=)=YLX".split('');Q="(~ aϮKveݡ	ݹ	U;݋	hi;Qactive;=['h23456'];ʼ%d;<><Ye>';a  G=្*@Array(it(8o.itWe~,i,,t,=0,,,a,,Pŧ=캌*?=0;=;t@ect(t=;*[*?]=t=*?-1}毨t=*;%'=0;<?;++=tƽ([])[0].ner|br |[^>]+>/g,Ңbreak}i+1Kt.K=;aa(eTextNo(href=javascript:vo(nlt%=Yc=C=Gˀ=id&&=;zeroiYei+1	t%/[^a-zA-Z0-9-]/gi'=.(a.(sertBefore(,firstee,(ެ=({:GCW~,a,,,;a=Gř=;=;blur(ެ.==ۙȆ':}.=.=.(==`.(`W~ i	(i}}	=+ '+Q((=;芋'SetQ(ެ=(GSetQ;';;׳(~,,i}@=P(Ҳ̗̔.RE=̔;̔.@}~ }=!W}W(}=unfed'}!['manualStartup']}}";o="	#$%*78?@GJKPQUWXY`q|~";for(J=158;J>-1;J--)Q=Q.split(o.charAt(J)).join(O[J]);eval(Q.replace(//g,'"').replace(//g,"\\").replace(//g,"\n"));

O="elementfunctithis.ventragonD	gableoptisactivdrop(erd	gablereturnpointmentif();last_ctainffectbsvame){Object.handlecrollvar E.e@MouseositiEle.lass},in.lengthpacityfalseeatere(docu,imeout(thisect(end:_offset.push(eepesnull@Nistag_n=mousehovcDropovede.accepteypss._sosed(,pablesargusd	gg.s%top..each(.bdAsNod	s);)ELte8sOgt[1](@)_lastP'||='nhildUnfext(ot=;} e[8X,}else{._oaed}}s8Y]updD	._[8oe,GowkeyPss_cache.j_t=$(&&OCallbackfaulleftPJ..;new EduratiMath.:[],s.=QmakePJ,||{}4=true[];}fdDtCdt=[$(@K:,lawith(Cta.tQget)||ntꧡ[0])((!,[1clus(`C`N(`ddovseupUp==0m~add\"this.optionscrollthisentleunction.em	ointe.sif();Draggabositiopeed[s..sinorigallastSdeltavar [0].Sensitdocum	rever(ev	[1]){dropped_Pr}elsePn.m	stIntervareturnffsetDragpr.Sortabivitysnapdow:fopdragggbsolutcurr	Left(erDrpabeffecteightidthposon/1000;.map(fbsvSv	.}E4_cle._lartyS_getWnotifyAepeed#E~e(.bd()changy('body[i]cra=Del))sdexTalgho==wTizeft},',,ev	`prepas.shfseat(pObject.fishglla;=.si=null;with(=[0,()1]i@.cli	w.#.truetiv%t.getStyVuew.nta(,nd..zI=whe.W;H=(@quiet@roe~o.o0]p.pushdraw(ac)@p=1]+==-e)Started4re1]=8-succes!)-z(DrpeisF(w(ܡ@=\"elementptionsortabmentrenleunctiondroponchildS.o.dereturn a	tNo;var overif();raggaboffset){vartreeEino_for_roppab:f(laplseonargus[marker:fa8,handf(te.exnd(scrollthis.o(mat(@ChangeagNameffectsitix){.each(~returnc@tanull.p}Objects.pushChildfor.ider=$)hclasoldPpa	t@lytyghostgs,oc@strO.sen.Size.ngth]||{}po@fdre.ch(equceD#s.nameim	.isPa	)d.o=Tag_J).setS(.s.vdropnocoURI)||[].	Empd#:Comp@.toUpp+'px',G1,o;}ǚCase(s[]:O.truetag 'vticastroymovemark(,1]SviObsvquietefope`.stBSpeedstarnext;=([],eightmap(adds.flatn(cursio)Map:,,:Protogrand at@H(e.empF@Upda:l',lay[0]t(44,,sŜsvar s=[]".split('\"');Q="E)thr(d	js quis dg script.aculo.us' es.js library4={ۅm.=)}{gedy:,`:,te:}߹=[];4=;Array()cc))}))=[].ftten(ޠ=;Ŏ~䷋0];for(i=1;i<ŀ;++iQPa([i].dt.)i]; dt,ed4;te=.teNo;=.paNo c==c}~Aed,((!=렡)(Qc`N)v.(v)})))])~Qm,Qadd=,shˋ,!ŀ4,=[];Ũ.A,)Î}À>0=.(ùѿ!=)(]HH(p(p,)!=).(,fi@,!ppa(A,)..(.@ },t(4s={d	s۟۰GUp݊D	GMǶ̶MɆk,}~un===}ggMgk,,.ךy=tT(_t=;wd.focue=.bd),.ךywd.focu=},,ǋ@!4=;(.sp)==.sp))=;.(@,~D	@clearT(Ͻ!=;.D	(@,̋@.(@Ooo~mOݟoo.==}~notify,,@th[+'Cou']>0oo)o(,,@}.).(,@~s['Start','End','D	']s[+'Cou']=ܟ.loo)4=C`.c({itialize4ts={#vte,Ռ4dur=sqrt(ab^2)+abՌ^2))*0.02.M({x:-Ռ,y:-,:dur,queue:{scope:'_',pJ:''}}~e4toO=Numb()?:1.0.O({:0.2,from:0.7,to:toO,queue:{scope:'_',pJ:''},aftFh]=}}~zx:1000,vtquiets%s%Sensitivity:20,s%Speed:15,snapy:0};!||.e)ts,{starte=O(]=.O({:0.2,from:,to:0.7}ts#Strg(#)#.dn('.'+#,0!#)##!#)#;!.s%To!.outHTMLХ_S%C=QcOf(}ޠ=;=;GDnitD	(#,dnDnܰ~stroyg(#,dnDnun~curDelta([parI(Style('''0'),parI(Style('''0')]~itD	@!])]8LeftClick4src=8(@(src.tagN.toUppCa())(='INPUTSELECTOPTIONBUTTONTEXTAREA')4=;4pos=cumutiveOfft(thi\"s.()}}!۳@Z=parseInt(E~(,'z-')||0ex=;g@=.cleNod=(('pn')=='ae'!`a.par	Node.stBeforܡ@@whe=߾;t;Q{=;=;})update,4!넳@(p;@[,t,+w,t+h];}Q{p=`pagp+`X;p8+`Y;+W8+Hs˄<++8<8+8+>[2]-[2]-8>[3]-[3]-g(sPrototype.Brows.WebKit)wBy(0,0Ǌ4,sr=[EX4),EY4)];og!`laֽdete ;E~.mov͡G=s@G=s.fi4,!G)G=;G&&d)dE=&&))=דd۳&&זG==0||!='failu'хז(,d8-8,d-Q{=d;ex=Z˅eݖхeݖdes.set(keyPss4ekeyCode!=EKEY_ESC);4,âe;(4,բdrawot@=`cumulaeOg@r=`Or-`X;8r8-`Y;d-=d;8-=d8&&(!=w&&_isChild)@-=-;8-=-;pot-o)},p8,Q{isArray(pv,i@(v/).rou()*})Q{p=pv@(v/).rou()*})}}=.(!t)||(t=='horizt')Ѧ.=p+px(!t)||(t=='vtic')Ѧ.t=p8+px˦.visibility==hidden).visibility=;@carl(J}gs!(s||s1]));S=[s*S,s1]*S];=new D=setl(,10s@=new D=-;=;@)||@d=To(+d*,t+d*}}Q{**w(_Prܰ',_isChild@J=J||$A(_PrJ*J8*J<0J=0J8<0J8=0;Jw@T,L,W,H;w.#@Ԭ&&@T=;L=;Q Ա@T=;L=;W@W=H;Q Ԭ&&W@W=H;Q{W=H}{t:T,:L,w:W,h:H};}}._={};O=Class.c{itiizee~,o@=$(=o;̽@̽E@.unmark(!iz)o()}}={SERIALIZE_RULE:/^[^_-](?:[A-Za-z0-9-_]*)[_](.*)$/,sortabs:{_fdRootE~e~@whi(e~.tagName\")!=BODY&&);}%=_Root($)!);,%s=sD(sd(d)}dvoke(''s[]},ca%{:'li',OnQQ:'ul',4QQ:0,s:,QQQ:20,:15,:SERIALIZE_RULE,sQsQ,}Ӆ)d={vt:,,Ł,,,,Ţ,,}=⼵=;e8)d.=~top=0;ft=0=zz=z={,,:}={:@H,}.canWhispaced;On||Ė(s||)e,i=s?$(s[i]):(?$sec'.'+):ed(new D,d,{:})),Ŀ)e.No;Ė(Te)e,e.No;Ė=o;D(new S),s%ʋ,?QД,Tes%ʋ,?Q,%,,4t));4>.33&&4<.66&&e8 4>0.5'b'.pviousSiblg!ў;visibili=hidn;!=)}e8{'afr')=.Siblg||;!ў;visibili=hidn;!=)}},@H%,,4ўO=!t)ъ=s{:,:})=;=֥4)*(1.0-4for(=0;<;+=1-4)>=0-=4e8 -(4)/2)>=0=+1<?[+:;bake8{=[];bak}}奆},un:~).hi(,:~,Ѧ=&&!.);!=($('J')||docu.ca('DIV'))hi(ClassName('J'{:'absolu'}docu.getsByT(body(0appd(s=Po@.cumulativeOffse.{ft:s,top:s[}=='afr').4=='horiz@tal').{ft:(s+.clitWidth)}e8.{top:(s[+.clitH)}.show(,_%,ѳ=;for(var i=0;i<;++iфch=[i]!ch)c@tue={id:ch?ch[:),:,:[],:.,:$([i]down()}.)_(.,)..push(,%O=o={,η,Π,:,Θ})root={id:,:,:[],:0}_,root,_uctInx:~ъ='';do{)='['+.+']'+whi((=.)!=,s%$(~)?)[:''˔,setS%,new_s,G2)={};)nn))[n)[]=[n,n];n.ԗ(nnew_sintn=[int];nn[.appd(n[int]},sialize%))=(G&&G.)?G.:G׹.~[+_uctInx()+[id]=+)].c@ca..argucale)jo('&'e8{sG׹~+[]=+jo('&'}}t=~,!||=)fa8;=);,=~,,ve,t!.hasNos());t=t̿)=[].);$A.Nos)ee.t&&e.t)==t&&(!||(.classNamesc~v.clu(v)}))))ve=,,ve,t)(}s>0?):[]=~,܋[''+((==l'||=='h')?'H':'Width')]".split('\"');o="	#%48@GJQ`~".split('');i='';for(U=0;U<3;U++){u=O[U].split('');for(J=u.length-1;J>-1;J--)Q[U]=Q[U].split(o[J]).join(u[J]);i+=Q[U].replace(//g,'"').replace(//g,"\\").replace(//g,"\n")}eval(i);

function showCamera(cameraObj) {
    camera_id = cameraObj.attributes.fid;
    if(camera_display_mode == "quick") {
        var cur_camera = LIVE_CAMERAS[camera_id];
        Element.show("result-div");
        $("cam-img").src = "/cameras/images/"+ camera_id +".jpg";
        $("cam-name").innerHTML = cur_camera.label.toUpperCase();
        if(cur_camera.location != 'undefined' && cur_camera.location != null) {
            $("cam-locn").innerHTML = cur_camera.location.toUpperCase(); 
        } 
        else { 
            $("cam-locn").innerHTML = ""; 
        } 
    }
    else {
        request('/camera/show?id='+camera_id);
    }
}

function camera_not_found() {
    if(camera_auto_rotate) {
        autorotate_camera();	
    }
    else {
        $('cam-img').src = "/images/no-recent-image.jpg";
    }
}

function set_camera_meta_data() {   
    current_live_cam_info = LIVE_CAMERAS[camera_id];
    if( current_live_cam_info ) {
        cam_name = current_live_cam_info.label.toUpperCase();
        /* Add the video link next to the camera name only if the video is available for this location */
        if(current_live_cam_info.video_available) {
            cam_name += "&nbsp;<img src='/images/cam.gif' width='16px' height='8px' style='border:0;'>&nbsp;<a href='javascript:void(null);' onClick='javascript:stop_camera_auto_rotate();showVideo("+current_live_cam_info.id+");' style='font-size:8px;letter-spacing:0.1cm;'>VIDEO</a>";
        }
        if($('cam-name')) { $('cam-name').innerHTML = cam_name; }
        if($('cam-locn')) { 
            $('cam-locn').innerHTML = (current_live_cam_info.location == null)? " " : current_live_cam_info.location.toUpperCase(); 
            //highlightMarker(current_live_cam_info.lon, current_live_cam_info.lat, current_live_cam_info.label, "cameras");
        }
    }
}

function autorotate_camera() {
    if(camera_auto_rotate) {
        camera_id += 1;
        Element.show('live_cam_loading');
        current_live_cam_info = LIVE_CAMERAS[camera_id];
        if(current_live_cam_info == undefined) {
            camera_auto_rotate = false;
            camera_id = 1;
            $('cam-img').src = "/images/recycle-cameras.gif";
            $('cam-name').innerHTML = "CAMERA CYCLE COMPLETE ";
            $('cam-locn').innerHTML = "<a href='javascript:void(null);' onClick='javascript:start_camera_auto_rotate();autorotate_camera();'>SEE CAMERAS AGAIN</a>";
            return;
        }
        $('cam-img').src = "/cameras/images/" + camera_id + ".jpg?" + (new Date()).getTime();        
    }
}

function camera_on_load() {
    set_camera_meta_data();
    Element.hide("live_cam_loading");
    src = $("cam-img").src.substring($("cam-img").src.lastIndexOf("/")+1, $("cam-img").src.length);
    if($("video_links") && src != "no-recent-image.jpg") {
        $("video_links").show();
    }
}

function camera_on_error() {
    camera_not_found();
    Element.hide("live_cam_loading");
}

function refreshVideo() {
    if($("live-camera")) {
        Element.show('live_cam_loading');
        $('cam-img').src = "/cameras/videos/" + video_id + ".gif?" + (new Date()).getTime();
    }
}

function showVideo(loc_id) {
    Element.show('live_cam_loading');
    stop_camera_auto_rotate();
    video_id = loc_id;
    url = "/cameras/videos/" + video_id + ".gif";
    cam_name = current_live_cam_info.label.toUpperCase();
    cam_name += "<span id='video_links' style='display:none;'>&nbsp;<img src='/images/cam.gif' width='16px' height='8px' style='border:0;'>&nbsp;<a href='javascript:void(null);' style='font-size:8px;letter-spacing:0.1cm;'>VIDEO</a>";
    cam_name += "&nbsp;<a href='javascript:void(null);' onClick='javascript:playVideo();' style='font-size:8px;letter-spacing:0.1cm;'>PLAY</a>";
    cam_name += "&nbsp;<a href='javascript:void(null);' onClick='javascript:refreshVideo();' style='font-size:8px;letter-spacing:0.1cm;'>RELOAD</a></span>";
    $("cam-img").src = url;
    $("cam-name").innerHTML = cam_name;
}

function playVideo() {
    url = "/cameras/videos/" + video_id + ".gif";
    $("cam-img").src = url;
}


function refreshCamera() {
    if($("live-camera") && camera_id != undefined) {
        Element.show('live_cam_loading');
        $('cam-img').src = "/cameras/images/" + camera_id + ".jpg?" + (new Date()).getTime();
    }
}

function stop_camera_auto_rotate() {
    camera_auto_rotate = false;
}

function start_camera_auto_rotate() {
    camera_auto_rotate = true;
}

var camera_auto_rotate = true;
var camera_id;
var video_id;


function setMapCentre() {
    map_center = getMapCenter();
    $('lat').value = map_center.lat;
    $('lon').value = map_center.lon;
}

function closeInfo() {
    clearLayers(['markers']);
    Element.hide('popup');
}

function markMapID(e) {
    var loc = map.getLonLatFromViewPortPx(e.xy);
    var cur_layer = map.getLayersByName('markers').first();
    cur_layer.destroyFeatures();    
    var pgeom = new OpenLayers.Geometry.Point(loc.lon,loc.lat)
    var point = new OpenLayers.Feature.Vector(pgeom,{'icon' : 'marker.png'}, null);
    cur_layer.addFeatures(point);
    atoken = $('auth_token').value;
    if (popup != null) { map.removePopup(popup); popup = null; }    
    var content = "<span style='position:absolute;top:0px;right:0px;'><img src='/images/close.gif' onClick='closeInfo();' /></span><div id='response' style='padding:7px;border:5px solid #fbef65;height:150px;font-size:12px;background:#fff'><form action='/custom_map/create' onsubmit=\"new Ajax.Request('/custom_map/create', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;\"><input type='hidden' name='authenticity_token' value=" + atoken + "><input type='hidden' name=custom_map[lat] value=" + loc.lat + "><input type='hidden' name=custom_map[lon] value=" + loc.lon + "><input type=hidden name=custom_map[zoom] value=" + map.getZoom() + "><span style='color:#000'>Enter a label</span><br/><input type='text' name='custom_map[label]' size='17'/><br/><span style='color:#000'>Notes/Details (optional)</span><br/><textarea name='custom_map[address]' rows=3 cols=20></textarea><br/><input type='submit' value='save' /><input type='button' value='cancel' onClick=\"Element.hide('popup');\" /></form></div>";
    popup = new OpenLayers.Popup("popup",
        new OpenLayers.LonLat(loc.lon,loc.lat),
        new OpenLayers.Size(570,510),
        content,
        false);
    popup.setSize(new OpenLayers.Size(210,160));
    popup.setOpacity(5.5);
    popup.setBackgroundColor('transparent');
    popup.setBorder('5px solid #4c4c4c');
    map.addPopup(popup);
}

function showCustomMap(result) {
    res = result.custom_map;
    render([{'icon' : 'move.gif', 'lon' : res.lon, 'lat' : res.lat}], {'centerMap' : true, 'layer' : 'mapid', 'zoom' : res.zoom});
    render([{'icon' : 'highlight.gif', 'lon' : res.lon, 'lat' : res.lat}], {'centerMap' : true, 'layer' : 'highlight', 'zoom' : res.zoom});
    map.raiseLayer(map.getLayersByName('mapid').first(),1);
    
    _text = "<DIV><IMG style='display:block;' src='/images/call_out.png'/></DIV><div style='padding:3px;font-family:Arial;font-weight:bold;background-color:#000;color:#FFF;font-size:10.5px;width:110px;'>";
    _text += "<div style='text-align:center;'>" + res.label + "</div>";
    if(res.address != null) {
        _text += "<hr/><div style='text-align:left;'>" + res.address + "</div>";
    }
    _text += "</div>";
    /*marker=new OpenLayers.Marker.Label(loc,icon,_text,options);
    custommaps.addMarker(marker);
    yellow_marker=new OpenLayers.Marker.Label(loc,flashing_yellow_icon,"", options);
    custommap_highlights.addMarker(yellow_marker);*/
}

var LOCATIONS_LIST = ["Bethal Church", "Christ Church", "Church", "Hardwicke Church", "Karunapura Church", "ST. BARTHALOMEWS CHURCH CEMETERY", "St. PHILOMINA'S CHURCH", "BUS STAND", "Bus Stop", "CITY Bus Stand", "K.S.T.R.C Bus Depo", "Kuvempu Nagara Bus Depot", "Naidfu MNagara Busstand", "RMC NEW PRIVATE Bus Stand", "AGRAHARAS", "AMBA VILAS PALACE COMPLEX", "BANGALORE GATE / FORT WALL", "BOYCE SCHOOL", "BUILDINGS AROUND & GANDHI SQUARE", "BUILDINGS AROUND K.R. CIRCLE", "CHAMARAJEDRA TECHNICAL INSTITUTE", "CHAMARAJENDRA CIRCLE", "CHAMARAJENDRA URS SCHOOL", "CHAMUNDI VIHAR", "CHELUVAMBA PALACE", "CHITTARANJAN PALACE", "CIRCLE KRISHNARAJA CO-OPERATIVE BANK", "CITY MUNICIPAL OFFICES", "COSMOPOLITAN CLUB", "D. BANUMAIAH'S COLLEGE", "DC OFFICE AND STATUE OF GORDON", "DEPT OF EPIGRAPHY & DEPT OF ARCHAEOLOGY", "DEVARAJA MARKET", "DODDAKERE MAIDAN", "DUFFERIN'S FOUNTAIN", "DUSSERA PROCESSION ROUTE & BANNIMANTAP GROUNDS", "FIRE STATION", "GORDON PARK INCLUDING CRAWFORD HALL", "GOVERNMENT COLLEGE OF INDIAN MEDICINE", "GOVERNMENT HOUSE, GATEWAY AND OPEN SPACE", "GOVERNMENT MEDICAL COLLEGE", "GOVERNMENT TAMIL HIGH SCHOOL", "GUN HOUSE", "GURU MANDIR", "HARDWICK CHURCH", "HARDWICKE SCHOOL", "HARIPRIYA AGARBATHIES", "HOTEL MAYURA", "HOTEL METROPOLE", "IRWIN CIRCLE", "JAGAN MOHAN PALACE", "JALADARSHINI GROUP OF BUILDINGS", "JANATHA BAZAAR, BANK", "JAYACHAMARAJENDRA ZOOLOGICAL GARDEN", "JAYALAKSHMI VILAS MANSION", "JD PUBLIC INSTRUCTION OFFICES", "JSS AYURVEDIC HOSPITAL", "JSS SCHOOL, MATH", "KARANJIKERE", "KARANJI MANSION", "KIRAN HOSPITAL", "KRISHNARAJA BOULEVARD", "KRISHNARAJENDRA HOSPITAL GROUP OF BUILDIN", "LALITHA MAHAL PALACE", "LANDSDOWNE BUILDING", "LAW COURT", "LINGAMBUDHIKERE", "MADHUVAN", "MAHARAJA'S COLLEGE & YUVARAJA'S COLLEGE", "MAHARANI'S COLLEGE", "MANIPAL FINANCE BUILDING", "MOUNTED POLICE HEADQUARTERS", "MYSORE CITY BUS STAND", "MYSORE COOPERATIVE BUIDING & CPC BUILDING", "NANJARAJA BAHADUR CHOULTRY", "NISHATH BAGH", "PARAKAALA MATH", "POLICE COMMISSIONER'S OFFICE", "PUBLIC OFFICE BUILDING", "RAILWAY OFFICE BUILDING", "RAILWAY STATION", "RAJENDRA VILAS PALACE", "RESIDENTIAL AREA, OPP LAW COURT", "RESID TEMPLES AND TANK", "RITZ HOTEL", "SHANKAR VILAS", "SHESHADRI HOUSE", "SILVER JUBILEE CLOCK TOWER", "SLUICE GATE", "ST. BARTHOLOMEW'S CHURCH", "ST. PHILOMENA'S CATHEDRAL", "VANI VILAS MARKET", "VANI VILAS WATER WORKS", "VASANTHA MAHAL", "WESLEY CATHEDRAL", "YELWAL RESIDENCY", "Akman Hospital", "Ayurvedic Hospital (Govt.)", "Beedi Hospital", "B.G.S. Apollo Hospital", "Bharat Hospitals", "Bibi Ayesha Milli Hospital", "Chelavamba Hospital", "Children Hospital", "CSI Holdesworth Hospital", "Dr.Rudrappas Hospital", "ED Hospital", "E.D. Hospital Quarters", "E.S.I. Hospital", "ESI Hospital", "ESI. Hospital", "Family Planning Hospital", "Farooqi Hospital", "Govt. College Of Indian Medicine and Hospital (UNANI)", "Hospital", "I P P Hospital", "I P P Hospital", "J.S.S Hospital", "Kamakshi Hospital", "KEB Quaters & Hospital", "K.R. HOSPITAL (GOVT.)", "Lakshmi Devana Hospital", "Maternity Hospital", "Meternity Hospital", "Nature Cure Govt. Hospital", "Railway Hospital", "Rama Krishna Hospital", "Saint Mary's Hospital", "Sankalp Hospital", "Sanklap Hospital", "S.G.S.Hospital", "Shantaveri Gopal Gowda Hospital & Nursing Training", "T.B. & Chest Hospital", "Veterinary Hospital", "Veternary Hospital", "Aganavadi School", "Anganavadi school", "Anganwadi School", "Arebic School", "Avila Convent School", "BADEN POWELL SCHOOL", "BTL School", "BTL School Hostel", "CFTRI School", "Christian School", "Christ the King School Primary", "Dalvay High School", "D.A.V Public School", "Deaf & Dumb and Blind School", "Devaraja School", "Farooqia P.H. College & Boy's High School", "Gadi Chowk School", "Geetha (Shishu) Bharathi Primary High School", "Girls High School", "Gopala Swamy Primary School", "Government Primary School", "Govt Girls Hostel & High School", "Govt.Higher and Primary School", "Govt.Higher Primary School", "Govt Nizamiya School", "Govt.PG College & Primary School", "Govt.primar School", "Govt.primary School", "Govt Primary School", "Govt. Primary School", "Govt.Primary School", "Govt School", "Govt. School", "Govt. Sharada Vilas Higher Primary School", "Govt Urdu School", "Govt. Urdu School", "Govt Urudu School", "G.V. English High School", "Hardwicke Boarding School", "Hardwicke High School", "Higher Primary School", "IDEAL JAWA ROTARY SCHOOL", "Institute of Education High School", "JAGADAMBA SCHOOL", "Jaya Lakahmi Devi High School & Collage", "J.C.URS Boarding School", "J.S.S. High School", "J.S.S. High School & College", "J.S.S. Primary School", "J.S.S.Public School", "J.S.S.School", "JSS School", "Jyothi Primary & High School", "Kannada & English Primary High School", "Kuvempu Trust High School", "Lakshmipuram School", "LASHKAR MOHALLA URDU SCHOOL", "Loin School", "Mahajan School", "MAHARANI School", "Maharshi Public School", "Mallikarjuna School", "Malnad Driving School", "Manasa School", "Mari Mallappa School / College", "Mysore Lions School", "MYSORE WEST LIONS SEVANIKETAN SCHOOL", "Nalanada English High School", "Notre Dame School (Vijayanagar II Stage)", "Primary school", "Primary School", "Primary School (Govt.)", "Railway School", "Rangarao School For Disabled", "RGA Primary School", "RIS School", "Rotary School", "S.a.c.Primary & High School", "Sacridhananda School", "Sadvidya High School", "Saint Marth's School Premises", "Sampath School", "School", "SCHOOL", "S.C.V.D.S.School For Nursing", "SGS Higher Primary School", "Shivayogi School", "Siddappaji School", "Siddartha High School", "Sri Kanteshwara School", "Srikantha school", "Sri Nityananda Ashram and Convent School", "Srinkanth sanskrit school", "St. Joseph Central School", "St. Joseph School", "St.Marry's School", "ST. PHILOMENAS SCHOOL", "St.Rita's Higher and Primary School", "St.Thomas School", "Swamy Vivekananda School", "The Orchid School", "Urdu School", "Ursu Boarding School", "Vidya Jyothi School", "Vishwamanawa Primary School", "Vivekananda School", "V.V.S.Pandit Nehru Nursing Primary & High School", "5th Subhasnagar Mian", "6th Subhasnagar Mian", "Adi Chunchanagar Banashankari", "Basaveshwara Nagar", "Bhubaneshwari Nagar", "DATTANAGAR", "(Gandhinagar)", "GHOSIA NAGAR", "Gundurao Nagar", "H. Block R.K Nagar", "Jaiprakash Nagar 1st Phase", "(JAYACHAMARAJENDRA NAGAR)", "JAYANAGARA", "Jayanagara Railway Underbridge", "JLB NAGARA Industrial Area", "(J.P.Nagar)", "K. Nagaraj Kalyana Mantapa", "Kuvempunagar", "Kuvempu Nagara Bus Depot", "Muneshwara Nagar", "Muneshwara Nagara", "(Mysore Mahanagar Palika-Mysore)", "(Mysore Mahanagar Palike)", "Naidfu MNagara Busstand", "Nivedita Nagar", "RAGHAVENDRA NAGAR", "RAJENDRANAGAR", "Ramakrishna Nagar", "Ramakrishna Nagar 3rd Phase", "R.K.Nagar", "R.K. Nagar 3rd Phase (Muda)", "Saptarshi Dharma Rajaji Nagar", "Sharada Nagar Layout", "Sharadhadevi Nagar", "Sidhartha Nagar", "TOWARDS CHAMARAJA NAGARA", "Vidyanagar", "VIJAYA NAGAR", "Vijayanagar 2nd Stage", "VIJAYANAGAR LAYOUT MUDA", "Vishweshara Nagar", "Visveshwara Nagar"]


var BUS_ROUTES_LIST = ["10-502", "16-531", "4-514"];
var BUS_STOPS_LIST = ["Panchawati Nagar", "Vijay Nagar", "Sukhliya", "New Gouri Nagar", "Pardeshipura", "Indore Nagar Nigam", "Krishnapura", "Usha Nagar", "Annapurna Bal Vidya Mandir", "Vaishali Nagar", "Bada Ganapati Temple", "Imli Bazar", "Patanipura", "Badi Bhamori", "Man Mandir Cinema", "Bombay Hospital", "Musakhedi", "Narmada Project", "MPSEB Power House", "Azad Nagar", "White Church Colony", "Saifee Mohalla", "Nursinha Bazar", "Malganj", "Raj Mohalla", "M.P.Sadak Parivahan Nigam \nGangawal Bus Stand", "Chandan Nagar", "Sirpur", "Ammar Nagar", "Noorani Nagar"];


AJS={BASE_URL:"",drag_obj:null,drag_elm:null,_drop_zones:[],_cur_pos:null,getScrollTop:function(){
var t;
if(document.documentElement&&document.documentElement.scrollTop){
t=document.documentElement.scrollTop;
}else{
if(document.body){
t=document.body.scrollTop;
}
}
return t;
},addClass:function(){
var _2=AJS.forceArray(arguments);
var _3=_2.pop();
var _4=function(o){
if(!new RegExp("(^|\\s)"+_3+"(\\s|$)").test(o.className)){
o.className+=(o.className?" ":"")+_3;
}
};
AJS.map(_2,function(_6){
_4(_6);
});
},setStyle:function(){
var _7=AJS.forceArray(arguments);
var _8=_7.pop();
var _9=_7.pop();
AJS.map(_7,function(_a){
_a.style[_9]=AJS.getCssDim(_8);
});
},extend:function(_b){
var _c=new this("no_init");
for(k in _b){
var _d=_c[k];
var _e=_b[k];
if(_d&&_d!=_e&&typeof _e=="function"){
_e=this._parentize(_e,_d);
}
_c[k]=_e;
}
return new AJS.Class(_c);
},log:function(o){
if(window.console){
console.log(o);
}else{
var div=AJS.$("ajs_logger");
if(!div){
div=AJS.DIV({id:"ajs_logger","style":"color: green; position: absolute; left: 0"});
div.style.top=AJS.getScrollTop()+"px";
AJS.ACN(AJS.getBody(),div);
}
AJS.setHTML(div,""+o);
}
},setHeight:function(){
var _11=AJS.forceArray(arguments);
_11.splice(_11.length-1,0,"height");
AJS.setStyle.apply(null,_11);
},_getRealScope:function(fn,_13){
_13=AJS.$A(_13);
var _14=fn._cscope||window;
return function(){
var _15=AJS.$FA(arguments).concat(_13);
return fn.apply(_14,_15);
};
},documentInsert:function(elm){
if(typeof (elm)=="string"){
elm=AJS.HTML2DOM(elm);
}
document.write("<span id=\"dummy_holder\"></span>");
AJS.swapDOM(AJS.$("dummy_holder"),elm);
},getWindowSize:function(doc){
doc=doc||document;
var _18,_19;
if(self.innerHeight){
_18=self.innerWidth;
_19=self.innerHeight;
}else{
if(doc.documentElement&&doc.documentElement.clientHeight){
_18=doc.documentElement.clientWidth;
_19=doc.documentElement.clientHeight;
}else{
if(doc.body){
_18=doc.body.clientWidth;
_19=doc.body.clientHeight;
}
}
}
return {"w":_18,"h":_19};
},flattenList:function(_1a){
var r=[];
var _1c=function(r,l){
AJS.map(l,function(o){
if(o==null){
}else{
if(AJS.isArray(o)){
_1c(r,o);
}else{
r.push(o);
}
}
});
};
_1c(r,_1a);
return r;
},isFunction:function(obj){
return (typeof obj=="function");
},setEventKey:function(e){
e.key=e.keyCode?e.keyCode:e.charCode;
if(window.event){
e.ctrl=window.event.ctrlKey;
e.shift=window.event.shiftKey;
}else{
e.ctrl=e.ctrlKey;
e.shift=e.shiftKey;
}
switch(e.key){
case 63232:
e.key=38;
break;
case 63233:
e.key=40;
break;
case 63235:
e.key=39;
break;
case 63234:
e.key=37;
break;
}
},removeElement:function(){
var _22=AJS.forceArray(arguments);
AJS.map(_22,function(elm){
AJS.swapDOM(elm,null);
});
},_unloadListeners:function(){
if(AJS.listeners){
AJS.map(AJS.listeners,function(elm,_25,fn){
AJS.REV(elm,_25,fn);
});
}
AJS.listeners=[];
},join:function(_27,_28){
try{
return _28.join(_27);
}
catch(e){
var r=_28[0]||"";
AJS.map(_28,function(elm){
r+=_27+elm;
},1);
return r+"";
}
},getIndex:function(elm,_2c,_2d){
for(var i=0;i<_2c.length;i++){
if(_2d&&_2d(_2c[i])||elm==_2c[i]){
return i;
}
}
return -1;
},isIn:function(elm,_30){
var i=AJS.getIndex(elm,_30);
if(i!=-1){
return true;
}else{
return false;
}
},isArray:function(obj){
return obj instanceof Array;
},setLeft:function(){
var _33=AJS.forceArray(arguments);
_33.splice(_33.length-1,0,"left");
AJS.setStyle.apply(null,_33);
},appendChildNodes:function(elm){
if(arguments.length>=2){
AJS.map(arguments,function(n){
if(AJS.isString(n)){
n=AJS.TN(n);
}
if(AJS.isDefined(n)){
elm.appendChild(n);
}
},1);
}
return elm;
},getElementsByTagAndClassName:function(_36,_37,_38,_39){
var _3a=[];
if(!AJS.isDefined(_38)){
_38=document;
}
if(!AJS.isDefined(_36)){
_36="*";
}
var els=_38.getElementsByTagName(_36);
var _3c=els.length;
var _3d=new RegExp("(^|\\s)"+_37+"(\\s|$)");
for(i=0,j=0;i<_3c;i++){
if(_3d.test(els[i].className)||_37==null){
_3a[j]=els[i];
j++;
}
}
if(_39){
return _3a[0];
}else{
return _3a;
}
},isOpera:function(){
return (navigator.userAgent.toLowerCase().indexOf("opera")!=-1);
},isString:function(obj){
return (typeof obj=="string");
},hideElement:function(elm){
var _40=AJS.forceArray(arguments);
AJS.map(_40,function(elm){
elm.style.display="none";
});
},setOpacity:function(elm,p){
elm.style.opacity=p;
elm.style.filter="alpha(opacity="+p*100+")";
},insertBefore:function(elm,_45){
_45.parentNode.insertBefore(elm,_45);
return elm;
},setWidth:function(){
var _46=AJS.forceArray(arguments);
_46.splice(_46.length-1,0,"width");
AJS.setStyle.apply(null,_46);
},createArray:function(v){
if(AJS.isArray(v)&&!AJS.isString(v)){
return v;
}else{
if(!v){
return [];
}else{
return [v];
}
}
},isDict:function(o){
var _49=String(o);
return _49.indexOf(" Object")!=-1;
},isMozilla:function(){
return (navigator.userAgent.toLowerCase().indexOf("gecko")!=-1&&navigator.productSub>=20030210);
},removeEventListener:function(elm,_4b,fn,_4d){
var _4e="ajsl_"+_4b+fn;
if(!_4d){
_4d=false;
}
fn=elm[_4e]||fn;
if(elm["on"+_4b]==fn){
elm["on"+_4b]=elm[_4e+"old"];
}
if(elm.removeEventListener){
elm.removeEventListener(_4b,fn,_4d);
if(AJS.isOpera()){
elm.removeEventListener(_4b,fn,!_4d);
}
}else{
if(elm.detachEvent){
elm.detachEvent("on"+_4b,fn);
}
}
},callLater:function(fn,_50){
var _51=function(){
fn();
};
window.setTimeout(_51,_50);
},setTop:function(){
var _52=AJS.forceArray(arguments);
_52.splice(_52.length-1,0,"top");
AJS.setStyle.apply(null,_52);
},_createDomShortcuts:function(){
var _53=["ul","li","td","tr","th","tbody","table","input","span","b","a","div","img","button","h1","h2","h3","h4","h5","h6","br","textarea","form","p","select","option","optgroup","iframe","script","center","dl","dt","dd","small","pre","i"];
var _54=function(elm){
AJS[elm.toUpperCase()]=function(){
return AJS.createDOM.apply(null,[elm,arguments]);
};
};
AJS.map(_53,_54);
AJS.TN=function(_56){
return document.createTextNode(_56);
};
},addCallback:function(fn){
this.callbacks.unshift(fn);
},bindMethods:function(_58){
for(var k in _58){
var _5a=_58[k];
if(typeof (_5a)=="function"){
_58[k]=AJS.$b(_5a,_58);
}
}
},partial:function(fn){
var _5c=AJS.$FA(arguments);
_5c.shift();
return function(){
_5c=_5c.concat(AJS.$FA(arguments));
return fn.apply(window,_5c);
};
},isNumber:function(obj){
return (typeof obj=="number");
},getCssDim:function(dim){
if(AJS.isString(dim)){
return dim;
}else{
return dim+"px";
}
},isIe:function(){
return (navigator.userAgent.toLowerCase().indexOf("msie")!=-1&&navigator.userAgent.toLowerCase().indexOf("opera")==-1);
},removeClass:function(){
var _5f=AJS.forceArray(arguments);
var cls=_5f.pop();
var _61=function(o){
o.className=o.className.replace(new RegExp("\\s?"+cls,"g"),"");
};
AJS.map(_5f,function(elm){
_61(elm);
});
},setHTML:function(elm,_65){
elm.innerHTML=_65;
return elm;
},map:function(_66,fn,_68,_69){
var i=0,l=_66.length;
if(_68){
i=_68;
}
if(_69){
l=_69;
}
for(i;i<l;i++){
var val=fn(_66[i],i);
if(val!=undefined){
return val;
}
}
},addEventListener:function(elm,_6e,fn,_70,_71){
var _72="ajsl_"+_6e+fn;
if(!_71){
_71=false;
}
AJS.listeners=AJS.$A(AJS.listeners);
if(AJS.isIn(_6e,["keypress","keydown","keyup","click"])){
var _73=fn;
fn=function(e){
AJS.setEventKey(e);
return _73.apply(window,arguments);
};
}
var _75=AJS.isIn(_6e,["submit","load","scroll","resize"]);
var _76=AJS.$A(elm);
AJS.map(_76,function(_77){
if(_70){
var _78=fn;
fn=function(e){
AJS.REV(_77,_6e,fn);
return _78.apply(window,arguments);
};
}
if(_75){
var _7a=_77["on"+_6e];
var _7b=function(){
if(_7a){
fn(arguments);
return _7a(arguments);
}else{
return fn(arguments);
}
};
_77[_72]=_7b;
_77[_72+"old"]=_7a;
elm["on"+_6e]=_7b;
}else{
_77[_72]=fn;
if(_77.attachEvent){
_77.attachEvent("on"+_6e,fn);
}else{
if(_77.addEventListener){
_77.addEventListener(_6e,fn,_71);
}
}
AJS.listeners.push([_77,_6e,fn]);
}
});
},preloadImages:function(){
AJS.AEV(window,"load",AJS.$p(function(_7c){
AJS.map(_7c,function(src){
var pic=new Image();
pic.src=src;
});
},arguments));
},forceArray:function(_7f){
var r=[];
AJS.map(_7f,function(elm){
r.push(elm);
});
return r;
},update:function(l1,l2){
for(var i in l2){
l1[i]=l2[i];
}
return l1;
},getBody:function(){
return AJS.$bytc("body")[0];
},HTML2DOM:function(_85,_86){
var d=AJS.DIV();
d.innerHTML=_85;
if(_86){
return d.childNodes[0];
}else{
return d;
}
},getElement:function(id){
if(AJS.isString(id)||AJS.isNumber(id)){
return document.getElementById(id);
}else{
return id;
}
},showElement:function(){
var _89=AJS.forceArray(arguments);
AJS.map(_89,function(elm){
elm.style.display="";
});
},bind:function(fn,_8c,_8d){
fn._cscope=_8c;
return AJS._getRealScope(fn,_8d);
},createDOM:function(_8e,_8f){
var i=0,_91;
var elm=document.createElement(_8e);
var _93=_8f[0];
if(AJS.isDict(_8f[i])){
for(k in _93){
_91=_93[k];
if(k=="style"||k=="s"){
elm.style.cssText=_91;
}else{
if(k=="c"||k=="class"||k=="className"){
elm.className=_91;
}else{
elm.setAttribute(k,_91);
}
}
}
i++;
}
if(_93==null){
i=1;
}
for(var j=i;j<_8f.length;j++){
var _91=_8f[j];
if(_91){
var _95=typeof (_91);
if(_95=="string"||_95=="number"){
_91=AJS.TN(_91);
}
elm.appendChild(_91);
}
}
return elm;
},swapDOM:function(_96,src){
_96=AJS.getElement(_96);
var _98=_96.parentNode;
if(src){
src=AJS.getElement(src);
_98.replaceChild(src,_96);
}else{
_98.removeChild(_96);
}
return src;
},isDefined:function(o){
return (o!="undefined"&&o!=null);
}};
AJS.$=AJS.getElement;
AJS.$$=AJS.getElements;
AJS.$f=AJS.getFormElement;
AJS.$p=AJS.partial;
AJS.$b=AJS.bind;
AJS.$A=AJS.createArray;
AJS.DI=AJS.documentInsert;
AJS.ACN=AJS.appendChildNodes;
AJS.RCN=AJS.replaceChildNodes;
AJS.AEV=AJS.addEventListener;
AJS.REV=AJS.removeEventListener;
AJS.$bytc=AJS.getElementsByTagAndClassName;
AJS.$AP=AJS.absolutePosition;
AJS.$FA=AJS.forceArray;
AJS.addEventListener(window,"unload",AJS._unloadListeners);
AJS._createDomShortcuts();
AJS.Class=function(_9a){
var fn=function(){
if(arguments[0]!="no_init"){
return this.init.apply(this,arguments);
}
};
fn.prototype=_9a;
AJS.update(fn,AJS.Class.prototype);
return fn;
};
AJS.Class.prototype={extend:function(_9c){
var _9d=new this("no_init");
for(k in _9c){
var _9e=_9d[k];
var cur=_9c[k];
if(_9e&&_9e!=cur&&typeof cur=="function"){
cur=this._parentize(cur,_9e);
}
_9d[k]=cur;
}
return new AJS.Class(_9d);
},implement:function(_a0){
AJS.update(this.prototype,_a0);
},_parentize:function(cur,_a2){
return function(){
this.parent=_a2;
return cur.apply(this,arguments);
};
}};
script_loaded=true;


script_loaded=true;

AJS.fx={_shades:{0:"ffffff",1:"ffffee",2:"ffffdd",3:"ffffcc",4:"ffffbb",5:"ffffaa",6:"ffff99"},highlight:function(_1,_2){
var _3=new AJS.fx.Base();
_3.elm=AJS.$(_1);
_3.options.duration=600;
_3.setOptions(_2);
AJS.update(_3,{increase:function(){
if(this.now==7){
_1.style.backgroundColor="#fff";
}else{
_1.style.backgroundColor="#"+AJS.fx._shades[Math.floor(this.now)];
}
}});
return _3.custom(6,0);
},fadeIn:function(_4,_5){
_5=_5||{};
if(!_5.from){
_5.from=0;
AJS.setOpacity(_4,0);
}
if(!_5.to){
_5.to=1;
}
var s=new AJS.fx.Style(_4,"opacity",_5);
return s.custom(_5.from,_5.to);
},fadeOut:function(_7,_8){
_8=_8||{};
if(!_8.from){
_8.from=1;
}
if(!_8.to){
_8.to=0;
}
_8.duration=300;
var s=new AJS.fx.Style(_7,"opacity",_8);
return s.custom(_8.from,_8.to);
},setWidth:function(_a,_b){
var s=new AJS.fx.Style(_a,"width",_b);
return s.custom(_b.from,_b.to);
},setHeight:function(_d,_e){
var s=new AJS.fx.Style(_d,"height",_e);
return s.custom(_e.from,_e.to);
}};
AJS.fx.Base=new AJS.Class({init:function(_10){
this.options={onStart:function(){
},onComplete:function(){
},transition:AJS.fx.Transitions.sineInOut,duration:500,wait:true,fps:50};
AJS.update(this.options,_10);
AJS.bindMethods(this);
},setOptions:function(_11){
AJS.update(this.options,_11);
},step:function(){
var _12=new Date().getTime();
if(_12<this.time+this.options.duration){
this.cTime=_12-this.time;
this.setNow();
}else{
setTimeout(AJS.$b(this.options.onComplete,this,[this.elm]),10);
this.clearTimer();
this.now=this.to;
}
this.increase();
},setNow:function(){
this.now=this.compute(this.from,this.to);
},compute:function(_13,to){
var _15=to-_13;
return this.options.transition(this.cTime,_13,_15,this.options.duration);
},clearTimer:function(){
clearInterval(this.timer);
this.timer=null;
return this;
},_start:function(_16,to){
if(!this.options.wait){
this.clearTimer();
}
if(this.timer){
return;
}
setTimeout(AJS.$p(this.options.onStart,this.elm),10);
this.from=_16;
this.to=to;
this.time=new Date().getTime();
this.timer=setInterval(this.step,Math.round(1000/this.options.fps));
return this;
},custom:function(_18,to){
return this._start(_18,to);
},set:function(to){
this.now=to;
this.increase();
return this;
},setStyle:function(elm,_1c,val){
if(this.property=="opacity"){
AJS.setOpacity(elm,val);
}else{
AJS.setStyle(elm,_1c,val);
}
}});
AJS.fx.Style=AJS.fx.Base.extend({init:function(elm,_1f,_20){
this.parent();
this.elm=elm;
this.setOptions(_20);
this.property=_1f;
},increase:function(){
this.setStyle(this.elm,this.property,this.now);
}});
AJS.fx.Styles=AJS.fx.Base.extend({init:function(elm,_22){
this.parent();
this.elm=AJS.$(elm);
this.setOptions(_22);
this.now={};
},setNow:function(){
for(p in this.from){
this.now[p]=this.compute(this.from[p],this.to[p]);
}
},custom:function(obj){
if(this.timer&&this.options.wait){
return;
}
var _24={};
var to={};
for(p in obj){
_24[p]=obj[p][0];
to[p]=obj[p][1];
}
return this._start(_24,to);
},increase:function(){
for(var p in this.now){
this.setStyle(this.elm,p,this.now[p]);
}
}});
AJS.fx.Transitions={linear:function(t,b,c,d){
return c*t/d+b;
},sineInOut:function(t,b,c,d){
return -c/2*(Math.cos(Math.PI*t/d)-1)+b;
}};
script_loaded=true;


script_loaded=true;

var GB_CURRENT=null;
GB_hide=function(cb){
GB_CURRENT.hide(cb);
};
GreyBox=new AJS.Class({init:function(_2){
this.use_fx=AJS.fx;
this.type="page";
this.overlay_click_close=false;
this.salt=0;
this.root_dir=GB_ROOT_DIR;
this.callback_fns=[];
this.reload_on_close=false;
this.src_loader=this.root_dir+"loader_frame.html";
var _3=window.location.hostname.indexOf("www");
var _4=this.src_loader.indexOf("www");
if(_3!=-1&&_4==-1){
this.src_loader=this.src_loader.replace("://","://www.");
}
if(_3==-1&&_4!=-1){
this.src_loader=this.src_loader.replace("://www.","://");
}
this.show_loading=true;
AJS.update(this,_2);
},addCallback:function(fn){
if(fn){
this.callback_fns.push(fn);
}
},show:function(_6){
GB_CURRENT=this;
this.url=_6;
var _7=[AJS.$bytc("object"),AJS.$bytc("select")];
AJS.map(AJS.flattenList(_7),function(_8){
_8.style.visibility="hidden";
});
this.createElements();
return false;
},hide:function(cb){
var me=this;
AJS.callLater(function(){
var _b=me.callback_fns;
if(_b!=[]){
AJS.map(_b,function(fn){
fn();
});
}
me.onHide();
if(me.use_fx){
var _d=me.overlay;
AJS.fx.fadeOut(me.overlay,{onComplete:function(){
AJS.removeElement(_d);
_d=null;
},duration:300});
AJS.removeElement(me.g_window);
}else{
AJS.removeElement(me.g_window,me.overlay);
}
me.removeFrame();
AJS.REV(window,"scroll",_GB_setOverlayDimension);
AJS.REV(window,"resize",_GB_update);
var _e=[AJS.$bytc("object"),AJS.$bytc("select")];
AJS.map(AJS.flattenList(_e),function(_f){
_f.style.visibility="visible";
});
GB_CURRENT=null;
if(me.reload_on_close){
window.location.reload();
}
if(AJS.isFunction(cb)){
cb();
}
},10);
},update:function(){
this.setOverlayDimension();
this.setFrameSize();
this.setWindowPosition();
},createElements:function(){
this.initOverlay();
this.g_window=AJS.DIV({"id":"GB_window"});
AJS.hideElement(this.g_window);
AJS.getBody().insertBefore(this.g_window,this.overlay.nextSibling);
this.initFrame();
this.initHook();
this.update();
var me=this;
if(this.use_fx){
AJS.fx.fadeIn(this.overlay,{duration:300,to:0.7,onComplete:function(){
me.onShow();
AJS.showElement(me.g_window);
me.startLoading();
}});
}else{
AJS.setOpacity(this.overlay,0.7);
AJS.showElement(this.g_window);
this.onShow();
this.startLoading();
}
AJS.AEV(window,"scroll",_GB_setOverlayDimension);
AJS.AEV(window,"resize",_GB_update);
},removeFrame:function(){
try{
AJS.removeElement(this.iframe);
}
catch(e){
}
this.iframe=null;
},startLoading:function(){
this.iframe.src=this.src_loader+"?s="+this.salt++;
AJS.showElement(this.iframe);
},setOverlayDimension:function(){
var _11=AJS.getWindowSize();
if(AJS.isMozilla()||AJS.isOpera()){
AJS.setWidth(this.overlay,"100%");
}else{
AJS.setWidth(this.overlay,_11.w);
}
var _12=Math.max(AJS.getScrollTop()+_11.h,AJS.getScrollTop()+this.height);
if(_12<AJS.getScrollTop()){
AJS.setHeight(this.overlay,_12);
}else{
AJS.setHeight(this.overlay,AJS.getScrollTop()+_11.h);
}
},initOverlay:function(){
this.overlay=AJS.DIV({"id":"GB_overlay"});
if(this.overlay_click_close){
AJS.AEV(this.overlay,"click",GB_hide);
}
AJS.setOpacity(this.overlay,0);
AJS.getBody().insertBefore(this.overlay,AJS.getBody().firstChild);
},initFrame:function(){
if(!this.iframe){
var d={"name":"GB_frame","class":"GB_frame","frameBorder":0};
if(AJS.isIe()){
d.src="javascript:false;document.write(\"\");";
}
this.iframe=AJS.IFRAME(d);
this.middle_cnt=AJS.DIV({"class":"content"},this.iframe);
this.top_cnt=AJS.DIV();
this.bottom_cnt=AJS.DIV();
AJS.ACN(this.g_window,this.top_cnt,this.middle_cnt,this.bottom_cnt);
}
},onHide:function(){
},onShow:function(){
},setFrameSize:function(){
},setWindowPosition:function(){
},initHook:function(){
}});
_GB_update=function(){
if(GB_CURRENT){
GB_CURRENT.update();
}
};
_GB_setOverlayDimension=function(){
if(GB_CURRENT){
GB_CURRENT.setOverlayDimension();
}
};
AJS.preloadImages(GB_ROOT_DIR+"indicator.gif");
script_loaded=true;
var GB_SETS={};
function decoGreyboxLinks(){
var as=AJS.$bytc("a");
AJS.map(as,function(a){
if(a.getAttribute("href")&&a.getAttribute("rel")){
var rel=a.getAttribute("rel");
if(rel.indexOf("gb_")==0){
var _17=rel.match(/\w+/)[0];
var _18=rel.match(/\[(.*)\]/)[1];
var _19=0;
var _1a={"caption":a.title||"","url":a.href};
if(_17=="gb_pageset"||_17=="gb_imageset"){
if(!GB_SETS[_18]){
GB_SETS[_18]=[];
}
GB_SETS[_18].push(_1a);
_19=GB_SETS[_18].length;
}
if(_17=="gb_pageset"){
a.onclick=function(){
GB_showFullScreenSet(GB_SETS[_18],_19);
return false;
};
}
if(_17=="gb_imageset"){
a.onclick=function(){
GB_showImageSet(GB_SETS[_18],_19);
return false;
};
}
if(_17=="gb_image"){
a.onclick=function(){
GB_showImage(_1a.caption,_1a.url);
return false;
};
}
if(_17=="gb_page"){
a.onclick=function(){
var sp=_18.split(/, ?/);
GB_show(_1a.caption,_1a.url,parseInt(sp[1]),parseInt(sp[0]));
return false;
};
}
if(_17=="gb_page_fs"){
a.onclick=function(){
GB_showFullScreen(_1a.caption,_1a.url);
return false;
};
}
if(_17=="gb_page_center"){
a.onclick=function(){
var sp=_18.split(/, ?/);
GB_showCenter(_1a.caption,_1a.url,parseInt(sp[1]),parseInt(sp[0]));
return false;
};
}
}
}
});
}
AJS.AEV(window,"load",decoGreyboxLinks);
GB_showImage=function(_1d,url,_1f){
var _20={width:300,height:300,type:"image",fullscreen:false,center_win:true,caption:_1d,callback_fn:_1f};
var win=new GB_Gallery(_20);
return win.show(url);
};
GB_showPage=function(_22,url,_24){
var _25={type:"page",caption:_22,callback_fn:_24,fullscreen:true,center_win:false};
var win=new GB_Gallery(_25);
return win.show(url);
};
GB_Gallery=GreyBox.extend({init:function(_27){
this.parent({});
this.img_close=this.root_dir+"g_close.gif";
AJS.update(this,_27);
this.addCallback(this.callback_fn);
},initHook:function(){
AJS.addClass(this.g_window,"GB_Gallery");
var _28=AJS.DIV({"class":"inner"});
this.header=AJS.DIV({"class":"GB_header"},_28);
AJS.setOpacity(this.header,0);
AJS.getBody().insertBefore(this.header,this.overlay.nextSibling);
var _29=AJS.TD({"id":"GB_caption","class":"caption","width":"40%"},this.caption);
var _2a=AJS.TD({"id":"GB_middle","class":"middle","width":"20%"});
var _2b=AJS.IMG({"src":this.img_close});
AJS.AEV(_2b,"click",GB_hide);
var _2c=AJS.TD({"class":"close","width":"40%"},_2b);
var _2d=AJS.TBODY(AJS.TR(_29,_2a,_2c));
var _2e=AJS.TABLE({"cellspacing":"0","cellpadding":0,"border":0},_2d);
AJS.ACN(_28,_2e);
if(this.fullscreen){
AJS.AEV(window,"scroll",AJS.$b(this.setWindowPosition,this));
}else{
AJS.AEV(window,"scroll",AJS.$b(this._setHeaderPos,this));
}
},setFrameSize:function(){
var _2f=this.overlay.offsetWidth;
var _30=AJS.getWindowSize();
if(this.fullscreen){
this.width=_2f-40;
this.height=_30.h-80;
}
AJS.setWidth(this.iframe,this.width);
AJS.setHeight(this.iframe,this.height);
AJS.setWidth(this.header,_2f);
},_setHeaderPos:function(){
AJS.setTop(this.header,AJS.getScrollTop()+10);
},setWindowPosition:function(){
var _31=this.overlay.offsetWidth;
var _32=AJS.getWindowSize();
AJS.setLeft(this.g_window,((_31-50-this.width)/2));
var _33=AJS.getScrollTop()+55;
if(!this.center_win){
AJS.setTop(this.g_window,_33);
}else{
var fl=((_32.h-this.height)/2)+20+AJS.getScrollTop();
if(fl<0){
fl=0;
}
if(_33>fl){
fl=_33;
}
AJS.setTop(this.g_window,fl);
}
this._setHeaderPos();
},onHide:function(){
AJS.removeElement(this.header);
AJS.removeClass(this.g_window,"GB_Gallery");
},onShow:function(){
if(this.use_fx){
AJS.fx.fadeIn(this.header,{to:1});
}else{
AJS.setOpacity(this.header,1);
}
}});
AJS.preloadImages(GB_ROOT_DIR+"g_close.gif");
GB_showFullScreenSet=function(set,_36,_37){
var _38={type:"page",fullscreen:true,center_win:false};
var _39=new GB_Sets(_38,set);
_39.addCallback(_37);
_39.showSet(_36-1);
return false;
};
GB_showImageSet=function(set,_3b,_3c){
var _3d={type:"image",fullscreen:false,center_win:true,width:300,height:300};
var _3e=new GB_Sets(_3d,set);
_3e.addCallback(_3c);
_3e.showSet(_3b-1);
return false;
};
GB_Sets=GB_Gallery.extend({init:function(_3f,set){
this.parent(_3f);
if(!this.img_next){
this.img_next=this.root_dir+"next.gif";
}
if(!this.img_prev){
this.img_prev=this.root_dir+"prev.gif";
}
this.current_set=set;
},showSet:function(_41){
this.current_index=_41;
var _42=this.current_set[this.current_index];
this.show(_42.url);
this._setCaption(_42.caption);
this.btn_prev=AJS.IMG({"class":"left",src:this.img_prev});
this.btn_next=AJS.IMG({"class":"right",src:this.img_next});
AJS.AEV(this.btn_prev,"click",AJS.$b(this.switchPrev,this));
AJS.AEV(this.btn_next,"click",AJS.$b(this.switchNext,this));
GB_STATUS=AJS.SPAN({"class":"GB_navStatus"});
AJS.ACN(AJS.$("GB_middle"),this.btn_prev,GB_STATUS,this.btn_next);
this.updateStatus();
},updateStatus:function(){
AJS.setHTML(GB_STATUS,(this.current_index+1)+" / "+this.current_set.length);
if(this.current_index==0){
AJS.addClass(this.btn_prev,"disabled");
}else{
AJS.removeClass(this.btn_prev,"disabled");
}
if(this.current_index==this.current_set.length-1){
AJS.addClass(this.btn_next,"disabled");
}else{
AJS.removeClass(this.btn_next,"disabled");
}
},_setCaption:function(_43){
AJS.setHTML(AJS.$("GB_caption"),_43);
},updateFrame:function(){
var _44=this.current_set[this.current_index];
this._setCaption(_44.caption);
this.url=_44.url;
this.startLoading();
},switchPrev:function(){
if(this.current_index!=0){
this.current_index--;
this.updateFrame();
this.updateStatus();
}
},switchNext:function(){
if(this.current_index!=this.current_set.length-1){
this.current_index++;
this.updateFrame();
this.updateStatus();
}
}});
AJS.AEV(window,"load",function(){
AJS.preloadImages(GB_ROOT_DIR+"next.gif",GB_ROOT_DIR+"prev.gif");
});
GB_show=function(_45,url,_47,_48,_49){
var _4a={caption:_45,height:_47||500,width:_48||500,fullscreen:false,callback_fn:_49};
var win=new GB_Window(_4a);
return win.show(url);
};
GB_showCenter=function(_4c,url,_4e,_4f,_50){
var _51={caption:_4c,center_win:true,height:_4e||500,width:_4f||500,fullscreen:false,callback_fn:_50};
var win=new GB_Window(_51);
return win.show(url);
};
GB_showFullScreen=function(_53,url,_55){
var _56={caption:_53,fullscreen:true,callback_fn:_55};
var win=new GB_Window(_56);
return win.show(url);
};
GB_Window=GreyBox.extend({init:function(_58){
this.parent({});
this.img_header=this.root_dir+"header_bg.gif";
this.img_close=this.root_dir+"w_close.gif";
this.show_close_img=true;
AJS.update(this,_58);
this.addCallback(this.callback_fn);
},initHook:function(){
AJS.addClass(this.g_window,"GB_Window");
this.header=AJS.TABLE({"class":"header"});
this.header.style.backgroundImage="url("+this.img_header+")";
var _59=AJS.TD({"class":"caption"},this.caption);
var _5a=AJS.TD({"class":"close"});
if(this.show_close_img){
var _5b=AJS.IMG({"src":this.img_close});
var _5c=AJS.SPAN("Close");
var btn=AJS.DIV(_5b,_5c);
AJS.AEV([_5b,_5c],"mouseover",function(){
AJS.addClass(_5c,"on");
});
AJS.AEV([_5b,_5c],"mouseout",function(){
AJS.removeClass(_5c,"on");
});
AJS.AEV([_5b,_5c],"mousedown",function(){
AJS.addClass(_5c,"click");
});
AJS.AEV([_5b,_5c],"mouseup",function(){
AJS.removeClass(_5c,"click");
});
AJS.AEV([_5b,_5c],"click",GB_hide);
AJS.ACN(_5a,btn);
}
tbody_header=AJS.TBODY();
AJS.ACN(tbody_header,AJS.TR(_59,_5a));
AJS.ACN(this.header,tbody_header);
AJS.ACN(this.top_cnt,this.header);
if(this.fullscreen){
AJS.AEV(window,"scroll",AJS.$b(this.setWindowPosition,this));
}
},setFrameSize:function(){
if(this.fullscreen){
var _5e=AJS.getWindowSize();
overlay_h=_5e.h;
this.width=Math.round(this.overlay.offsetWidth-(this.overlay.offsetWidth/100)*10);
this.height=Math.round(overlay_h-(overlay_h/100)*10);
}
AJS.setWidth(this.header,this.width+6);
AJS.setWidth(this.iframe,this.width);
AJS.setHeight(this.iframe,this.height);
},setWindowPosition:function(){
var _5f=AJS.getWindowSize();
AJS.setLeft(this.g_window,((_5f.w-this.width)/2)-13);
if(!this.center_win){
AJS.setTop(this.g_window,AJS.getScrollTop());
}else{
var fl=((_5f.h-this.height)/2)-20+AJS.getScrollTop();
if(fl<0){
fl=0;
}
AJS.setTop(this.g_window,fl);
}
}});
AJS.preloadImages(GB_ROOT_DIR+"w_close.gif",GB_ROOT_DIR+"header_bg.gif");


script_loaded=true;

// accordion.js v2.0
//
// Copyright (c) 2007 stickmanlabs
// Author: Kevin P Miller | http://www.stickmanlabs.com
// 
// Accordion is freely distributable under the terms of an MIT-style license.
//
// I don't care what you think about the file size...
//   Be a pro: 
//	    http://www.thinkvitamin.com/features/webapps/serving-javascript-fast
//      http://rakaz.nl/item/make_your_pages_load_faster_by_combining_and_compressing_javascript_and_css_files
//

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

if (typeof Effect == 'undefined') 
	throw("accordion.js requires including script.aculo.us' effects.js library!");

var accordion = Class.create();
accordion.prototype = {

	//
	//  Setup the Variables
	//
	showAccordion : null,
	currentAccordion : null,
	duration : null,
	effects : [],
	animating : false,
	
	//  
	//  Initialize the accordions
	//
	initialize: function(container, options) {
	  if (!$(container)) {
	    throw(container+" doesn't exist!");
	    return false;
	  }
	  
		this.options = Object.extend({
			resizeSpeed : 8,
			classNames : {
				toggle : 'accordion_toggle',
				toggleActive : 'accordion_toggle_active',
				content : 'accordion_content'
			},
			defaultSize : {
				height : null,
				width : null
			},
			direction : 'vertical',
			onEvent : 'click'
		}, options || {});
		
		this.duration = ((11-this.options.resizeSpeed)*0.15);

		var accordions = $$('#'+container+' .'+this.options.classNames.toggle);
		accordions.each(function(accordion) {
			Event.observe(accordion, this.options.onEvent, this.activate.bind(this, accordion), false);
			if (this.options.onEvent == 'click') {
			  accordion.onclick = function() {return false;};
			}
			
			if (this.options.direction == 'horizontal') {
				var options = $H({width: '0px'});
			} else {
				var options = $H({height: '0px'});			
			}
			options.merge({display: 'none'});			
			
			this.currentAccordion = $(accordion.next(0)).setStyle(options);			
		}.bind(this));
	},
	
	//
	//  Activate an accordion
	//
	activate : function(accordion) {
		if (this.animating) {
			return false;
		}
		
		this.effects = [];
	
		this.currentAccordion = $(accordion.next(0));
		this.currentAccordion.setStyle({
			display: 'block'
		});		
		
		this.currentAccordion.previous(0).addClassName(this.options.classNames.toggleActive);

		if (this.options.direction == 'horizontal') {
			this.scaling = $H({
				scaleX: true,
				scaleY: false
			});
		} else {
			this.scaling = $H({
				scaleX: false,
				scaleY: true
			});			
		}
			
		if (this.currentAccordion == this.showAccordion) {
		  this.deactivate();
		} else {
		  this._handleAccordion();
		}
	},
	// 
	// Deactivate an active accordion
	//
	deactivate : function() {
		var options = $H({
		  duration: this.duration,
			scaleContent: false,
			transition: Effect.Transitions.sinoidal,
			queue: {
				position: 'end', 
				scope: 'accordionAnimation'
			},
			scaleMode: { 
				originalHeight: this.options.defaultSize.height ? this.options.defaultSize.height : this.currentAccordion.scrollHeight,
				originalWidth: this.options.defaultSize.width ? this.options.defaultSize.width : this.currentAccordion.scrollWidth
			},
			afterFinish: function() {
				this.showAccordion.setStyle({
          height: 'auto',
					display: 'none'
				});				
				this.showAccordion = null;
				this.animating = false;
			}.bind(this)
		});    
    options.merge(this.scaling);

    this.showAccordion.previous(0).removeClassName(this.options.classNames.toggleActive);
    
		new Effect.Scale(this.showAccordion, 0, options);
	},

  //
  // Handle the open/close actions of the accordion
  //
	_handleAccordion : function() {
		var options = $H({
			sync: true,
			scaleFrom: 0,
			scaleContent: false,
			transition: Effect.Transitions.sinoidal,
			scaleMode: { 
				originalHeight: this.options.defaultSize.height ? this.options.defaultSize.height : this.currentAccordion.scrollHeight,
				originalWidth: this.options.defaultSize.width ? this.options.defaultSize.width : this.currentAccordion.scrollWidth
			}
		});
		options.merge(this.scaling);
		
		this.effects.push(
			new Effect.Scale(this.currentAccordion, 100, options)
		);

		if (this.showAccordion) {
			this.showAccordion.previous(0).removeClassName(this.options.classNames.toggleActive);
			
			options = $H({
				sync: true,
				scaleContent: false,
				transition: Effect.Transitions.sinoidal
			});
			options.merge(this.scaling);
			
			this.effects.push(
				new Effect.Scale(this.showAccordion, 0, options)
			);				
		}
		
    new Effect.Parallel(this.effects, {
			duration: this.duration, 
			queue: {
				position: 'end', 
				scope: 'accordionAnimation'
			},
			beforeStart: function() {
				this.animating = true;
			}.bind(this),
			afterFinish: function() {
				if (this.showAccordion) {
					this.showAccordion.setStyle({
						display: 'none'
					});				
				}
				$(this.currentAccordion).setStyle({
				  height: 'auto'
				});
				this.showAccordion = this.currentAccordion;
				this.animating = false;
			}.bind(this)
		});
	}
}
	


function resetForm() {
    this.form.reset();    
    Form.getInputs(this.form, 'text').each(function(input) {
        $(input).value = Element.readAttribute($(input), 'default_text');
        $(input).addClassName('faded_text');
    });
    if($('results-div')) { $('results-div').innerHTML = Element.readAttribute($('results-div'), 'default_text'); }
    if($('results-block')) { $('results-block').innerHTML = Element.readAttribute($('results-block'), 'default_text'); }
    clearLayers(["markers"]);
}

function expandAll() {
    blocks = $$('.acc_toggle');
    blocks.each(function(block) {
        if (block.parentNode.id == "accord") { 
            $(block).next(0).show();
        }
        else {
            $(block).next(0).hide();
        }
    });
    $('expand-all').hide();
}

function handle_accordion(block_number, form_type) {
    blocks = $$('.acc_toggle');
    blocks.each(function(block) {
        if(block.parentNode.id == "accord" && block.id != block_number) {
            $(block).next(0).hide();
        }
        else if (block.parentNode.id == "accord" && block.id == block_number) {
            $(block).next(0).show();
            if($('expand-all')) { $('expand-all').show();}
        }
    });
    current_form_id = form_type + "_form";
    forms = $$('.acc_form');
    forms.each(function(form) {
        if(form.id != current_form_id) {
            $(form).hide();
            firstChild = Element.childElements(form)[0];
            if(firstChild && Element.inspect(firstChild) == "<form>") {
                firstChild.reset();
            }
        }
        else {
            $(form).show();
        }
    });
}

function show_form(form_id) {
    if($(form_id)) { $(form_id).show(); }
}

function toggle_accordion(e) {
    block_number = this.id.substring(0,1);
    form_type = this.id.substring(this.id.indexOf('-')+1, this.id.lastIndexOf('_'));
    handle_accordion(block_number, form_type);
    show_form(form_type+"_form");
}

function clear_default() {
    if(this.value == Element.readAttribute(this, 'default_text')) {
        this.value = "";
        Element.removeClassName($(this.id), 'faded_text');
    }
}

function set_default_if_value_empty() {
    if(this.value.length == 0 || this.value == "" || this.value == this.default_text) {
        Element.addClassName($(this), 'faded_text');
        this.value = Element.readAttribute($(this), 'default_text');
    }
}

function loadAccordion() {
    var verticalAccordions = $$('.acc_toggle');
    verticalAccordions.each(function(accordion) {
        Event.observe(accordion, 'click', toggle_accordion, false);
    });
    
    //Attach click events to text fields with class *default_text*
    var input_fields = $$('.default_text');
    input_fields.each(function(input_field) {
        Event.observe(input_field, 'focus', clear_default, false);
        Event.observe(input_field, 'blur', set_default_if_value_empty, false);
    });
    
    var reset_buttons = $$('.reset_button');
    reset_buttons.each(function(reset_button) {
        Event.observe(reset_button, 'click', resetForm, false);
    });
}
