// King Systems SRL - Adrian MADARAS - Telefon 0722758698
// Acesta este un cod creat de Adrian Madaras pentru Casa Nationala de Asigurari de Sanatate. 
// Copierea, distribuirea, modificarea sunt interzise fara acordul scris al autorului.

function bwcheck()
{
	this.ver    = navigator.appVersion;
	this.agent  = navigator.userAgent;

	this.dom    = document.getElementById ? 1 : 0;

	this.opera5 = (navigator.userAgent.indexOf("Opera") > -1 && document.getElementById) ? 1 : 0;

	this.ie5    = (this.ver.indexOf("MSIE 5") > -1 && this.dom && !this.opera5) ? 1 : 0;
	this.ie6    = (this.ver.indexOf("MSIE 6") > -1 && this.dom && !this.opera5) ? 1 : 0;
	this.ie7    = (this.ver.indexOf("MSIE 7") > -1 && this.dom && !this.opera5) ? 1 : 0;
	this.ie4    = (document.all && !this.dom && !this.opera5) ? 1 : 0;
	this.ie     = this.ie4 || this.ie5 || this.ie6 || this.ie7;

	this.mac    = this.agent.indexOf("Mac") > -1;

	this.ns6    = (this.dom && parseInt(this.ver) >= 5) ? 1 : 0;
	this.ns4    = (document.layers && !this.dom) ? 1 : 0;

	return this;
}



/*	MENIU	*/
var menus = "";
var separator = "||";
var separator2 = "--";
function openMenu(id, op, parent)
{
	var menu = document.getElementById(id);
	var p = document.getElementById(parent);
	
	if (menus && menus.length > 0 && menus.indexOf(separator+id+separator2+"block") > -1)
	{
		var txt = separator+id+separator2+"block";
		menus = menus.substring(0, menus.indexOf(txt))+( menus.indexOf(separator, menus.indexOf(txt)+3) > -1 ? menus.substring(menus.indexOf(separator, menus.indexOf(txt)+3)) : "");
	}
	if (menus && menus.length > 0 && menus.indexOf(separator+id+separator2+"none") > -1)
	{
		var txt = separator+id+separator2+"none";
		menus = menus.substring(0, menus.indexOf(txt))+( menus.indexOf(separator, menus.indexOf(txt)+3) > -1 ? menus.substring(menus.indexOf(separator, menus.indexOf(txt)+3)) : "");
	}
	
	op.blur();
	
	if (menu.style.display=="block" || ((op.className == "menuTop" || op.className == "menuTop_deschis")  && menu.style.display != "none"))
	{
		if(p.className.indexOf("_deschis")>0)
		{
			p.className = p.className.substring(0, p.className.indexOf("_deschis"));
		}
		else
		{
			p.className = p.className+"_deschis";
		}
		
		menu.style.display="none";
		if (menus)
			menus = menus + (separator + id + separator2 + "none" + separator2 + parent+ separator2+ p.className);
		else
			menus = (separator + id + separator2 + "none" + separator2 + parent+ separator2+ p.className);
	}
	else
	{
		if(p.className.indexOf("_deschis")>0)
		{
			p.className = p.className.substring(0, p.className.indexOf("_deschis"));
		}
		else
		{
			p.className = p.className+"_deschis";
		}
		menu.style.display="block";
		if (menus)
			menus =  menus + (separator + id + separator2 + "block" + separator2 + parent+ separator2+ p.className);
		else
			menus = (separator + id + separator2 + "block" + separator2 + parent+ separator2+ p.className)
		
	}
	Set_Cookie("opened_menus",menus);
}


function Get_Cookie(name) {
    var start = document.cookie.indexOf(name+"=");
    var len = start+name.length+1;
    if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
    if (start == -1) return null;
    var end = document.cookie.indexOf(";",len);
    if (end == -1) end = document.cookie.length;
    return unescape(document.cookie.substring(len,end));
}

function Set_Cookie(name,value) {
    document.cookie = name + "=" +escape(value) + ";expires=Thu, 01-Jan-10 00:00:01 GMT";
    	/*+
        ( (path) ? ";path=" + path : "") + 
        ( (domain) ? ";domain=" + domain : "") +
        ( (secure) ? ";secure" : "");*/
}

function Delete_Cookie(name,path,domain) {
    if (Get_Cookie(name)) document.cookie = name + "=" +
       ( (path) ? ";path=" + path : "") +
       ( (domain) ? ";domain=" + domain : "") +
       ";expires=Thu, 01-Jan-70 00:00:01 GMT";
}

//openMenus();

function openMenus()
{
	var text = Get_Cookie("opened_menus");
	menus = text;

	var els = new Array();
	if (text)
	{
		els = text.split(separator);
		if (els)
		for (var i=0;i<els.length; i++)
		{
			var el = els[i].split(separator2);
			if (el[0] && el[0] != '')
			{
				document.getElementById(el[0]).style.display = el[1];
				document.getElementById(el[2]).className = el[3];
			}
		}
	}
}