var IE = document.all?true:false
var loopTo = ''
var timeoutYoutube = ''
var checkSelected = false

//All fields with id filled in are required fields.
function cOn(td, clss) {
  td.className = clss;
}

function display(id,arr) {
	if(arr!=undefined) {
		var a = arr.split(',')
		for(i=0;i<a.length;i++){
			document.getElementById(a[i]).style.display='none'
			document.getElementById(a[i].replace('txt','subnav')).src = document.getElementById(a[i].replace('txt','subnav')).src.replace('_o.gif','.gif')
		}
	}
	var obj = document.getElementById(id).style
	if(obj.display=='none'){
		obj.display='block'
	//}else{
	//	obj.display='none'
	}
	return false
}

function togglePC(id,arr) {
	if(arr!=undefined) {
		if(document.getElementById('locaties_search')) document.getElementById('locaties_search').style.display = 'block'
		if(document.getElementById('locaties_tip')) document.getElementById('locaties_search').style.display = 'block'
		var a = arr.split(',')
		for(i=0;i<a.length;i++){
			document.getElementById(a[i]).style.display='none'
			if(document.getElementById(a[i]+'_img')) document.getElementById(a[i]+'_img').src = document.getElementById(a[i]+'_img').src.replace('_o.gif','.gif')
		}
	}
	var obj = document.getElementById(id).style
	if(obj.display=='none'){
		obj.display='block'
		document.getElementById(id+'_img').src = document.getElementById(id+'_img').src.replace('.gif','_o.gif')
	//}else{
	//	obj.display='none'
	}
	
	if(id=='srch_dist'){
		document.getElementById('moduleBannerContent_2').style.height = '250px'
	}else{
		document.getElementById('moduleBannerContent_2').style.height = '410px'
	}
	return false
}

function locOn(nr,show){
	if(show){
		document.getElementById('loc_choose_'+nr).style.display='block'
		document.getElementById('loc_img_'+nr).className='borderActive'
		document.getElementById('loc_title_'+nr).className='tbor'
	}else{
		document.getElementById('loc_choose_'+nr).style.display='none'
		document.getElementById('loc_img_'+nr).className='border'
		document.getElementById('loc_title_'+nr).className=''
	}
}

function mOn(id) {
	var obj = document.getElementById(id)
	if(obj.src.indexOf('_o.gif')>-1){
		obj.src=obj.src.replace('_o.gif','.gif')
	}else{
		obj.src=obj.src.replace('.gif','_o.gif')
	}
}

function smOn(id) {
	var obj = document.getElementById(id)
	if(obj.src.indexOf('_o.gif')>-1){
		if(document.getElementById(id.replace('subnav','txt')).style.display=='none'){
			obj.src=obj.src.replace('_o.gif','.gif')
		}
	}else{
		obj.src=obj.src.replace('.gif','_o.gif')
	}
}

function sh(id1,id2) {
	var obj1 = document.getElementById(id1)
	var obj2 = document.getElementById(id2)
	if(obj1.style.display=='none'){obj1.style.display='block'}else{obj1.style.display='none'}
	if(obj2.style.display=='none'){obj2.style.display='block'}else{obj2.style.display='none'}
}

function getCheckboxValue(id) {
	var allInputTags = document.getElementById(id+'_group').getElementsByTagName('INPUT');
	for (var c=0; c<allInputTags.length; c++) {
		if (allInputTags[c].checked) {
			return allInputTags[c].value;
			break;
		}
	}
	return ""
}

function backToSearch() {
	document.getElementById('locatietabs').style.display='block'
	document.getElementById('locatiebg').style.top='20px'
	document.getElementById('locaties_block').style.visibility = 'hidden'
//	document.getElementById('scrollSliderContainer_2').style.visibility = 'hidden'
	document.getElementById('locaties_search').style.display = 'block'
	document.getElementById('locaties_search').style.visibility = 'visible'
	$('#moduleBannerTitle_2').removeClass('open');

	if(document.getElementById('srch_dist').style.display == 'block'){
		document.getElementById('moduleBannerContent_2').style.height = '250px'
	}else{
		document.getElementById('moduleBannerContent_2').style.height = '415px'
	}
}

function check(id) {
	checkSelected = true //zodat menu niet open/dichtklapt
	//var obj = document.getElementById('check'+id)
	//if(obj.src.indexOf('_o.gif')>-1){
		//do iets met session zodat locatie geditch wordt.
		clearSession(id)
		//obj.src = obj.src.replace('_o.gif','.gif')
		updateFlashMap()
		updatePriceOfferte()
		doNotExpand=true
	//}
	if(_SESS_CATID==4) {
		document.location.href=_PROJECT_URL + 'dag'
	}else{
		if(_SESS_CATID==2){
			document.location.href=_PROJECT_URL + 'meerdaags'
		}else{
			document.location.href=_PROJECT_URL
		}
	}
}

function reloadAfter(time) {
	setTimeout('document.location.reload()',time)
}

var opties = ''
var optioneel = ''
var aantal

function updatePriceOfferte(fcs){
	opties=''
	var isOptionsPage = false // bepaal of op deze pagina de opties worden gezet (anders sessie opties gebruiken).
	if(document.getElementById('opties_group')) {
		isOptionsPage = true; // opties uit pagina gebruiken.
		if(document.getElementById('optie_optioneel')) {
			optioneel = document.getElementById('optie_optioneel').value
		}
		var spanObj = document.getElementById('opties_group')
		var allOptions = spanObj.getElementsByTagName('INPUT');
		for (var c=0; c<allOptions.length; c++) {
			if (allOptions[c].id.indexOf('_optioneel')==-1) {
				if (allOptions[c].checked) {
					if(opties!=''){opties+=','}
					opties += document.getElementById(allOptions[c].id).value
				}
			}
		}
	}else{
		isOptionsPage = false; // opties uit sessie gebruiken.
	}
	aantal = '';
	if(document.getElementById('aantal')) {
		aantal = parseInt(document.getElementById('aantal').value)
		if(isNaN(aantal)){
			aantal='';
			document.getElementById('srch_aantalgasten').value = '';
			//document.getElementById('aantalgasten').value = '';
		}else{
            if (document.getElementById('srch_aantalgasten')){
			    document.getElementById('srch_aantalgasten').value = aantal;
			}
		    if (aantal != 2) {
			    if(document.getElementById('aantalgasten').value=='') document.getElementById('aantalgasten').value = aantal;
		    }
			    //document.getElementById('aantalgasten').value = aantal;			
		}
	}
	if (checkPersons()) {
		if(fcs){
			updatePrice(aantal,opties,optioneel,true,isOptionsPage);
		}else{
			updatePrice(aantal,opties,optioneel,false,isOptionsPage);
		}
	}
	$("#container-choices").load(_PROJECT_URL + 'xml/choices.asp');
}


function checkPersons() {
	if( (document.getElementById('locatieMin')) && (document.getElementById('locatieMax')) )
	{
		var locatieMin = document.getElementById('locatieMin').value
		var locatieMax = document.getElementById('locatieMax').value
		if(locatieMin!='' || locatieMax!=''){
			if(aantal < locatieMin || aantal > locatieMax) { // te veel of te weinig gasten ingevuld.
				document.getElementById('contPrice').style.display='none'
				document.getElementById('contAantalgasten').style.display='block'
				document.getElementById('contAantalgasten').innerHTML = 'Min. '+locatieMin+' en max. '+locatieMax+' gasten in deze locatie.'
				return false;
			}else{ // juiste aantal gasten ingevuld.
				document.getElementById('contPrice').style.display='block'
				document.getElementById('contAantalgasten').style.display='none'
			}
		}
	}
	return true;
}

function updateFlashMap(id,type){
	if(document.getElementById('flashMap')) document.getElementById('flashMap').innerHTML = updateFlash(_PROJECT_URL+'flash/kaart.swf?id='+id,140,160)
	if(document.getElementById('srch_kaart')) document.getElementById('srch_kaart').innerHTML = updateFlash(_PROJECT_URL+'flash/kaart_groot.swf?id='+id,190,185)
}

function showPlayer(type,id,absurl,autostart){
	switch(type){
		case 'photo':
			if(document.getElementById('player_tab1')) document.getElementById('player_tab1').style.marginTop = '1px'
			if(document.getElementById('player_tab2')) document.getElementById('player_tab2').style.marginTop = '0px'
			//id = feestid
			document.getElementById('player_content').innerHTML = updateFlash(_PROJECT_URL+'flash/player.swf',285,210,'player=p&id='+id+'&key=FEESTEN&autostart='+autostart+'&absURL='+absurl)
			break
		case 'photo_loc':
			if(document.getElementById('player_tab3')) document.getElementById('player_tab3').style.marginTop = '0px'
			if(document.getElementById('player_tab1')) document.getElementById('player_tab1').style.marginTop = '1px'
			if(document.getElementById('player_tab2')) document.getElementById('player_tab2').style.marginTop = '0px'
			//id = locatieid
			document.getElementById('gmaps_content').style.display='none'
			document.getElementById('player_content').style.display='block'
			document.getElementById('player_content').innerHTML = updateFlash(_PROJECT_URL+'flash/player.swf',285,210,'player=p&id='+id+'&key=LOCATIES&autostart='+autostart+'&absURL='+absurl)
			break
		case 'video':
			if(document.getElementById('player_tab3')) document.getElementById('player_tab3').style.marginTop = '1px'
			if(document.getElementById('player_tab1')) document.getElementById('player_tab1').style.marginTop = '0px'
			if(document.getElementById('player_tab2')) document.getElementById('player_tab2').style.marginTop = '0px'
			//id = videoid
			document.getElementById('player_content').innerHTML = updateFlash(_PROJECT_URL+'flash/player.swf',285,210,'player=v&id='+id+'&autostart='+autostart+'&absURL='+absurl)
			break
		case 'route':
			if(document.getElementById('player_tab3')) document.getElementById('player_tab3').style.marginTop = '0px'
			if(document.getElementById('player_tab1')) document.getElementById('player_tab1').style.marginTop = '0px'
			if(document.getElementById('player_tab2')) document.getElementById('player_tab2').style.marginTop = '1px'
			document.getElementById('player_content').style.display='none'
			document.getElementById('gmaps_content').style.display='block'
			document.getElementById('frm_google').src='http://www.leukefeesten.nl/googlemaps.asp?size=small&fill=1&locatieId=' + id
			break
	}
}

function updateFlash(src,w,h,args) {
	return "<OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' WIDTH='"+w+"' HEIGHT='"+h+"' id='sizetest' ALIGN='left'>" +
		"<PARAM NAME=movie VALUE='"+src+"'>" +
	  "<PARAM NAME=FlashVars VALUE='"+args+"'>" +
		"<PARAM NAME=menu VALUE=false>" +
		"<PARAM NAME=quality VALUE=high>" +
		"<PARAM NAME=wmode VALUE=transparent>" +
		"<EMBED FlashVars='"+args+"' src='"+src+"' menu=false quality=high wmode=transparent WIDTH='"+w+"' HEIGHT='"+h+"' NAME='sizetest' ALIGN='left' TYPE='application/x-shockwave-flash' PLUGINSPAGE='http://www.macromedia.com/go/getflashplayer'></EMBED></OBJECT>"
}

function disablePostalCity(result) {
	if (result==0) {
		document.getElementById('srch_postcode').style.color = '#CCCCCC';
		document.getElementById('srch_plaats').style.color = '';
	} else if(result==1) {
		document.getElementById('srch_postcode').style.color = '';
		document.getElementById('srch_plaats').style.color = '#CCCCCC';
	} else if(result==2) {
		if ( (document.getElementById('srch_postcode').value != '') || (document.getElementById('srch_plaats').value != '') ) {
			document.getElementById('srch_afstand').style.color = '';
		} else {
			document.getElementById('srch_afstand').style.color = '#CCCCCC';
		}
	}
}

function changeNewsTabs() {
	id = 'newsImage';
	if ( document.getElementById('newslist').style.display == 'none' ) {
		document.getElementById(id).src = _PROJECT_URL+'img/bt_tab_nieuwsbrief.gif';
		document.getElementById(id).alt = 'meld je aan voor de nieuwsbrief';
	}
	else {
		document.getElementById(id).src = _PROJECT_URL+'img/bt_tab_nieuws.gif';
		document.getElementById(id).alt = 'test';
		document.getElementById(id).alt = 'terug naar nieuwsoverzicht';
	}

}

function openSearch() {
//	GB_showCenter('Zoekresultaten',_PROJECT_URL+'zoeken/'+urlencode(document.getElementById('searchfor').value), /* optional */ 500, 500)	
	location.href=_PROJECT_URL + 'zoeken/' + urlencode(document.getElementById('searchfor').value)
}

function urlencode(str) {
return escape(str).replace('+', '%2B').replace('%20', '+').replace('*', '%2A').replace('/', '%2F').replace('@', '%40');
}

function openOverlay(title,url) {
	GB_showCenter(title, url, /* optional */ 200, 250)
}

function GBopenOverlay(title,url, height, width) {
	GB_showCenter(title, url, /* optional */ width, height)
}


function printFrame(url) {
	var iframeCmd = document.getElementById('iframeCmd');
	iframeCmd.setAttribute('src',url);
	if(IE){
		iframeCmd.onreadystatechange = function() {
			if (iframeCmd.readyState == "complete") {
				window.frames['iframeCmd'].focus();
				window.frames['iframeCmd'].print();
			}
		}
	}else{//mozilla
		//window.frames['iframeCmd'].focus();
		//window.frames['iframeCmd'].print()
	}
}

function checkOptie() {
	if((document.getElementById('optie0')) && (document.getElementById('optie0').checked)){
		document.getElementById('optie_optioneel').disabled = false
		document.getElementById('optie_optioneel').focus()
	}else{
		document.getElementById('optie_optioneel').value = ''
		document.getElementById('optie_optioneel').disabled = true
	}
}

function loadYoutube(container, width, height, align, wmode, url) {
	if(document.getElementById('gmaps_content')) document.getElementById('gmaps_content').style.display='none'
	if(document.getElementById('player_content')) {
		if(document.getElementById('player_tab3')) document.getElementById('player_tab3').style.marginTop = '1px'
		if(document.getElementById('player_tab1')) document.getElementById('player_tab1').style.marginTop = '0px'
		if(document.getElementById('player_tab2')) document.getElementById('player_tab2').style.marginTop = '0px'
		document.getElementById('player_content').style.display='block'
	}
	clearTimeout(timeoutYoutube); timeoutYoutube = null
	document.getElementById(container).innerHTML = AC_FL_RunContent_youtube('codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0',
	'width',width,
	'height',height,
	'align',align,
	'wmode',wmode,
	'FlashVars','required_version=8,0,24,0',
	'src',url,
	'quality','high',
	'bgcolor','#ffffff',
	'name',url,
	'allowscriptaccess','sameDomain',
	'pluginspage','http://www.macromedia.com/go/getflashplayer',
	'movie',url + '&rel=0');
}

function show(id,arr) {
	if(arr!=undefined) {
		var a = arr.split(',')
		for(i=0;i<a.length;i++){
			document.getElementById(a[i]).style.display='none'
		}
	}
	var obj = document.getElementById(id)
	if(obj){
		if(obj.style.display=='none'){
			obj.style.display='block'
		}
	}
	return false
}

function msg(url) {
	document.getElementById('btnja').onclick=function(){
		clearSession(2)
		location.href=url
	}
	var l
	var t, scrollTop
	l = (970-250) / 2;
	scrollTop = (document.all ? document.body.scrollTop : window.pageYOffset);
	if (document.all) {
		document.getElementById('container_message').style.top = 350
	}	else {
		document.getElementById('container_message').style.top = '350px'
	}
	document.getElementById('container_message').style.display = 'block'
	document.getElementById('container_message').style.left = l + 'px'
}
function hideMsg(){
	document.getElementById('container_message').style.display = 'none'
}

function getStyle(elem, name) {
	if(name){
		if (elem.currentStyle) {
			return elem.currentStyle[name];
		}
	
		else if (document.defaultView && document.defaultView.getComputedStyle) {
			name = name.replace(/([A-Z])/g, "-$1");
			name = name.toLowerCase();
	
			var s = document.defaultView.getComputedStyle(elem, "");
			return s && s.getPropertyValue(name);
		}
	
		else {
			return null;
		}
	}
}

function isHidden(dOb, style, val) {        
	var display = getStyle(dOb, style), parent = dOb.parentNode

	if (display == val) {
		return true
	}
	else if (parent && parent.tagName != 'HTML'){// && parent != document) {
		return isHidden(parent);
	}

	else {
		return false;
	}
}