var horizontal_offset="9px";
var disablehint=0;

var vertical_offset="0";
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") && disablehint==0){
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, "rightedge")+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;
}

function showview(id)
{
	if ( itm = my_getbyid(id) )
	{
		my_show_div(itm);
	}
}

function hideview(id)
{
	if ( itm = my_getbyid(id) )
	{
		my_hide_div(itm);
	}
}

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);
		}
	}
}

function my_hide_div(itm)
{
	if ( ! itm ) return;

	itm.style.display = "none";
}

function my_show_div(itm)
{
	if ( ! itm ) return;

	itm.style.display = "";
}

function processGetPostCom(){
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){
            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] ) {
           getvars+='&'+keyVar+'='+ajaxselection[sec][keyVar];
        }
        //alert(ajaxfileurl+getvars);
        ajaxpack.getAjaxRequest(ajaxfileurl, getvars, processGetPostCom, "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, processGetPostCom, "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;
}