var opt1a,opt2a,opt3a,opt4a,opt5a,opt6a=false;


getElem = function (id,base) {
base = (base == null) ? "" : base;
 return eval(base+"document.all") ? eval(base+"document.all[id]") : eval(base+"document.getElementById(id)"); };
 
function hide(id,base)
{
getElem(id,base).style.display = 'none';
}
 
function show(id,base)
{
getElem(id,base).style.display = '';
}


function schedule()
{
	hide("now");
	hide("showshow");
	show("schedule");
}

function now()
{
	hide("showshow");
	hide("schedule");
	show("now");
}
function showsh(id)
{
	eval("getElem('showshow').innerHTML = document.formsch.tarea"+id+".value");
	hide("schedule");
	hide("now");
	show("showshow");
}


function showpod(id)
{
	for(i=1;i<=20;i++)
	{
		eval("hide('podc"+i+"');");
	}
	show(id);
}

function maxpod()
{
hide("hide3");
hide("bmaximize2");
show("bminimize2");
getElem("podcastmare").style.height = '360px';
getElem("bar1").style.height = '310px';
}

function minpod()
{
show("hide3");
show("bmaximize2");
hide("bminimize2");
getElem("podcastmare").style.height = '260px';
getElem("bar1").style.height = '208px';
}


function getWinSc(ygrec)
{
	if(ygrec)
	{
		ScrollTop = document.body.scrollTop;
		if (ScrollTop == 0)
		{
		    if (window.pageYOffset)
		        ScrollTop = window.pageYOffset;
		    else
		        ScrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
		}
		return ScrollTop;
	}
	else
	{
			ScrollLeft = document.body.scrollLeft;
		if (ScrollLeft == 0)
		{
		    if (window.pageXOffset)
		        ScrollLeft = window.pageXOffset;
		    else
		        ScrollLeft = (document.body.parentElement) ? document.body.parentElement.scrollLeft : 0;
		}
		return ScrollLeft;
	}	
}	



function getWinScTop(ygrec)
{
	if(ygrec)
	{
		ScrollTop = top.document.body.scrollTop;
		if (ScrollTop == 0)
		{
		    if (top.window.pageYOffset)
		        ScrollTop = top.window.pageYOffset;
		    else
		        ScrollTop = (top.document.body.parentElement) ? top.document.body.parentElement.scrollTop : 0;
		}
		return ScrollTop;
	}
	else
	{
			ScrollLeft = top.document.body.scrollLeft;
		if (ScrollLeft == 0)
		{
		    if (top.window.pageXOffset)
		        ScrollLeft = top.window.pageXOffset;
		    else
		        ScrollLeft = (top.document.body.parentElement) ? top.document.body.parentElement.scrollLeft : 0;
		}
		return ScrollLeft;
	}	
}	

		
function afiseaza_box(continut,event)
{


  ny = event.clientY;
  nx = event.clientX;
   getElem("preview","top.").innerHTML = continut ;
   getElem('preview',"top.").style.display = '';  
  getElem("preview","top.").style.top = ny+getWinSc(true)-4+'px';
    getElem("preview","top.").style.left = nx+getWinSc(false)+6+'px'; 
	//getElem("preview","top.").style.minWidth = '200px';
}

function revino()
{
getElem('preview',"top.").style.display = 'none';
}


var xmlHttp

function station(start)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="ajax_station_updates.php?start="+start+"&c="+Math.random();
xmlHttp.onreadystatechange=stateChangedStation;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
} 

function calendar(mo,y)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="calendar.php?mo="+mo+"&y="+y+"&c="+Math.random();
xmlHttp.onreadystatechange=stateChangedCalendar;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
} 

function stateChangedStation() 
{ 
if (xmlHttp.readyState==4)
{ 
document.getElementById("column1").innerHTML=xmlHttp.responseText;
tb_init('a.thickbox2');
}
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}



function stateChangedCalendar() 
{ 
if (xmlHttp.readyState==4)
{ 
document.getElementById("divcalendar").innerHTML=xmlHttp.responseText;
tb_init('a.thickbox3');
}
}





var temp, temp2, cookieArray, cookieArray2, cookieCount;
function initiate(){
  cookieCount=0;
  if(document.cookie){
    cookieArray=document.cookie.split(";");
    cookieArray2=new Array();
    for(i in cookieArray){
      cookieArray2[cookieArray[i].split("=")[0].replace(/ /g,"")]=cookieArray[i].split("=")[1].replace(/ /g,"");
    }
  }
  cookieArray=(document.cookie.indexOf("state=")>=0)?cookieArray2["state"].split(","):new Array();
  temp=document.getElementById("containerul");
  for(var o=0;o<temp.getElementsByTagName("li").length;o++){
    if(temp.getElementsByTagName("li")[o].getElementsByTagName("ul").length>0){
      temp2 = document.createElement("span");
      temp2.className = "symbols";
      temp2.style.backgroundImage = (cookieArray.length>0)?((cookieArray[cookieCount]=="true")?"url(minus.png)":"url(plus.png)"):"url(plus.png)";
      temp2.onclick=function(){
        showhide(this.parentNode);
        writeCookie();
      }
      temp.getElementsByTagName("li")[o].insertBefore(temp2,temp.getElementsByTagName("li")[o].firstChild)
      temp.getElementsByTagName("li")[o].getElementsByTagName("ul")[0].style.display = "none";
      if(cookieArray[cookieCount]=="true"){
        showhide(temp.getElementsByTagName("li")[o]);
      }
      cookieCount++;
    }
    else{
      temp2 = document.createElement("span");
      temp2.className = "symbols";
      temp2.style.backgroundImage = "url(page.png)";
      temp.getElementsByTagName("li")[o].insertBefore(temp2,temp.getElementsByTagName("li")[o].firstChild);
    }
  }
}

function showhide(el){
  el.getElementsByTagName("ul")[0].style.display=(el.getElementsByTagName("ul")[0].style.display=="block")?"none":"block";
  el.getElementsByTagName("span")[0].style.backgroundImage=(el.getElementsByTagName("ul")[0].style.display=="block")?"url(minus.png)":"url(plus.png)";
}

function writeCookie(){ // Runs through the menu and puts the "states" of each nested list into an array, the array is then joined together and assigned to a cookie.
  cookieArray=new Array()
  for(var q=0;q<temp.getElementsByTagName("li").length;q++){
    if(temp.getElementsByTagName("li")[q].childNodes.length>0){
      if(temp.getElementsByTagName("li")[q].childNodes[0].nodeName=="SPAN" && temp.getElementsByTagName("li")[q].getElementsByTagName("ul").length>0){
        cookieArray[cookieArray.length]=(temp.getElementsByTagName("li")[q].getElementsByTagName("ul")[0].style.display=="block");
      }
    }
  }
  document.cookie="state="+cookieArray.join(",")+";expires="+new Date(new Date().getTime() + 365*24*60*60*1000).toGMTString();
}

