function GetXmlHttpObject() {
	var XMLHttp=null
	if (window.XMLHttpRequest) {
  		XMLHttp=new XMLHttpRequest() }
	else if (window.ActiveXObject) {
		XMLHttp=new ActiveXObject("Microsoft.XMLHTTP") }
	return XMLHttp;
}

function olc_call(obj,funk,sid,val2,val3) {
	xmlHttp=GetXmlHttpObject();
	var  xml_stop=1
	var 	vr=""
	var 	vr2=""
	var 	vr3=""
	var err_txt=""
	if (xmlHttp==null) {
		alert ("Browser does not support HTTP Request");
		return;
	}
	vr=obj;
	vr2=val2;
	vr3=val3;
	var url="biblio_olc.asp";
	url=url+"?"+"funk="+funk+"&id="+sid+"&vr="+escape(vr)+"&vr2="+escape(vr2)+"&vr3="+escape(vr3)
//window.alert(url)
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function stateChanged() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
		var odgovor=unescape(xmlHttp.responseText)
//window.alert(odgovor)
		var odg_array = odgovor.split("##")

		if (odg_array[0]==1){
			if (odg_array[1]==1){
				if (odg_array[3]==2){
					$("#main_filter1, #main_filter1a").hide();
					$("#main_filter2, #main_filter2a").show();
					$("#opozorilo_txt").html("&nbsp;");
//					$("#opozorilo_txt").hide();
					$("#prekoracitev_txt").html("Na mobilni telefon boste v kratekem prejeli potrditveno geslo za prijavo na SMS obvešcanje");
					$("#obvestilo_korak_2").html(odg_array[4]);
					document.getElementById("pin_id").value="";
					document.getElementById("pin_id").focus();
				}
				if (odg_array[3]==1 || odg_array[3]==3){
					$("#opozorilo_txt").html(odg_array[4]);
				}
				if (odg_array[3]==3){
					$("#opozorilo_txt").html("");
					$("#prekoracitev_txt").html(odg_array[4]);
				}
			}
		}

		if (odg_array[0]==2){
			if (odg_array[1]==1){
				if (odg_array[3]==4){
					$("#main_filter2, #main_filter2a").hide();
					$("#main_filter3, #main_filter3a").show();
					$("#obvestilo_korak_3").html(odg_array[4]);
					$("#prekoracitev_txt").html("");
				}
				if (odg_array[3]==2 || odg_array[3]==5){
					$("#prekoracitev_txt").html(odg_array[4]);
				}
			}
		}
	}
}

$(document).ready(function(){
   $("#gsm_id").mask("999 999-999",{placeholder:" "});

	$(".menu_mid").click(function () {
		$("#prekoracitev_txt").html("");
		$(".menu_mid").css("color","#336699");
		$(this).css("color","#ff0000");
	});
	$("#menu_main1").hide()
	$("#menu_showhide1").click(function () {
		$("#menu_main1").show()
		$("#menu_main6, #menu_main5, #menu_main4, #menu_main3, #menu_main2").hide()
	});
	$("#menu_main2").hide()
	$("#menu_showhide2").click(function () {
//		$("#menu_main2").show()
//		$("#menu_main6, #menu_main5, #menu_main4, #menu_main3, #menu_main1").hide()
//		$("#knjiznice_container").dialog('open')
		$("#knjiznice_container").dialog({
					bgiframe: true,
					width: 400,
					height: 200,
					modal: true
			});
	});
	$("#menu_main2a").hide()
	$("#menu_showhide2a").click(function () {
		$("#menu_main2a").toggle()
		$("#menu_main6, #menu_main5, #menu_main4, #menu_main3, #menu_main1").hide()
	});
	$("#menu_main3").hide()
	$("#menu_showhide3, #menu_showhide3a, #menu_showhide3b").click(function () {
		$("#menu_main3").toggle()
		$("#menu_main6, #menu_main5, #menu_main2, #menu_main1").hide()
	});
	$("#menu_main4").hide()
	$("#menu_showhide4").click(function () {
		$("#menu_main4").show()
		$("#menu_main6, #menu_main5, #menu_main3, #menu_main2, #menu_main1").hide()
	});
	$("#menu_main5").show()
	$("#menu_showhide5, #showhide5a").click(function () {
		$("#menu_main6, #menu_main4, #menu_main3, #menu_main2, #menu_main1").hide();
		$("#menu_main5").show();
		$("#main_filter1, #main_filter1a").show();
		$("#main_filter2, #main_filter2a").hide();
		$("#main_filter3, #main_filter3a").hide();
		$("#opozorilo_txt").html("&nbsp;");
		$("#prekoracitev_txt").html("&nbsp;");
		document.getElementById("clanska_id").value="";
		document.getElementById("gsm_id").value="";
	});
	$("#menu_main6").hide()
	$("#menu_showhide6, #menu_showhide6a").click(function () {
		$("#menu_main5, #menu_main4, #menu_main3, #menu_main2, #menu_main1").hide()
		$("#menu_main6").show()
	});
	$("#main_filter1, #main_filter1a").show()
	$("#main_filter3, #main_filter3a").hide();
	$("#showhide1").click(function () {
		olc_call($("select[name='knjiznica_id'] :selected").text(),1,document.getElementById("knjiznica_id").value,document.getElementById("clanska_id").value,document.getElementById("gsm_id").value);
	});
	$("#main_filter2, #main_filter2a").hide()
	$("#showhide2").click(function () {
		if (document.getElementById("pin_id").value.length==4){ 
			olc_call("",2,document.getElementById("pin_id").value,"","");
		}
		else{
			$("#prekoracitev_txt").html("Napačna koda - prosimo preverite vnesene podatke.");
		}
	});
	$("#pin_id").click(function () {
		$("#prekoracitev_txt").html("");
	});	
	$("#showhide1_back").click(function () {
	$("#main_filter1").show()
		$("#main_filter1, #main_filter1a").show();
		$("#main_filter2, #main_filter2a").hide();
	});
});


