// JavaScript Document


function checkForm(form) {
	return true;
}

function checkLoginForm(){
	errorString = '';
	username=document.getElementById('usernameInput');
	if (username) {
		if (username.value==''){
			errorString += '<li><span>Unesite Va&scaron;e korisni&#269;ko ime</span></li>';
		}
	}
	password=document.getElementById('passwordInput');
	if (username) {
		if (password.value==''){
			errorString += '<li><span>Unesite zaporku</span></li>';
		}
	}
	
	if (errorString != '') {
		e_errorDiv = document.getElementById('errorDiv');
		if (e_errorDiv ) {
			e_errorDiv.innerHTML = '<ul class="errorList">'+errorString+'</ul>';
		} else {
			window.alert('Popunite sva polja!');
		}
		return false;
	}
	
}

function checkPasswordForm() {
	errorString = '';
	username = document.getElementById('usernameInput');
	if (username) {
		if (username.value==''){
			errorString += '<li><span>Unesite korisničko ime</span></li>';
		}
	}
	
	a = document.getElementById('emailInput');
	if (a) {
		if (a.value==''){
			errorString += '<li><span>Unesite ispravnu e-mail adresu</span></li>';
		}
	}
	if (errorString != '') {
		e_errorDiv = document.getElementById('errorDiv');
		if (e_errorDiv ) {
			e_errorDiv.innerHTML = '<ul class="errorList">'+errorString+'</ul>';
		} else {
			window.alert('Popunite sva polja!');
		}
		return false;
	}
}
function checkRegisterForm() {
	errorString = '';

	username = document.getElementById('usernameInput1');
	if (username) {
		if (username.value==''){
			errorString += '<li><span>Unesite željeno korisničko ime</span></li>';
		}
	}
	
	p1 = document.getElementById('passwordInput1');
	if (p1) {
		if (p1.value=='' || p1.value.length < 6){
			errorString += '<li><span>Unesite zaporku dužu od šest znakova</span></li>';
		}
	}
	
	p2 = document.getElementById('passwordInput2');
	if (p1 && p2) {
		if (p1.value!=p2.value){
			errorString += '<li><span>Niste točno potvrdili zaporku</span></li>';
		} else {
			
			if (errorString == '') {
				
				if (p1.value == username.value) {
					errorString += '<li><span>Korisničko ime je jednako kao i zaporka. Upišite drukčiju zaporku.</span></li>';
				}
			}
			
		}
	}


	a = document.getElementById('emailInput');
	if (a) {
		if (a.value==''){
			errorString += '<li><span>Unesite ispravnu e-mail adresu</span></li>';
		}
	}

	a = document.getElementById('nameInput');
	if (a) {if (a.value==''){
		errorString += '<li><span>Unesite ime</span></li>';
	}}
	
	a = document.getElementById('surnameInput');
	if (a) {if (a.value==''){
			errorString += '<li><span>Unesite prezime</span></li>';
	}}


	s1 = document.getElementById('sexInputF');
	s2 = document.getElementById('sexInputM');
	if (s1 && s2) {
		if (!s1.checked && ! s2.checked){
			errorString += '<li><span>Odaberite spol</span></li>';
		}
	}
	if (errorString != '') {
		e_errorDiv = document.getElementById('errorDiv');
		if (e_errorDiv) {
			e_errorDiv.innerHTML = '<ul class="errorList">'+errorString+'</ul>';
			document.location.href='#error'
		} else {
			window.alert('Popunite označena polja');
		}
		return false;
	} else {
		return true;
	}
}


function over(object) {
	if (object) {
		object.style.backgroundColor = '#EEEEEE';
	}
}

function out(object) {
	if (object) {
		object.style.backgroundColor = '';
	}
}
