function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}
	
	return { 
		pageWidth : pageWidth, 
		pageHeight : pageHeight, 
		windowWidth : windowWidth, 
		windowHeight : windowHeight
	};
}

Array.prototype.call = function() {
  var args = arguments;
  this.each(function(f){ f.apply(this, args) });
}

function ShowHideTab(tabname, active)
 {
	var tab = document.getElementById(tabname)
	if (tab) tab.style.display="none"
    tab = document.getElementById(active);
    if (tab) tab.style.display="block";
    var imgtab = document.getElementById(tabname + '_tab');
    if (imgtab) imgtab.className="cnt";
    imgtab = document.getElementById(active + '_tab');
    if (imgtab) imgtab.className="cnt_a";
    
    
    imgtab = document.getElementById(tabname + '_imgL');
    if (imgtab) imgtab.setAttribute("src", CmsSkin + "img/tab_L.gif");
	imgtab = document.getElementById(tabname + '_imgR');
	if (imgtab) imgtab.setAttribute("src", CmsSkin + "img/tab_R.gif");
 
    imgtab = document.getElementById(active + '_imgL');
    if (imgtab) imgtab.setAttribute("src", CmsSkin + "img/tab_L_active.gif");
	imgtab = document.getElementById(active + '_imgR');
	if (imgtab) imgtab.setAttribute("src", CmsSkin + "img/tab_R_active.gif");
 }

function deleteText(object)
{
	
	if(!object.dlt)
	{
		object.value="";
		object.dlt=true;
	}
}

function addBookmark(title){
	if (window.sidebar) //Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, location.href, '');
	else if (window.external) //IE bookmark
		external.AddFavorite(location.href, title);
	else if(window.opera && window.print) //Opera Hotlist
		return true;
}

function closePopup(id) {
	var pop=document.getElementById(id);
	if (pop) {
		pop.style.display="none";
	}
}

function showPopup(id) {
	var pop=document.getElementById(id);
	if (pop) {
		pop.style.display="block";
	}
}

function togglePopup(id) {
	var pop=document.getElementById(id);
	if (pop) {
		if (pop.style.display=="none") 
			pop.style.display=""; 
		else 
			pop.style.display="none";
	}
}


function execute(e,command)
{	
	if(e && command)
	{
		var key=e.keyCode;
		if(key && key==13)
			eval(command);
	}
}

function setFormAction(object,action,target)
{	
	while(object && object.nodeName.toLowerCase()!="form" && (object.parentNode ||object.parentElement))
	{
		if(object.parentNode)
			object=object.parentNode;
		else if(object.parentElement)
			object=object.parentElement;
	}
	if(object)
	{
		object.action=action;
		object.target=target;
		
	}
}

function DisableWindow(id)
{
	var object=document.getElementById(id);
	if(object)
	{
		object.disabled=true;
	}
}





function setCookie(name, value, expires, path, domain, secure)
{
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

function deleteCookie(name, path, domain)
{
    if (getCookie(name))
    {
        document.cookie = name + "=" + 
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}


var currentIncrease=0;
function increaseText(id,increase)
{
	if((currentIncrease>2 && increase>0) || (currentIncrease<-2 && increase<0))
		{
			return;
		}
	
	if(increase==0)
		currentIncrease=0;
	else
		currentIncrease+=increase;

	var o=$(id);
	if(o)
	{
	    var el = o.childElements();
		for (var i=0; i<el.length; i++)				
            handleIncrease(el[i], increase);
	}
}


function getStyle(x,styleProp)
{
	var y=null;
    try{
	    if (document.defaultView && document.defaultView.getComputedStyle)
		    y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
	    else if (x.currentStyle)
		    y = eval('x.currentStyle.' + styleProp);
    }catch(e) {}
	
	return y;
}   


function handleIncrease(o, increase)
{
	if(o)
	{
	    var el = o.childElements();
		for (var i=0; i<el.length; i++)				
            handleIncrease(el[i], increase);
            
		var newval=null;
		
		if(o.style && o.style.fontSize)
			newval=o.style.fontSize;
		else
			newval=getStyle(o,(document.all ? "fontSize" : "font-size") );
			
		if(newval && newval!="")
		{
			var extension=newval.match(/[a-z]+$/i);
			newval=newval.match(/^[\d\.]+/i);
			try {
			    o.setStyle({"fontSize":((parseFloat(newval) + increase) + extension)});
			} catch (e) {
				alert("Napaka v cookieincrease!\n" + e + "\nnewval: " + newval + "\nincrease: " + increase + "\nextension: " + extension);
				throw(e);
			}
		}
	}	
}