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);

document.getElementById(ajaxdiv).innerHTML=''+myajax.responseText+'';
ajaxisloading=false;
}else{
alert(myajax.responseXML);
}
}
}
}

function ajaxShow(cat,el){
    var elparent=el.parentNode;
    while (typeof elparent.id != 'undefined' && 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){
            if (classname=buttons[0].className!='child'){
                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] ) {
           if(ajaxselection[sec][keyVar] != 'default')
            getvars+='&'+keyVar+'='+ajaxselection[sec][keyVar];
        }
        if(limba == 'en') 
            getvars+='&limba='+limba;
        //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'];
        if (typeof(ajaxcalendar[care]['extraurl']) != 'undefined') getvars+='&extraurl='+ajaxcalendar[care]['extraurl'];
        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;
}

