jQuery(document).ready(function($){
	
	
	$("#close_shoutbox").click(function() {
		$("#shoutbox_ouverte1").hide();
		$("#shoutbox_ouverte2").hide();
		$("#shoutbox_fermee").show();
		SetCookie('shoutbox', 'close');
	});

	$("#open_shoutbox").click(function() {
		$("#shoutbox_fermee").hide();
		$("#shoutbox_ouverte1").show();
		$("#shoutbox_ouverte2").show();
		SetCookie('shoutbox', 'open');
	});
	
	var cookie_shoutbox = getCookie("shoutbox");
	if (cookie_shoutbox == "open") {
			$("#shoutbox_fermee").hide();
			$("#shoutbox_ouverte1").show();
			$("#shoutbox_ouverte2").show();        
		}

		
	$('.login').mouseenter(function() {
		$("div#panel").stop(true, true).slideDown(500);
		$(".open").hide();
		$(".close").show();
		});
		
		
	$('#toppanel').mouseleave(function() {
		$("div#panel").delay(1000).slideUp(500);
		$(".close").hide();
		$(".open").show();
	});
		
	// Expand Panel
	$("#open").click(function(){
		$("div#panel").slideDown("slow");
	});	
	
	// Collapse Panel
	$("#close").click(function(){
		$("div#panel").slideUp("slow");	
	});		
	
	// Switch buttons from "Log In | Register" to "Close Panel" on click
	$("#toggle a").click(function () {
		$("#toggle a").toggle();
	});		
		

	
	
});




function SetCookie (name, value) {
	var argv=SetCookie.arguments;
	var argc=SetCookie.arguments.length;
	var expires=(argc > 2) ? argv[2] : null;
	var path=(argc > 3) ? argv[3] : null;
	var domain=(argc > 4) ? argv[4] : null;
	var secure=(argc > 5) ? argv[5] : false;
	document.cookie=name+"="+escape(value)+
		((expires==null) ? "" : ("; expires="+expires.toGMTString()))+
		"; path=/; domain=.team-ncis.com"+
		((secure==true) ? "; secure" : "");
}

function getCookie(c_name)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
{
  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
  x=x.replace(/^\s+|\s+$/g,"");
  if (x==c_name)
    {
    return unescape(y);
    }
  }
}

function Toggle( id ) {
	for (i=0; i<=9; i++) {
		if (document.getElementById) {
			var cdiv = document.getElementById( 'tab-saison-' + i );
			if (cdiv) {
				if (id == i) {
					if (cdiv.className != 'minimized') cdiv.className = 'minimized';
					else cdiv.className = '';
				}
				else {
					cdiv.className = 'minimized';
				}
			}
		}
	}
}

