// JavaScript Document
var h_onama = 0;
var h_usluge = 0;
var h_proizvodi = 0;
var h_reference = 0;
var h = 0;
var host = "";

function define() {
		if(navigator.appName == "Netscape")
			win_w = window.innerWidth;
		if(navigator.appName == "Microsoft Internet Explorer")
			win_w = document.body.offsetWidth;
		stat_pos = win_w/2 + 80;
		$("div#static").css({left:stat_pos+'px'});
		$("div#static").css({display:'block'});
		if(document.getElementById("control").name == "onama") {
			document.getElementById("button1").src =  host +"/images/arrow_down.gif";
			document.getElementById("O_nama").style.display="block";			
		}
		if(document.getElementById("control").name == "proizvodi") {
			document.getElementById("Proizvodi").style.display="block";
			document.getElementById("button2").src =  host +"/images/arrow_down.gif";
		}
		if(document.getElementById("control").name == "usluge"){
			document.getElementById("Usluge").style.display="block";
			document.getElementById("button3").src =  host +"/images/arrow_down.gif";
		}
		if(document.getElementById("control").name == "reference") { 
			document.getElementById("Reference").style.display="block";
			document.getElementById("button4").src =  host +"/images/arrow_down.gif";
		}
 }
 function show(id, parm) {
		if(document.getElementById(id).offsetHeight > 0) {
			//document.getElementById(id).style.display="none";
			switch (parm) {
				case 1: {
							document.getElementById("button1").src =  host +"/images/arrow.gif";
							h=h_onama;
							fadeout(id);
							break;
						}
				case 2: {
							document.getElementById("button2").src =  host +"/images/arrow.gif";
							h=h_proizvodi;
							fadeout(id);
							break;
						}
				case 3: {
							document.getElementById("button3").src =  host +"/images/arrow.gif";
							h=h_usluge;
							fadeout(id);
							break;
						}
				case 4: {
							document.getElementById("button4").src =  host +"/images/arrow.gif";
							h=h_reference;
							fadeout(id);
							break;
						}
			}
			
		}
		else {
			document.getElementById(id).style.display="block";
			switch (parm) {
				case 1: {
							document.getElementById("button1").src =  host +"/images/arrow_down.gif";
							h=h_onama;
							gradient("O_nama",0);
							fadein("O_nama");
							break;
				}
				case 2: {
							document.getElementById("button2").src =  host +"/images/arrow_down.gif";
							h=h_proizvodi;
							gradient("Proizvodi",0);
							fadein("Proizvodi");
							break;
				}
				case 3: {
							document.getElementById("button3").src =  host +"/images/arrow_down.gif";
							h=h_usluge;
							gradient("Usluge",0);
							fadein("Usluge");
							break;
				}
				case 4: {
							document.getElementById("button4").src =  host +"/images/arrow_down.gif";
							h=h_reference;
							gradient("Reference",0);
							fadein("Reference");
							break;
				}
			}
		}
 }
 
 
function fadein(id) 
{
	var level = 0;
	while(level <= 100)
	{
		setTimeout( "gradient('" + id + "'," + level + ")", (level* 3) + 10);
		level += 5;
	}
}

function fadeout(id) 
{
	var level = 0;
	while(level <= 100)
	{
		setTimeout( "gradient2('" + id + "'," + level + ")", (level* 3) + 10);
		level += 5;
	}
	
}

function gradient2(id, level)
{
	var box = document.getElementById(id);
	box.style.opacity = 1 - level/100; //za FF
	box.style.filter = "alpha(opacity=" + (100 - level/100) + ")"; //za ie7
	box.style.overflow = "hidden";	
	box.style.height = parseInt(h - level/100 * h) + 'px';
	return;
}

function gradient(id, level)
{
	var box = document.getElementById(id);
	box.style.opacity = level/100; //za FF
	box.style.filter = "alpha(opacity=" + level + ")"; //za ie7
	box.style.overflow = "hidden";
	box.style.height = Math.round(level/100 * h) + 'px';
	return;
}
 
function posaljiPHP() {
	unIme = window.prompt("Unesite vase korisnicko ime:");
	unPass = window.prompt("Unesite vasu lozinku:");
	window.location.href = "../login.php?unIme=" + unIme + "&unPass=" + unPass;
}
 
window.onresize = resize; 

function resize(){
		if(navigator.appName == "Netscape")
			win_w = window.innerWidth;
		if(navigator.appName == "Microsoft Internet Explorer")
			win_w = document.body.offsetWidth;
		stat_pos = win_w/2 + 200;
		$("div#static").css({left:stat_pos+'px'});
}

$(document).ready( function() {
		//$("div#povuci").draggable();
		h_onama = document.getElementById("O_nama").offsetHeight;
		h_usluge = document.getElementById("Usluge").offsetHeight;
		h_proizvodi = document.getElementById("Proizvodi").offsetHeight;
		h_reference = document.getElementById("Reference").offsetHeight;
		$("div#O_nama").hide();
		$("div#Proizvodi").hide();
		$("div#Usluge").hide();
		$("div#Reference").hide();
		$("div#licen_firme").hide();
		$("div#licen_pojed").hide();
		$("div#trazi").hide();
		$("span#frm").hover(
			function(){
				$("div#licen_firme").slideDown(500)},
			function(){	
				$("div#licen_firme").slideUp(500)
				})
			$("span#pojed").hover(
				function(){
					$("div#licen_pojed").slideDown(500)},
				function(){	
					$("div#licen_pojed").slideUp(500)
				})
			
			$("div#inz_submenu").hide();
			$("ul.ref_meni > li#inz").hover(
				function(){ 
					$("div#inz_submenu").slideDown(300)
				},
				function(){ 
					$("div#inz_submenu").slideUp(300)
				}
			)
		
		$("p.bg_meni").hover(
				function(){
					$(this).css({backgroundColor:'#F10000', color:'#FFF'})
					//$(this).css({backgroundImage:'url("../../images/meni_bg.jpg")'})
				},
				function(){
					$(this).css({backgroundColor:'', color: ''})
					//$(this).css({backgroundImage:''})
				}
		)
		$("p.bg_meni_naslov").hover(
				function(){
					$(this).css({backgroundColor:'#F10000', color:'#FFF'})
					//$(this).css({backgroundImage:'url("../../images/meni_bg.jpg")'})
				},
				function(){
					$(this).css({backgroundColor:'', color:''})
					//$(this).css({backgroundImage:''})
				}
		)
		$("p.VS").hover(
				function(){
					$(this).css({backgroundColor:'#F10000', color: '#FFF', paddingBottom: '7px'});
				},
				function(){
					$(this).css({backgroundColor:'', color: '', paddingBottom: ''});
				}
		)
		$("div#static").hover(
				function(){
					$("div#trazi").slideDown(300)
				}, function(){
					$("div#trazi").slideUp(300)
				}
		)
		
		$(function() {
			$("div#makeMeScrollable").smoothDivScroll({scrollingSpeed: 12, mouseDownSpeedBooster: 3, autoScroll: "onstart", autoScrollDirection: "endlessloop", autoScrollSpeed: 2, visibleHotSpots: "always", startAtElementId: "startAtMe"});		
});

		var headline_count;
		var current_headline=0;
		headline_count = $("div.naslovi").size();
		$("div.naslovi:eq("+current_headline+")").css('top', '5px');
		var interval = setInterval(headline_rotate,7000); //time in milliseconds
		$("div.naslovi").hover(
			function(){clearInterval(interval)},function(){interval = setInterval(headline_rotate,7000);}
		);
		function headline_rotate() {
		  old_headline = current_headline % headline_count;
		  new_headline = ++current_headline % headline_count;
		  $("div.naslovi:eq(" + old_headline + ")").css('top', '210px');
		  $("div.naslovi:eq(" + new_headline + ")").show().animate({top: 5},"slow");     
		}



	
}) 

 
 
//za prikaz vecih slika 
 
hs.graphicsDir = ''; hs.align = 'center'; hs.transitions = ['expand', 'crossfade']; hs.wrapperClassName = 'dark borderless floating-caption'; hs.fadeInOut = true; hs.blockRightClick = true; hs.dimmingOpacity = .40;
/*if (hs.addSlideshow) hs.addSlideshow({ interval: 3000, repeat: false,	useControls: true, fixedControls: 'fit', overlayOptions: {opacity: .6, position: 'bottom center',	hideOnMouseOut: true}	}); */
 
 
