function GoogleTranslate(){
	if (!ConfirmTranslate()){return;}
	var URL='http://translate.google.com/translate?prev=hp&hl=en&js=y&sl=en&tl=es&history_state0=We%20hope%20your%20visit%20was%20informative%20and%20enjoyable.%20&u='+escape(window.location.href);
	window.location=URL;
//window.open(URL,'_blank'); 
}
function MSTranslate(){
	if (!ConfirmTranslate()){return;}
	var URL='http://www.microsofttranslator.com/BV.aspx?ref=BVNav&from=en&to=es&a='+escape(window.location.href);
	window.location=URL;
//window.open(URL,'_blank'); 
}
function CreoleTranslate(){
	if (!ConfirmTranslate()){return;}
	var URL='http://translate.google.com/translate?prev=hp&hl=en&js=y&sl=en&tl=ht&history_state0=We%20hope%20your%20visit%20was%20informative%20and%20enjoyable.%20&u='+escape(window.location.href);
	window.location=URL;
//window.open(URL,'_blank'); 
}
function MoreTranslate(){
	if (!ConfirmTranslate()){return;}
	var URL='http://translate.google.com/translate?prev=hp&hl=en&js=y&sl=en&tl=pt&history_state0=We%20hope%20your%20visit%20was%20informative%20and%20enjoyable.%20&u='+escape(window.location.href);
	window.location=URL;
//window.open(URL,'_blank'); 
}
function ConfirmTranslate(){
	var a=confirm('You are leaving Broward.org, are you sure you want to continue?');
	if (a){return true;}
}

var _gaq = _gaq || []; 

function BCPageLoad(){

	AddWWW();
	HideSignIn();
	MakePrintFriendly();
	MakeMobileFriendly();
	
  	_gaq.push(['_setAccount', 'UA-20386207-1']);
  	_gaq.push(['_setDomainName', 'broward.org']);
  	_gaq.push(['_trackPageview']);

  	(function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  	})();
}

function AddWWW(){ 
	var url=window.location.toString().toLowerCase();
	var newurl=url.replace('http://broward.org','http://www.broward.org');
	if (newurl!=url)
	{	
		window.location=newurl;
	}
}


function HideSignIn(){
var host=window.location.hostname.toLowerCase();
if (host=='browardauthor')
{
	var loginDiv=document.getElementById('SharePointLogin');
	if (loginDiv)
	{
		loginDiv.style.display = 'block';
		return;
	}	
}

var signLink=document.getElementById('ctl00_explitLogout_ExplicitLogin');
if (signLink){
	signLink.style.display = 'none';
	}
	var loginDiv=document.getElementById('SharePointLogin');
if (loginDiv){
	loginDiv.style.display = 'block';	
	}	
}
function MakePrintFriendly()
{//Makes the window print friendly if "print=1" is detected as a query string argument 
var p=getQueryVariable("print");
if (p==1)
{
	var newSS=document.createElement("link");
	newSS.rel='stylesheet';
	newSS.type='text/css';	
	newSS.href='/Style%20Library/bc-printfriendly.css';	
	document.getElementsByTagName("head")[0].appendChild(newSS);
}
}
function PrintFriendly()
{
var URL=window.location.href;
var PrintURL
var randomnumber=Math.floor(Math.random()*101)
if(window.location.search.substring(1).length>0)
{
	PrintURL=URL+"&print=1";
}
else
{
	PrintURL=URL + "?print=1";
}
pWin=window.open(PrintURL,"print_window"+randomnumber);
pWin.focus();

//window.location.href=window.location.href + "?print=1";
}

function getQueryVariable(variable) {
	var query = window.location.search.substring(1);
	var vars = query.split("&");
    for (var i=0;i<vars.length;i++) {
        var pair = vars[i].split("=");
        if (pair[0] == variable) {
        	return pair[1];
        }
    }
}

function MakeMobileFriendly()
{//Makes the window mobile friendly if "mobile=1" is detected as a query string argument 
var p=getQueryVariable("mobile");
if (p==1)
{
	var newSS=document.createElement("link");
	newSS.rel='stylesheet';
	newSS.type='text/css';	
	newSS.href='/Style%20Library/bc-mobilefriendly.css';	
	document.getElementsByTagName("head")[0].appendChild(newSS);
}
}

function SubmitUSASearch(){
	var s=document.getElementById('query-field').value;
	if((s=='')||(s=='Search')||(s=='Enter search words'))
	{
	alert('Please enter one or more search words.');
	return false;	
	}	
	var query=document.getElementById('query-field').value;
	query=unescape(query.replace(/ /g,"+"));
	var url=window.location.toString().toLowerCase();	
	var affiliateID;
	if(url.indexOf("/browardhousingcouncil")>0)
		{
			affiliateID="browardhousingcouncil";
		}
	else
		{
			affiliateID="co.broward.fl.us";
		}
	URL='http://usasearch.gov/search?affiliate='+affiliateID+'&query='+query;
	window.open(URL,'_New');	
} 

