function openPayPopup()
{
	window.name='citybox_main';
	window.open("booking?operation=showPayment", "blank", "toolbar=no,status=no,menubar=no,width=550,height=600");
}

function popUp(URL, width, height)
{
	day = new Date();
	id = day.getTime();

	if( width == null || width == 'undefined' || width <= 0 )
	{
		width = 717;
	}

	if( height == null || height == 'undefined' || height <= 0 )
	{
		height = 600;
	}

	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width="+width+",height="+height+"');");
}


function setGuestCount(roomType, roomNo, guestCount)
{
	var SINGLE_ROOM_WITH_BATH = 1;
	var DOUBLE_ROOM_WITH_BATH = 2;
	var FAMILY_ROOM_WITH_BATH = 3;
	var SINGLE_ROOM_WITH_ACCESS_TO_BATH = 4;
	var DOUBLE_ROOM_WITH_ACCESS_TO_BATH = 5;

	switch( roomType )
	{
		case SINGLE_ROOM_WITH_BATH:
			var maxGuestCount = 1;
			break;

		case DOUBLE_ROOM_WITH_BATH:
			var maxGuestCount = 2;
			break;

		case FAMILY_ROOM_WITH_BATH:
			var maxGuestCount = 4;
			break;

		case SINGLE_ROOM_WITH_ACCESS_TO_BATH:
			var maxGuestCount = 1;
			break;

		case DOUBLE_ROOM_WITH_ACCESS_TO_BATH:
			var maxGuestCount = 2;
			break;

		default:
			var maxGuestCount = 0;
			break;
	}

	guestCount = (guestCount > maxGuestCount ? maxGuestCount : guestCount);

	window.location='booking?operation=guestCount&roomType=' + roomType + '&roomNo=' + roomNo + '&guestCount=' + guestCount;
}

function addRoom(type)
{
	window.location='booking?operation=addRoom&roomType=' + type;
}

function removeRoom(type)
{
	window.location='booking?operation=removeRoom&roomType=' + type;
}

var preloadFlag = false;
function preloadImages()
{
	if (document.images)
	{
		pre_vpil_markert = newImage('grafikk/vpil_markert.gif');
		pre_hpil_markert = newImage('grafikk/hpil_markert.gif');
		preloadFlag = true;
	}
}



function TryLogin()
{
	document.login.submit();			// Submit the page
	return true;
}



function TryRegisterPayment()
{
	document.payment.submit();			// Submit the page
	return true;
}


function TryRegisterClientInfo()
{
	document.clientInfo.submit();			// Submit the page
	return true;
}


function popUp(URL, width, height, resizable, scrollbars)
{
	if(width == null || width == 'undefined')
	{
		width = '450';
	}
	if(height == null || height == 'undefined')
	{
		height = '230';
	}
	if(resizable == null || resizable == 'undefined')
	{
		resizable = '0';
	}
	if(scrollbars == null || scrollbars == 'undefined')
	{
		scrollbars = '0';
	}

	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars="+scrollbars+",location=0,statusbar=0,menubar=0,resizable="+resizable+",width="+width+",height="+height+"');");
}


var processingConfirm = false;
function TryConfirm()
{
	// avoid multiple bookings
	if( !processingConfirm )
	{
		processingConfirm = true;
		document.confirm.submit();			// Submit the page
		return true;
	}
}



var popupId = '';
function setPopupId( id )
{
	popupId = id;
}



function togglePopup(id, event)
{
	if( !event )
		event = window.event;


	var element = document.getElementById( id );


	// toggle hidden/visible
	if( element.style.display == 'block' )
		element.style.display = 'none';
	else
		element.style.display = 'block';
}

function showhide(id){
	if (document.getElementById){
	obj = document.getElementById(id);
	if (obj.style.display == "none"){
	obj.style.display = "";
	} else {
	obj.style.display = "none";
	}
	}
	}

