afisat = '1';

/***********************************************
* Show Hint script- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/
		
var horizontal_offset="9px" //horizontal offset of hint box from anchor link

/////No further editting needed

var vertical_offset="0" //horizontal offset of hint box from anchor link. No need to change.
var ie=document.all
var ns6=document.getElementById&&!document.all

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1
if (whichedge=="rightedge"){
var windowedge=ie && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-30 : window.pageXOffset+window.innerWidth-40
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth+parseInt(horizontal_offset)
}
else{
var windowedge=ie && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight
}
return edgeoffset
}

function showhint(menucontents, obj, e, tipwidth){
	if ((ie||ns6) && document.getElementById("hintbox")){
		dropmenuobj=document.getElementById("hintbox")
		dropmenuobj.innerHTML=menucontents
		dropmenuobj.style.left=dropmenuobj.style.top=-500
		if (tipwidth!=""){
			dropmenuobj.widthobj=dropmenuobj.style
			dropmenuobj.widthobj.width=tipwidth
		}
		dropmenuobj.x=getposOffset(obj, "left")
		dropmenuobj.y=getposOffset(obj, "top")
		dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightsedge")+obj.offsetWidth+"px"
		dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+"px"
		dropmenuobj.style.visibility="visible"
		obj.onmouseout=hidetip
	}
}

function hidetip(e){
	dropmenuobj.style.visibility="hidden"
	dropmenuobj.style.left="-500px"
}

function createhintbox(){
	var divblock=document.createElement("div")
	divblock.setAttribute("id", "hintbox")
	document.body.appendChild(divblock)
}

if (window.addEventListener)
window.addEventListener("load", createhintbox, false)
else if (window.attachEvent)
window.attachEvent("onload", createhintbox)
else if (document.getElementById)
window.onload=createhintbox


function my_getbyid(id)
{
	itm = null;

	if (document.getElementById)
	{
		itm = document.getElementById(id);
	}
	else if (document.all)
	{
		itm = document.all[id];
	}
	else if (document.layers)
	{
		itm = document.layers[id];
	}

	return itm;
}

//==========================================
// Show div
//==========================================

function showview(id)
{
	if ( itm = my_getbyid(id) )
	{
		my_show_div(itm);
	}
}

//==========================================
// Hide div
//==========================================

function hideview(id)
{
	if ( itm = my_getbyid(id) )
	{
		my_hide_div(itm);
	}
}

//==========================================
// Show/hide section
//==========================================

function section(id)
{
//	if ( ! id ) return;
//	if (id==divviz) return;
//    alert(afisat+"  "+id);

    if (id != afisat)
    {
        itm = my_getbyid("popup_continut_"+afisat);
		my_hide_div(itm);
        itm = my_getbyid("but_popup_"+afisat+"_hover");
		my_hide_div(itm);
        itm = my_getbyid("but_popup_"+afisat);
    	my_show_div(itm);

        itm = my_getbyid("popup_continut_"+id);
    	my_show_div(itm);
        itm = my_getbyid("but_popup_"+id+"_hover");
    	my_show_div(itm);
        itm = my_getbyid("but_popup_"+id);
		my_hide_div(itm);

        afisat=id;
    }

}

//==========================================
// Show/hide toggle
//==========================================

function toggleview(id)
{
	if ( ! id ) return;

	if ( itm = my_getbyid(id) )
	{
		if (itm.style.display == "none")
		{
			my_show_div(itm);
		}
		else
		{
			my_hide_div(itm);
		}
	}
	return false;
}

//==========================================
// Set DIV ID to hide
//==========================================

function my_hide_div(itm)
{
	if ( ! itm ) return;

	itm.style.display = "none";
}

//==========================================
// Set DIV ID to show
//==========================================

function my_show_div(itm)
{
	if ( ! itm ) return;

	itm.style.display = "";
}


function ajaxFrames(url){
   if (window.XMLHttpRequest) {
       req = new XMLHttpRequest();
       req.onreadystatechange = function() {ajaxFramesDone();};
       req.open("GET", url, true);
       req.send(null);
   // IE/Windows ActiveX version
   } else if (window.ActiveXObject) {
       req = new ActiveXObject("Microsoft.XMLHTTP");
       if (req) {
           req.onreadystatechange = function() {ajaxFramesDone();};
           req.open("GET", url, true);
           req.send();
       }
   }
   //poate nu mai e nevoie, doar pentru linkuri
   return false;
}


function ajaxFramesDone() {
	// only if req is "loaded"
	if (req.readyState == 4) {
		// only if "OK"
		if (req.status == 200 || req.status == 304) {
			results = req.responseText;
			eval("result = "+req.responseText+"");
			for (var s in result){
			  	if (document.getElementById(s))
					document.getElementById(s).innerHTML = result[s];
			}
		} else {
			alert("ajax error:\n" + req.statusText);
		}
	}
}

function openSubMenus(objid){
	var divlayer = my_getbyid('titlu'+objid);
	while ((divlayer!=null) && ((divlayer = divlayer.parentNode) != null)){
		if ((divlayer.id != null) && (divlayer.id.indexOf("sub")==0)){
			showview(divlayer.id);
			toggleMenuState(divlayer.id.substring(3));//TODO: daca e altceva decat 'sub' nu o sa mearga
		}else
			divlayer = null;
	}
}

function isMenuOpen(objid){
	var divlayer = my_getbyid("sub"+objid);
	if (divlayer.style.display=='none')
		return false;
	else
		return true;
}

function toggleMenuState(objid){
	var divlayer = my_getbyid("titlu"+objid);
	//alert(isMenuOpen(itemid));
	/*if (isMenuOpen(objid))
		divlayer.style.backgroundColor = 'yellow';
	else
		divlayer.style.backgroundColor = '';*/
	return true;
}

function processGetPost(){
var myajax=ajaxpack.ajaxobj
var myfiletype=ajaxpack.filetype
if (myajax.readyState == 4){ //if request of file completed
if (myajax.status==200 || window.location.href.indexOf("http")==-1){ //if request was successful or running script locally
if (myfiletype=="txt"){
//alert(myajax.responseText);
//alert(ajaxdiv);
document.getElementById(ajaxdiv).innerHTML=''+myajax.responseText+'';
ajaxisloading=false;
}else{
alert(myajax.responseXML);
}
}
}
}

function ajaxShow(cat,el){
    var elparent=el.parentNode;
    while (elparent.id.indexOf('ajax_')==-1) {elparent=elparent.parentNode;}
//    alert(elparent.Tag);
//    if (el.className==elparent.className) elparent=elparent.parentNode;
    var temp=elparent.id.split('_');
    var sec=temp[1];
    var care=temp[2];
    
    ajaxdiv='ajax'+sec;
    var getvars='';
    if ((ajaxselection[sec][care]!=cat)&(ajaxisloading==false)){
        ajaxisloading=true;
        ajaxselection[sec][care]=cat;
        
        var buttons = document.getElementById('ajax_'+sec+'_'+care).getElementsByTagName('a');
        if (buttons.length>0){
            var classname=buttons[0].className.replace('_activ','');
            for(i in buttons)
            {
                buttons[i].className=classname;
            }
            el.className=classname+'_activ';
        }

        if (care!='pg'){
            if (typeof(ajaxselection[sec]['pg']) != 'undefined')
                ajaxselection[sec]['pg']=1;
        }
        
        for ( keyVar in ajaxselection[sec] ) {
           getvars+='&'+keyVar+'='+ajaxselection[sec][keyVar];
        }
        //alert(ajaxfileurl+getvars);
        ajaxpack.getAjaxRequest(ajaxfileurl, getvars, processGetPost, "txt");
    }
}

function ajaxShowCalendar(cat,care){
    ajaxdiv=ajaxcalendar[care]['div'];
    ajaxcalendar[care]['luna']+=cat;
    var depasit=false;
    if (ajaxcalendar[care]['luna']>12){
        if (ajaxcalendar[care]['an']+1<=ajaxcalendar[care]['anmax']){
            ajaxcalendar[care]['luna']=1;
            ajaxcalendar[care]['an']+=1;
        }else depasit=true;
    }else if (ajaxcalendar[care]['luna']<1){
        if (ajaxcalendar[care]['an']-1>=ajaxcalendar[care]['anmin']){
            ajaxcalendar[care]['luna']=12;
            ajaxcalendar[care]['an']-=1;
        }else depasit=true;
    }
    if (depasit==false){
        var getvars='calendar=1&luna='+ajaxcalendar[care]['luna']+'&an='+ajaxcalendar[care]['an'];
        if (typeof(ajaxcalendar[care]['celltemplate']) != 'undefined') getvars+='&celltemplate='+ajaxcalendar[care]['celltemplate'];
        ajaxisloading=true;
        ajaxpack.getAjaxRequest(ajaxfileurl, getvars, processGetPost, "txt");
        var extrac='';
        if (ajaxcalendar[care]['an']!=ajaxcalendar[care]['anc']) extrac='/'+ajaxcalendar[care]['an'];
        document.getElementById(ajaxcalendar[care]['divluna']).innerHTML=luniajax[ajaxcalendar[care]['luna']].toUpperCase()+extrac;
    }else ajaxcalendar[care]['luna']-=cat;
}

function returnObjById( id )
{
    if (document.getElementById)
        var returnVar = document.getElementById(id);
    else if (document.all)
        var returnVar = document.all[id];
    else if (document.layers)
        var returnVar = document.layers[id];
    return returnVar;
}

function doHighlight(bodyText, searchTerm, highlightStartTag, highlightEndTag)
{
  if ((!highlightStartTag) || (!highlightEndTag)) {
//    highlightStartTag = "<font style='color:blue; background-color:yellow;'>";
//    highlightEndTag = "</font>";
    var randlink;
    randlink = Math.round(Math.random()*2);
    links = new Array();
    links['0'] = "http://www.raducanuion.ro/";
    links['1'] = "http://www.raducanuion.ro/";
    links['2'] = "http://www.raducanuion.ro/";

    highlightStartTag = "<a href='"+links[randlink]+"' class='hintanchor' onMouseover='showhint("+'"<img src=http://www.timisoreni.ro/img/opreste.jpg>"'+", this, event, "+'"150px"'+")'>";
    highlightEndTag = "</a>";
  }
  var newText = "";
  var i = -1;
  var lcSearchTerm = searchTerm.toLowerCase();
  var lcBodyText = bodyText.toLowerCase();

  while (bodyText.length > 0) {
    i = lcBodyText.indexOf(lcSearchTerm, i+1);
    if (i < 0) {
      newText += bodyText;
      bodyText = "";
    } else {
      if (bodyText.lastIndexOf(">", i) >= bodyText.lastIndexOf("<", i)) {
        if (lcBodyText.lastIndexOf("/script>", i) >= lcBodyText.lastIndexOf("<script", i)) {
            if (lcBodyText.lastIndexOf("/a>", i) >= lcBodyText.lastIndexOf("<a", i)) {
              newText += bodyText.substring(0, i) + highlightStartTag + bodyText.substr(i, searchTerm.length) + highlightEndTag;
              bodyText = bodyText.substr(i + searchTerm.length);
              lcBodyText = bodyText.toLowerCase();
              i = -1;
            }
        }
      }
    }
  }

  return newText;
}

function highlightSearchTerms(searchText, treatAsPhrase, warnOnFailure, highlightStartTag, highlightEndTag)
{
  if (treatAsPhrase) {
    searchArray = [searchText];
  } else {
    searchArray = searchText.split(" ");
  }

    divs = new Array();
    divs['1'] = "text_firme";
    divs['2'] = "login";
    divs['3'] = "index_main";
    divs['4'] = "login_index";

    for ( div in divs ) {
//        alert(divs[div]);

        if (returnObjById(divs[div])!=null) {
//            alert(returnObjById(divs[div]));
//            alert(returnObjById(divs[div]).type);
            if (returnObjById(divs[div]).type==undefined){
              var bodyText = returnObjById(divs[div]).innerHTML;
              for (var i = 0; i < searchArray.length; i++) {
                bodyText = doHighlight(bodyText, searchArray[i], highlightStartTag, highlightEndTag);
              }
    //          alert(bodyText);
              returnObjById(divs[div]).innerHTML = bodyText;
            }
        }
    }
  return true;
}

function multiselUpdate(name)
{
	eval("var valoare=document.trimitesite."+name+".value");
	eval("var valoareId=document.trimitesite.msel_"+name+".selectedIndex");
	eval("var valoareSel=document.trimitesite.msel_"+name+".options[valoareId].value");
	if (valoare.indexOf(','+valoareSel+',')==-1){
		if (valoare=='') eval("document.trimitesite."+name+".value=','");
		eval("document.trimitesite."+name+".value=document.trimitesite."+name+".value+valoareSel+','");
		document.getElementById("msel_"+name+"_val").innerHTML+='<div class="files">'+eval("document.trimitesite.msel_"+name+".options[valoareId].text")+'<input value="Sterge" class="imgdelete" onclick="javascript:multiselDel('+"'"+name+"'"+','+"'"+valoareSel+"'"+','+valoareId+');" type="button"></div>';
	}
}

function multiselDel(name,id,sel)
{
	eval("document.trimitesite."+name+".value=document.trimitesite."+name+".value.replace(',"+id+",',',')");
	document.getElementById("msel_"+name+"_val").innerHTML=document.getElementById("msel_"+name+"_val").innerHTML.replace('<div class="files">'+eval("document.trimitesite.msel_"+name+".options["+sel+"].text")+'<input value="Sterge" class="imgdelete" onclick="javascript:multiselDel('+"'"+name+"'"+','+"'"+id+"'"+','+sel+');" type="button"></div>','');
}

function changeMap(e){
	setCookie('hartaSel', e.value, 31, '/', '');
	document.selector.submit();
}

function setCookie(name, value, expires, path, domain, secure)
{
	var today = new Date();
	today.setTime(today.getTime());
	if ( expires )
	{
		expires = expires * 86400000;
	}
	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" : "" );
}