/*
  general functions
*/
var aPopups = new Array();
var aModalPopups = new Array();

window.onfocus = function(){
	if(aModalPopups.length != 0){
		aModalPopups[0].focus();
	}
}

var sDefaultFeatures = 'channelmode=0, fullscreen=0, location=0, menubar=0, resizable=0, scrollbars=0, status=0, titlebar=0, toolbar=0';

// create popup
function createPopup(sURL, name, sFeatures, iWidth, iHeight){
	var iLeft	= (screen.availWidth - iWidth) / 2;
	var iTop	= (screen.availHeight - iHeight) / 2;
	
	return window.open(sURL, name, sFeatures + ', width=' + iWidth + ', height=' + iHeight + ', left=' + iLeft + ', top=' + iTop);
}

function getCookie(sName){
	var aCookie = document.cookie.split("; ");
	
	for (var i=0; i < aCookie.length; i++){
		var aCrumb = aCookie[i].split("=");
		if (sName == aCrumb[0]){
			return unescape(aCrumb[1]);
		}
	}
	
	return null;
}
 /*
  getElementsByClassName	
*/
document.getElementsByClassName = function (needle){
    var s = [document.documentElement || document.body], i = 0, r = [], l = 0, e;
    var re = new RegExp('(^|\\s)' + needle + '(\\s|$)');

    do{
        e = s[i];

        while (e){
            if (e.nodeType == 1){
                if (e.className && re.test(e.className)) r[l++] = e;

                s[i++] = e.firstChild;
            }

            e = e.nextSibling;
        }
    }
	
    while (i--);

    return r;
} /*
  handleBodyLoad
*/
function handleBodyLoad(){

 /* if(window.self == window.top){
    window.open('/start.cfm?path=' + window.location.href, '_self');
  } */

  initStyle();
  redirectbeachevent();
  handleNewsLetterService();

} /*
  handleNewsLetterService
*/

function handleNewsLetterService(){
  if(!document.getElementById('newsLetterServiceEmailAddress')) return;

  var emailAddress = document.getElementById('newsLetterServiceEmailAddress');
  var emailAddressValue = emailAddress.value;

  emailAddress.onfocus = function(){
    if(this.value.length > 0) this.value = '';
  }
  emailAddress.onblur = function(){
    if(this.value.length == 0) this.value = emailAddressValue;
  }
} function redirectbeachevent() {
  var link = document.getElementsByClassName('d1157')[0].getElementsByTagName('a')[0];
  link.href = "http://beachevent.com/nl-nl/home";
  link.target = '_self';
} /*
  styleSwitch
*/
function initStyle(){
	document.getElementsByTagName('body')[0].style.marginTop = ((parseInt(document.documentElement.offsetHeight) - 630) / 2) + 'px';
	
	
	if(getCookie('styleSwitch') == null){
		document.getElementsByTagName('body')[0].className = 'angels';
	}else{
		if(getCookie('styleSwitch') == 'angels'){
			document.getElementsByTagName('body')[0].className = 'angels';
		}else{
			document.getElementsByTagName('body')[0].className = 'rough';
		}
	}
}

function switchStyle(className){
	switch(className){
		case 'angels':
			document.getElementsByTagName('body')[0].className = 'angels';
			document.cookie = 'styleSwitch=angels; path=/nl-nl/';
			break;
		
		case 'rough':
			document.getElementsByTagName('body')[0].className = 'rough';
			document.cookie = 'styleSwitch=rough; path=/nl-nl/';
			break;
	}
}
