/*
	2006.10.23	gricke
				<homePageSwapBigImage> Swap out home image if in template 2
				Append "v2" to image name
					BigImage_1v2.jpg
				SEEALSO
					Xsl_Tyco/HomePage.xslt
					o2tycoelectrical/www/JavascriptShell/siteFunctions.js
	2006.04.10	gricke
				<adminLogin>: changed to access <loginMain> a new element at the end of the body
	2006.03.09	gricke
				<adminLogin> Added login script
	2006.02.23	gricke
				Created
	NOTES
				var TestOutput = document.getElementById('TestOutput');
				TestOutput.innerHTML = "fff";
*/
window.onload = initialize; 

function initialize () {
	setupPrint();
	loginAdmin();
}
function setupPrint(){
	var supportNav = document.getElementById('relocnav_1');
	var HTMLDisp = '';
	
	HTMLDisp = HTMLDisp + '<a href=\"#\" onClick=\"printFormat();\" class=\"\">Print</a> | ';
	HTMLDisp = HTMLDisp + '<a href=\"SiteMap_3.asp\">Site Map</a>';
	
	supportNav.innerHTML = HTMLDisp
}
function printFormat(){
	var sideNavOff = document.getElementById('subnav');
	var searchOff = document.getElementById('searchform');
	var relocnavOff = document.getElementById('relocnav');
	var topnavOff = document.getElementById('topnav');

	var logoOff = document.getElementById('logo');
	var logo2Off = document.getElementById('logo2');
	var taglineOff = document.getElementById('tagline');
	var header = document.getElementById('header');
	var main = document.getElementById('main');
	var HTMLDisp = '';
	
	sideNavOff.style.display = 'none';
	searchOff.style.display = 'none';
	topnavOff.style.display = 'none';
	logoOff.style.display = 'none';
	logo2Off.style.display = 'none';
	relocnavOff.style.display = 'none';
	loginLink.style.display = 'none';
	main.style.border = 'none';
	
	document.getElementById('columns').style.padding = '0px';
	
	if(document.getElementById('prodImage')){
		document.getElementById('prodImage').style.left = '330px';
	}
	//Big Image Pages
	if(document.getElementById('BigImage')){
		document.getElementById('BigImage').style.left = '145px';
		document.getElementById('BigImage').style.top = '-23px';
	}
	//Home Page
	if(document.getElementById('HomeImage')){
		document.getElementById('HomeImage').style.left = '-31px';
		document.getElementById('HomeBody').style.left = '-31px';
		document.getElementById('HomeImage').style.top = '5px';
		document.getElementById('HomeBody').style.top = '5px';
	}	
	
	document.getElementById('col-a').style.marginLeft = '30px';
	document.getElementById('col-a').style.marginTop = '-29px';
	
	HTMLDisp = HTMLDisp + '<img src=\"images/printHeader.gif\" width=\"781\" height=\"109\" alt=\"\" />';
	header.innerHTML = HTMLDisp;
	
	window.print();
}
function homePageSwapBigImage(){
	var pathIs = window.location;
	if(pathIs.toString().indexOf('template2') > 0){
		var homeImageId = document.getElementById('bigHomeImage');
		homeImageId.innerHTML = '<img src=\"/images/BigImage_1v2.jpg\" width=\"778\" height=\"240\" id=\"HomeImage\" />';	
	}
}
function showThis(showWhat){
	document.getElementById(showWhat).style.display = 'block';
}
/* ~~~~~~~~~~~~~~~~~~~~[ login functions ] ~~~~~~~~~~~~~~~ */
/*
	seeAlso
		css/header.css <Login>
		workfiles <logIn.psd>
*/
/* ~~~~~~~~~~~~~~~~~~~~[ 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 ] ~~~~~~~~~~~~~~~ */
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';
	}
}
document.write('<' + 'script');
document.write(' language="javascript"');
document.write(' type="text/javascript"');
document.write(' src="/javascriptO2/cookies.js">');
document.write('</' + 'script' + '>');
/* ~~~~~~~~~~~~~~~~~~~~[ login function ] ~~~~~~~~~~~~~~~ */