
function Toggle(e) {
	if (e.checked) {
	    Highlight(e);
	    document.list.all.checked = AllChecked();
	} else {
	    Unhighlight(e);
	    document.list.all.checked = false;
	}
}


function ToggleAll(e) {
	if (e.checked) {
	    CheckAll();
	}
	else {
	    ClearAll();
	}
}

function Check(e) {
	e.checked = true;
	Highlight(e);
}


function Clear(e) {
	e.checked = false;
	Unhighlight(e);
}


function CheckAll() {
	var ml = document.list;
	var len = ml.elements.length;
	for (var i = 0; i < len; i++) {
	    var e = ml.elements[i];
	    if (e.type && e.type== "checkbox" && (e.name.indexOf("Id", 0) != -1 || e.name.indexOf("id", 0) != -1))  {
		    Check(e);
	    }
	}
	ml.all.checked = true;
}


function ClearAll()  {
	var ml = document.list;
	var len = ml.elements.length;
	for (var i = 0; i < len; i++) {
	    var e = ml.elements[i];
	    if (e.type && e.type == "checkbox" && (e.name.indexOf("Id", 0)  != -1 || e.name.indexOf("id", 0) != -1)) {
		    Clear(e);
	    }
	}
	ml.all.checked = false;
}


function Highlight(e) {
	var r= null;
    	
	if (e.parentElement) {
	    r = e.parentElement;
	} else if (e.parentNode) {
	    r = e.parentNode;
	}
	
	if ( r.className =="checkbox") {
		 r.className = "highlight";
	}
}


function Unhighlight(e) {
	var r= null;
    	
	if (e.parentNode) {
	    r = e.parentNode;
	} else if (e.parentElement) {
	    r = e.parentElement;
	}
	
	if (r.className =="highlight") {
		 r.className = "checkbox";
	}
}


function AllChecked()
    {
	ml = document.list;
	len = ml.elements.length;
	for(var i = 0 ; i < len ; i++) {
	    if (ml.elements[i].name && (ml.elements[i].name.indexOf("id") != -1 || ml.elements[i].name.indexOf("del") != -1) && !ml.elements[i].checked) {
		return false;
	    }
	}
	return true;
}

function toggleVisibility(elemId, chck){
	var c = null; var p = null; var f = null;
	c = document.getElementById("c"+elemId)
	p = document.getElementById("p"+elemId)
	f = document.getElementById("f"+elemId)
	if(  chck.checked ) {
		if( f) f.className = "visible"
		if( c) c.className = "visible";
		if( p) p.className = "visible";
	} else {
		if( c) c.className = "hidden";
		if( f) f.className = "hidden";
		if( p) p.className = "hidden";
	}
}

/*
function toggleVisibility(elemId, chck){
	var r = null;
	r = document.getElementById(elemId)
	if (r) {
		if( chck.checked ) {
		    r.className = "visible";
		} else {
    		r.className = "hidden";
		}
	}
}
*/

function toggleBiVisibility(elemId, chck){
	var normal = null;
	var alt = null;
	normal = document.getElementById(elemId)
	alt = document.getElementById(elemId + "Alt")
	if (normal && alt) {
		if( chck.checked ) {
			normal.className = "hidden";
		    alt.className = "visibleS";
		} else {
			normal.className = "visibleS";
		    alt.className = "hidden";
		}
	}
}

function delBox(titlu, url ) {
  if ( confirm( titlu ) ) {
        location.href=url
  }
}

function delBoxNoUrl(titlu ) {
  return confirm( titlu );
}




// This next little bit of code tests whether the user accepts cookies.
var WM_acceptsCookies = false;
if(document.cookie == '') {
    document.cookie = 'WM_acceptsCookies=yes'; // Try to set a cookie.
    if(document.cookie.indexOf('WM_acceptsCookies=yes') != -1) {
	WM_acceptsCookies = true; 
    }// If it succeeds, set variable
} else { // there was already a cookie
  WM_acceptsCookies = true;
}


function WM_setCookie (name, value, hours, path, domain, secure) {
    if (WM_acceptsCookies) { // Don't waste your time if the browser doesn't accept cookies.
	var not_NN2 = (navigator && navigator.appName 
		       && (navigator.appName == 'Netscape') 
		       && navigator.appVersion 
		       && (parseInt(navigator.appVersion) == 2))?false:true;

	if(hours && not_NN2) { // NN2 cannot handle Dates, so skip this part
	    if ( (typeof(hours) == 'string') && Date.parse(hours) ) { // already a Date string
		var numHours = hours;
	    } else if (typeof(hours) == 'number') { // calculate Date from number of hours
		var numHours = (new Date((new Date()).getTime() + hours*3600000)).toGMTString();
	    }
	}
	document.cookie = name + '=' + escape(value) + ((numHours)?(';expires=' + numHours):'') + ((path)?';path=' + path:'') + ((domain)?';domain=' + domain:'') + ((secure && (secure == true))?'; secure':''); // Set the cookie, adding any parameters that were specified.
    }
} // WM_setCookie


function WM_readCookie(name) {
    if(document.cookie == '') { // there's no cookie, so go no further
	return false; 
    } else { // there is a cookie
	var firstChar, lastChar;
	var theBigCookie = document.cookie;
	firstChar = theBigCookie.indexOf(name);	// find the start of 'name'
	var NN2Hack = firstChar + name.length;
	if((firstChar != -1) && (theBigCookie.charAt(NN2Hack) == '=')) { // if you found the cookie
	    firstChar += name.length + 1; // skip 'name' and '='
	    lastChar = theBigCookie.indexOf(';', firstChar); // Find the end of the value string (i.e. the next ';').
	    if(lastChar == -1) lastChar = theBigCookie.length;
	    return unescape(theBigCookie.substring(firstChar, lastChar));
	} else { // If there was no cookie of that name, return false.
	    return false;
	}
    }	
} // WM_readCookie

function WM_killCookie(name, path, domain) {
  var theValue = WM_readCookie(name); // We need the value to kill the cookie
  if(theValue) {
      document.cookie = name + '=' + theValue + '; expires=Fri, 13-Apr-1970 00:00:00 GMT' + ((path)?';path=' + path:'') + ((domain)?';domain=' + domain:''); // set an already-expired cookie
  }
} // WM_killCookie


function switchLang(value) {
	WM_killCookie("language", null, null);
	if( value != "" )  {
		WM_setCookie("language", value, 24*365*10, "/", null, false);
	}	
	document.forms['langSwitchForm'].submit();
}