var SFGov = (function(){
	function news_slide_load(){$.ajax({url:"Rss.aspx?type=5&paramtime=current",success:news_success,error:news_error});	}
	function news_success(d){
		if($(d).find('item').length > 0){
			var h='';
			$(d).find('item').each(function(i){var l=$(this).find('link').text().replace("sf-police.org//index.aspx","sf-police.org/index.aspx");h+='<a href="'+l+'">'+$(this).find('title').text()+'</a>';});
			$('#sfpd_homepage_newsbox_caption').html(h);news_slide();
		}
	}
	function news_slide(){
		$('#sfpd_homepage_newsbox_caption').cycle({ fx:'scrollLeft', timeout: 10000,next: '#sfpd_homepage_newsbox_next_btn'});
		$('#sfpd_homepage_newsbox_pause_btn').click(function(){$('#sfpd_homepage_newsbox_caption').cycle('pause');}); 
		$('#sfpd_homepage_newsbox_next_btn').click(function(){$('#sfpd_homepage_newsbox_caption').cycle('resume');}); 
	}
	function news_error(){}
	function qcv_get(){ return $('#qcv').attr('value');}
	function se_get(){return $('#search_url').attr('href');}
	function qi_run(){_qi='#txtHowDoI';_qb=$(_qi).val();qbc();qce();qsp();}
	function qbc(){
		$(_qi).focus(function(e){if($(_qi).val()==_qb){$(_qi).val('');}});
		$(_qi).blur(function(e){if($(_qi).val()==''){$(_qi).val(_qb);}});}
	function qce(){$(_qi).keydown(function(e){if(e.keyCode=='13'){qgo();}});}
	function qsp(){$('#txtHowDoI_search').click(function(e){qgo();return false;});}
	function qcl(){if($(_qi).val()==''){return '';}else{return se_get()+"&q="+encodeURIComponent($(_qi).val())+"&cx="+encodeURIComponent(qcv_get());}}
	function qgo(){l=qcl();if(l!=''){window.location=l;}}
	function ts(){if($('#sfpd_homepage_translate_box').length>0){$('#sfpd_homepage_translate_box .translate_es').click(function(){tsg('es')});$('#sfpd_homepage_translate_box .translate_ch').click(function(){tsg('zh-TW')});}}
	function tsg(l){var e=(document.charset||document.characterSet);location.href='http://translate.google.com/translate?u='+escape(location.href)+'&hl=en&langpair=auto|'+l+'&tbb=1&ie='+e;}
	function ran(){$(document).ready(function(){if($('#sfpd_homepage_newsbox').length>0){news_slide_load();}if($('#txtHowDoI').length>0){qi_run();}ts();});}
	return ran();
})();




