/*
	2007.10.03	gricke
				<ajaxErrorTo> - these variables are used by javascripto2/ajax.js to send error email if an AJAX error occurs - used for careers
	2006.04.19	gricke
				Copied from javascriptO2				
	SEEALSO
				css/header.css 
								<Login>
								<loginLink>
*/

window.onload = initialize; 

var ajaxErrorTo = 'gricke@orbisdesign.com';
var ajaxErrorFrom = 'errors@federalsignal-integratedsystems.com';
var ajaxErrorSubject = 'federalsignal-integratedsystems.com error';

function initialize () {
	loginAdmin();
	emailFooter();
	setupFooterNav();
	//contactUsImageFooter();
}
function setupFooterNav(){
	var footerNav = document.getElementById('FooterImage_1');
	var HTMLDisp = '';
	HTMLDisp += '<div id="socialLinks">';
	HTMLDisp += '<div id="twitter"><a href="http://twitter.com/FedSigEmcomm" target="_blank"><img src="/images/content/footer_twitter.png" width="91" height="34" alt="Follow us on Twitter" /></a></div>';
	HTMLDisp += '<div id="fb"><a href="http://www.facebook.com/pages/Federal-Signal-EMComm/175371215847084" target="_blank"><img src="/images/content/footer_facebook.png" width="107" height="34" alt="Follow us on Facebook" /></a></div>';
	HTMLDisp += '</div>';
	footerNav.innerHTML = HTMLDisp;
}
var functionLoop = 0;
function sideBanner(){
	if(document.getElementById('subNavBanner')){
		//document.getElementById('subNavBanner').innerHTML = '<a href="/PublicSafetySurvey_31173.aspx"><img src="/images/content/sideBanner_survey.png" width="200" height="163" ></a>';
		document.getElementById('subNavBanner').innerHTML = '<a href="http://emcomm.federalsignal.com" target="_blank"><img src="/images/content/sideBanner_emcomm.png" width="199" height="310" ></a>';
	}else{
		functionLoop += 1;
		if(window.functionLoop < 50){
			setTimeout('sideBanner()',10);
		}	
	}
}
sideBanner();

function emailFooter(){
	var HTMLDisp = '';
	if (document.getElementById('CoEmail')){
	
		var sSite = window.location;
		sSite = sSite + ' ';
		sSite = sSite.toLowerCase();

		if(sSite.indexOf("home_2") == -1){
			var emailClick = document.getElementById('CoEmail');
			HTMLDisp = HTMLDisp + 'E-mail: <a href=\"MailTo:systems@fedsig.com?CC=smoss@fedsig.co.uk,griddiough@fedsig.co.uk,jbentley@fedsig.com\">systems@fedsig.com</a>';
			emailClick.innerHTML = HTMLDisp;
		}
	}
}
function contactUsImageFooter(){
	var HTMLDisp = '';
	var ProductRfiName = document.title;
	
	if (document.getElementById('FooterImage_1')){
		var footerImageClick = document.getElementById('FooterImage_1');
	
		HTMLDisp = HTMLDisp + '<div id=\"contactImage\"><a href=\"RequestInformation_9520' + isDotNet() + '?productRfi=' + ProductRfiName + '\"><img src=\"images/contactUsFooter-d.gif\" alt="Contact Us" width=\"720\" height=\"73\" border=\"0\" /></a></div>';
		footerImageClick.innerHTML = HTMLDisp
	}
}
/* ~~~~~~~~~~~~~~~~~~~~[ login functions ] ~~~~~~~~~~~~~~~ */
function loginAdmin(){
	var rev = 20090626;
	if (document.getElementById('loginFoot')){
		var LoginBox = document.getElementById('loginFoot');
		var HTMLDisp = '';
		var sPath = window.location.pathname;
		var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
		var sSite = window.location;
		
		if(sPage.indexOf('.aspx') > 0){
			sPage = sPage.substring(0,(sPage.length - 1));
		}
		//Correct for root
		if(sPage.length < 3){
			sPage = 'home_2.asp';
		}
		sSite = sSite + ' ';
		if(sSite.indexOf('orbisdesign.net') != -1){
			sSite = sSite.substring(sSite.indexOf("/")+2);
			sSite = sSite.substring(0,sSite.indexOf("/"));
			sSite = sSite.substring(0,sSite.indexOf("."));
	
			var sUser = sSite + 'User';
			var sPass = sSite + 'Pass';		
	
			if(getCookie(sSite + 'AdminLoggedIn') == 'True' && sPath.indexOf('.aspx') > 0){
				HTMLDisp = HTMLDisp + '<a href="#" id=\"loginLink\" onClick="DispLogin();return false;" style=\"\text-decoration:none;font-size:8px;">Log In</a>';
			}else if(getCookie(sSite + 'AdminLoggedIn') == 'True' && sPath.indexOf('.aspx') == -1){
				HTMLDisp = HTMLDisp + '<a href="#" id=\"loginLink\" onClick="LogOut(\'' + sSite + '\');return false;" style=\"\text-decoration:none;font-size:8px;">Log Out</a>';
			}else{
				HTMLDisp = HTMLDisp + '<a href="#" id=\"loginLink\" onClick="DispLogin();return false;" style=\"\text-decoration:none;font-size:8px;">Log In</a>';
			}
			HTMLDisp = HTMLDisp + '<div id=\"Login\">';
			HTMLDisp = HTMLDisp + '<form id=\"adminLoginForm\" method=\"post\" action=\"/Admin/Default.asp?OnTo=' + sPage + '" name=\"Security\" style=\"display:inline;\" >';
			HTMLDisp = HTMLDisp + '<input class=\"txtInput\" type=\"text\" name=\"txtUserID\">';
			HTMLDisp = HTMLDisp + '<input class=\"txtInput\" type=\"password\" name=\"txtPassword\">';
			HTMLDisp = HTMLDisp + '<input type=\"button\" value=\"log in\" name=\"Login2\" onClick=\"submitLogin();">';
			HTMLDisp = HTMLDisp + '<br /><span style=\"white-space:nowrap;\"><input type=\"checkbox\" name=\"savePass\" value =\"true\">Remember me</span><br />';
			HTMLDisp = HTMLDisp + '<input type=\"hidden\" name=\"FormSubmitted\" value =\"true\">';
			HTMLDisp = HTMLDisp + '<input type=\"hidden\" name=\"ByPassAdmin\" value =\"true\">';
			HTMLDisp = HTMLDisp + '<input type=\"hidden\" name=\"siteUrlSec\" value =\"\">';
			HTMLDisp = HTMLDisp + '<a href="#" id=\"closeLink\" onClick="hideLogin();return false;">Cancel</a>';
			HTMLDisp = HTMLDisp + '</form>';
			HTMLDisp = HTMLDisp + '</div>';
			HTMLDisp = HTMLDisp + '';
	   		LoginBox.innerHTML = HTMLDisp;
			
			if(getCookie(sUser) != null){
				document.forms['Security'].txtUserID.value = getCookie(sUser);
				document.forms['Security'].txtPassword.value = getCookie(sPass);
			}
		}	
	}
}
function submitLogin(){
	var sSite = window.location;
	document.forms['Security'].siteUrlSec.value = sSite;
	sSite = document.forms['Security'].siteUrlSec.value;
	sSite = sSite.substring(sSite.indexOf("/")+2);
	sSite = sSite.substring(0,sSite.indexOf("/"));
	sSite = sSite.substring(0,sSite.indexOf("."));
	var sUser = sSite + 'User';
	var sPass = sSite + 'Pass';
	
	if(document.Security.savePass.checked == true){
		SetGetCookie(sUser,document.forms['Security'].txtUserID.value);
		SetGetCookie(sPass,document.forms['Security'].txtPassword.value);
		document.forms['Security'].submit();
	}else{
		document.forms['Security'].submit();
	}
}
function DispLogin(){
	var Login = document.getElementById('Login');
	Login.style.display = 'block';
	document.Security.txtUserID.focus();
}
function hideLogin(){
	var Login = document.getElementById('Login')
	Login.style.display = 'none';
}
/* ~~~~~~~~~~~~~~~~~~~~[ END: login functions ] ~~~~~~~~~~~~~~~ */
function isDotNet(){
	var checkDotNet;
	if(document.getElementById('searchform') != null){
		checkDotNet = document.searchform.isDotNet.value.indexOf('aspx');
		if(checkDotNet != -1){
			return '.aspx';
		}else{
			return '.asp';
		}
	}else if(document.getElementById('searchPageform') != null){
		checkDotNet = document.searchPageform.isDotNet.value.indexOf('aspx');
		if(checkDotNet != -1){
			return '.aspx';
		}else{
			return '.asp';
		}	
	}else{
		return '.aspx';
	}
}
function siteUrl(){
	var sSite = window.location;
	var tempHold = document.forms['searchform'].vars1.value;
	
	document.forms['searchform'].vars1.value = sSite;
	sSite = document.forms['searchform'].vars1.value;
	document.forms['searchform'].vars1.value = tempHold;
	sSite = sSite.substring(sSite.indexOf("/")+2);
	sSite = sSite.substring(0,sSite.indexOf("/"));
	return sSite;
}
function baseURL(){
	var sSite;
	sSite = window.location;
	sSite = sSite + ' ';
	sSite = sSite.replace(/^\s+|\s+$/g, '');
	sSite = sSite.toLowerCase();
	return sSite;
}
document.write('<' + 'script');
document.write(' language="javascript"');
document.write(' type="text/javascript"');
document.write(' src="/javascriptO2/cookies.js">');
document.write('</' + 'script' + '>');
/* ~~~~~~~~~~~~~~~~~~~~[ login function ] ~~~~~~~~~~~~~~~ */
/* ~~~~~~~~~~~~~~~~~~~~[ sifr ] ~~~~~~~~~~~~~~~ */
document.write('<' + 'script');
document.write(' language="javascript"');
document.write(' type="text/javascript"');
document.write(' src="/javascriptO2/sifr_v3.js">');
document.write('</' + 'script' + '>');

document.write('<' + 'script');
document.write(' language="javascript"');
document.write(' type="text/javascript"');
document.write(' src="/javascript/sifr_config.js">');
document.write('</' + 'script' + '>');
