// JavaScript Document

	/* 
		Descirption: Otvaranje novog prozora
		File: *.asp
	*/
	function openWin(file,name,w,h,resizable,otherFeat){
		l=screen.width/2-w/2;
		t=screen.height/2-h/2;
		if(otherFeat) otherFeat= ',' + otherFeat
		return window.open(file,name,'width='+w+',height='+h+',resizable='+resizable+',top='+t+',left='+l+otherFeat);
	}
	
	/* 
		Descirption: navigacija
		File: default.asp
	*/
	function searchLocation(objForm,msg) {
		var reference =  objForm.searchList.options[objForm.searchList.selectedIndex].value;
		if (reference != '0') {
			window.location.href = reference;
			return true;
		}
		else 
			alert(msg);
	}
	
	/* 
		Descirption: validacija forme za upit
		File: place.asp / details.asp
	*/
		function validateForm(objForm) {
			if (!checkEmail(objForm.senderEmail.value)){
			//(objForm.senderEmail.value.length < 6 || objForm.senderEmail.value.indexOf('@')==-1) 
				alert('You must enter valid E-MAIL address!\n');
				return false;
			  }
			openWin('','inqury','350','350','yes','scrollbars=yes');
		}
	
		function validateFormRecomand(objForm) {
			if (!checkEmail(objForm.email.value)) {
			//(objForm.email.value.length < 6 || objForm.email.value.indexOf('@')==-1) 
				alert('You must enter valid E-MAIL address!\n');
				return false;
			  }
		}
	
	
	/* 
		Descirption: validacija forme za kreiranje accounta
		File: place.asp / details.asp
	*/
	function checkCreateAccount(objForm) {
		var ime = (objForm.ime.value)?1:0;
		var prezime = (objForm.prezime.value)?1:0;
		var email = checkEmail(objForm.email.value)?1:0;
		var email2 = (objForm.email.value == objForm.email2.value)?1:0;
		var mjestoID = (objForm.mjestoID.options[objForm.mjestoID.selectedIndex].value=='0')?0:1;
		var uvjeti = (objForm.uvjeti.checked)?1:0;
		
		var msg = 'Ispravite greške;\n\n';
		
		if (!ime || !prezime || !email || !email2 || !mjestoID || !uvjeti) {
			if (!ime) 	msg += ('- potrebno unjeti ime!\n');
			if (!prezime) 	msg += ('- potrebno unjeti prezime!\n');
			if (!email) 	msg += ('- potrebno unjeti ispavan e-mail!\n');
			if (!email2)	msg += ('- uneseni e-mailovi ne odgovaraju!\n');
			if (!mjestoID) 	msg += ('- potrebno odabrati mjesto!\n');
			if (!uvjeti) 	msg += ('- potrebno pročitati i prihvatiti uvjete!\n');
			alert(msg);
			//alert(ime + ' ' + prezime + ' ' + email + ' ' + mjestoID + ' ' + uvjeti);
			return false;
		  }
		  
		openWin('','createAccount','350','350','yes','scrollbars=yes');
	}
	
	/* 
		Descirption: validacija e-maila
		File: internal usage
	*/
	
	function checkEmail(email) {
		var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (filter.test(email)) {
			return true;
			}
		return false;
	}	
	
	
	function createLink(saveLink,rAddress,server) {
		
		var len;
		var address = '';
		
		for(len = rAddress.length; len >=0; len--) {
			if (rAddress.charAt(len) == '*') { 
				address += '@';
				continue;
			}
			address += rAddress.charAt(len);
		}
				
		var strOut;
		
		strOut = '<a onclick="openWin(\'' + saveLink + '\',\'email\',\'10\',\'10\',\'no\');" href="mai' + 'lto:' + address + '?sub' + 'ject=Upit:' + server + '">' + address + '</a>';
		
		return strOut;
	}	
	
	
	
	
	
	
	
	
	
	
	
