/***********************************************
* Ajax Includes script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

//To include a page, invoke ajaxinclude("afile.htm") in the BODY of page
//Included file MUST be from the same domain as the page displaying it.
var rootdomain="http://"+window.location.hostname

function ajaxinclude(url,containerid) {
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
} 
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
page_request.open('GET', url, false) //get page synchronously 
page_request.send(null)
if(containerid == null) {
writecontent(page_request)
} else {
loadpage(page_request, containerid)
} 
}

function writecontent(page_request){
if (window.location.href.indexOf("http")==-1 || page_request.status==200)
document.write(page_request.responseText)
}

function loadpage(page_request, containerid){
if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)) {
document.getElementById(containerid).innerHTML=page_request.responseText
} else {document.getElementById(containerid).innerHTML="Conţinutul se incarca";}
}

function get_page (linkid,url, containerid) {
var url = url+'.html';
if(linkid!=''){
var links=document.getElementById('masterdiv').getElementsByTagName("a");
for(i=0;i<links.length;i++) {
//alert(links[i].innerHTML+'->'+links[i].style.color);
if(links[i].style.color=="rgb(226, 80, 50)" || links[i].style.color=="rgb(226,80,50)" || links[i].style.color=="#e25032") {
links[i].style.color="#464e75";
document.getElementById(linkid).style.color="rgb(226, 80, 50)";
}
}
}

document.getElementById(containerid).innerHTML="Conţinutul se incarca...";
ajaxinclude(url,containerid);
}

//meniu
document.write('<style type="text/css">\n')
document.write('.submenu{display: none;}\n')
document.write('</style>\n')

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=")
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1 
    c_end=document.cookie.indexOf(";",c_start)
    if (c_end==-1) c_end=document.cookie.length
    //alert (document.cookie);
    return unescape(document.cookie.substring(c_start,c_end))
    } 
  }
return ""
}

function setCookie(c_name,value,expiredays,erase)
{
//alert(c_name+','+value+','+expiredays+','+erase);
if(erase!=null){ eraseCookie(erase); }
var exdate=new Date()
exdate.setDate(exdate.getDate()+expiredays)
document.cookie=c_name+ "=" +escape(value)+ ";path=/";
}

function eraseCookie(name) {
	setCookie(name,"",-1);
}

function checkCookie()
{
		exapnd_content=getCookie('switchmenu');
		if (exapnd_content!=null && exapnd_content!="") {
				//	alert('expand'+exapnd_content);
					document.getElementById(exapnd_content).style.display = "block";
					
					var last_caracter = get_ultimul_caracter(exapnd_content);
     if (last_caracter!="") {
       document.getElementById('item'+last_caracter).style.color="#E25032"
					}
					//document.getElementById(exapnd_content).style.color = "#E25032";	
		}
		
		highlight_item=getCookie('subitem');
		if (highlight_item!=null && highlight_item!="") {
				//alert('highlight: '+highlight_item);
					document.getElementById(highlight_item).style.color="#E25032"
		}

}

function get_ultimul_caracter(valoare) {
var the_length=valoare.length;
var last_char=valoare.charAt(the_length-1);
return last_char;
}



if (window.addEventListener)
window.addEventListener("load", checkCookie, false)
else if (window.attachEvent)
window.attachEvent("onload", checkCookie)
else if (document.getElementById)
window.onload=checkCookie

