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

function show_confirm(text,urlok)
{
	var r=confirm(text);
	if (r==true)
	  {
	  window.location.href=urlok;
	  }
}

function show_confirm_form(text)
{
	var r=confirm(text);
	
	if (r==true)
	  {
	 	document.viewzbozi_form.submit()
	  }
	  
	
}
function dynamic_text_in_input_onkeyup (idobject,text,captcha)
{
	if(document.getElementById(idobject).value!='' && document.getElementById(idobject).value!=text){visibled(captcha,'yes');}else{visibled(captcha,'no');}
}
function dynamic_text_in_input_onfocus (idobject,text)
{
	if (document.getElementById(idobject).value==text) {document.getElementById(idobject).value='';}
}
function dynamic_text_in_input_onblur (idobject,text)
{
	if (document.getElementById(idobject).value=='') {document.getElementById(idobject).value=text;}
}

function noveokno (adresa1,width,height) { 
 var adresa = adresa1
 	window.open(adresa, "podkatfrm", "width="+width+",height="+height+",menubar=no,resizable=no,toolbar=yes,scrollbars=yes,left=100,top=100")
 	
 }
  
 function substr_count (haystack, needle, offset, length) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Onno Marsman
    // *     example 1: substr_count('Kevin van Zonneveld', 'e');
    // *     returns 1: 3
    // *     example 2: substr_count('Kevin van Zonneveld', 'K', 1);
    // *     returns 2: 0
    // *     example 3: substr_count('Kevin van Zonneveld', 'Z', 0, 10);
    // *     returns 3: false

    var pos = 0, cnt = 0;

    haystack += '';
    needle += '';
    if (isNaN(offset)) {offset = 0;}
    if (isNaN(length)) {length = 0;}
    offset--;

    while ((offset = haystack.indexOf(needle, offset+1)) != -1){
        if (length > 0 && (offset+needle.length) > length){
            return false;
        } else{
            cnt++;
        }
    }
	document.getElementById('ajaxtest').innerHTML=cnt;
    return cnt;
}

function isKeyPressed(event)
{
if (event.shiftKey==1)
  {
   	return true;
  }
else
  {
  	return false;
  }
}
function keyPressHandler(e) {
     var keynum
	var keychar
	var numcheck
	
	if(window.event) // IE
	{
	keynum = e.keyCode
	}
	else if(e.which) // Netscape/Firefox/Opera
	{
	keynum = e.which
	}
	
	if (keynum==27) return true;
	
}

/*------------------------scrolling ----------*/
iens6=document.all||document.getElementById
ns4=document.layers


var speed=5	

function movedown(){
if (iens6&&parseInt(crossobj.style.top)>=(contentheight*(-1)+100))
crossobj.style.top=parseInt(crossobj.style.top)-speed+"px"
else if (ns4&&crossobj.top>=(contentheight*(-1)+100))
crossobj.top-=speed
movedownvar=setTimeout("movedown()",20)
}

function moveup(){
if (iens6&&parseInt(crossobj.style.top)<=0)
crossobj.style.top=parseInt(crossobj.style.top)+speed+"px"
else if (ns4&&crossobj.top<=0)
crossobj.top+=speed
moveupvar=setTimeout("moveup()",20)

}

function getcontent_height(){
if (iens6)
contentheight=crossobj.offsetHeight
else if (ns4)
document.nscontainer.document.nscontent.visibility="show"
}
window.onload=getcontent_height

/*----------------------bookmark--------------*/
function bookmark()
{
	title = document.title; 
	url = document.URL;
	
	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title,url,"");
	} else if (window.external) { // IE Favorite
		window.external.AddFavorite(url,title);
	} else if (window.opera && window.print) {
    linkObj.title = addTitle;
    return true;
    } 
}

function hodnota (id)
{
	return document.getElementById(id).value;
}
/*------------url encode decode -----------*/
var Url = {
 
	// public method for url encoding
	encode : function (string) {
		return escape(this._utf8_encode(string));
	},
 
	// public method for url decoding
	decode : function (string) {
		return this._utf8_decode(unescape(string));
	},
 
	// private method for UTF-8 encoding
	_utf8_encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";
 
		for (var n = 0; n < string.length; n++) {
 
			var c = string.charCodeAt(n);
 
			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}
 
		}
 
		return utftext;
	},
 
	// private method for UTF-8 decoding
	_utf8_decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;
 
		while ( i < utftext.length ) {
 
			c = utftext.charCodeAt(i);
 
			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}
 
		}
 
		return string;
	}
 
}
		