function showMe(id) { $("#"+id).fadeIn(200); }
function hideMe(id) { $("#"+id).fadeOut(100); }

function goRegion(value) {
	if(value == 'a') {
		location.href = '/slovenija/';
	} else {
		location.href = '/slovenija/' + value + '/'
	}
}

function goCelina(value) {
	if(value == 'a') {
		location.href = '/svet/';
	} else {
		location.href = '/svet/' + value + '/'
	}
}

function goDay(value, dnevi) {
	if(value == '0') {
		if($('#att_regija').val() != 'a') {
			location.href = '/slovenija/' + $('#att_regija').val() + '/dan/' + getDayName(value, dnevi) + '/';
		} else {
			location.href = '/slovenija/';
		}
	} else {
		if($('#att_regija').val() != 'a') {
			location.href = '/slovenija/' + $('#att_regija').val() + '/' + 'dan/' + getDayName(value, dnevi) + '/';			
		} else {
			location.href = '/slovenija/dan/' + getDayName(value, dnevi) + '/';
		}		
	}
}
//surfing

//value = region/spot
function goSpot(value) {
	location.href = '/prosti-cas/surf/' + value + '/';
}

function goSurfRegion(value) {
	if(value == 'a') {
		location.href = '/prosti-cas/surf/';
	} else if (value.length > 2) {
		location.href = '/prosti-cas/surf/' + value + '/'
	} else {
		$('#att_kraj').hide();
		$('#att_kraj').load('/ajax/dropdown/?drzava=' + value);
		$('#att_kraj').show();
	}
}

//end surfing

function getDayName(value, dnevi){
	return dnevi[value];
}

function goDayCelina(value, dnevi) {
	if(value == '0') {
		if($('#att_celina').val() != 'a') {
			location.href = '/svet/' + $('#att_celina').val() + '/';
		} else {
			location.href = '/svet/';
		}
	} else {
		if($('#att_celina').val() != 'a') {
			location.href = '/svet/' + $('#att_celina').val() + '/dan/' + getDayName(value, dnevi) + '/';
		} else {
			location.href = '/svet/dan/' + getDayName(value, dnevi) + '/';
		}
	}
}

function goTime(value, dnevi) {
	
	
	if($('#att_regija').val() != 'a') {
		location.href = '/slovenija/' + $('#att_regija').val() + '/dan/' + getDayName($('#att_day').val(), dnevi) + '/' + getTimeOfDay(value) + '/';
	} else {
		if (value != 'current_weather'){
			location.href = '/slovenija/dan/' + getDayName($('#att_day').val(), dnevi) + '/' + getTimeOfDay(value) + '/';
		} else {
			location.href = '/slovenija/dan/' + getDayName($('#att_day').val(), dnevi) + '/';
		}
	}
	
}

function getTimeOfDay(value){
	var timesOfDay = [];
	timesOfDay['current_weather'] = 'naslednja-ura'
	timesOfDay['forenoon'] = 'dopoldan';
	timesOfDay['afternoon'] = 'popoldan';
	timesOfDay['evening'] = 'zvecer';
	timesOfDay['night'] = 'ponoci';
	
	return timesOfDay[value];
}

function goKraj(value) {
	location.href = '/slovenija/' + $('#att_regija').val() + '/' + value + '/';
}

function goMesta(value) {
	location.href = '/svet/' + $('#att_celina').val() + '/' + value + '/';
}

function goPDay(day, controller, action, dnevi){
	if(day != 0) {
		location.href  = '/' + controller + '/' + action + '/dan/' + getDayName(day, dnevi) + '/';
	} else {
		location.href  = '/' + controller + '/' + action + '/';
	}
}

function goSDay(day, controller, action, region, dnevi){
	if(day != 0) {
		location.href  = '/' + controller + '/' + action + '/' + region + '/dan/' + getDayName(day, dnevi) + '/';
	} else {
		location.href  = '/' + controller + '/' + action + '/' + region + '/' ;
	}
}

function goPTime(time, controller, action, dnevi){
	if($('#att_day').val() == 0) {
		location.href = '/' + controller + '/' + action + '/dan/danes/' + getTimeOfDay(time) + '/'
	} else {
		location.href = '/' + controller + '/' + action + '/dan/' + getDayName($('#att_day').val(), dnevi) + '/' + getTimeOfDay(time) + '/';
	}
}

function goSTime(time, controller, action, region, dnevi){
	if($('#att_day').val() == 0) {
		location.href = '/' + controller + '/' + action + '/' + region + '/dan/danes/' + getTimeOfDay(time) + '/';
	} else {
		location.href = '/' + controller + '/' + action + '/' + region + '/dan/' + getDayName($('#att_day').val(), dnevi) + '/' + getTimeOfDay(time) + '/';
	}
}

function goPKraj(kraj, controller, action){
	location.href = '/' + controller + '/' + action + '/' + kraj + '/';
}

function goSKraj(kraj, controller, action){
	location.href = '/' + controller + '/' + action + '/' + $('#att_regija').val() + '/' + kraj + '/';
}

function goSSKraj(kraj, controller, action, regija){
	location.href = '/' + controller + '/' + action + '/' + regija + '/' + kraj + '/';
}

function goSRegija(regija, controller, action){
	location.href = '/' + controller + '/' + action + '/' + regija + '/';
}


function setSource(src, div){
	jQuery("#imageSrc").attr("src", src);
	$("#player").children("a").removeClass("active");
	$(div).addClass("active");
	var div_id = $(div).attr('id');
	div_id = div_id.split('_');
	setTime(div_id[1]);
}

function setPlayerSource(src, frame) {
	jQuery("#imageSrc").attr("src", src);
	$("#player").children("a").removeClass("active");
	$("#f_" + frame).addClass("active");
	setTime(frame);
}

function preloadImages(arr, counter) {

	var me = new Image();
	me.src = arr[counter];

	$(me).load(function() {

		var div = $('<a href="javascript: void(0)" onmouseover="setSource(\'' + me.src + '\', this)" id="f_' + counter + '">' + (counter + 1) + '</a> <small>|</small>').appendTo("#player");

		setSource(me.src, div);
		counter = counter + 1;

		if(counter == 2) {
			$("#loader").fadeOut("slow");
		}

		if(counter < arr.length) {
			preloadImages(arr, counter);
		}

	});

}


function updateClock(){
  var currentTime = new Date ( );
  var currentHours = currentTime.getHours ( );
  var currentMinutes = currentTime.getMinutes ( );
  var currentSeconds = currentTime.getSeconds ( );
  currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;
  currentSeconds = ( currentSeconds < 10 ? "0" : "" ) + currentSeconds;
  var currentTimeString = currentHours + ":" + currentMinutes + ":" + currentSeconds;
  document.getElementById("clock").firstChild.nodeValue = currentTimeString;
}


function addToFavorites() {
	var urlAddress = "http://www.vreme.net/";
	var pageName = "Žurnal / vreme.net";

	if (window.sidebar) {
		window.sidebar.addPanel(pageName, urlAddress,"");
	} else if(window.external ) {
		window.external.AddFavorite( urlAddress, pageName);
	} else if(window.opera && window.print) {
		return true;
	}

}

var weekday=new Array(7);
weekday[0]="Nedelja";
weekday[1]="Ponedeljek";
weekday[2]="Torek";
weekday[3]="Sreda";
weekday[4]="Četrtek";
weekday[5]="Petek";
weekday[6]="Sobota";



function setHomePage() {
		
	if (document.all){
		var html_body = document.getElementsByTagName('body').item(0);
		var homepage_link = document.createElement('a');
		html_body.appendChild(homepage_link);
		homepage_link.style.display = 'none';

		homepage_link.style.behavior='url(#default#homepage)';
		homepage_link.setHomePage('http://www.vreme.net');
	}
	else
	{
		window.location = '/orodja/domaca-stran/';
	}

}
