// JavaScript Document
//Onload Script to check if the user is already logged in
$(document).ready(function() {
	
		$('.reglink').html('<a href="http://www.suntimes.com/community/register/index.html?'+document.location.href+'">Register</a>');  //This line of code ensures the register link has a reference back to page the user is logging in from, ergo the user registers and is bounced back to that page!
		var cooktest = $.cookie('HD'); //check for pluck cookie
		if(cooktest != null){ 
			var cookval=cooktest.split("|");
			$('#bigf').addClass("closed");
			$('#alreadylogged').removeClass("closed");
			$('#alreadylogged').addClass("open");
			$('#alreadylogged').html("Hello, "+cookval[1]+' <a href="/community/signin/index.html">Click here to edit your account</a>');
		}
		else{
			$('#notlogged').removeClass("closed");
			$('#notlogged').addClass("open");
		}




 });//end document.ready

function openpop(){ //open the "hidden" pop up window that the pluck forms will have to process from
	oNewWindow = window.open('','loadwin','height=250,width=250,channelmode=no,directories=no,menubar=no,titlebar=no,status=no,scrollbars=no,toolbar=no,replace=false');
	oNewWindow.blur(); //hide the window by sending it 'behind' the main window
	window.focus(); //secodnary catch to make sure the 'mainwindow' is in at the forefron for the user
}

function errr(opt,num){
	if (opt == 0){
		$('#errormessage').removeClass("open");
		$('#errormessage').addClass("closed");
		$('#errormessage').html(''); //reset the rroe message if needed
	}
	else if (opt == 1 && num >= 3){
		$('#errormessage').removeClass("closed");
		$('#errormessage').addClass("open");
		$('#errormessage').html('<img src="http://media.suntimes.com/images/cds/icons/cancel.png" width="16" height="16" />&nbsp;&nbsp;Sorry, your login has failed. <br /><strong>We may be experiencing technical difficulties!</strong><br />Did you <a href="#ForgotPass" onclick="ToggleDiv(\'ForgotPass\')" class="Pointer">forget your password</a>?<br />Maybe you have not <a title="Register" onclick="ToggleDiv(\"#loginHolder\");ToggleDiv(\"#regIframe\");" class="Pointer">registered</a> yet?');
	}	
	else{
		$('#errormessage').removeClass("closed");
		$('#errormessage').addClass("open");
		$('#errormessage').html('<img src="http://media.suntimes.com/images/cds/icons/error.png" width="16" height="16" />&nbsp;&nbsp;Sorry, your login has failed. <br />Did you <a href="#ForgotPass" onclick="ToggleDiv(\'ForgotPass\')" class="Pointer">forget your password</a>?<br />Maybe you have not <a title="Register" onclick="ToggleDiv(\"#loginHolder\");ToggleDiv(\"#regIframe\");" class="Pointer">registered</a> yet?');
	}
	
}