/*
 * hoverIntent r6 // 2011.02.26 // jQuery 1.5.1+
 * <http://cherne.net/brian/resources/jquery.hoverIntent.html>
 * 
 * @param  f  onMouseOver function || An object with configuration options
 * @param  g  onMouseOut function  || Nothing (use configuration options object)
 * @author    Brian Cherne brian(at)cherne(dot)net
 */
(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev])}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob)},cfg.interval)}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev])};var handleHover=function(e){var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t)}if(e.type=="mouseenter"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob)},cfg.interval)}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob)},cfg.timeout)}}};return this.bind('mouseenter',handleHover).bind('mouseleave',handleHover)}})(jQuery);

/*
 * Inline Scripts
 */
$(function() {
	// Direct navigation animation
	$('.directNavigation ul').children('li').hover(function() { $(this).siblings().stop().fadeTo(400,0.5); }, function() { $(this).siblings().stop().fadeTo(400,1); });
	
	// Follow us animation
	$('ul.followusList').children('li').hover(function() { $(this).siblings().stop().fadeTo(400,0.2); }, function() { $(this).siblings().stop().fadeTo(400,1); });

    //rel external
    $('a[rel*=external]').click(function(){window.open(this.href);return false;});
    
    $('.twitterWidgetContent').getTwitter({
    	userName: 'anna_ziekenhuis',
    	numTweets: 1,
    	loaderText: 'Tweet laden...',
    	slideIn: true,
    	slideDuration: 750,
    	showProfileLink: false,
    	showTimestamp: false
    });
    
    var clearMePrevious = '';$('.newsletterInput').focus(function(){if($(this).val()==$(this).attr('title')){clearMePrevious = $(this).val();$(this).val('');}});$('.newsletterInput').blur(function(){if($(this).val()==''){$(this).val(clearMePrevious);}});

    $('.newsActivities').tabs();
    
	/* Small font */
	$('#textSmall').click(function(){
	    $('.introtext, .mainContent').css('font-size','12px');
	    return false;
	});
	/* Normal font */
	$('#textNormal').click(function(){
	    $('.introtext, .mainContent').css('font-size','inherit');
	    return false;
	});
	/* Big font */
	$('#textBig').click(function(){
	    $('.introtext, .mainContent').css('font-size','16px');
	    return false;
	});
    
    //cookie set homepage accordion
    jQuery.cookie=function(a,b,c){if(typeof b!="undefined"){c=c||{};if(b===null){b="";c.expires=-1}var d="";if(c.expires&&(typeof c.expires=="number"||c.expires.toUTCString)){var e;if(typeof c.expires=="number"){e=new Date;e.setTime(e.getTime()+c.expires*24*60*60*1e3)}else{e=c.expires}d="; expires="+e.toUTCString()}var f=c.path?"; path="+c.path:"";var g=c.domain?"; domain="+c.domain:"";var h=c.secure?"; secure":"";document.cookie=[a,"=",encodeURIComponent(b),d,f,g,h].join("")}else{var i=null;if(document.cookie&&document.cookie!=""){var j=document.cookie.split(";");for(var k=0;k<j.length;k++){var l=jQuery.trim(j[k]);if(l.substring(0,a.length+1)==a+"="){i=decodeURIComponent(l.substring(a.length+1));break}}}return i}}
    $("#activitytrigger").click(function(){$.cookie("home_accordion","activity")});$("#newstrigger").click(function(){$.cookie("home_accordion","news")});if($.cookie("home_accordion")!=undefined){if($.cookie("home_accordion")=="activity"){$("#activitytrigger").click()}}
    
    /*
    $('.tooltip').qtip({
      // Simply use an HTML img tag within the HTML string
     // alert($(this).html());
     
     //alert($(this).html());
      content: '<img src="'+$(this).find('img').attr('src')+'"/>' 
   });
   */
   
   // Notice the use of the each method to gain access to each element individually
    $('.tooltip').each(function()
    {
        //alert($(this).find('img').attr('src'));
        
        thumbnail = $('<img />').attr({
            src: $(this).attr('href'),
            alt: 'Loading thumbnail...',
            width: 220
        });
        
        $(this).qtip(
        {
            content: thumbnail,
            position: {
                corner: {
                    tooltip: 'bottomLeft',
                    target: 'topRight'
                }
            }
     
        });   
        
    });
    
    $('.tooltip').click(function(){
        $(this).parent().find('input:radio').attr('checked','checked');
        return false;
    });

});
