//MIKARE CMS
//public javascript functions
//Kristo Vaher - kristo@waher.net, kristo.vaher@mikare.net

$(document).ready(function(){
	var ajaxurl='http://www.skypark.ee/libraries/ajax.php';
	$("[type=reservable]").click(function(){
		var room_id=$(this).attr("room_id");
		var year=$(this).attr("year");
		var month=$(this).attr("month");
		var day=$(this).attr("day");
		var exception=$(this).attr("exception");
		var timeslot_id=$(this).attr("timeslot_id");
		var public_id=$("#public_id").attr("value");
		$.ajax({
			type: "GET",
			url: ajaxurl,
			data: "act=setreserved&room_id="+room_id+"&year="+year+"&exception="+exception+"&timeslot_id="+timeslot_id+"&month="+month+"&day="+day+"&public_id="+public_id,
			success: function(msg){
				if(msg==''){
					document.location.href=$("#nextstep").attr("value");
				} else {
					alert(msg);
				}
			}
		});
	});
});

function toggleLayer( whichLayer )
{
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  // if the style.display value is blank we try to figure it out here
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
  vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}


sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
