<!--

	/**
	 * @author: Icarus
	 * @description: Main Functions
	 * @version: 0.2
	**/

	function getEl(element){
		return eval("document.getElementById(element)");
	}

	/**
	 * @access public
	 * @description: writes email addresses from string parts
	 * @params: strpart : array(object) of string parts of the email address, obj : if we use it for link
	 * @usage:
	 *	<a href="" onmouseover="write_email(['ema','il@por','tal.','com'],this)"><script> write_email(['ema','il@por','tal.','com'],null); </script></a>
  **/

	function write_email(strparts,obj){
	 	if (obj==null) {
			for (i=0;i<strparts.length;i++) {
				document.write(strparts[i]);
			}
	  } else {
			var mail = "";
			for (i=0;i<strparts.length;i++) {
				mail += strparts[i];
			}
			obj.href=('mai'+'lto:'+mail);
	  }
	}

	/**
	 * @access public
	 * @description: submits the form when enter has been pressed.
	 * @params: field : in which field the event has happened in, e : event object
	 * @usage: onKeyPress="return submitEnter(this,event);"
  **/

	function submitEnter(field,e)
	{
		var keycode;
		if (window.event) keycode = window.event.keyCode;
		else if (e) keycode = e.which;
		else return true;

		if (keycode == 13)
		   {
			   field.form.submit();
			   return false;
		   }
		else
		   return true;
	}

	/**
	 * @access public
	 * @description: Opens a popup window with given parameters
	 * @params: name,file,width,height
	 *					scrollbar,resizable,modal (true/false)
  **/

	function popup(name,file,width,height,scrollbar,resizable,modal) {
		wLeft=(screen.width)?(screen.width-width)/2:100;
		wTop=(screen.height)?(screen.height-height)/2:100;
		childWindow=window.open(file,name,"modal=yes,width="+width+"px,height="+height+"px,scrollbars="+scrollbar+",resizable="+resizable+",top="+wTop+",left="+wLeft);
		if (childWindow.opener == null) childWindow.opener = self;
			childWindow.focus();
	}

		function resize(el) {
			var w=document.getElementById(el).width;
			var h=document.getElementById(el).height;
			if( window.innerWidth ) { mW = 8; mH = 80; } else { mW = 0; mH = 0 }
			w=w+mW; h=h+mH;
			window.resizeTo( w,h );

			/*var mW = 0, mH = 0, d = window.document.documentElement, b = window.document.body;
			if( window.innerWidth ) { mW = window.innerWidth; mH = window.innerHeight; }
			else if( d && d.clientWidth ) { mW = d.clientWidth; mH = d.clientHeight; }
			else if( b && b.clientWidth ) { mW = b.clientWidth; mH = b.clientHeight; }
			//Opera 6- adds on 16 pixels for the non-existent scrollbar
			if( window.opera && !document.childNodes ) { mW += 16; }
			window.resizeTo( w + ((w)-mW),h+((h)-mH) );*/
		}


	/**
	 * @access public
	 * @description: preload rollover images
	**/

	function preloadImages() {
	  var d=document; if(d.images){ if(!d.ps) d.ps=new Array();
		var i,j=d.ps.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
		if (a[i].indexOf("#")!=0){ d.ps[j]=new Image; d.ps[j++].src=a[i];}}
	}

	/**
	 * @access public
	 * @description: submit form
	 * @params: formId : id of the form element
	 **/

	function submitForm(formId){
		formEl = document.getElementById(formId);
		formEl.submit();
	}
	
	
	
	function trim12 (str) {
	var	str = str.replace(/^\s\s*/, ''),
		ws = /\s/,
		i = str.length;
	while (ws.test(str.charAt(--i)));
	return str.slice(0, i + 1);
	}

	/**
	 * @access public
	 * @description: checks whether form elements are filled out and valid & submit the form
	 * @params: formEl : form element
	 * @validate
	**/
	

	function checkForm(formId) {
		formEl = document.getElementById(formId);
		for (i=0;i<formEl.elements.length; i++ ) {
			el = formEl.elements[i];
			if ( el.type == "text") {
				if ( el.value == "" ) {
					alert("Sva polja trebaju se ispuniti!"); return;
				} else {
					if (el.name.search(/email/) != -1) {
					 var emailExp = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
					 if ( emailExp.test(el.value) == false ) { alert ("Format e-mail adrese nije ispravan!"); return }  ;
					}
				}
			}
		}
		formEl.submit();
	}
	
	function check_jo_tudni_Form(formId) {
		formEl = document.getElementById(formId);
		for (i=0;i<formEl.elements.length; i++ ) {
			el = formEl.elements[i];
			if ( el.type == "text") {
				if ( el.value == "" ) {
					alert("Sva polja trebaju se ispuniti!"); return;
				} else {
					if (el.name.search(/email/) != -1) {
					 var emailExp = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
					 if ( emailExp.test(el.value) == false ) { alert ("Format neke e-mail adrese je neispravan!"); return }  ;
					}
					
					elem = getEl('sender_name');
					if( (elem.value.length<3) || (trim12(elem.value)=='') || (elem.value=='Ime') ){
						alert ("Molimo unesite ime!"); 
						return 
					}
					
					elem = getEl('recipient_name');
					if( (elem.value.length<3) || (trim12(elem.value)=='') || (elem.value=='Ime poznanika') ){
						alert ("Molimo unesite ime poznanika!"); 
						return 
					}
					
					elem = getEl('message');
					if(elem.value=='Primjedba...') elem.value='';
					
				}
			}
		}
		formEl.submit();
	}
	
	function check_kerdezz_Form(formId){
		formEl = document.getElementById(formId);
		for (i=0;i<formEl.elements.length; i++ ) {
			el = formEl.elements[i];
			if ( el.type == "text") {
				if ( el.value == "" ) {
					alert("Sva polja trebaju se ispuniti!"); return;
				} else {
					if (el.name.search(/email/) != -1) {
					 var emailExp = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
					 if ( emailExp.test(el.value) == false ) { alert ("Format e-mail adrese  nije ispravan!"); return }  ;
					}
					
					elem = getEl('name');
					if( (elem.value.length<3) || (trim12(elem.value)=='') || (elem.value=='Ime') ){
						alert ("Molimo unesite ime!"); 
						return 
					}
					
					elem = getEl('email');
					if( (elem.value.length<3) || (trim12(elem.value)=='') || (elem.value=='Ime') ){
						alert ("Molimo ispunite polje e-maila!"); 
						return 
					}
					
					elem = getEl('title');
					if( (elem.value.length<3) || (trim12(elem.value)=='') ){
						alert ("Molimo navedite temu o kojoj želite postaviti pitanje!"); 
						return 
					}
					
					elem = getEl('message');
					if( (elem.value.length<3) || (trim12(elem.value)=='') || (elem.value=='Napišite pitanje!') ){
						alert ("Molimo unesite pitanje!"); 
						return 
					}
					
				}
			}
		}
		formEl.submit();
	}

	function onLoad() {
		for(i=0;i<=document.links.length-1;i++) {document.links[i].hideFocus='true'}
	}


//-->
