
/* ------------------------------------------------------------------------------------------------------------
	UniScript - univerzalne funkcie na pracu s layermi a dokumentom
	zalozene na 1K DHTML API (http://www.dithered.com/experiments/1kdhtml/index.html)
	modifikoval, rozsiril a dopolnil Riki Fridrich (http://acid.nfo.sk)
--------------------------------------------------------------------------------------------------------------- */
d=document;l=(d.layers)?1:0;op=navigator.userAgent.toLowerCase().indexOf('opera')!=-1;ie=(d.all)?1:0;
function gE(e,f){if(l){f=(f)?f:self;var V=f.document.layers;if(V[e])return V[e];for(var W=0;W<V.length;)t=gE(e,V[W++]);return t;}if(d.all)return d.all[e];return d.getElementById(e);}

function sE(e){if(l)e.visibility='show';else e.style.visibility='visible'; e.style.display='';}
function sEb(e){if(l)e.visibility='show';else e.style.visibility='visible'; e.style.display='block'; }
function sEi(e){if(l)e.visibility='show';else e.style.visibility='visible'; e.style.display='inline';}
function hE(e){if(l)e.visibility='hide';else e.style.visibility='hidden'; e.style.display='none';}


function sX(e,x){if(l)e.left=x;else if(op)e.style.pixelLeft=x;else e.style.left=x+'px';}
function gX(e){if(l)return e.left;else if(op)return e.style.pixelLeft;else return parseInt(e.style.left);}
function sY(e,y){if(l)e.top=y;else if(op)e.style.pixelTop=y;else e.style.top=y+'px';}
function gY(e){if(l)return e.top;else if(op)return e.style.pixelTop;else return parseInt(e.style.top);}
function sW(e,w){if(l)e.clip.width=w;else if(op)e.style.pixelWidth=w;else e.style.width=w;}
function gW(e){if(l)return e.clip.width;else if(op)return e.style.pixelWidth;else return parseInt(e.style.width);}
function sH(e,h){if(l)e.clip.height=h;else if(op)e.style.pixelHeight=h;else e.style.height=h;}
function gH(e){if(l)return e.clip.height;else if(op)return e.style.pixelHeight;else return parseInt(e.style.height);}

function mT(e,x,y){sX(e,x);sY(e,y);}
function mB(e,x,y){sX(e,gX(e)+x);sY(e,gY(e)+y);}


function wH(e,h){/*if(l){Y=e.document;Y.write(h);Y.close();}if(e.innerHTML)*/if(e) e.innerHTML=h;}
function rH(e){/*if(l){Y=e.document;Y.write(h);Y.close();}if(e.innerHTML)*/ if(e) return e.innerHTML;}
function wHa(e,h){ /*if(l)	{/*Y=e.document;Y.write(h);Y.close();}if(e.innerHTML)*/	e.innerHTML=e.innerHTML+h;
						}
function sC(e,t,r,b,x){if(l){X=e.clip;X.top=t;X.right=r;X.bottom=b;X.left=x;}else e.style.clip='rect('+t+'px '+r+'px '+b+'px '+x+'px)';}

function winW(){if(window.innerWidth)return window.innerWidth;else return d.body.clientWidth;}
function winH(){if(window.innerHeight)return window.innerHeight;else return d.body.clientHeight;}
function winL(){if(ie)return d.body.scrollLeft;else return window.pageXOffset;}
function winT(){if(ie)return d.body.scrollTop;else return window.pageYOffset;}



// ---------------------------------------------------------------------------------------------------------------------
// dalsie univerzalne funkcie  ------------------------------------------------------------------------------------------

function addCls(elm,cls)
{
    if(elm)
    {
		var isok=1;
    	var clses = new Array();
    	// zistenie ci uz taku nema
    	clses=elm.className.split(" ");
		for(var i=0;i<clses.length;i++)
			if(cls==clses[i])
				isok=false;
		// ak este taku nema pridaj
    	if(isok==1)
    		elm.className+=" "+cls;
		//elm.setAttribute(elm.getAttribute('class')+" "+cls);

		return 1;
    }
    else
        return 0;
}

function remCls(elm,cls)
{

    if(elm)
	{
        //elm.setAttribute(elm.getAttribute('class').replace(new RegExp(" "+cls), ""));
		//elm.setclass=this.className.replace(new RegExp(" "+cls), "");

		// ak je jedina
		if(elm.className==cls)
		  elm.className='';
		// ak sa nachadza za medzerou
    	elm.className=elm.className.replace(new RegExp(" "+cls), "");
    	// ak je na zaciatku
    	if(elm.className.substring(0,cls.length)==cls)
    	   elm.className=elm.className.substring(cls.length+1);
	}

}




function showhide(objid)
  {
	  
		el=document.getElementById(objid);
		if (el.style.display=='block')
		     el.style.display='none';
		else
		   el.style.display='block'; 		 
	}
	


// ---------------------------------------------------------------------------------------------------------------------
// akoze ajax -spustanie php skriptov  ----------------------------------------------------------------------------------
function runPhpScript(url,postRequest,intoDivId,otherFunction)
{
	   //document.body.style.cursor='wait !important';

	   //loading_on();
        var http_request = false;

		var r='';
        if (window.XMLHttpRequest) {
            http_request = new XMLHttpRequest();
        } else if (window.ActiveXObject) {
            try {
              http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (eror) {
              http_request = new ActiveXObject("Microsoft.XMLHTTP");
            }
        }
        	http_request.onreadystatechange = function() {
        	    if(intoDivId!=''||otherFunction!='')
        	    if (http_request.readyState == 4){
            	    if (http_request.status == 200)
            	    {
        	           if((intoDivId!='' )&& (elmdiv=gE(intoDivId)))
        	               elmdiv.innerHTML=http_request.responseText;
                	   //loading_off();
        	           if(otherFunction!='')
                	       eval(otherFunction);
                	   //document.body.style.cursor='default';

            	    }
            	    else
            	    {
            	        alert('Chyba:'+http_request.responseText);
            	    }
        	    }


        	};

        http_request.open('POST', url, true);
        http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        http_request.send(postRequest);
}


function runOtherFunction(http_request,otherFunction) {
		//alert('Chyba'+http_request.responseText);
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
				eval(otherFunction);
                //alert(http_request.responseText);
            } else {
                //alert('Chyba');
            }
        }
    }

	
	