jQuery(document).ready( function() {
		Cufon.replace("h1");
	Cufon.replace("#Navigation li",{ hover: 'true' });
	Cufon.replace("#FooterInfo h3");
	/* NA VRH */
	$("#GoTop").click(function(){
		$('html, body').animate({scrollTop:0}, 'slow');
	});
	/* NA VRH */
	/* REFERENCE SLIDER */
	

//	$("#SliderControl #goLeft").css("visibility","hidden");
	var twitter = $("#twitter_update_list").html();
	twitter = twitter.replace("days ago", "dni nazaj");
	$("#twitter_update_list").html(twitter);
	$("#pages img").mouseenter(function(){
		var pozicija = $(this).position();
		var id = $(this).attr("id");
		id = id.substr(3);
		$("#inf"+id).css({"left":pozicija.left,"top":pozicija.top}).show();

		$("#pages .pagesInfo").mouseleave(function(){
			$("#inf"+id).hide();
		});
	});
	$("#SliderControl .controler").click(function(){
		var kolko = $('#SliderControl span').size();
		var kam = $(this).attr("id");
		var kje = $(".bulletsA").attr("id");
		kje = parseInt(kje.substr(6));
		$("#SliderControl span").removeClass("bulletsA");
		if(kam=="goRight"){
			if(kje<kolko){
				$("#pages").animate({right: 512*kje});
				$("#b_site"+(kje+1)).addClass("bulletsA");
			}else{
				$("#pages").animate({right: 0});
				$("#b_site1").addClass("bulletsA");
			}
		}else if(kam=="goLeft"){
			if(kje!=1){
				$("#pages").animate({right: (512*(kje-1))-512});
				$("#b_site"+(kje-1)).addClass("bulletsA");
			}else{
				$("#pages").animate({right: 512*(kolko-1)});
				$("#b_site"+(kolko)).addClass("bulletsA");
			}
		}
		//$("#Testing").text("kje:"+kje+" kontrola: "+kam);
		
		//$("#pages").animate({right:512*(kolko-1)});
		
		
		
	});
	$("#SliderControl span").click(function(){
		var id = $(this).attr("id");
		id = id.substr(6);
		$("#SliderControl span").removeClass("bulletsA");
		$(this).addClass("bulletsA");
		$("#pages").animate({right: 512*(id-1)});
	});
	$("#ContactForm .button").click(function(){
		$("#ContactFormInfo").hide();
		var ime = $("#ContactForm #ime").val();
		var podjetje = $("#ContactForm #podjetje").val();
		var email = $("#ContactForm #email").val();
		var tel = $("#ContactForm #tel").val();
		var vprasanje = $("#ContactForm #vprasanje").val();
		var name = $("#ContactForm #name").val();
		if(ime!="" && email!="" && vprasanje!="" && name==""){
			validRegExp = /^[\.A-z0-9_\-\+]+[@][A-z0-9_\-]+([.][A-z0-9_\-]+)+[A-z]{1,4}$/i;
		  if (email.search(validRegExp) == -1){
			  $("#ContactFormInfo").empty().fadeIn(200).text("Vnešen email naslov ni pravilen, prosim da vnesete veljaven email naslov.");
		  }else{
			$.ajax({
			type: "POST",
			url: "kontakt.php",
			data: "ime="+sumniki(ime)+"&podjetje="+sumniki(podjetje)+"&email="+email+"&tel="+tel+"&vprasanje="+sumniki(vprasanje),
            success: function(msg){	
                if(msg){
                 	$("#ContactForm").empty().fadeIn(200).html("<h2>Poizvedba poslana</h2><p>Hvala Vam za vaše sporočilo, odgovorili bomo kar se da hitro.</p>");
                }else{
					$("#ContactFormInfo").empty().fadeIn(200).text("Ojoj! Interna napaka :( Prosimo, da poiskusite ponovno.");
				}
            },
			error: function(){
				alert("joj! Interna napaka :( Prosimo, da poiskusite ponovno.");
			}
			});	
		  }
		}else{
			$("#ContactFormInfo").fadeIn(200);
		}
	});
	function sumniki(string){
		string = string.replace("š","s1337s").replace("Š","s1337S").replace("č","c1337c").replace("Č","c1337C").replace("ž","z1337z").replace("Ž","z1337Z").replace("ć","o1337o").replace("Ć","o1337O").replace("đ","d1337d").replace("Đ","d1337D");
		return string;
	}
	/* REFERENCE SLIDER */
	/* SEARCH SKRIPTICA */
	/*var v="Išči...";
	$("#SearchInput").click(function(){
		v = $(this).val();
		if(v=="Išči..."){
			$(this).val("");
		}
		$("#SearchInput").change(function(){
			v = $(this).val();
		});
		$("#SearchInput").focusout(function(){
		if(v=="Išči..." || v==""){
			$(this).val("Išči...");
		}
	});
	});*/
	/* SEARCH SKRIPTICA */
	/* SLIDE TOP */
	var isIE6 = /msie|MSIE 6/.test(navigator.userAgent);
	if(!isIE6){
	$('#RotatorContent').nivoSlider({
		effect:'fade', //Specify sets like: 'fold,fade,sliceDown'
		slices:15,
		animSpeed:300,
		pauseTime:7000,
		pauseOnHover:true //Stop animation while hovering
	});
	}
});
