function handleEnter (field, event) 
{
  var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
	if (keyCode == 13) 
	{
    if(field.name == 'zoeken')
    {
      document.location='http://www.topvakanties.nl/site_search.php?zoeken='+document.getElementById('zoekenmaar').value;
      return false;
    }
    else
    {		
			var i;
			for (i = 0; i < field.form.elements.length; i++)
				if (field == field.form.elements[i])
					break;
			i = (i + 1) % field.form.elements.length;
			field.form.elements[i].focus();
			return false;					
  	}  	
  }  
  else
  	return true; 
}

// deze functie verwijdert de stippellijntjes van een geklikte <a>-tag.
function remove_link_lines() {
	document.getElements('a').addEvent('focus', function(){this.blur()});
}


// hieronder de uitklapbare lijsten van het main-menu bovenaan
function init_collapsiple_mainmenulists() {
	open_mainmenulist = 'none';
	$E('a', $('btn_bestemming')).addEvent ('click', function (){
		switch(open_mainmenulist) {
			case 'none': bestemminglist_open();
			  break
			case 'soort': soortlist_close(); bestemminglist_open();
			  break
			case 'bestemming': bestemminglist_close();
		}
	});

	$E('a', $('btn_soortvakantie')).addEvent ('click', function (){
		switch(open_mainmenulist) {
			case 'none': soortlist_open();
			  break
			case 'bestemming': bestemminglist_close(); soortlist_open();
			  break
			case 'soort': soortlist_close();
		}
	});
}
function bestemminglist_open() {
	bestemminglist_close();
	
	$E('ul', $('btn_bestemming')).effect('height',{
		duration: 200,
		onComplete: function (){ $('btn_bestemming').className = 'active'; }
	}).start($E('ul', $('btn_bestemming')).scrollHeight);
	open_mainmenulist = 'bestemming';
}

function bestemminglist_close() {
	$E('ul', $('btn_bestemming')).style.height = '0px';
	$('btn_bestemming').className = '';
	open_mainmenulist = 'none';
}
function soortlist_open() {
	soortlist_close();
	
	$E('ul', $('btn_soortvakantie')).effect('height',{
		duration: 200,
		onComplete: function (){ $('btn_soortvakantie').className = 'active'; }
	}).start($E('ul', $('btn_soortvakantie')).scrollHeight);
	open_mainmenulist = 'soort';
}
function soortlist_close() {
	$E('ul', $('btn_soortvakantie')).style.height = '0px';
	$('btn_soortvakantie').className = '';
	open_mainmenulist = 'none';
}


// hieronder de uitklapbare lijsten van het submenu, onderaan de header
function init_collapsiple_headerlists() {
	if (!$('countrylist')) {return}
	if (!$('themelist')) {return}
	open_headerlist = 'none';
	countrylist_open();
	/*
	$E('a.more', $('countrylist')).addEvent ('click', function (){
		switch(open_headerlist) {
			case 'none': countrylist_open();
			  break
			case 'theme': themelist_close(); countrylist_open();
			  break
			case 'country': countrylist_close();
		}
	});
	*/

	$E('a.more', $('themelist')).addEvent ('click', function (){
		switch(open_headerlist) {
			case 'none': themelist_open();
			  break
			//case 'country': countrylist_close(); themelist_open();
			//  break
			case 'country': themelist_open();
			  break
			case 'theme': themelist_close();
		}
	});
}
function countrylist_open() {
	$('countrylist').effect('height',{
		duration: 300,
		onComplete: function (){ $E('a.more', $('countrylist')).className = 'more active'; }
	}).start($('countrylist').scrollHeight);
	open_headerlist = 'country';
}
function countrylist_close() {
	$('countrylist').effect('height',{
		duration: 300,
		onComplete: function (){ $E('a.more', $('countrylist')).className = 'more'; }
	}).start(11);
	open_headerlist = 'none';
}
function themelist_open() {
	$('themelist').effect('height',{
		duration: 300,
		onComplete: function (){ $E('a.more', $('themelist')).className = 'more active'; }
	}).start($('themelist').scrollHeight);
	open_headerlist = 'theme';
}
function themelist_close() {
	$('themelist').effect('height',{
		duration: 300,
		onComplete: function (){ $E('a.more', $('themelist')).className = 'more'; }
	}).start(14);
	open_headerlist = 'none';
}


// hieronder de popup-balloons bij de aanbiedingen rechts
function init_alsoseepopups() {
	aanbiedingen = $ES('div.aanbieding', 'div#alsosee');
	aanbiedingen.each(function(item){
		item.addEvents({
			'mouseover': function(){
				item.className = 'aanbieding hover';
			},
			'mouseout': function(){
				item.className = 'aanbieding';
			}
		});
	});
}


// hieronder de uitvouwbare zoekbox in de footer
function init_zoekenfoldout() {
	if (!$('uitgebreidzoeken')) {return}
	boxes = $ES('input', 'fieldset.subgroep');
	$('uitgebreidzoeken').addEvent('click', function(){
		$('zoekenfoldout').effect('height',{ duration: 300 }).start($('zoekenfoldout').scrollHeight);
		$('zoekenfoldout').effect('top',{ duration: 300 }).start(-($('zoekenfoldout').scrollHeight));
	});
	$('sluiten').addEvent('click', function(){
		$('zoekenfoldout').effect('height',{ duration: 300 }).start(0);
		$('zoekenfoldout').effect('top',{ duration: 300 }).start(0);
	});
	$('wissen').addEvent('click', function(){
		boxes.each(function(item){
			item.checked = '';
		});
	});
}
imgPath = "http://tv.emesa-static.com/";
//deze functie zorgt ervoor dat IE niet moeilijk doet over de Flash ActiveX component
function init_flashheader(filename) {
	if(!$('flash_header')) {return}
	var so_header = new SWFObject(imgPath + "flash/header/header.swf", "header", "775", "160", "8", "#000000");
	so_header.addParam("wmode", "transparent");
	so_header.addVariable("XMLfilepath", imgPath + "flash/header/" + filename + ".xml");
	so_header.write("flash_header");
}


function sifr_replace() {
	if(typeof sIFR == "function"){
    boldSrc   = imgPath + "flash/sifr/futurabold.swf";
    normalSrc = imgPath + "flash/sifr/futura.swf";
  	sIFR.replaceElement("h3.sifr_aanbieding", named({sFlashSrc: boldSrc, sColor: "#4e4e4e", sWmode: "transparent", sFlashVars: "texts=18"}));
  	sIFR.replaceElement("h2.sifr_welkom", named({sFlashSrc: normalSrc, sColor: "#962b0a", sWmode: "transparent", sFlashVars: "texts=15"}));
  	sIFR.replaceElement("h3.sifr_alsosee", named({sFlashSrc: boldSrc, sColor: "#ffffff", sWmode: "transparent", sFlashVars: "texts=15"}));
  	sIFR.replaceElement("legend.sifr_zoeken", named({sFlashSrc: normalSrc, sColor: "#ffffff", sWmode: "transparent", sFlashVars: "texts=15"}));
  	sIFR.replaceElement("a.sifr_prijs", named({sFlashSrc: boldSrc, sColor: "#962B0A", sWmode: "transparent", sFlashVars: "texts=18"}));
  	sIFR.replaceElement("a.sifr_tabactief", named({sFlashSrc: normalSrc, sColor: "#4e4e4e", sWmode: "transparent", sFlashVars: "texts=12&textalign=center"}));
  	sIFR.replaceElement("a.sifr_tab", named({sFlashSrc: normalSrc, sColor: "#ffffff", sWmode: "transparent", sFlashVars: "texts=12&textalign=center"}));
	};
}
