var IE = document.all?true:false
var timeoutYoutube = ''

//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) {
		var a = arr.split(',')
		for(i=0;i<a.length;i++){
			document.getElementById(a[i]).style.display='none'
			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'
	}
	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() {
}

function check(id,type) {
	var obj = document.getElementById('check'+id)
	if(!type) type=''
	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('',type)
		updatePriceOfferte()
		doNotExpand=true
	}
	document.location.href='default.asp'
}

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('aantalgasten').value = '';
		}else{

			if (aantal != 2) {
				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);
		}
	}
	/*
	if (
		( (document.getElementById('contAantalgasten')) && (document.getElementById('contAantalgasten').style.display == 'none') )
		|| ( (document.getElementById('offerte_content')) && (document.getElementById('offerte_content').style.display == 'none') )
	) {
		if(fcs){
			updatePrice(aantal,opties,optioneel,true,isOptionsPage);
		}else{
			updatePrice(aantal,opties,optioneel,false,isOptionsPage);
		}
	}
	*/
}


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.'
				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('flash/kaart.swf?id='+id,140,160)
	if(document.getElementById('srch_kaart')) document.getElementById('srch_kaart').innerHTML = updateFlash('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(absurl + '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(absurl + '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(absurl + '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) {
}

function changeNewsTabs() {
	id = 'newsImage';
	if ( document.getElementById('newslist').style.display == 'none' ) {
		document.getElementById(id).src = 'img/bt_tab_nieuwsbrief.gif';
		document.getElementById(id).alt = 'meld je aan voor de nieuwsbrief';
	}
	else {
		document.getElementById(id).src = 'img/bt_tab_nieuws.gif';
		document.getElementById(id).alt = 'test';
		document.getElementById(id).alt = 'terug naar nieuwsoverzicht';
	}

}

function openSearch() {
	GB_showCenter('Zoekresultaten', '/search.asp?searchfor='+document.getElementById('searchfor').value, /* optional */ 500, 500)
}

function openOverlay(title,url) {
	GB_showCenter(title, url, /* optional */ 200, 250)
}




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) {
	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);
}
