function delete_cookie ( cookie_name )
{
  var cookie_date = new Date ( );  // current date & time
  cookie_date.setTime ( cookie_date.getTime() - 1 );
 


  document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();



}






function getCookie(name) {
        var prefix = name + "="
        var cookieStartIndex = document.cookie.indexOf(prefix)
        if (cookieStartIndex == -1)
                return null

	var cookieStartIndexNext = document.cookie.indexOf(prefix, cookieStartIndex + prefix.length)	

        if (cookieStartIndexNext != -1)
{
                cookieStartIndex = cookieStartIndexNext

}

        var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length)
        if (cookieEndIndex == -1)
                cookieEndIndex = document.cookie.length
        return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex))
}




function setCookie( name, value, expires, path, domain, secure ) {
	var today = new Date();
	today.setTime( today.getTime() );
	expires = expires ? expires * 1000 * 60 * 60 * 24 : 1 * 1000 * 60 * 60 * 24;
	var expires_date = new Date( today.getTime() + (expires) );
	document.cookie = name+'='+escape( value ) +
		( ( expires ) ? ';expires='
+expires_date.toGMTString() : '' ) +
		( ( path ) ? ';path=' + path : '' ) +
		( ( domain ) ? ';domain=' + domain : '' ) +
		( ( secure ) ? ';secure' : '' );
}


/*

function setCookie(name, value) {

//confirm(document.cookie);

delete_cookie(name);
document.cookie=name+"="+value+";"


//confirm(document.cookie);


//delete_cookie("CommunityServer-LastVisitUpdated-2358");
//delete_cookie("CommunityServer-LastVisitUpdated-2101");
//delete_cookie("CSAnonymous");
//delete_cookie(".CSRoles");
//delete_cookie("CommunityServer-UserCookie2101");
//delete_cookie("ANON");
//delete_cookie("NAP");
//delete_cookie("RPSMSA");
//delete_cookie("CommunityServer-UserCookie2358");




}

*/

function SetPanelOpened() {
    setCookie("UserPanelOpened", "True", 31,"/")  ;
}

function SetPanelClosed() {
    setCookie("UserPanelOpened", "False",31,"/")  ;
}

function PanelIsOpened() {
    return (getCookie("UserPanelOpened") == "True");
}

function TogglePanel() {
    if (PanelIsOpened()) SetPanelClosed();
        else SetPanelOpened();
}

function tabControl() {
	this.selectedItem;
}

tabControl.prototype.register = function (tabItem) {
	tabItem.label.addEventListener("click", this.change.lock(this, tabItem), false);
	if (!this.selectedItem) {
		tabItem.select();
		this.selectedItem = tabItem;
	}
}



tabControl.prototype.registersave = function (tabItem) {
	tabItem.label.addEventListener("click", this.changecook.lock(this, tabItem), false);
}

tabControl.prototype.changecook = function (tabItem) {
    TogglePanel();
}





tabControl.prototype.change = function (tabItem)

 {




	if (this.selectedItem) {
		this.selectedItem.deselect();
	} 
	if (tabItem != this.selectedItem) {
		tabItem.select();
		this.selectedItem = tabItem;
	} else {
		this.selectedItem = null;
	} 

	
}



function tabItem(label, content) {
	this.label = $(label);
	this.content = $(content);
}

tabItem.prototype.select = function () {
	this.label.addClass("tab-label-selected");
	this.content.addClass("tab-content-selected");
}

tabItem.prototype.deselect = function () {
	this.label.removeClass("tab-label-selected");
	this.content.removeClass("tab-content-selected");
	}



















