	// Main image
$(document).ready(function() {	

	//Show Banner
	$(".main_image .desc").show(); //Show Banner
	$(".main_image .block").animate({ opacity: 0.65 }, 1 ); //Set Opacity

	//Click and Hover events for thumbnail list
	$(".image_thumb ul li:first").addClass('active'); 
	$(".image_thumb ul li div h2 a").click(function(){
		var alink = $(this).attr('href');
		window.location = alink;
	});
	
	$(".image_thumb ul li").hover(function(){ 
		//Set Variables
		var imgAlt = $(this).find('img').attr("alt"); //Get Alt Tag of Image
		var imgTitle = $(this).find('a').attr("href"); //Get Main Image URL
		var imgDesc = $(this).find('.block').html(); 	//Get HTML of block
		var imgDescHeight = $(".main_image").find('.block').height();	//Calculate height of block	
		
		if ($(this).is(".active")) {  //If it's already active, then...
			return false; // Don't click through
		} else {
			//Animate the Teaser				
			$(".main_image .block").animate({ opacity: 0, marginBottom: -imgDescHeight }, 200 , function() {
				$(".main_image .block").html(imgDesc).animate({ opacity: 0.65,	marginBottom: "0" }, 200 );
				$(".main_image img").attr({ src: imgTitle , alt: imgAlt});
			});
		}
		
		$(".image_thumb ul li").removeClass('active'); //Remove class of 'active' on all lists
		$(this).addClass('active');  //add class of 'active' on this list only
		return false;
		
	}) .hover(function(){
		$(this).addClass('hover');
		}, function() {
		$(this).removeClass('hover');
	});
	$('#sat-sarajevo').jclock({utc:true,utc_offset:2});
	$('#sat-newyork').jclock({utc:true,utc_offset:-4});
	$('#sat-sydney').jclock({utc:true,utc_offset:10});
	$('#sat-moscow').jclock({utc:true,utc_offset:4});
	
});//Close Function

		var turntosingle=0 //0 for no (default), 1 for yes
		var disabletablinks=0 //0 for no (default), 1 for yes
		var previoustab=""
		function expandcontent(cid, aobject){
		if (disabletablinks==1)
		aobject.onclick=new Function("return false")
		if (document.getElementById){
		highlighttab(aobject)
		if (turntosingle==0){
		if (previoustab!="")
		document.getElementById(previoustab).style.display="none"
		document.getElementById(cid).style.display="block"
		previoustab=cid
		}}}
		function highlighttab(aobject){
			if (typeof tabobjlinks=="undefined")
			collecttablinks()
			for (i=0; i < tabobjlinks.length; i++)
			tabobjlinks[i].className=""
			aobject.className="here"
		}
		function collecttablinks(){
			var tabobj=document.getElementById("menu-top")
			tabobjlinks=tabobj.getElementsByTagName("A")
		}
		function do_onload(){
			collecttablinks()
			expandcontent(initialtab[1], tabobjlinks[initialtab[0]])
		}
		if (window.addEventListener)
		window.addEventListener("load", do_onload, false)
		else if (window.attachEvent)
		window.attachEvent("onload", do_onload)
		else if (document.getElementById)
		window.onload=do_onload
		
//slider
$(document).ready(function() {		
	
	//Execute the slideShow
	slideShow();

});

function slideShow() {

	//Set the opacity of all images to 0
	$('#gallery a').css({opacity: 0.0});
	
	//Get the first image and display it (set it to full opacity)
	$('#gallery a:first').css({opacity: 1.0});
	
	//Set the caption background to semi-transparent
	$('#gallery .caption').css({opacity: 0.7});

	//Resize the width of the caption according to the image width
	$('#gallery .caption').css({width: $('#gallery a').find('img').css('width')});
	
	//Get the caption of the first image from REL attribute and display it
	$('#gallery .content').html($('#gallery a:first').find('img').attr('rel'))
	.animate({opacity: 0.7}, 400);
	
	//Call the gallery function to run the slideshow, 6000 = change to next image after 6 seconds
	setInterval('gallery()',6000);
	
}

function gallery() {
	
	//if no IMGs have the show class, grab the first image
	var current = ($('#gallery a.show')?  $('#gallery a.show') : $('#gallery a:first'));

	//Get next image, if it reached the end of the slideshow, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('caption'))? $('#gallery a:first') :current.next()) : $('#gallery a:first'));	
	
	//Get next image caption
	var caption = next.find('img').attr('rel');	
	
	//Set the fade in effect for the next image, show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);

	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
	
	//Set the opacity to 0 and height to 1px
	$('#gallery .caption').animate({opacity: 0.0}, { queue:false, duration:0 }).animate({height: '1px'}, { queue:true, duration:300 });	
	
	//Animate the caption, opacity to 0.7 and heigth to 100px, a slide up effect
	$('#gallery .caption').animate({opacity: 0.7},100 ).animate({height: '80px'},500 );
	
	//Display the content
	$('#gallery .content').html(caption);
	
	
}


$(document).ready(function() {
	
	//On Click Event
	$("ul.tabs li").click(function() {
		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content").hide(); //Hide all tab content
		var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active content
		return false;
	});
	
	var first_id = $('#gradovi').val();
	$('#prognoza_'+first_id).show();
    $('#gradovi').bind('change',function(){
        var new_id = $(this).val();
        $("div[id^='prognoza_']").hide();
        $('#prognoza_'+new_id).show();
    });

});

function tab_switch_main(tabgroup,tabselected){
    switch(tabgroup){
        case 'info':
            if(tabselected == 'vrijeme_nav'){
                $('#vrijeme_nav').removeClass('box_head').addClass('foot_head g');
                $('#lista_nav').removeClass('foot_head g').addClass('box_head');
                $('#vrijeme_sad').show();
                $('#lista_sad').hide();
            } else if (tabselected == 'lista_nav'){
                $('#vrijeme_nav').removeClass('foot_head g').addClass('box_head');
                $('#lista_nav').removeClass('box_head').addClass('foot_head g');
                $('#vrijeme_sad').hide();
                $('#lista_sad').show();
            }
			
        case 'vrijeme':
            if(tabselected == 'vrijeme_danas'){
                $('#vrijeme_danas').removeClass('box_head').addClass('foot_head g');
                $('#vrijeme_sutra').removeClass('foot_head g').addClass('box_head');
                $('#vrijeme_prekosutra').removeClass('foot_head g').addClass('box_head');
                $('#vrijeme_danas_sad').show();
                $('#vrijeme_sutra_sad').hide();
                $('#vrijeme_prekosutra_sad').hide();
            } else if (tabselected == 'vrijeme_sutra'){
                $('#vrijeme_sutra').removeClass('box_head').addClass('foot_head g');
                $('#vrijeme_danas').removeClass('foot_head g').addClass('box_head');
                $('#vrijeme_prekosutra').removeClass('foot_head g').addClass('box_head');
                $('#vrijeme_sutra_sad').show();
                $('#vrijeme_danas_sad').hide();
                $('#vrijeme_prekosutra_sad').hide();
            } else if (tabselected == 'vrijeme_prekosutra'){
                $('#vrijeme_prekosutra').removeClass('box_head').addClass('foot_head g');
                $('#vrijeme_sutra').removeClass('foot_head g').addClass('box_head');
                $('#vrijeme_danas').removeClass('foot_head g').addClass('box_head');
                $('#vrijeme_prekosutra_sad').show();
                $('#vrijeme_sutra_sad').hide();
                $('#vrijeme_danas_sad').hide();
            }
    }
}
