 $(document).ready(function() {
// 	$('.izbornik').accordion({
// 		header: "span",
// 		autoHeight: false,
// 		event: 'mouseover',
// 		animated: 'easeslide'
// 	});


 	if ( $("#novosti_obrazac").length > 0 )
 	{
 		$.ajax({
 			url: "/include/novosti.inc.php",
 			cache: false,
 			success: function(data){
 						$("#novosti_obrazac").html(data);
											
						$(".cycle-novosti").cycle({
								fx:      'scrollDown',
								next:   '#sljedeca-novost',
								prev:   '#prethodna-novost',
								timeout:  6000
						});
 					}
 		});
 	}
 	
  	// cycle-slideshow inicijalizacija
	var cycle_opcije_slideshow = {
			fx:      'scrollRight',
			next:   '.slideshow-okvir',
			timeout:  0,
			easing:  'backinout'
		}; 

	// zamijeni svaki cycle-slideshow img tag sa divom, daj mu isti id i klasu
	$("img.cycle-slideshow").each( function () {
								var slideshow   	= $(this);
								var slideshow_id    = $(slideshow).attr("id");
								var slideshow_class = $(slideshow).attr("class");
														
								var okvir = $('<div class="slideshow-okvir"></div>').append('<span></span>').append('<div class="' + slideshow_class + '" id="' + slideshow_id + '"></div>').append('<div class="cleaner"></div>');
								
								$(slideshow).after(okvir).remove(); 
							});
	
	// napuni svaki cycle-slideshow div sa slikama putem ajaxa
	$("div.cycle-slideshow").each( function () {
								var slideshow   	= $(this);
								var slideshow_id    = $(slideshow).attr("id");
													
								$.ajax({
									url: "/include/slideshow.inc.php",
									cache: false,
									data: 'slideshow_id=' + slideshow_id,
									success: function(html){
												$(slideshow).append(html)
															.cycle(cycle_opcije_slideshow);
											}
								});
		});
	
	function submit_metoda ()
	{
		$("#kontakt").submit( function (e) {
			e.preventDefault();
			
			var ime = $("#ime").val();
			var adresa = $("#adresa").val();
			var grad = $("#grad").val();
			var email = $("#email").val();
			var poruka = $("#poruka").val();
			var telefon = $("#telefon").val();
			var code = $("#code").val();
			var fax = $("#fax").val();
			
			$.ajax({
				url: "/include/kontakt.inc.php",
				type: "POST",
				data: {ime: ime, adresa: adresa, grad: grad, email: email, poruka: poruka, telefon: telefon, fax:fax, code: code, kontakt: 1},
				cache: false,
				success: function(data){
					$("#kontakt_obrazac").html(data);
					submit_metoda();
					}
			});
		});		
	}
	
 	if ( $("#kontakt_obrazac").length > 0 )
 	{
 		$.ajax({
 			url: "/include/kontakt.inc.php",
 			cache: false,
 			success: function(data){
 						$("#kontakt_obrazac").html(data);
						submit_metoda();					

 					}
 		});
 	}
	
	
  });
  
	function pop(url){
		newwindow=window.open(url,'Novosti','height=500px,width=550px, scrollbars=yes  ');
		if (window.focus) {newwindow.focus()}
	}

