/*----------------------------------------------------------------------------
Global functions

version:		1.0
author:		Sjoerd Gal <sjoerd@trendesign.nl>
-----------------------------------------------------------------------------*/


function startCircling()
{
	replaceHeaders();
	ellipsis();

	if ( isSet( top.tImages ) && top.tImages.length > 1 ) var oPreload = new ImagePreload( tImages, OnCompletion );
};


function isSet( variable )
{
	return( typeof( variable ) != 'undefined' );
};

// Replace the page main H1 and H2 tags with generated images, used as a background

function replaceHeaders()
{

	var imgH1 = ( isSet( top.imgH1 ) ) ? top.imgH1 : '';
	var imgH2 = ( isSet( top.imgH2 ) ) ? top.imgH2 : '';
	var imgH3 = ( isSet( top.imgH3 ) ) ? top.imgH3 : '';

	// Set H1 params
	var objH1 = document.getElementById('h1f');
	if(objH1) objH1.style.backgroundImage = 'url(/files/headers/'+ imgH1 +')';

	// Set H2 params
	var objH2 = document.getElementById('h2f');
	if(objH2) objH2.style.backgroundImage = 'url(/files/headers/'+ imgH2 +')';

	// Set H3 params
	var objH3 = document.getElementById('h3f');
	if(objH3) objH3.style.backgroundImage = 'url(/files/headers/'+ imgH3 +')';

};

function toggleGeneralLoginForm( type )
{
	loginForm = document.getElementById( 'loginformGeneral' );
	div1 = document.getElementById( 'divGeneralLogin' ).style;
	div2 = document.getElementById( 'divGeneralForgotPassword' ).style;
	p1 = document.getElementById( 'questionPassword' ).style;
	p2 = document.getElementById( 'questionLogin' ).style;
	document.getElementById( 'errorGeneralLogin' ).innerHTML = '';
	if( type == 'login' )
	{
		loginForm.type.value = 'login';
		div1.display = 'block';
		div2.display = 'none';
		p1.display = 'block';
		p2.display = 'none';
	}
	if( type == 'password' )
	{
		loginForm.type.value = 'password';
		div1.display = 'none';
		div2.display = 'block';
		p1.display = 'none';
		p2.display = 'block';
	}
};

function toggleLoginForm( type )
{
	loginForm = document.getElementById( 'boekenReis' );
	div1 = document.getElementById( 'divLogin' ).style;
	div2 = document.getElementById( 'divForgotPassword' ).style;
	div3 = document.getElementById( 'optionsForgotPassword' ).style;
	div4 = document.getElementById( 'optionsLogin' ).style;
	document.getElementById( 'errorGeneralLogin' ).innerHTML = '';
	if( type == 'login' )
	{
		loginForm.type.value = 'login';
		div1.display = 'block';
		div2.display = 'none';
		div3.display = 'block';
		div4.display = 'none';
	}
	if( type == 'password' )
	{
		loginForm.type.value = 'password';
		div1.display = 'none';
		div2.display = 'block';
		div3.display = 'none';
		div4.display = 'block';
	}
};

function toggleReisbureauLoginForm( type )
{
	loginForm = document.getElementById( 'inloggenReisbureau' );
	div1 = document.getElementById( 'divReisbureauLogin' ).style;
	div2 = document.getElementById( 'divReisbureauForgotPassword' ).style;
	p1 = document.getElementById( 'questionReisbureauPassword' ).style;
	p2 = document.getElementById( 'questionReisbureauLogin' ).style;
	document.getElementById( 'errorReisbureauLogin' ).innerHTML = '';
	if( type == 'login' )
	{
		loginForm.type.value = 'reisbureauLogin';
		div1.display = 'block';
		div2.display = 'none';
		p1.display = 'block';
		p2.display = 'none';
	}
	if( type == 'password' )
	{
		loginForm.type.value = 'reisbureauPassword';
		div1.display = 'none';
		div2.display = 'block';
		p1.display = 'none';
		p2.display = 'block';
	}
};

var submitting = false;

function showAvailableTips( product )
{
	if( !submitting )
	{
		try
		{
			submitting = true;
			var rpcAction = document.getElementById( 'rpcAction' );
			var baseURI = document.getElementById( 'baseURI' );

			/*
			if( reissoort.selectedIndex !=0 && land.selectedIndex != 0 && bestemming.selectedIndex != 0 )
			{
				return true;
			}
			else
			{
			*/
				var params = [
					'type=rpcAvailableTipSearch',
					'baseURI=' + baseURI.value,
					'product=' + product
				]
				myLightbox.params = params.join( '&' );
				//alert( myLightbox.params );
				myLightbox.responseType = 'text';
				myLightbox.start( rpcAction.value );
				return false;
			//}
		}
		catch( failed )
		{
			submitting = false;
			if( document.debug )
			{
				alert( failed );
				return false;
			}
			else
			{
				return true;
			}
		}
	}
	else
	{
		alert( 'Een ogenblik geduld a.u.b. Uw zoekopdracht wordt verwerkt' );
		return false;
	}
};

function submitSearchForm( obj )
{
	if( !submitting )
	{
		try
		{
			submitting = true;
			var rpcAction = document.getElementById( 'rpcAction' );
			var baseURI = document.getElementById( 'baseURI' );
			var product = document.getElementById( 'product' );
			var reissoort = document.getElementById( 'reissoort' );
			var land = document.getElementById( 'land' );
			var bestemming = document.getElementById( 'bestemming' );
			var leeftijdscategorie = document.getElementById( 'leeftijdscategorie' );
			var datumVan = document.getElementById( 'datumVan' );
			var datumTot = document.getElementById( 'datumTot' );

			/*
			if( reissoort.selectedIndex !=0 && land.selectedIndex != 0 && bestemming.selectedIndex != 0 )
			{
				return true;
			}
			else
			{
			*/
				var params = [
					'type=rpcSearch',
					'baseURI=' + baseURI.value,
					'product=' + ( ( product.type == 'select-one' ) ? product.options[ product.selectedIndex ].value : product.value ),
					'reissoort=' + reissoort.options[ reissoort.selectedIndex ].value,
					'land=' + land.options[ land.selectedIndex ].value,
					'bestemming=' + bestemming.options[ bestemming.selectedIndex ].value,
					'leeftijdscategorie=' + ( ( leeftijdscategorie.type == 'select-one' ) ? leeftijdscategorie.options[ leeftijdscategorie.selectedIndex ].value : leeftijdscategorie.value ),
					'datumVan=' + datumVan.options[ datumVan.selectedIndex ].value,
					'datumTot=' + datumTot.options[ datumTot.selectedIndex ].value
				]
				myLightbox.params = params.join( '&' );
				//alert( myLightbox.params );
				myLightbox.responseType = 'text';
				myLightbox.start( rpcAction.value );
				return false;
			//}
		}
		catch( failed )
		{
			submitting = false;
			if( document.debug )
			{
				alert( failed );
				return false;
			}
			else
			{
				return true;
			}
		}
	}
	else
	{
		alert( 'Een ogenblik geduld a.u.b. Uw zoekopdracht wordt verwerkt' );
		return false;
	}
};

function refreshSearchForm( obj )
{
	try
	{
		var rpcAction = document.getElementById( 'rpcAction' );
		var baseURI = document.getElementById( 'baseURI' );
		var product = document.getElementById( 'product' );
		var reissoort = document.getElementById( 'reissoort' );
		var land = document.getElementById( 'land' );
		var bestemming = document.getElementById( 'bestemming' );
		var leeftijdscategorie = document.getElementById( 'leeftijdscategorie' );
		var datumVan = document.getElementById( 'datumVan' );
		var datumTot = document.getElementById( 'datumTot' );

		var searchFormOrder = new Array( product, reissoort, land, bestemming, leeftijdscategorie, datumVan, datumTot );

		for( var i = 0, found = false; i < searchFormOrder.length; i++ )
		{
			if( obj == searchFormOrder[ i ] )
			{
				found = true;
			}
			else if( found )
			{
				searchFormOrder[ i ].selectedIndex = 0;
			}
		}

		var params = [
			'type=rpcRefreshSearchForm',
			'baseURI=' + baseURI.value,
			'product=' + ( ( product.type == 'select-one' ) ? product.options[ product.selectedIndex ].value : product.value ),
			'reissoort=' + reissoort.options[ reissoort.selectedIndex ].value,
			'land=' + land.options[ land.selectedIndex ].value,
			'bestemming=' + bestemming.options[ bestemming.selectedIndex ].value,
			'leeftijdscategorie=' + ( ( leeftijdscategorie.type == 'select-one' ) ? leeftijdscategorie.options[ leeftijdscategorie.selectedIndex ].value : leeftijdscategorie.value ),
			'datumVan=' + datumVan.options[ datumVan.selectedIndex ].value,
			'datumTot=' + datumTot.options[ datumTot.selectedIndex ].value
		]
		var ajaxRequest = new RealAjax();
		ajaxRequest.url = rpcAction.value;
		ajaxRequest.params = params.join( '&' );
		//alert( ajaxRequest.params );
		ajaxRequest.callbackObj = document;
		ajaxRequest.callback = populateSearchForm;
		ajaxRequest.responseType = '';
		ajaxRequest.send();
		return true;

	}
	catch( failed )
	{
		if( document.debug )
		{
			alert( failed );
			return false;
		}
		else
		{
			return true;
		}
	}
};

function populateSearchForm( ajaxResult )
{
	try
	{
		var baseURI = document.getElementById( 'baseURI' );
		var product = document.getElementById( 'product' );
		var reissoort = document.getElementById( 'reissoort' );
		var land = document.getElementById( 'land' );
		var bestemming = document.getElementById( 'bestemming' );
		var leeftijdscategorie = document.getElementById( 'leeftijdscategorie' );
		var datumVan = document.getElementById( 'datumVan' );
		var datumTot = document.getElementById( 'datumTot' );

		var xmlResult = ajaxResult.responseXML;
		//alert( ajaxResult.responseText );
		var optionsproduct = xmlResult.getElementsByTagName( 'product' );
		var optionsReissoort = xmlResult.getElementsByTagName( 'reissoort' );
		var optionsLand = xmlResult.getElementsByTagName( 'land' );
		var optionsBestemming = xmlResult.getElementsByTagName( 'bestemming' );
		var optionsLeeftijdscategorie = xmlResult.getElementsByTagName( 'leeftijdscategorie' );
		var optionsDatumVan = xmlResult.getElementsByTagName( 'datumVan' );
		var optionsDatumTot = xmlResult.getElementsByTagName( 'datumTot' );
		if( reissoort.type == 'select-one' )
		{
			populateSelectFromXML( reissoort, optionsReissoort );
		}
		if( land.type == 'select-one' )
		{
			populateSelectFromXML( land, optionsLand );
		}
		if( bestemming.type == 'select-one' )
		{
			populateSelectFromXML( bestemming, optionsBestemming );
		}
		if( leeftijdscategorie.type == 'select-one' )
		{
			populateSelectFromXML( leeftijdscategorie, optionsLeeftijdscategorie );
		}
		if( datumVan.type == 'select-one' )
		{
			populateSelectFromXML( datumVan, optionsDatumVan );
		}
		if( datumTot.type == 'select-one' )
		{
			populateSelectFromXML( datumTot, optionsDatumTot );
		}
	}
	catch( failed )
	{
		if( document.debug )
		{
			alert( failed );
			return false;
		}
		else
		{
			return true;
		}
	}
};

function populateSelectFromXML( obj, optionsXML )
{
	obj.options.length = 0;
	if( optionsXML.length > 0 )
	{
		for( var i = 0; i < optionsXML.length; i++ )
		{
			var labelValue = optionsXML[ i ].getAttribute( 'label' );
			var valueValue = optionsXML[ i ].getAttribute( 'value' );
			var defaultSelectedValue = Boolean( parseInt( optionsXML[ i ].getAttribute( 'defaultSelected' ) ) );
			var selectedValue = Boolean( parseInt( optionsXML[ i ].getAttribute( 'selected' ) ) );
			//alert( selectedValue + ' ' + labelValue  );
			obj.options[ obj.options.length ] = new Option( unescape( labelValue ), unescape( valueValue ), defaultSelectedValue, selectedValue );
		}
		//obj.disabled = ( obj.options.length <= 1 ) ? true : false;
	}
	else
	{
		obj.options[ obj.options.length ] = new Option( 'Geen resultaat', '', true, true );
	}
};

function gotoEditWebdeelnemer( pid )
{
	document.getElementById('subaction').value = 'edit';
	document.getElementById('argument').value = pid;
	document.getElementById('boekenReis').submit();
};

function gotoRemoveWebdeelnemer( pid )
{
	if( confirm( 'Weet u zeker dat u deze persoon wilt verwijderen?\n\nDeze gegevens gaan hiermee definitief verloren!\n ' ) )
	{
		document.getElementById('subaction').value = 'remove';
		document.getElementById('argument').value = pid;
		document.getElementById('boekenReis').submit();
	}
};

function gotoNewWebdeelnemer()
{
	document.getElementById('subaction').value = 'new';
	document.getElementById('boekenReis').submit();
};

function gotoSelectClient( firstLetters )
{
	firstLetters = firstLetters != undefined ? firstLetters : '';
	document.getElementById('subaction').value = 'clients-select';
	document.getElementById('argument').value = firstLetters;
	document.getElementById('boekenReis').submit();
};

function gotoNewClient()
{
	document.getElementById('subaction').value = 'clients-new';
	document.getElementById('boekenReis').submit();
};

function gotoEditClient( uid )
{
	document.getElementById('subaction').value = 'clients-edit';
	document.getElementById('boekenReis').submit();
};

function showLoginForm()
{
	Element.toggle('loginGeneral');
}

function showQuickSelector( product, reissoort )
{
	if( !submitting )
	{
		try
		{
			submitting = true;
			var rpcAction = document.getElementById( 'rpcAction' );
			var baseURI = document.getElementById( 'baseURI' );

            var params = [
                'type=rpcQuickSelectorSearch',
                'baseURI=' + baseURI.value,
                'product=' + product,
                'reissoort=' + reissoort
            ]
            myLightbox.params = params.join( '&' );
            //alert( myLightbox.params );
            myLightbox.responseType = 'text';
            myLightbox.start( rpcAction.value, false, 'quickselector' );
            return false;
		}
		catch( failed )
		{
			submitting = false;
			if( document.debug )
			{
				alert( failed );
				return false;
			}
			else
			{
				return true;
			}
		}
	}
	else
	{
		alert( 'Een ogenblik geduld a.u.b. Uw opdracht wordt verwerkt' );
		return false;
	}
}

function toggleQuickSelectorCountry( obj )
{
	obj = $( obj );
	try {
		parentLi = obj.up( 0 );
		parentLi.toggleClassName( 'selected' );
	}
	catch( failed )
	{
		alert( failed );
	}
	return false;
}

// show button startBooking

function startBookingProces()
{
	//Element.show('startbooking');
	new Effect.SlideDown('startbooking', { duration: 0.5, from: 0.0, to: 1.0 });
};

function showDates( isPrijsIndicatie )
{
	$('prijsIndicatie').value = isPrijsIndicatie;
	Element.hide('selectdates');
	Element.show('dates');
};

function showLargePhoto( rpcPhotoAction )
{
	try
	{
		var params = [
			'type=rpcPhoto'
		]
		myLightbox.params = params.join( '&' );
		myLightbox.responseType = 'text';
		myLightbox.start( rpcPhotoAction );
		return false;
	}
	catch( failed )
	{
		if( document.debug )
		{
			alert( failed );
			return false;
		}
		else
		{
			return true;
		}
	}
};

function showCustomPhoto( url ) {
	myLightbox.start();
	Element.hide('overlayload');
	Element.setInnerHTML('overlaycontent', '<br /><img src="'+url+'" alt="" />');
}

function showSinglePhoto( rpcPhotoAction )
{
	try
	{
		var params = [
			'type=rpcPhoto'
		]
		myLightbox.loadImage = true;
		myLightbox.params = params.join( '&' );
		myLightbox.responseType = 'text';
		myLightbox.imageOnly = true;
		myLightbox.start( rpcPhotoAction );
		return false;
	}
	catch( failed )
	{
		if( document.debug )
		{
			alert( failed );
			return false;
		}
		else
		{
			return true;
		}
	}
};

function showInfo( rpcInfoAction )
{
	try
	{
		var params = [
			'type=rpcInfo'
		]
		myLightbox.params = params.join( '&' );
		myLightbox.responseType = 'text';
		myLightbox.start( rpcInfoAction );
		return false;
	}
	catch( failed )
	{
		if( document.debug )
		{
			alert( failed );
			return false;
		}
		else
		{
			return true;
		}
	}
};

function showSendtofriendForm( action, url )
{
	if( !submitting )
	{
		try
		{
			submitting = true;
			var params = [
				'type=rpcSendtofriend',
				'url=' + url
			]
			myLightbox.params = params.join( '&' );
			myLightbox.responseType = 'text';
			myLightbox.start( action );
			return false;
		}
		catch( failed )
		{
			submitting = false;
			if( document.debug )
			{
				alert( failed );
				return false;
			}
			else
			{
				return true;
			}
		}
	}
	else
	{
		alert( 'Een ogenblik geduld a.u.b. Het formulier wordt geopend.' );
		return false;
	}
};

function submitSendtofriendForm( action, url )
{
	if( !submitting )
	{
		try
		{
			submitting = true;
			var senderName = document.getElementById( 'senderName' );
			var senderEmail = document.getElementById( 'senderEmail' );
			var recipientName = document.getElementById( 'recipientName' );
			var recipientEmail = document.getElementById( 'recipientEmail' );
			var params = [
				'type=rpcSendtofriend',
				'submit=1',
				'senderName=' + senderName.value,
				'senderEmail=' + senderEmail.value,
				'recipientName=' + recipientName.value,
				'recipientEmail=' + recipientEmail.value,
				'url=' + url
			]
			myLightbox.params = params.join( '&' );
			myLightbox.responseType = 'text';
			myLightbox.start( action );
			return false;
		}
		catch( failed )
		{
			submitting = false;
			if( document.debug )
			{
				alert( failed );
				return false;
			}
			else
			{
				return true;
			}
		}
	}
	else
	{
		alert( 'Een ogenblik geduld a.u.b. Het formulier wordt verzonden.' );
		return false;
	}
};


// Ellipsis functions
// *************************************************************************** //

function computedStyle(el, property)
{
	var style = false;

	if (el)
	{
		if (el.currentStyle)
			style = el.currentStyle[property.replace(/-([a-z])/, function($0,$1){ return $1.toUpperCase(); })];
		else if (window.getComputedStyle)
			style = document.defaultView.getComputedStyle(el, '').getPropertyValue(property);
	}

	return style;
};

// browser detect object
var is = {
	opera: !!window.opera,
	ie: /*@cc_on!@*/false,
	khtml: navigator.userAgent.indexOf('KHTML') > -1,
	gecko: navigator.userAgent.indexOf('KHTML') == -1 && navigator.userAgent.indexOf('Gecko') > -1,
	mac: navigator.userAgent.indexOf('Macintosh') > -1,
	handheld: computedStyle(document.documentElement, 'z-index') == 1
};

function ieRenderFix(el)
{
	if (is.ie)
	{
		el.style.display = 'none';
		el.style.display = 'block';
	}
};

function getElementsByClassName(className, nodeName, parentElement, callback)
{
	if (!nodeName)
		nodeName = '*';

	if (!parentElement)
		parentElement = document;

	var results = [], multiple = className.indexOf('|') > -1, s, i = 0, element;

	if (parentElement.getElementsByClassName && nodeName == '*' && !multiple)
	{
		results = parentElement.getElementsByClassName(className);

		if (callback)
			Array.forEach(results, callback);
	}
	else if (document.evaluate && !multiple)
	{
		s = document.evaluate(
			".//" + nodeName + "[contains(concat(' ', @class, ' '), ' " + className + " ')]",
			parentElement,
			null,
			XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
			null
		);

		while ((element = s.snapshotItem(i++)))
		{
			results.push(element);
			if (callback)
				callback(element);
		}
	}
	else
	{
		s = parentElement.getElementsByTagName(nodeName);
		var re = getClassRegExp(className), elementClassName;

		while ((element = s[i++]))
		{
			elementClassName = element.className;
			if (	elementClassName.length &&
				(	elementClassName == className ||
					re.test(elementClassName)
				)
			)
			{
				results.push(element);
				if (callback)
					callback(element);
			}
		}
	}

	return results;
};


function ellipsis(root)
{
	if (ellipsis.__native == undefined)
	{
		ellipsis.__native = true;
		if (document.defaultView && document.defaultView.getComputedStyle)
		{
			var foo = document.createElement('div');
			foo.style.cssText = 'text-overflow:ellipsis;-o-text-overflow:ellipsis';
			if (!foo.style.cssText)
				ellipsis.__native = false;
		}
	}

	if (!ellipsis.__native)
	{
		if (!root)
			getElementsByClassName('ellipsis', null, null, ellipsis_do);
		else
			ellipsis_do(root);
	}
};

function ellipsis_table(tableId)
{
	if (is.ie || is.khtml)
	{
		var productTable = document.getElementById(tableId);
		if (productTable)
		{
			var tableBody = productTable.getElementsByTagName('tbody')[0];
			var row = tableBody && tableBody.rows[0];
			if (row)
			{
				var cell, i = 0, j = 0;
				while (row && (cell = row.cells[i]))
				{
					if (cell.colSpan && cell.colSpan > 1)
					{
						row = tableBody.rows[++j];
						continue;
					}

					if (!hasClass(cell, 'ellipsis'))
						productTable.rows[0].cells[i].width = cell.clientWidth - (is.ie ? 8 : 0);

					i++;
				}

				productTable.style.tableLayout = 'fixed';
			}
		}
	}
};

function ellipsis_do(root)
{
	var ellipsis_word = false;

	// speed things up
	if (root.clientWidth)
	{
		if (root.nodeName != 'TD')
		{
			root.style.width = root.clientWidth + 'px';
			root.style.position = 'fixed';
		}

		var s = [root], e, o, w;

		while ((e = s.pop()))
		{
			do
			{
				switch (e.nodeType)
				{
					case 1:
						if (e.style.display != 'none')
						{
							if (document.defaultView.getComputedStyle(e, null).getPropertyValue('overflow') == 'hidden')
							{
								ellipsis_overflow(e, ellipsis_word);
							}
							else
							{
								if ((o = e.nextSibling)) s.push(o);
								e = e.firstChild;
								break;
							}
						}

					default:
						e = e.nextSibling;
				}
			}
			while (e);
		}

		root.style.position = '';
	}
};

function ellipsis_overflow(p, ellipsis_word)
{
	var w = p.clientWidth;
	if (w && p.scrollWidth > w)
	{
		var s = [p], e, o, q, l;

		while ((e = s.pop()))
		{
			do
			{
				switch (e.nodeType)
				{
					case 1:
						if ((o = e.previousSibling)) s.push(o);
						e = e.lastChild;
						break;

					case 3:
						if (/[^\t\n\r ]/.test(e.data))
						{
							// Take an educated guess on what the length of the text should be
							q = e.nodeValue;
							l = Math.floor((q.length * w) / p.scrollWidth) - 1;
							if (l > 0)
							{
								do
								{
									e.nodeValue = q.substr(0, --l) + '...';
								}
								while (l && (p.scrollWidth > w || (ellipsis_word && e.nodeValue.charAt(l-1) != ' ')));

								if (l > 0) return;
							}

							e.nodeValue = '';
						}

					default:
						e = e.previousSibling;
				}
			}
			while(e);
		}
	}
};


// what to run at start?
// replaceHeaders()
// doEllipsis()

function checkOverlay(){

	var oLay = document.getElementById('overlay');
	if (oLay.style.display != 'none'){
		//alert ("Overlay visible")
		resizeOverlay();
	}

};

function openMenuItems(item1, item2) {
	if (document.getElementById) {
		el1 = document.getElementById(item1);
		el2 = document.getElementById(item2);

		if(el1.style.display == 'none') {
			el1.style.display = 'block';
		} else {
			el1.style.display = 'none';
		}
		if(el2.style.display == 'none') {
			el2.style.display = 'block';
		} else {
			el2.style.display = 'none';
		}
	}
};


function showVertrek(){
	Element.toggle( this.target );

//	Element.toggle('box-vertrekkalender');
};


function printSelection( sVar ){

	var sElm = ( sVar ) ? sVar : "overlaycontent";
	var sSelection = document.getElementById(sElm).innerHTML;
	var sTitle = '<h1>' + document.getElementById("h1f").innerHTML + '</h1>';

  var pWin = window.open("",'printcontent','width=300,height=10');
	var sHTML = '';

	sHTML += '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
	sHTML += '<html>';
	sHTML += '<head>';
	sHTML += '<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">';
	sHTML += '<meta http-equiv="Content-Language" content="NL">';
	sHTML += '<title>Cirkel Vakanties</title>';
	sHTML += '<link rel="stylesheet" type="text/css" media="screen" href="http://cirkel.trendesign.nl/includes/css/overlay-printscreen.css">';
	sHTML += '<link rel="stylesheet" type="text/css" media="print" href="http://cirkel.trendesign.nl/includes/css/overlay-print.css">';
	sHTML += '</head>';
	sHTML += '<body style="padding: 100px 0 0 0;" onload="window.print(); window.close()">';
	sHTML += '<div id="container">';
	sHTML += '</div></body></html>';

  pWin.document.open();
  pWin.document.write(sHTML);
  pWin.document.getElementById('container').innerHTML = sTitle + sSelection;
  pWin.document.close();

  setTimeout(function(){pWin.close(); }, 250);

};



// Run function(s) when DOM is ready
// ----------------------------------------------------
document.observe('dom:loaded', function() {

	startCircling();

	if ( $('vertrektrigger') ){
		$('vertrektrigger').observe('click', showVertrek.bindAsEventListener( { target: 'box-vertrekkalender' } ) );
	}

	if ( $('vertrektrigger-w') ){
		$('vertrektrigger-w').observe('click', showVertrek.bindAsEventListener( { target: 'box-vertrekkalender-w' } ) );
	}

	// Tooltips Product view
  $$('#box-vertrekkalender .vertrek-item a').each(function(element) {
    new Tip(element, element.rel, {	style: 'cirkel' });
	});

	// Tooltips Product view
  $$('#box-vertrekkalender-w .vertrek-item a').each(function(element) {
    new Tip(element, element.rel, {	style: 'cirkelw' });
	});

});


// Element.observe(document, 'dom:loaded', startCircling);

//Event.observe(window, 'resize', checkOverlay, false);