
//onmouseover="over(this);" onmouseout="out(this);"
function over(doc){
	doc.style.backgroundColor="#CC9900"

}
function out(doc){
	doc.style.backgroundColor="#dddddd"
}


function gl_slika(url){
	window.location = url;
} 

function izbrisi_alert(url){
	var answer = confirm  ("Želite izbrisat to sliko?");
	if (answer) window.location = url;
}
 
function posli_post(a, url){
	document.body.innerHTML += '<form style="padding:0px; margin:0px;" id="dynForm" action="'+url+'" method="post"><input type="hidden" name="skrit" value="'+a+'"></form>';
	document.getElementById("dynForm").submit();
}

function izpis(id,besedilo){
	if(id.value == '') id.value = besedilo;
	else if(id.value == besedilo) id.value = '';
}

//zmanšaj besedilo in dodaj 3 pikice ...
function fitStringToWidth(obj,width,className) {
	str =  document.getElementById(obj).innerHTML;
	  // str    A string where html-entities are allowed but no tags.
	  // width  The maximum allowed width in pixels
	  // className  A CSS class name with the desired font-name and font-size. (optional)
	  // ----
	  // _escTag is a helper to escape 'less than' and 'greater than'
	  function _escTag(s){ return s.replace("<","&lt;").replace(">","&gt;");}

	  //Create a span element that will be used to get the width
	  var span = document.createElement("span");
	  //Allow a classname to be set to get the right font-size.
	  if (className) span.className=className;
	  span.style.display='inline';
	  span.style.visibility = 'hidden';
	  span.style.fontSize='14px';
	 span.style.fontFamily = 'sans-serif';    
	//  span.style.textDecoration = 'none';
	  
	  span.style.padding = '0px';
	  document.body.appendChild(span);

	  var result = _escTag(str); // default to the whole string
	  span.innerHTML = result;
	  // Check if the string will fit in the allowed width. NOTE: if the width
	  // can't be determinated (offsetWidth==0) the whole string will be returned.
	  if (span.offsetWidth > width) {
	    var posStart = 0, posMid, posEnd = str.length, posLength;
	    // Calculate (posEnd - posStart) integer division by 2 and
	    // assign it to posLength. Repeat until posLength is zero.
	    while (posLength = (posEnd - posStart) >> 1) {
	      posMid = posStart + posLength;
	      //Get the string from the begining up to posMid;
	      span.innerHTML = _escTag(str.substring(0,posMid)) + '&hellip;';

	      // Check if the current width is too wide (set new end)
	      // or too narrow (set new start)
	      if ( span.offsetWidth > width ) posEnd = posMid; else posStart=posMid;
	    }

	    result = '<span title="' +
	      str.replace("\"","&quot;") + '">' +
	      _escTag(str.substring(0,posStart)) +
	      '&hellip;<\/span>';
	  }
	  document.body.removeChild(span);
	  document.getElementById(obj).innerHTML = result;
	  //return result;
	}






var timeout         = 200;
var closetimer		= 0;
var ddmenuitem      = 0;


// POST vrednost
//primer: post_vrednost('posta.php',{ime:'jaka',cc:'aus'})
function post_vrednost (to,p) {
	  var myForm = document.createElement("form");
	  myForm.method="post" ;
	  myForm.action = to ;
	  for (var k in p) {
	    var myInput = document.createElement("input") ;
	    myInput.setAttribute("name", k) ;
	    myInput.setAttribute("value", p[k]);
	    myForm.appendChild(myInput) ;
	  }
	  document.body.appendChild(myForm) ;
	  myForm.submit() ;
	  document.body.removeChild(myForm) ;
	}


// odpri (levo- uporabnik)
/*
function odpri1()
{
	window.open('http://www.pageresource.com/jscript/jex5.htm','mywindow','width=400,height=200');
}
*/


// open hidden layer
function mopen(id)
{	
	// cancel close timer
	mcancelclosetime();

	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';

}
// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

// close layer when click-out
document.onclick = mclose; 

function setCookie(name,value,days) 
{

	
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}



function StetjeBesed(field,cntfield,maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else
cntfield.value = maxlimit - field.value.length;
}
