/*

*/

window.onload = initialize; 
window.onresize = doResize;

function doResize(){
	setBackgroundPos()
}

function initialize () {
	setBackgroundPos();
	setupFooterNav();
	loginAdmin();
}
function setBackgroundPos(){
	var CurrentBrowserWindowWidth = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    	CurrentBrowserWindowWidth = window.innerWidth;

	} else if( document.documentElement && ( document.documentElement.clientWidth ) ) {
    	//IE 6+ in 'standards compliant mode'
		CurrentBrowserWindowWidth = document.documentElement.clientWidth;

	} else if( document.body && ( document.body.clientWidth ) ) {
		//IE 4 compatible
		CurrentBrowserWindowWidth = document.body.clientWidth;
	}
	
	var CurrentBrowserWindowWidthMidPoint = (CurrentBrowserWindowWidth/2);
	var circlePointOfArchOffCenterOfMain = 170;	//radius pix to the right of center   175
	var ArchFromLeftOfBackgroundImage = 1426;	
	
	//new updates /images/interface/AlliedSprinklerBkgd3.png
	circlePointOfArchOffCenterOfMain = 340;
	var ArchFromLeftEdgeNeedsToBe = CurrentBrowserWindowWidthMidPoint + circlePointOfArchOffCenterOfMain;
	var MoveBackgroundImage = (ArchFromLeftOfBackgroundImage - ArchFromLeftEdgeNeedsToBe);
	var MoveBackgroundImageStyle = '-' + MoveBackgroundImage + 'px 0px';
	document.getElementsByTagName('body')[0].style.backgroundPosition = MoveBackgroundImageStyle;
}
function setupFooterNav(){
	var footerNav = document.getElementById('FooterImage_1');
	var HTMLDisp = '';
	HTMLDisp = HTMLDisp + '<div id=\"#FooterImage_1\">'
	HTMLDisp = HTMLDisp + '<a href=\"PrivacyPolicy_6899.aspx\">Usage & Regulations of Our Website</a>';
	HTMLDisp = HTMLDisp + '</div>'
	footerNav.innerHTML = HTMLDisp;
}
function alertSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  window.alert( 'Width = ' + myWidth );
  window.alert( 'Height = ' + myHeight );
}
/* ~~~~~~~~~~~~~~~~~~~~[ login functions ] ~~~~~~~~~~~~~~~ */
function loginAdmin(){
	var rev = 20071220;
	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));
		}
		
		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'){
				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 ] ~~~~~~~~~~~~~~~ */
document.write('<' + 'script');
document.write(' language="javascript"');
document.write(' type="text/javascript"');
document.write(' src="/javascriptO2/cookies.js">');
document.write('</' + 'script' + '>');
/* ~~~~~~~~~~~~~~~~~~~~[ 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' + '>');

function baseURL(){
	var sSite;
	sSite = window.location;
	sSite = sSite + ' ';
	sSite = sSite.replace(/^\s+|\s+$/g, '');
	sSite = sSite.toLowerCase();
	return sSite;
}
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';
	}
}
