function isEmpty(input, message) {
	if (input.value.length == 0) {
		alert(message)
		input.focus()
		return false
	} 
	return true
}

function isEmail(input, message) {
	if (input.value.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
		return true;
	else {
		alert(message);
		input.focus();
		return false;
	}
}

function isSelected(radio, message) {
	blnOK = false;
	for (var intIndex = 0; intIndex < radio.length; intIndex++) {
		if (radio[intIndex].checked) {
			blnOK = true;
		}
	}
	if (blnOK) {
		return true;
	} else {
		alert(message);
		return false;
	}
}

function isNumber(input, message) {
	if (isNaN(input.value)) {
		alert(message)
		input.focus()
		return false
	}
	return true
}

/* vecanje/manjsanje pisave */
if($.cookie("css")) {
	$("head #size").attr("href",$.cookie("css"));
}

$(document).ready(function() {
	/* vecanje/manjsanje pisave */
	$("#header .icons li.size a").click(function() {
		$("head #size").attr("href",$(this).attr('rel'));
		$.cookie("css",$(this).attr('rel'), {expires: 365, path: '/'});
		return false;
	});
	/* prikazovanje/skrivanje vsebine */
	$('#content .content h3 a').click( function() {
		var id = $(this).attr('id');
		$('#content .content div#content' + id).toggle();
	});
   	/* visina crte v sitempau */
	var divHeight = $("#sitemap .menu").height() + "px";
	$("#sitemap .company").css("height", divHeight);
	// okno igre Rado locuje
	$('.game-modal').click(function (e) {
		$('#game-modal-content').modal({
			overlayId: 'game-overlay',
			containerId: 'game-container',
			opacity:80,
			minWidth:740,
			minHeight:420
		});
		return false;
	});
	// okno animacije Vodni krog
	$('.animation-modal').click(function (e) {
		$('#animation-modal-content').modal({
			overlayId: 'animation-overlay',
			containerId: 'animation-container',
			opacity:80,
			minWidth:880,
			minHeight:500
		});
		return false;
	});
	/* tooltip */
	$('#header .icons a').tooltip({
		delay: 0,
		track: true,
		showURL: false,
		top: 25,
		left: 0
	});
	/* submit arhiva novic */
	$("#ArchivedYear").change( function() {
  		$('#frmNews').submit();
	});
});

/* spustni meniji */
var timeout		= 750;
var closetimer	= 0;
var menuitem	= 0;

function ShowMenu(id) {
	CancelTimer();
	MenuClose();
	menuitem = $('#header .links').find('#' + id).css('display', 'block');
}

function ShowMenuServices(id) {
	CancelTimer();
	MenuClose();
	menuitem = $('#header .tabs').find('#' + id).css('display', 'block');
}

function MenuClose() {
	if(menuitem) menuitem.css('display', 'none');
}

function Timer(id) {
	closetimer = window.setTimeout(MenuClose, timeout);
}

function CancelTimer() {
	if(closetimer) {
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

document.onclick = MenuClose;
