var destPage;
function tryToAccess(gotoPage) {
    var authCookie = readCookie('supportAuth');
    if (!authCookie){
        fadeToBlack();
	setTimeout("showLogin()",1000);
	destPage = gotoPage;
    } else {location = gotoPage;}
}

function getPageFileName(){
    var lastSlash = location.href.lastIndexOf('/');
    return (location.href.substring(lastSlash+1,location.href.length));
}
  
    
function createCookie(name,value,minutes) {
	if (minutes) {
		var date = new Date();
		date.setTime(date.getTime()+(minutes*60*1000));
		var expires = '; expires='+date.toGMTString();
	}
	else var expires = '';
	document.cookie = name+'='+value+expires+'; path=/';
}

function readCookie(name) {
	var nameEQ = name + '=';
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}



function fadeToBlack(){
    fader = document.getElementById('fadeLayer');
    fader.style.display = 'block';
    slowhigh(fader);
}

function showLogin(){
    var loginForm = document.getElementById('LoginContainer');
    loginForm.style.display = 'block';
	if (location.pathname.indexOf('login.php4')==-1){
	    loginForm.style.left = ie4?(screen.width/2)-76 :(screen.width/2)-76+'px';
	    loginForm.style.top = ie4?(screen.height/2)-100 :(screen.height/2)-100+'px';
	}
    document.forms[0].user.focus();
}

function unFade(){
    fader.style.display = 'none';
}

function slowhigh(which2){
    imgobj=which2;
    browserdetect=which2.filters? "ie" : typeof which2.style.MozOpacity=="string"? "mozilla" : "";
    instantset(0);
    highlighting=setInterval("gradualfade(imgobj)",50);
}

function instantset(degree){
    if (browserdetect=="mozilla")
        imgobj.style.MozOpacity=degree/100;
    else if (browserdetect=="ie")
        imgobj.filters.alpha.opacity=degree;
}

function cleartimer(){
    if (window.highlighting) clearInterval(highlighting);
}

function gradualfade(cur2){
    if (browserdetect=="mozilla" && cur2.style.MozOpacity<0.6)
        cur2.style.MozOpacity=Math.min(parseFloat(cur2.style.MozOpacity)+0.03, 0.99);
    else if (browserdetect=="ie" && cur2.filters.alpha.opacity<60)
        cur2.filters.alpha.opacity+=3;
    else if (window.highlighting)
        clearInterval(highlighting);
}

var loginActive = true;
function toggleLogin(){
    var loginDiv = document.getElementById('login');
    var requestDiv = document.getElementById('requestNew');
    var requestLink = document.getElementById('requestLink');
    if (loginActive) {
        loginDiv.style.display = 'none';
        requestDiv.style.display = 'block';
        requestLink.innerHTML = 'Login';
        loginActive = false;
    } else {
        loginDiv.style.display = 'block';
        requestDiv.style.display = 'none';
        requestLink.innerHTML = 'Request New Account';
        loginActive = true;
    }
}

function whichForm(){
    if (!loginActive)
        return true;
    else submitLogin();
    return false;
}
//checkAuth();
