var SWIS = {

    /**
     *  @desc start function, wordt altijd uitgevoerd
     *
     */
    start: function(){
        SWIS.pageHit();
    },

    /**
     *  @desc pageHit: statistieken
     *
     */
    pageHit: function(){
        p = escape(document.location.href);
        rfr = escape(document.referrer);
        if (rfr == "undefined"){ rfr = "";}
        sx = screen.width;
        sy = screen.height;
        sc = (navigator.appName.indexOf("Microsoft") > -1) ? screen.colorDepth : screen.pixelDepth;
        src = 'stats.php?p=' + p + '&rfr=' + rfr + '&sx=' + sx + '&sy=' + sy + '&sc=' + sc;
        src = '<img style="position:absolute;left:-10px;top:-10px;" src="' + src + '" width="1" height="1" border="0" alt="" />';
        document.getElementById('counter').innerHTML = src;
    }

}


// jQuery functies
$(document).ready(function () {

    // statistieken
    SWIS.start();

	// stylesheet switcher
	$('.styleswitch').click(function(event){
		event.preventDefault();
		switchStylestyle(this.getAttribute("rel"));
		//return false;
	});
	var c = readCookie('style');
	if (c) switchStylestyle(c);

	// Hoogte van de site oprekken tot minimaal browser grootte
	siteHeight();

    //Cufon font replacement
    Cufon.replace('h1');

    //slideshow op homepage beginnen
    if ($('.partner_slideshow .slides').length > 0) {
        $('.partner_slideshow .slides').cycle({
            fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
            timeout: 5000,
            containerResize: 0,
            before: zetSlideshowNaam
        });
    }

});

function zetSlideshowNaam(currSlideElement, nextSlideElement, options, forwardFlag) {

    $('.partner_slideshow span.titel a').html($(nextSlideElement).find('img').attr('alt'));
    $('.partner_slideshow span.titel a').attr('href', $(nextSlideElement).attr('href'));


}

/**
* Styleswitch stylesheet switcher built on jQuery
* Under an Attribution, Share Alike License
* By Kelvin Luck ( http://www.kelvinluck.com/ )
**/
function switchStylestyle(styleName){
	$('link[@rel*=style][title]').each(function(i){
		this.disabled = true;
		if (this.getAttribute('title') == styleName) this.disabled = false;
	});
	createCookie('style', styleName, 365);
}


// Hoogte van de site oprekken tot minimaal browser grootte
function siteHeight(){
	if(jQuery.browser.msie){
		iWindowHeight = document.documentElement.clientHeight;
	} else {
		iWindowHeight = window.innerHeight;
	}
	iSiteHeight = $('#header').height() + $('#contentWrap').height() + $('#footer').height();

	if(iSiteHeight < iWindowHeight){
		iDifference = iWindowHeight - iSiteHeight;

		// Let op: in ie6 wordt de iContentHeight niet goed ingesteld (2 pixels...)
		iContentHeight = $('#contentWrap').height() + iDifference;
		$('#contentWrap').css('height',iContentHeight+'px');

		// ranzige hack voor ie: bij het resizen van #contentWrap, wordt de tekst van de footer niet op de juiste plek gezet. Door opnieuw de style sheet in te laden wordt dit verholpen.
		if(jQuery.browser.msie){
			var c = readCookie('style');
			if (c) switchStylestyle(c);
			else switchStylestyle('Standaard');
		}
	}
}

// cookie functions http://www.quirksmode.org/js/cookies.html
function createCookie(name,value,days){
	if (days){
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name){
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++){
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name){
	createCookie(name,"",-1);
}



