function deleteText(object)
{
	
	if(!object.dlt)
	{
		object.value="";
		object.dlt=true;
	}
}

function addBookmark(title) {
  if (window.external)
    external.AddFavorite(location.href, title)
}

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";
    }
}


/*function increaseText(id,increase)
{
	var cookieIncrease=getCookie("textincrease");
	var currentIncrease;
	
	if(!cookieIncrease)
		currentIncrease=0;
	else {
		currentIncrease=parseInt(cookieIncrease);
	}
	
	if(increase)
		currentIncrease+=increase;
	else if(currentIncrease!=0)
		increase=currentIncrease;
	else
		return;

	if (currentIncrease<-1) { increase=currentIncrease=-1; return; }
	if (currentIncrease>3) { increase=currentIncrease=10; return; }
//	alert(increase);		
//	if (currentIncrease<0)
//		increase=currentIncrease=0;
	
	setCookie("textincrease",currentIncrease,null,"/");
		

	var o=document.getElementById(id);
	if(o)
	{
		if (o.hasChildNodes() || (o.childNodes && o.childNodes.length>0) ) {
			var el;
		    if(document.all)
				el= o.children;
			else
				el= o.childNodes;
				
			
			for (var i=0; i<el.length; i++)
				if(el[i].nodeName.toLowerCase()!="#text")
					handleIncrease(el[i], increase);
		}
			
	}	
}
*/
var currentIncrease=0;
function increaseText(id,increase)
{
	//alert(currentIncrease);
	if((currentIncrease>2 && increase>0) || (currentIncrease<-1 && increase<0))
		{
			return;
		}
	
	if(increase==0)
		currentIncrease=0;
	else
		currentIncrease+=increase;
	
	//setCookie("textincrease",currentIncrease,null,"/");
		

	var o=document.getElementById(id);
	if(o)
	{
		if (o.hasChildNodes() || (o.childNodes && o.childNodes.length>0) ) {
			var el;
		    if(document.all)
				el= o.children;
			else
				el= o.childNodes;
				
			
			for (var i=0; i<el.length; i++)
				if(el[i].nodeName.toLowerCase()!="#text")
					handleIncrease(el[i], increase);
		}
			
	}	
}


function getStyle(x,styleProp)
{
	var y=null;

	if (document.defaultView && document.defaultView.getComputedStyle)
		y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
	else if (x.currentStyle)
		y = eval('x.currentStyle.' + styleProp);
	
	return y;
}


function handleIncrease(o, increase)
{

	if(o)
	{
		if (o.hasChildNodes() || (o.childNodes && o.childNodes.length>0) ) {
			var el;
		    if(document.all)
				el= o.children;
			else
				el= o.childNodes;
					
			for (var i=0; i<el.length; i++)
			{ //alert(el[i].nodeName.substr(0,1));
				if(el[i].nodeName.substr(0,1)!="#")
					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!="")
		{
//			alert(newval);
			var extension=newval.match(/[a-z]+$/i);
//			alert("ext: " + extension);
			newval=newval.match(/^[\d\.]+/i);
//			alert("\nnewval: " + newval + "\nincrease: " + increase + "\nextension: " + extension);
//			alert("" + (parseFloat(newval) + increase) + extension);
//			throw("x");
			
			try {
				o.style.fontSize=(parseFloat(newval) + increase) + extension;			
			} catch (e) {
				alert("Napaka v cookieincrease!\n" + e + "\nnewval: " + newval + "\nincrease: " + increase + "\nextension: " + extension);
				throw(e);
			}
		}
	
	}	

}





