// JavaScript Document
function popUp()
	{
	window.open("pages/form.php","Intresseanmälan","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,fullscreen=no,width=250,height=550,top=0,left=0");	
	}
	
function checkConference()
		{
		var form = document.sendMail;

		if((form.antal.value=="")||(form.checkIn.value=="")||(form.checkOut.value=="")||(form.name.value=="")||(form.tel.value==""))
			{alert("Du måste fylla i alla fält markerade med *");
			return false;
			}
		}

function checkConferenceEN()
		{
		var form = document.sendMail;

		if((form.antal.value=="")||(form.checkIn.value=="")||(form.checkOut.value=="")||(form.name.value=="")||(form.tel.value==""))
			{alert("You have to fill out all fields marked with *");
			return false;
			}
		}

function checkPackages()
		{
		var form = document.sendMail;

		if((form.antal.value=="")||(form.date.value=="")||(form.name.value=="")||(form.tel.value==""))
			{alert("Du måste fylla i alla fält markerade med *");
			return false;
			}
		}
	
	function openBook()
	{
	window.open("http://nynashotell.comers.se/comers/pages/SiteLanguage.action?lang_cd=sv","Boka_online","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,fullscreen=no,width=700,height=500,top=0,left=0");	
	}
	
	function openBookEN()	
	{
	window.open("http://nynashotell.comers.se/comers/pages/SiteLanguage.action?lang_cd=en","Book_online","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,fullscreen=no,width=700,height=500,top=0,left=0");	
	}
	
function deleteImg(id)
	{
	if(confirm("Är du säker på att du vill radera bilden?"))
		{
		window.location="redirects/deleteImg.php?id="+id;	
		}
		
	}
	
	function deleteId(id)
	{
	if(confirm("Är du säker på att du vill radera inlägget?"))
		{
		window.location="redirects/delete.php?id="+id;	
		}
		
	}
	
	function deleteRoom(id)
	{
	if(confirm("Är du säker på att du vill radera raden?"))
		{
		window.location="redirects/deleteRoom.php?id="+id;	
		}
		
	}
	
	function deleteConference(id)
	{
	if(confirm("Är du säker på att du vill radera raden?"))
		{
		window.location="redirects/deleteConference.php?id="+id;	
		}
		
	}
	
	
	function img_enlarge(img, w, h)
	{
	window.open("/popUps/img_enlarge.php?img="+img,"Large_image","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,fullscreen=no,width="+w+",height="+h+",top=0,left=0");	
	}
	
	function close_window()
		{
			window.close();
		}
		
// Modal
$(document).ready(function() {
	
	$('a#open').live('click', function() {
		openModal();
	});
	
	function openModal() {
		$('.mask').fadeIn('slow', function() {
			if ($('.modal').css("top").replace("px", "") >= 20 || $('.modal').css("top") == 'auto') {
				$('.modal').css("top", (($(window).height() - $('.modal').outerHeight()) / 2) + "px");
			}
			$('.modal').css("left", (($(window).width() - $('.modal').outerWidth()) / 2) + "px");
			$('.modal').fadeIn('fast', function() {
				// Modal öppen
				
				$('.mask').live('click', function() {
					closeModal();
				});
			});
		});
		$(window).resize(function() {
			if ($('.modal').css("top").replace("px", "") >= 20 || $('.modal').css("top") == 'auto') {
				$('.modal').css("top", (($(window).height() - $('.modal').outerHeight()) / 2) + "px");
			}
			$('.modal').css("left", (($(window).width() - $('.modal').outerWidth()) / 2) + "px");
		});
	}
	
	function closeModal() {
		$('.modal').fadeOut('slow', function() {
			$('.mask').fadeOut('fast', function() {
				// Modal stängd
			});
		});
	}
});
