var detect = navigator.userAgent.toLowerCase();
var lbSearch;
var OS,browser,version,total,thestring;
if (checkIt('konqueror')){
	browser = "Konqueror";
	OS = "Linux";
}
else if (checkIt('safari')) browser = "Safari"
else if (checkIt('omniweb')) browser = "OmniWeb"
else if (checkIt('opera')) browser = "Opera"
else if (checkIt('webtv')) browser = "WebTV";
else if (checkIt('icab')) browser = "iCab"
else if (checkIt('msie')) browser = "Internet Explorer"
else if (!checkIt('compatible')){
	browser = "Netscape Navigator"
	version = detect.charAt(8); 
	
	if(checkIt('netscape')) {
		x=false;
		y=0;
		thisversion = "";
		while(!x) {
			version = detect.charAt(place+y + thestring.length);
			if(version==";" || version==" " || version=="") x = true;
			else
			{	thisversion = thisversion+version
				y=y+1;
			}
		}
		version= thisversion;
	}
	
	
}
else browser = "An unknown browser";

if (!version){
	x=false;
	y=0;
	thisversion = "";
	while(!x){
		version = detect.charAt(place+y + thestring.length);
		if(version==";" || version==" " || version=="") x = true;
		else
		{	thisversion = thisversion+version
			y=y+1;
		}
	}
	version= thisversion;
}

if (!OS){
	if (checkIt('linux')) OS = "Linux";
	else if (checkIt('x11')) OS = "Unix";
	else if (checkIt('mac')) OS = "Mac"
	else if (checkIt('win')) OS = "Windows"
	else OS = "an unknown operating system";
}

function checkIt(string){
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}

function resetGrid () { }
function setupGrid () { }


/* PULLDOWN */
/* CSS-names */
/*
    #seoPulldownContainer
    .seoPulldown
    .seoPulldownCurrent
    
*/

var pulldownHeight = 410; 
var pulldownCurrent = null;
var hidePulldownContainer = document.forms[0];
var el = null;

function pullDownOpen(theElement,container)
{   hidePulldownContainer = document.getElementById(container);
    if(pulldownCurrent!=null) { 
        if(theElement==pulldownCurrent)
        {
            pullDownClose(false); 
            return false;
        }
        else
        {
            pullDownClose(false); 
        }

    }

    pulldownCurrent = theElement;
    pulldownHeight2 = pulldownHeight + 21; 
   
    if(document.getElementById(theElement)!=null)
    {
        el = document.getElementById(theElement);
        
        if(el.style.height!='' && el.style.height!='18px') { pullDownClose(false);return;  }
        
        for (i=0; i<el.childNodes.length; i++) {
	        node = el.childNodes[i];
	        if (node.nodeName=="UL") { 
                theUL = node;
                theUL.style.overflowY = "scroll";
	        }
        }
        el.style.zIndex = '999';
        if(browser=="Internet Explorer") hidePulldownContainer.className += "";
        if(browser=="Internet Explorer" && version=="6.0")   hidePulldownContainer.className += " pullDownOpen";
        
        if(window.opera)
        {  el.style.height = 'auto';  }
        else
        {  if(theUL.offsetHeight<pulldownHeight2) { el.style.height = 'auto'; theUL.style.overflowX = 'hidden';theUL.style.overflowY = 'auto'; }
           else  { el.style.height = pulldownHeight2+'px';  theUL.style.height = pulldownHeight+'px';}
        }
   }
}

function pullDownClose(e)
{  
    if(e!=false)
    {   
        e = e || window.event;
        var obj = e.target || e.srcElement;
        
        theClass = obj.className;
        
        theClass = theClass.toLowerCase();
        
    }
    else theClass = "";
    
    if(theClass.indexOf("seopulldowncurrent") < 0 && document.getElementById(pulldownCurrent)!=null)
    {   
        el = document.getElementById(pulldownCurrent);
       
        el.style.height = '18px'; 
        el.style.overflow = 'hidden';
        el.style.zIndex = '1';

        for (i=0; i<el.childNodes.length; i++) {
	        node = el.childNodes[i];
	        if (node.nodeName=="UL") { 
                theUL = node;	
                if(browser!="Internet Explorer") theUL.style.overflow = "hidden";    
	        }    
        }        
        
        pulldownCurrent = null;
        
        if(browser=="Internet Explorer" && version=="6.0")  hidePulldownContainer.className = hidePulldownContainer.className.replace(" pullDownOpen", "");
    }
}

function pulldownSelect(theText,currentEl,thisEl)
{
    if(document.getElementById('seoPulldownSelected')!=null) 
    {
        if(document.getElementById('seoPulldownSelected').className.indexOf("seopulldowncurrent") > -1)
        {
            document.getElementById('seoPulldownSelected').className.replace("seoPulldownSelected", "");
        }
        document.getElementById('seoPulldownSelected').className = "";
        document.getElementById('seoPulldownSelected').id = "";
        
    }

    
    if(document.getElementById(currentEl)!=null)
    {
        curEl = document.getElementById(currentEl);
        curEl.innerHTML = theText;
        thisEl.className += " seoPulldownSelected";
        thisEl.id = "seoPulldownSelected";

    }
}

function pulldownSelectAccommodation(theText,currentEl,thisEl,accommodationNumberOfPersons)
{
	if(accommodationNumberOfPersons != null)
	{
		//alert('setCookie accommodationNumberOfPersons');
		setCookie('accommodationNumberOfPersons', accommodationNumberOfPersons);
	}

    if(document.getElementById('seoPulldownSelected')!=null) 
    {
        if(document.getElementById('seoPulldownSelected').className.indexOf("seopulldowncurrent") > -1)
        {
            document.getElementById('seoPulldownSelected').className.replace("seoPulldownSelected", "");
        }
        document.getElementById('seoPulldownSelected').className = "";
        document.getElementById('seoPulldownSelected').id = "";
        
    }

    
    if(document.getElementById(currentEl)!=null)
    {
        curEl = document.getElementById(currentEl);
        curEl.innerHTML = theText;
        thisEl.className += " seoPulldownSelected";
        thisEl.id = "seoPulldownSelected";

    }
}
 
/* PULLDOWN end */


function initTabs() 
{   if($('content').select(".tabNav")==null) return   
    tabContainers = $('content').select(".tabNav");
    for (tc=0;tc<tabContainers.length;tc++)
    {   activeTab=0;
        tabsObj = tabContainers[tc].select('.tabNavTabs>ul>li>a');
        
        for (i=0;i<tabsObj.length;i++)
        {   
            Event.observe(tabsObj[i], 'click', function (event) { 
                if(event.element().hasClassName("tabActive")==false)
                {   
                
                    thisTabObjArray = event.element().ancestors();
                    for (k=0;k<thisTabObjArray.length;k++)
                    {
                        if(thisTabObjArray[k].className=='tabNav')
                            thisTabObj = thisTabObjArray[k];
                        
                    }
                    if(thisTabObj==null) return;
                    
                    el = thisTabObj.select('.tabNavTabs>ul>li>a');
                    for (j=0;j<el.length;j++)
                    {
                        if(el[j].className=="tabActive")  
                            el[j].removeClassName('tabActive');
                    }                      
                    event.element().addClassName("tabActive");
                    for (j=0;j<el.length;j++)
                    { 
                        if(el[j].className=="tabActive")  
                            thisTabObj.select('.tabNavContent>ul>li')[j].addClassName("tabContentActive");
                        else
                            thisTabObj.select('.tabNavContent>ul>li')[j].removeClassName("tabContentActive");
                    }
                
                }
                Event.stop(event);
            });   
            if(tabsObj[i].className=="tabActive") {
                tabsObj[i].removeClassName("tabActive");
                activeTab = i;         
            }
        }
        
        tabsObj[activeTab].simulate('click');
        
    }
}

var currentOnload;
if (window.onload) currentOnload= window.onload;
window.onload=function(){ 
    if(currentOnload)
        currentOnload();
    initTabs();
    //Event.observe(window, 'load', function (){ initTabs(); });
}

function accoFilterHide(hideSelector,effect)
{
    el = $("bungalowtypeFilter").select(hideSelector);
    for (i=0;i<el.length;i++)
    {
        if(el[i].visible()==true)
        {
            if(effect=="hide") el[i].hide() 
            if(effect=="slide") el[i].slideUp() 
            if(effect=="fade") el[i].fade() 
        }
    }
}
function accoFilterUnSelect(hideSelector)
{
    el = $("bungalowtypeFilter").select(hideSelector);
    for (i=0;i<el.length;i++)
    {
        el[i].ancestors()[0].removeClassName("selected");
    }
}

function accoFilterExtraheight(sel)
{
    anchors = sel.select("a");
    for (i=0;i<anchors.length;i++)
    {
        if(anchors[i].getHeight()>24 && anchors[i].hasClassName("extraHeight")==false)
        { anchors[i].addClassName("extraHeight");  }
    }
}

function initAccoFilter()
{   if($('bungalowtypeFilter')==null) return
    filterContainer = $('bungalowtypeFilter');
    filterAnchors = filterContainer.select("a");
    
    accoFilterHide("li.regionsCountry","hide");
    accoFilterHide("li.parcsRegion","hide");
    accoFilterHide("li.accosParc","hide");
    
    for (i=0;i<filterAnchors.length;i++)
    {   
        if(filterAnchors[i].readAttribute('href')=="#")
        {   
        
            Event.observe(filterAnchors[i], 'click', function (event) { 
                elID = event.element().identify();

                if(elID.startsWith('Country') && $("Regions"+elID).visible()!=true)
                {   
                    accoFilterUnSelect("li.country a");
                    accoFilterUnSelect("li.region a");
                    accoFilterUnSelect("li.parc a");
                    accoFilterHide("li.regionsCountry","hide");
                    accoFilterHide("li.parcsRegion","hide");
                    accoFilterHide("li.accosParc","hide");
                    
                    $("bungalowtypeFilterParcs").select(".makeChoice")[0].appear({duration: 0.4});
                    $("bungalowtypeFilterAccos").select(".makeChoice")[0].appear({duration: 0.4});
                    
                    Effect.Appear("Regions"+elID,{duration: 0.4});
                    
                    setTimeout("accoFilterExtraheight($('Regions'+elID))",100);
                    
                }
                
                if(elID.startsWith('Region') && $("Parcs"+elID).visible()!=true)
                {   
                    accoFilterUnSelect("li.region a");
                    accoFilterUnSelect("li.parc a");
                    accoFilterHide("li.parcsRegion","hide");
                    accoFilterHide("li.accosParc","hide");

                    $("bungalowtypeFilterParcs").select(".makeChoice")[0].hide();
                    $("bungalowtypeFilterAccos").select(".makeChoice")[0].appear({duration: 0.4});
                    
                    Effect.Appear("Parcs"+elID,{duration: 0.4});
                    $("Parcs"+elID).show();
                    accoFilterExtraheight($("Parcs"+elID));
                }
                
                if(elID.startsWith('Parc') && $("Accos"+elID).visible()!=true)
                {   
                    accoFilterUnSelect("li.parc a");
                    accoFilterHide("li.accosParc","hide");

                    $("bungalowtypeFilterParcs").select(".makeChoice")[0].hide();
                    $("bungalowtypeFilterAccos").select(".makeChoice")[0].hide();
                    
                    Effect.Appear("Accos"+elID,{duration: 0.4});
                }
                
                $(elID).ancestors()[0].addClassName("selected")
                
                Event.stop(event);
                
            });
        }
    }
    
    if(typeof(filterAnchors[0]) != 'undefined')
		filterAnchors[0].simulate('click');
	
	$("bungalowtypeFilter").select("ul.regions")[0].setStyle({ display : 'block'});
	$("bungalowtypeFilter").select("ul.parcs")[0].setStyle({ display : 'block'});
	$("bungalowtypeFilter").select("ul.accos")[0].setStyle({ display : 'block'});
	
}

var accoFilterOnload;
if (window.onload) accoFilterOnload= window.onload;
window.onload=function(){ 
    if(accoFilterOnload)
        accoFilterOnload();
    initAccoFilter();
    
}

function initFaqCategories() {   
    if($('faqFeedback'))  $('faqFeedbackPlaceholder').setStyle({ display : 'block'});
    if($('faqCategoryList')==null) { return;}
    var faqCatContainer = $('faqCategoryList');

    if($('faqQuestions'))
    { 
        var faqCatAnchors = faqCatContainer.select("a");
        for (i=0;i<faqCatAnchors.length;i++)
        {   
            Event.observe(faqCatAnchors[i], 'click', function (event) { 
                
                filterFaqCats = $('faqQuestions').select(".faqSubCat");
                for (j=0;j<filterFaqCats.length;j++)
                {   
                    filterFaqCats[j].setStyle({ display : 'none'});
                }

                for (j=0;j<faqCatAnchors.length;j++)
                {   
                    faqCatAnchors[j].ancestors()[0].removeClassName("selected");  
                }

                elID = event.element().identify();
                catQuestions =  $(elID+"Questions");
                catQuestions.setStyle({ display : 'block'});
                event.element().ancestors()[0].addClassName("selected");
                
				$(elID+"Questions").scrollTo();
                Event.stop(event);
            });
        }
    }
    if($('faqCatListMore'))
    {
        Event.observe($('faqCatListMore'),'click', function (event) {
            $('otherCategory').setStyle({ display : 'block'});
            $('faqCatListMore').setStyle({ display : 'none'});
            $('faqCatListLess').setStyle({ display : 'block'});
            
            Event.stop(event);
        });
        
        Event.observe($('faqCatListLess'),'click', function (event) {
            $('otherCategory').setStyle({ display : 'none'});
            $('faqCatListMore').setStyle({ display : 'block'});
            $('faqCatListLess').setStyle({ display : 'none'});
            
            Event.stop(event);
        });
    }
    if($('faqCatPanel') && $('faqCategoryList'))
    {   
        faqCatItems = $('faqCatPanel').select('#faqCategoryList .faqCategory');
        faqCatHeaders = $('faqCatPanel').select('#faqCategoryList h4 span');
        
        for (i=0;i<faqCatHeaders.length;i++) {
            Event.observe(faqCatHeaders[i], 'click', function (event) { 

                closeCurrent = false; //var used to detect if the current item is open and clicked. 
                if(event.element().ancestors()[1].hasClassName("currentCategory")) { closeCurrent = true; }
                
                for (j=0;j<faqCatItems.length;j++)
                {   
                    if(faqCatItems[j].hasClassName("currentCategory"))
                    {
                        Effect.SlideUp(faqCatItems[j].select(".faqSubCatWrapper")[0], { duration: 0.6 });
                        faqCatItems[j].removeClassName("currentCategory");
                    }                
                    
                } 
                
                if(closeCurrent==true) return;
                
                event.element().ancestors()[1].addClassName("currentCategory");
                
                for (j=0;j<faqCatItems.length;j++)
                {   
                    if(faqCatItems[j].hasClassName("currentCategory"))
                    {
                        Effect.SlideDown(faqCatItems[j].select(".faqSubCatWrapper")[0], { duration: 0.6 });
                    }                
                } 

            });
            
        }
        for (j=0;j<faqCatItems.length;j++)
        {          
            if(!faqCatItems[j].hasClassName("currentCategory"))
            {
                faqCatItems[j].select('.faqSubCatWrapper')[0].setStyle({ display : 'none'});
            }
        }
    }


}

var faqCategoriesOnload;
if (window.onload) faqCategoriesOnload= window.onload;
window.onload=function(){ 
    if(faqCategoriesOnload)
        faqCategoriesOnload();
    initFaqCategories();
}

function openConditionsDIV(event, id) {
    //alert(event.clientY);
    if(id==null) id='conditionsDiv';
    hDiv = $(id).getHeight();
    yDiv = 0;
    if(event.pageY!=null) yDiv = event.pageY;
    if(event.y!=null)     yDiv = event.y;
    
    yDiv = yDiv-hDiv-20;
    if(yDiv<0) yDiv = 0;
    
    $(id).style.top = yDiv+'px';
    $(id).style.display='block';
    
}	


function ganaar_backHTML(content_id) {
  var get_vars = new Array();
  var search = location.search.substr(1);
  search = unescape(search);
  
  var pairs = search.split('&');
  for (var i = 0; i < pairs.length; i++) {
	var items = pairs[i].split('=');
	get_vars[unescape(items[0])] = items[1];
  }
  var strHref = '/template3.aspx?cp=vervolghtml&vervolgid=' + content_id;
  if (get_vars['menu'] != null)
	strHref += '&menu=' + get_vars['menu'] + '&mid=' + get_vars['mid'];
  else
  {
	if (get_vars['mid'] != null)
	{
		strHref += '&mid=' + get_vars['mid'];
	}
  }
  location.href = strHref
}

function ganaar_backHTML(content_id, mid, menu, parkcode) {
  var strHref = '/template3.aspx?cp=vervolghtml&vervolgid=' + content_id;
  if (menu != null)
	strHref += '&menu=' + menu;
  
  if (mid != null)
	strHref += '&mid=' + mid;

  if (parkcode != null)
	strHref += '&parkcode=' + parkcode;
  
  location.href = strHref
}