// gebruik $j als jquery variabele zodat deze niet conflicteerd met de scripts uit de smartsite formulieren generator
var $j = jQuery.noConflict();  

// home - laat images zien bij hover over de visual
function hoverhome(what){
   $j(what).css({opacity:"0",display:"block"});
   $j(what).hover(function(){
      if ((jQuery.browser.msie)&&(parseInt(jQuery.browser.version)<7)) {
           $j(this).css({opacity:"1"}).addClass("hover");
      } else {   
         $j(this).animate({opacity:"1"},'fast').addClass("hover");
      }
   }, function(){
         if ((jQuery.browser.msie)&&(parseInt(jQuery.browser.version)<7)) {
              $j(this).not('.active', this).css({opacity:"0"}).removeClass("hover");
         } else {   
            $j(this).not('.active', this).animate({opacity:"0"},'fast').removeClass("hover");
         }
   });
}

// home - geef de visuals de clickfunctie om de textbox uit te schuiven
function initclicks(visual,textbox,closevisual,closetextbox){
   // verwijder andere clickevents
   $j(visual).unbind('click').click(function(){
      openhome(visual,textbox,closevisual,closetextbox);
   });
   
}

// home - schuif de textbox uit
function openhome(visual,textbox,closevisual,closetextbox){
   var h = $j('#kolomwrapper').height() + 30;
   //sluit de andere textbox
   closehome(closevisual,closetextbox);
   // geef de andere visual de initiele clickfunctie terug
   initclicks(closevisual,closetextbox,visual,textbox);
   $j(textbox).animate({height:h});
   // geef de visual een nieuwe clickfunctie om te sluiten
   $j(visual).addClass('active').css({opacity:"1"}).unbind('click').click(function(){
      closehome(visual,textbox);
      initclicks(visual,textbox,closevisual,closetextbox);
   });
}

// home - schuif de textbox in
function closehome(visual,textbox){
   $j(textbox).animate({height:'0px'});
   if ((jQuery.browser.msie)&&(parseInt(jQuery.browser.version)<7)) {
        $j(visual).css({opacity:"0"}).removeClass('active').removeClass('hover');
   } else {   
      $j(visual).animate({opacity:"0"}).removeClass('hover').removeClass('active');
   }
}

function closefunctions(){
      closehome('#visual_left','#wathebik');
      closehome('#visual_right','#watdoetaltrecht');
      initclicks('#visual_left','#wathebik','#visual_right','#watdoetaltrecht');
      initclicks('#visual_right','#watdoetaltrecht','#visual_left','#wathebik');   
}

$j(document).ready(function(){

   var img = Math.ceil(Math.random() * 10);
   $j("#home_visual").css({background: "url(/images/Home_visual"+img+".gif)"});

   // home
   hoverhome('#visual_left');
   hoverhome('#visual_right');
   initclicks('#visual_left','#wathebik','#visual_right','#watdoetaltrecht');
   initclicks('#visual_right','#watdoetaltrecht','#visual_left','#wathebik');
   
   
   
   // home - sluit de textboxen als men op ... klikt
   $j('.home #spottabs a').click(function(){     closefunctions();  });
   $j('#kolomwrapper').click(function(){         closefunctions();  });
   $j('#footer').click(function(){         closefunctions();  });
   
   
  // home - clickfunctie voor de spotlight-tabs
  $j("#spottabs td a").click(function(){
      $j("#spottabs td.active").removeClass('active');
      $j(this).parent().addClass('active').blur();
      var ajaxurl = $j(this).attr('href');
      $j("#spotlight .fade").load(ajaxurl);
      return false;
  });
  
});   