function submitForm(str) {
	document.MyForm.action = str;
	document.MyForm.submit();
	return false;
}
function setFocusElement(id) {
	if (document.getElementById(id)) 
		window['focusElement'] = document.getElementById(id);
	return 0;
}
function lib_focusElement() {
	if (window['focusElement']) window['focusElement'].focus();
	return 0;
}

function addElement (parent, what, content) {
	var what = document.createElement(what);
	what.innerHTML = content;
	parent.appendChild(what);
	return what;
}

function addAfter(after, what) {
	var element = document.getElementById(after);
	if (element.nextSibling) {
		element.parentNode.insertBefore(what, element.nextSibling);
	} else element.parentNode.appendChild(what);
}

function addStatus(type, title, text) {
	//alert("type: "+type+"\ntitle: "+title+"\ntext: "+text);
	// find div
	var box = $('status-box');
	// if !exists create status-box
	if (box==null) {
		var box_parent = $('content');
		if (box_parent==null) return; // there is no header
		// todo: box_parent = document.body;
		box = document.createElement('span');
		box.id = 'status-box'; // to apply css
		//box_parent.appendChild(box); // add inside
		addBefore('content', box); // add after
		//box.innerHTML = '<span class="status-box-close" onclick="javascript: this.parentNode.parentNode.removeChild(this.parentNode);"><p>x</p></span><br><hr>';
	}
	
	var info_box = document.createElement('div');
	info_box.id = 'notify'; // to apply css

	var elem = null;
	//elem = addElement(info_box, 'div', '<a href="#" new Effect.SlideUp(this.parentNode.parentNode, {afterFinish: function(obj){obj.element.parentNode.removeChild(obj.element);}} ); return false;" id="close" title="Zatvori"></a>\n<p><b>'+title+'</b>: '+text+'</p>');
	elem = addElement(info_box, 'div', '<a href="#" id="close" title="Zatvori"></a>\n<p><b>'+title+'</b>: '+text+'</p>');
	elem.id = 'box_'+type; // to apply css
	// set close btn action
	//elem.firstChild.href = 'javascript: alert("href works");'; // to apply css
	elem.firstChild.onclick = function () {
		new Effect.SlideUp(this.parentNode.parentNode, {duration: 0.5, afterFinish: function(obj){obj.element.parentNode.removeChild(obj.element);}} );
		return false;
	};


	box.appendChild(info_box);
}

/***********************************************
* Form Field Progress Bar- By Ron Jonk- http://www.euronet.nl/~jonkr/
* Modified by Dynamic Drive for minor changes
* Script featured/ available at Dynamic Drive- http://www.dynamicdrive.com
* Please keep this notice intact
***********************************************/

function textCounter(field,counter,maxlimit,linecounter) {
	// text width//
	var fieldWidth =  parseInt(field.offsetWidth);
	var charcnt = field.value.length;        

	// trim the extra text
	if (charcnt > maxlimit) { 
		field.value = field.value.substring(0, maxlimit);
	}

	else { 
	// progress bar percentage
	var percentage = parseInt(100 - (( maxlimit - charcnt) * 100)/maxlimit) ;
	document.getElementById(counter).style.width =  parseInt((fieldWidth*percentage)/100)+"px";
	document.getElementById(counter).innerHTML="Limit: "+percentage+"%"
	// color correction on style from CCFFF -> CC0000
	setcolor(document.getElementById(counter),percentage,"background-color");
	}
}

function setcolor(obj,percentage,prop){
	obj.style[prop] = "rgb(80%,"+(100-percentage)+"%,"+(100-percentage)+"%)";
}
/***********************************************
* Form Field Progress Bar END
***********************************************/
