/**
* init
**/
$(document).ready( function(){
	Website.init();
});


Website.init = function() {    
    
    $.ajaxSetup ({
		cache: false
	});
	
	// jsEnabled class for body
    $(document.body).addClass('jsEnabled');
	
	
	this.initFormCheckFields();
	
	this.setExternalLinks();
	
	this.setLogoutConfirmation();
	
    
};



/**
* Form Check Fields
**/
var aCheckFields;
var iCheckFields;

Website.initFormCheckFields = function() {
	
	// Form check fields
	aCheckFields = $('.swisFormCheck');
	iCheckFields = aCheckFields.length;
	
	if(iCheckFields > 0) {
		$.get(Website.Config.sBaseUrl +'default/index/get-default-form-check-value', null,
		this.fillFormCheckFields);
	}
	
};

Website.fillFormCheckFields = function(sFormCheckValue) {
	
	while (iCheckFields--) {
		if (aCheckFields[iCheckFields].value == '') {
			aCheckFields[iCheckFields].value = sFormCheckValue;
		}
	}
	
};


// Links met rel="external" moeten in een nieuw venster worden geopend
Website.setExternalLinks = function() {
	
	$('a[rel="external"]').click( function() {
	    window.open( jQuery(this).attr('href') );
	    return false;
	});
	
}


// Confirm on logout link
Website.setLogoutConfirmation = function() {
	
	// Als ingelogd is
	if(Website.Config.bLoggedIn) {
		$('a#logoutLink').click( function() {
			jQuery(this).blur();
		    return confirm('Are you sure you want to log out?');
		});
	}
	
}

