Cufon.replace('h1');

var clearQueue = true;
var gotoEnd = true;
$(document).ready(function(){
	$(document).pngFix(); 
	var pos = "info";
	var ta = "pletisa";
	$(".posta").attr("href","mailto:" + pos + "@" + ta + ".si").html(pos + "@" + ta + ".si");
	$(".zemljevid").click(function (e) {
		$.modal('<iframe src="'+this.href+'&output=embed"></iframe><p class="larger"><a target="_blank" href="'+this.href+'">Večji zemljevid</a></p>',
		{
			containerCss:{
			height:400
			}
		});
		return false;
	});
	function response_msg(res,msg){
		var msgr = (msg) ? msg : 'Prišlo je do napake, prosim poskusite pozneje.';
		if(res == "error"){
			$.modal('<div id="obvestilo"><div class="' + res + '">' + unescape(msgr) + '</div><input type="button" name="close" value="Zaprite okno" class="simplemodal-close" /></div>');
		} else {
			$.modal('<div id="obvestilo"><div class="' + res + '">' + unescape(msgr) + '</div><input type="button" name="close" value="Zaprite okno" class="simplemodal-close" /></div>');
			if(res == "success"){
				$(".obrazec").empty().remove();
			}
		}
	}
	function mark_missing(input){
		if(input){
			$.each(input, function(){
				$("label[for=" + this + "],#" + this + ":input").addClass("missing");
			});
			setTimeout(function(){
				$("label,input,select,textarea").removeClass("missing");
			}, 5000);
		}
	}
	$(".missing").keyup(function(){
		var polje = $("input", this);
		if(polje.val().length > 1)
			polje.removeClass("missing");
	});
	$("input[type='submit']").click(function(){
		$.ajax({
			type: "POST",
			url: $("#kontaktni_obrazec").attr("action"),
			data: $("#kontaktni_obrazec").serialize(),
			dataType: "json",
			success: function(res){
				response_msg(res.status, res.msg);
				mark_missing(res.mark)
			}
			
		});
		return false;
	});
	$("#ime").focus(function(){
		$(".gumbi").append('<input type="hidden" name="doform" value="" />');
	});
	$("#scroll").jScrollPane();
});

