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 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);;


		}
	}
}

//==========================================
// 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 = "";
}


//==========================================
// Toogle img
//==========================================

		
		function toggleImg(imgID)
		{
			// get the tag by id
			var imgTag = document.getElementById(imgID);
			// full path
			var fullPathName = imgTag.src;
			// full path as array via '/'
			var pathSplit = fullPathName.split("/");
			// minus 1 to get number of last array element number
			var getfileNameExt = pathSplit.length - 1;
			// will hold the file path value
			var fullFilePath = ''; 
		 
			// construct the file path based on the split of the path delimiter "/"
			// if there are no "/", it is just an image name
			if (pathSplit.length == 0)
			{
				// no file path
				fullFilePath = ''; 
			}
			// there are "/" then image name needs to be removed from the path
			else if (pathSplit.length > 0)
			{
				// remove file name which should be the last element in the array
				fullFilePath = fullPathName.replace(pathSplit[getfileNameExt], ''); 
			}
		 
			// work out the dynamics of the file name
			var fileNameExt = pathSplit[getfileNameExt]; // name of file with ext
			var fileNameSpilt = fileNameExt.split("."); // filename as array via '.'
			var fileName = fileNameSpilt[0]; // just the file name
			var fileExt = fileNameSpilt[1]; // just the file extention
			var fileNameMainSpilt = fileName.split("_"); // check for a spilt on '_'
			var imgName ='';
		 
			// check the array to see if there is more that 1 array element
			// if there is more than 1 array element that means that
			// this is an _2 image.
		 
			if (fileNameMainSpilt.length > 1)
			{
				// If it is greater than 1, minus 1 to get number of last array 
				// element number
				var fileNameMain = fileNameMainSpilt.length - 1;
				// get array value at fileNameMain
				fileNameMain = fileNameMainSpilt[fileNameMain]; 
				// if the value of the last array element is 2
				if (fileNameMain == 2)
				{
					// create the img 1 file name
					imgName = fileNameMainSpilt[0] + '.' + fileExt;
				}
				// if it isn't 2, then create img 2 file name
				else
				{
					imgName = fileName + '_2.' + fileExt;
				}
			}
			// if the array length is 1
			else
			{
				// create the img 2 file name
				imgName = fileName + '_2.' + fileExt;
			}
		 
			var finalFile = fullFilePath + imgName;
			imgTag.src = finalFile;
			
		}
             

//==========================================
// style active link in left menu
//==========================================
function setActive() {
  aObj = document.getElementById('left_menu').getElementsByTagName('a');
  for(i=0;i<aObj.length;i++) { 
    if(document.location.href.indexOf(aObj[i].href)>=0) {
      aObj[i].className='active';
    }
  }
}
//window.onload = setActive;

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 ajaxisloading = ajaxisloading || false;
    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");
    }
}

/**
 *
 */
jQuery(document).ready(function() {

    // Top bar with ie6 message
    var browser = jQuery.browser;
    if (browser.msie && parseInt(browser.version) <= 6) {
        jQuery("<div />", {'class': 'topbar', text: ie6message}).prependTo("body").slideDown('slow');
        jQuery("<div />", {'class': 'close'}).appendTo('.topbar');
        jQuery('.topbar .close').click(function() {
            jQuery('.topbar').remove();
        });
    }

});
