/**
 * getPageSize() by quirksmode.com
 *
 * @return Array Return an array with page width, height and window width, height
 */
function ___getPageSize() {
    var xScroll, yScroll;
    if (window.innerHeight && window.scrollMaxY) {
        xScroll = window.innerWidth + window.scrollMaxX;
        yScroll = window.innerHeight + window.scrollMaxY;
    } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
        xScroll = document.body.scrollWidth;
        yScroll = document.body.scrollHeight;
    } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
        xScroll = document.body.offsetWidth;
        yScroll = document.body.offsetHeight;
    }
    var windowWidth, windowHeight;
    if (self.innerHeight) {	// all except Explorer
        if(document.documentElement.clientWidth){
            windowWidth = document.documentElement.clientWidth;
        } else {
            windowWidth = self.innerWidth;
        }
        windowHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
        windowWidth = document.documentElement.clientWidth;
        windowHeight = document.documentElement.clientHeight;
    } else if (document.body) { // other Explorers
        windowWidth = document.body.clientWidth;
        windowHeight = document.body.clientHeight;
    }
    // for small pages with total height less then height of the viewport
    if(yScroll < windowHeight){
        pageHeight = windowHeight;
    } else {
        pageHeight = yScroll;
    }
    // for small pages with total width less then width of the viewport
    if(xScroll < windowWidth){
        pageWidth = xScroll;
    } else {
        pageWidth = windowWidth;
    }
    arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
    return arrayPageSize;
}

jQuery.noConflict();
jQuery(document).ready(function(){	
	
	jQuery("#slider").easySlider({
		auto: true,
		continuous: true 
	});
	
	//gives the main nav the class "first"
	jQuery(".sf-menu > li").each(function(){
		jQuery(this).addClass("first");
	});
	
	//removes separator on last subnav item
	jQuery(".sf-menu li ul li:last-child").addClass("no-sep");
	
	//cufon
	Cufon.replace('.sf-menu li span.separator', {
		fontFamily: 'Arial'
	});
        
//        Cufon.replace('#slider li a', {
//		fontFamily: 'Arial'
//	});
	
	Cufon.replace('.sf-menu li a', {
		fontFamily: 'Arial'
	});
	
	Cufon.replace('#subnav li a', {
		fontFamily: 'Arial'
	});
	
	Cufon.replace('#subnav li span.separator', {
		fontFamily: 'Arial'
	});
	
	jQuery('#content .contentheading').addClass('heading');
	jQuery('#content .componentheading').addClass('heading');
	jQuery('#content .blog .contentheading').removeClass('heading');
	
	Cufon.replace('#content .contentheading.heading', {
		fontFamily: 'Arial'			  
	});
	
	Cufon.replace('#content .componentheading.heading', {
		fontFamily: 'Arial'			  
	});
	
	Cufon.replace('#footer_nav h3',  {
		fonFamily: 'Arial'
	});
	
	Cufon.replace('#voordelen_container_cat .componentheading.heading',  {
		fonFamily: 'GeosansLight'
	})
	
	Cufon.replace('#voordelen_container .componentheading.aanmelden.heading',  {
		fonFamily: 'GeosansLight'
	})
	
	Cufon.replace('#voordelen_container.success h1.componentheading.heading',  {
		fonFamily: 'GeosansLight'
	})
	
	Cufon.replace('.download_container h2',  {
		fonFamily: 'GeosansLight'
	})
	
	Cufon.replace('.download_container a',  {
		fonFamily: 'GeosansLight'
	})
	
	jQuery('.item75').hide();
	
	//navigation color
	jQuery('.item6').hover(function(){
		jQuery('#nav').css('background', 'none');
		jQuery('#nav').css('background-color', '#EBAB00');
	},function(){
		 jQuery('#nav').css('background', 'none');
		 jQuery('#nav').css({
							'background-image': 'url("http://www.assuria.sr/staging/templates/ass_voordelen/gfx/nav_bg.png")',
							'backgroundPosition': '0 100%'
						});
	});
	
	jQuery('.item7').hover(function(){
		jQuery('#nav').css('background', 'none');
		jQuery('#nav').css('background-color', '#468612');
	},function(){
		 jQuery('#nav').css('background', 'none');
		 jQuery('#nav').css({
							'background-image': 'url("http://www.assuria.sr/staging/templates/ass_voordelen/gfx/nav_bg.png")',
							'backgroundPosition': '0 100%'
						});
	});
	
	jQuery('.item12').hover(function(){
		jQuery('#nav').css('background', 'none');
		jQuery('#nav').css('background-color', '#E31B2E');
	},function(){
		 jQuery('#nav').css('background', 'none');
		 jQuery('#nav').css({
							'background-image': 'url("http://www.assuria.sr/staging/templates/ass_voordelen/gfx/nav_bg.png")',
							'backgroundPosition': '0 100%'
						});
	});
	
	jQuery('.item13').hover(function(){
		jQuery('#nav').css('background', 'none');
		jQuery('#nav').css('background-color', '#EBAB00');
	},function(){
		 jQuery('#nav').css('background', 'none');
		 jQuery('#nav').css({
							'background-image': 'url("http://www.assuria.sr/staging/templates/ass_voordelen/gfx/nav_bg.png")',
							'backgroundPosition': '0 100%'
						});;
	});
	
	jQuery('.item14').hover(function(){
		jQuery('#nav').css('background', 'none');
		jQuery('#nav').css('background-color', '#E31B2E');
	},function(){
		 jQuery('#nav').css('background', 'none');
		 jQuery('#nav').css({
							'background-image': 'url("http://www.assuria.sr/staging/templates/ass_voordelen/gfx/nav_bg.png")',
							'backgroundPosition': '0 100%'
						});
	});
	
	jQuery('.item15').hover(function(){
		jQuery('#nav').css('background', 'none');
		jQuery('#nav').css('background-color', '#468612');
	},function(){
		 jQuery('#nav').css('background', 'none');
		 jQuery('#nav').css({
							'background-image': 'url("http://www.assuria.sr/staging/templates/ass_voordelen/gfx/nav_bg.png")',
							'backgroundPosition': '0 100%'
						});
	});
	
	/*jQuery('.item148').hover(function(){
		jQuery('#nav').css('background', 'none');
		jQuery('#nav').css('background-color', '#E31B2E');
	},function(){
		 jQuery('#nav').css('background', 'none');
		 jQuery('#nav').css({
							'background-image': 'url("http://localhost/assuria_consumer_website/trunk/src/main/webapp/templates/ass_voordelen/gfx/nav_bg.png")',
							'backgroundPosition': '0 100%'
						});
	});*/
	
	jQuery('#sidebar ul li:first-child').addClass('sidebar_first');
	
	
	
	//openWoonhertax()
	jQuery("a").each(function(){
		
		var href = jQuery(this).attr("href");
		if(href == "#advies"){
			jQuery(this).click(function(){
				openWoonhertax();							
			});
		}
		
	});
	
	//register kliks to facebook from the site
	jQuery("#facebook a").click(function(){
		pageTracker._trackPageview("/facebook.html");
		return true;
	});
	
	//faq
	jQuery("#accordion div").hide().addClass("close");
	jQuery("#accordion div:first").show().addClass("open").removeClass("close");
	
	jQuery("#accordion h3").click(function(){
			
			if(jQuery(this).next().hasClass("close")){
				//alert(jQuery(this).parent().html());
				jQuery("#accordion div").removeClass("open").slideUp().addClass("close");
				jQuery(this).next().addClass("open").slideDown().removeClass("close");
			}
			/*jQuery("#accordion div").removeClass("open").slideUp().addClass("close");	
			*/
	});
	//jQuery("#accordion").accordion();



        jQuery("#nextBtn a").fadeTo("slow", 0); // This sets the opacity of the thumbs to fade down to 60% when the page loads

        jQuery("#nextBtn a").hoverIntent(function(){
        jQuery(this).fadeTo("slow", 1.0); // This should set the opacity to 100% on hover
        },function(){
        jQuery(this).fadeTo("slow", 0); // This should set the opacity back to 60% on mouseout
        });

        jQuery("#prevBtn a").fadeTo("slow", 0); // This sets the opacity of the thumbs to fade down to 60% when the page loads

        jQuery("#prevBtn a").hoverIntent(function(){
        jQuery(this).fadeTo("slow", 1.0); // This should set the opacity to 100% on hover
        },function(){
        jQuery(this).fadeTo("slow", 0); // This should set the opacity back to 60% on mouseout
        });


        jQuery("#slider li .title_txt").css({ opacity: 0.5 });
		
		
		// Voordelen scroller
		//jQuery('#thumbcontainer').jparallax({yparallax: false});
		
		//azpas submit
		jQuery('#voordelen_container .aanvraagformulier #submitimage').click(function(){
			jQuery('#aanmeldformulier').submit();																	  
		});

});



//woon her taxatie module
function openWoonhertax(){
	
	pageTracker._trackPageview("/woonhuisverzekering/advies.html"); 
	
	var arrPageSizes = ___getPageSize();
	jQuery('#woonhertax_container').css({opacity: 0.8, width: arrPageSizes[0], height: arrPageSizes[1] + 1}).fadeIn();
	jQuery('#woonhertax_flash').delay(500).css("opacity", "1").fadeIn();
	
	return false;
}

function closeWoonHertax() {
	
	jQuery('#woonhertax_container').fadeOut(500);
	jQuery('#woonhertax_flash').fadeOut(500);
	
	var url = document.location.href;
	url = url.replace("#advies", "");
	
	window.location = url;
}

