var req;
var lastView = "";
var OldFldMsg = "";

function navigate(month,year,fieldmsg) {
	if(fieldmsg) {
		OldFldMsg = fieldmsg;
	} else if(OldFldMsg!="") {
		fieldmsg = OldFldMsg;
	}
	hideOld();
	lastView = "popupDate";

	obj = document.getElementById("popupDate");
	restaurantObj = document.getElementById("f_restaurant_id");
	var url = "/ajax/reserver_bord_-_kalender.htm?month="+month+"&year="+year+"&restaurant_id="+restaurantObj.value;

    ajax_request('calendar',url);
    
    obj.style.display="block";
    elTime = document.getElementById('f_time');
    if(elTime.value!=fieldmsg) { elTime.value=fieldmsg; }
}

function hideOld() {
	if(lastView) {
		obj = document.getElementById(lastView);
    	obj.style.display="none";
	}
}


function hideCal() {
	obj = document.getElementById("popupDate");
    obj.style.display="none";
	showNhideSelect("block");
}
function showCal() {
	obj = document.getElementById("popupDate");
    obj.style.display="block";
    showNhideSelect("none");
}

function setCalDate(id,info) {
	el = document.getElementById(id);
	el.value = info;
	hideCal();
}

function ajax_request(id,url,options) {
	$('#'+id).html('<img src="/modules/jensens/public/table_reservation/ajax-loader.gif" style="width:16px;height:16px;border:0px;" />');
	$('#'+id).load(url,options);
}

function setTime(time) {
	hideOld();
	el = document.getElementById('f_time');	
	el.value = time;
}
function showTime(text,fieldmsg) {
	hideOld();
	lastView = "popupTime";

	elDate = document.getElementById('f_date');
	restaurantObj = document.getElementById("f_restaurant_id");
	if(elDate.value!="" && elDate.value!=fieldmsg) {
		el = document.getElementById('popupTime');
		ajax_request('popupTimeContent','/ajax/reserver_bord_-_tid.htm?date='+elDate.value+"&restaurant_id="+restaurantObj.value);
	    el.style.display='block';
	} else {
		alert(text);
	}
}

function showNhideSelect(style) {
	/*
	inputs = document.getElementsByTagName("select");
	for(a = 0; a < inputs.length; a++) {
		if(inputs[a].className == "styled") {
			inputs[a].style.display = style;
		}
	}
	*/
}