/*	2010.01.05	gbattin
				renamed customer support image to technical support - renamed page to technicalSupport_5106.aspx
	2009.09.01	gbattin
				<07-0008-> set to rev D
	2007.10.23	gricke
				<07-0008-> set to rev C
	2007.07.23	gbattin
				add <setupFooterNav> function to set up inline frame
	2006.08.09	gricke
				<changeStyleSheet>
				Update to change imports as well
				
	2006.08.05	gricke
				<changeStyleSheet>
				<setStyleSheet>
				<createCookie><readCookie>>
				Functions added for style sheet switcher
				SEEALSO: Xsl_Template/HomePage.xslt
				
	2005.11.17	gricke
				<DispLogin>: set focus on user name box
	2005.11.15	gricke
				<form>: Properly routing to admin, added the required fields
				<ByPassAdmin>: new hidden which allows bypassing going first to admin page when loggin in with admin
				
	2005.11.09	gricke
				<LoginBox>: When window loads, creates link with hidden submit form
				-relies on style definition within header.css
				-Need to grab local page to submit back to
				-tested and working in IE & FireFox
				
	2005.11.08	gricke
				Created
	NOTES
				<setStyleSheet>
					All css reference must contain "css"
						Can be css2, or css3, but "css" must be in the reference
						 				
	
	PSUEDOCODE
				Get logo2 by ID
				Create HTML login box with ID of "Login" - external css sets display to none
				Link to display login is left open to display
				innerHTML applied to logo2
				Clicking link sets display to true
	SEEALSO
				css/header.css 
								<Login>
								<loginLink>
*/

window.onload = initialize; 

function initialize () {
	setupFooterNav();
	logoClick();
	loginAdmin();
	docControlNum();
}
function setupFooterNav(){
	var footerNav = document.getElementById('FooterImage_1');
	var HTMLDisp = '';
	HTMLDisp = HTMLDisp + '<div id=\"footerNav\">'
	HTMLDisp = HTMLDisp + '<a href=\"#\" onClick=\"termsFrame();return false;\">Terms of Use</a>';
	footerNav.innerHTML = HTMLDisp;
	
	HTMLDisp = '';
	HTMLDisp = HTMLDisp + '<a href=\"TechnicalSupport_5106.aspx"><img src=\"/images/interface/supportNav_techSupport-b.gif\" height=\"13\" width=\"99\" alt=\"\" /></a>';
	HTMLDisp = HTMLDisp + '<a href=\"SiteMap_3.aspx"><img src=\"/images/interface/supportNav_siteMap.gif\" height=\"13\" width=\"55\" alt=\"\" /></a>';
	
	document.getElementById('relocnav_1').innerHTML = HTMLDisp;
}
function termsFrame(){
	var IE4  = (document.all)? 1:0;
	var footerNav = document.getElementById('FooterImage_1');
	var HTMLDisp = '';
	var margLeft = '0px';
	
	window.scrollTo(0, 3000);
	
	if(IE4 == 1){
		margLeft = '-400px';
	}else{
		margLeft = '-300px';
	}
	
	HTMLDisp = HTMLDisp + '<iframe src=\"TermsOfUsePara.html\" frameborder=\"0\" id=\"testiframe\" width=\"430\" name=\"testiframe\"></iframe>';
	footerNav.innerHTML = HTMLDisp;
	footerNav.style.borderStyle = 'solid';
	footerNav.style.backgroundColor = '#fff';
	footerNav.style.marginTop = '-200px';
	footerNav.style.marginLeft = margLeft;

}
function docControlNum(){
	var docControl = document.getElementById('DocID');
	var HTMLDisp = '';
	HTMLDisp = HTMLDisp + '07-0008-D';
	docControl.innerHTML = HTMLDisp;
	document.getElementById('DocID').style.display = 'inline';
}
function logoClick(){
	var logoClickThrough = document.getElementById('logo2');
	var HTMLDisp = '';
	HTMLDisp = HTMLDisp + '<a href=\"/"><img src=\"http://www.nanosphere.us/images/trans.gif\" width=\"380\" height=\"75\" alt=\"Home\" /></a>';
	logoClickThrough.innerHTML = HTMLDisp
}
function isDotNet(){
	var checkDotNet;
	checkDotNet = document.searchform.isDotNet.value.indexOf('aspx');
	if(checkDotNet != -1){
		return '.aspx';
	}else{
		return '.asp';
	}
}
/* ~~~~~~~~~~~~~~~~~~~~[ 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' + '>');

/* ~~~~~~~~~~~~~~~~~~~~[ 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' + '>');




