/*--JavaScript Document---------------------------*/
/*------------------------------------------------*/
/*      Autor:	Damjan Gataric                    */
/*      damjan@gataric.info                       */
/*------------------------------------------------*/


$(document).ready(function() {
	
//	$('div#tabsContainer div.inside ul').each(function() {
//		$(this).children('li:last').css('border','none');
//	});

	$('ul#tabsMenu a').click(function() {
		if(!$(this).hasClass('active')) {
			var id = $(this).attr('href');
			var content = document.getElementById(id);
			//$('#tabsContainer div.inside').slideUp(100);
			$('#tabsContainer div.inside').children().slideUp(200);
			$(id).slideDown();
			$('ul#tabsMenu a').removeClass('active');
			$(this).addClass('active');
		}
		return false;
	});
	
	$('input.clearValue').focus(function(event) {
		var oldValue = $(this).attr('alt');
		var curValue = $(this).val();
		if (oldValue==curValue) {
			$(this).val('');
		}
	});
	$('input.clearValue').blur(function(event) {
		var oldValue = $(this).attr('alt');
		var curValue = $(this).val();
		if (curValue=='') {
			$(this).val(oldValue);
		}
	});
	
	$('input#s').focus(function(event) {
		var oldValue = 'pretraga';
		var curValue = $(this).val();
		if (oldValue==curValue) {
			$(this).val('');
		}
	});
	$('input#s').blur(function(event) {
		var oldValue = 'pretraga';
		var curValue = $(this).val();
		if (curValue=='') {
			$(this).val(oldValue);
		}
	});
						   
});


function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		}
		else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}
function setFooter() {
	if (document.getElementById) {
		var windowHeight = getWindowHeight();
		if (windowHeight > 0) {
			var contentHeight = document.getElementById('container').offsetHeight + 20;
			var footerElement = document.getElementById('footer');
			var footerHeight  = footerElement.offsetHeight;
			if (windowHeight - (contentHeight + footerHeight) >= 0) {
				footerElement.style.top = (windowHeight - (contentHeight + footerHeight)) + 'px';
			}
			else {
				footerElement.style.top = '0px';
			}
		}
	}
}
window.onload = function() {	
	if (document.getElementById('footer')) { setFooter(); }
}
window.onresize = function() {
	if (document.getElementById('footer')) { setFooter(); }
}