$(window).bind("load", function() { 
                
/* Selectedlist */ 
  if ($('.block-newslist .molist-selected ul li:nth-child(1)').length > 0) {
    $('.block-newslist .molist-selected ul li:nth-child(1)').delay(500).fadeIn(500);
    $('.block-newslist .molist-selected ul li:nth-child(2)').delay(1500).fadeIn(500);
    $('.block-newslist .molist-selected ul li:nth-child(3)').delay(1750).fadeIn(500);
    $('.block-newslist .molist-selected ul li:nth-child(4)').delay(3000).fadeIn(500);
    $('.block-loadingflash .top').delay(3500).fadeIn(500);
  }
  
/* Newsflash  

  var items = $('.block-newsflash ul').children().size(); 
  var current = 1;
  for(i=0;i<items;i++) {
    if($('.block-newsflash ul li:nth-child('+i+')').height()<30){
      $('.block-newsflash ul li:nth-child('+i+')').css({'margin-top':'10px'});
    }
  }
  $('.block-newsflash ul li:nth-child('+current+')').show().delay(5500).fadeOut(500);
  $('.block-newsflash ul li:nth-child('+current+')').everyTime(6000,function (){ 
    current = current+1;
    if(current>items){
      current = 1;
    }
    $('.block-newsflash ul li:nth-child('+current+')').fadeIn(500).delay(5000).fadeOut(500);
  });
  
*/
  
});

$(document).ready(function(){ 
  
  // move the quote content to the first paragraph    
  if ($('#quotecontent').length != 0 && $('#tab-content .paragraph-default:first .top').length != 0) {
    $('#quotecontent').insertBefore('#tab-content .paragraph-default:first .top');
    $('#quotecontent').show();
  }

/* Download lightbox */        
  $('.download').click(function(e) {   
    var c = $.cookie('gxInfo');
    var userid = $.cookie('_gxt_id');
    var campaignId = '';
    if ($(this).find("div.campaignIdDiv").length > 0){
    	campaignId = $(this).find("div.campaignIdDiv").html();
    }
    var authUrl = $(this).data('lightboxurl'); 
    var downloadUrl = ''; 
    var downloadTitle = '';    
    
    if ($(this).children('a').length > 0) {    
        // When the click is binded on the parent of the ahref
      downloadUrl = $(this).children('a:first').attr('href');
      downloadTitle  = $(this).children('a:first').attr('title');
    } else {
      // When the click is binded to the a href itself
      downloadUrl = $(this).attr('href');
      downloadTitle  = $(this).attr('href').attr('title');
    }    
    
    // No authorization url defined, continue with the download
    if (authUrl === null || authUrl == '' || typeof authUrl == 'undefined') {
      //document.location.href = downloadUrl;
      
    // we have enough information about the client
    } else if (typeof c != 'undefined' && c != '' && c != 'null' && c != null) {
      //document.location.href = downloadUrl;
      
    // show lightbox with a request for extra information
    } else {
      e.preventDefault();
      
      // show the lightbox with the form
      $.fn.nyroModalManual({
    	  wrap: { // Wrapper div used to style the modal regarding the content type
    	    div: '<div class="jqmWindow" id="lbx"></div>',
    	    ajax: '<div class="jqmWindow" id="lbx"></div>',
    	    form: '<div class="jqmWindow" id="lbx"></div>',
    	    formData: '<div class="jqmWindow" id="lbx"></div>',
    	    image: '<div class="jqmWindow" id="lbx"></div>',
    	    swf: '<div class="jqmWindow" id="lbx"></div>',
    	    iframe: '<div class="jqmWindow" id="lbx"></div>',
    		iframeForm: '<div class="jqmWindow" id="lbx"></div>',
    	    manual: '<div class="jqmWindow" id="lbx"></div>'
    	  },

  		showBackground: function (elts, settings, callback) {
  			elts.bg.css({opacity:0}).fadeTo(500, 0.5, callback);
  		},
    	      	  
        bgColor: '#000000',
        minHeight: 450, 
        width: 645,
        url: authUrl,
        endShowContent: function(settings) {
        // Set clientside routing
        $('#nyroModalWrapper #clientsideRouting').val('false');
        // Bind the submit button
        // 26-05-2010 - these functions seem to be missing and break the
        // downloadform in IE.
        //initialHide();       
        //addChangeEvent();
        //addOnSubmitEvent();
        $(".wmpform").submit(function(event) {
          
          // If the event was prevented this is an indication that the form has clientside errors.
          // When their are clientside errors we don't continue.
          if (event.isDefaultPrevented()) {           
            return;
          }
          
          //  event.preventDefault(); // Prevent the default submit                    

          // Perform the validations for emailadress (inputfield has id wmtext_email_address)
          obj = document.getElementById('wmtext_email_address');
      
          if (typeof obj != 'undefined') {
            var email = document.getElementById('wmtext_email_address').value;
            
            // check if email is not empty
            if (email == null || email == '') {
              obj_commentsdiv = document.getElementById('error_email_address');

              // show error in div if div exists else alert
              if (typeof obj_commentsdiv != 'undefined') {
                obj_commentsdiv.style.display = 'block';
                obj_commentsdiv.innerHTML = dlErrorEmailEmpty;        
              } else {
                alert("" + dlErrorEmailEmpty);              
              }
              
              document.getElementById('wmtext_email_address').focus();
              return false;
            } else {
              // reset the errorfield to its default values
              obj_commentsdiv = document.getElementById('error_email_address');
              if (typeof obj_commentsdiv != 'undefined') {
                obj_commentsdiv.innerHTML = '';              
                obj_commentsdiv.style.display = 'none';
              }
            }  

            // check if email has valid format
            var myExpression = /^[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/;
            if(!myExpression.test(email)) {
              obj_commentsdiv = document.getElementById('error_email_address');

              // show error in div if div exists else alert
              if (typeof obj_commentsdiv != 'undefined') {
                obj_commentsdiv.style.display = 'block';
                obj_commentsdiv.innerHTML = dlErrorEmailNotValid;        
              } else {
                alert("" + dlErrorEmailNotValid);              
              }
             
              document.getElementById('wmtext_email_address').focus();
              return false;
            } else {
              // reset the errorfield to its default values
              obj_commentsdiv = document.getElementById('error_email_address');
              if (typeof obj_commentsdiv != 'undefined') {
                obj_commentsdiv.innerHTML = '';              
                obj_commentsdiv.style.display = 'none';
              }
            } 
          } 

          // Put the profileid in the hidden field profileid.                
          if ($('#wmtext_profileiddownload').length > 0) {            
            $('#wmtext_profileiddownload').val(userid);
          }

          if ($('#wmtext_titledownload').length > 0) {
            $('#wmtext_titledownload').val(downloadTitle);
          }

          if ($('#wmtext_gxdownloadurl').length > 0) {
            $('#wmtext_gxdownloadurl').val(downloadUrl);
          }
          
          if ($('#wmtext_campaignid').length > 0) {
              $('#wmtext_campaignid').val(campaignId);
          }          
          
          pageTracker._trackEvent('Downloads', 'PDF', '' + downloadTitle);          
          
          $.nyroModalRemove();                    
          
          // This is the old Ajax based submit
          /*          
          $(this).ajaxSubmit({
            dataType:'json',
            error: function() {
              // alert('Er is een onbekende fout opgetreden');
              document.location.href = downloadUrl;
            },
            success: function(data) {
              if (data.routingResult.hasErrors == 'true') {
                // Do nothing, errors are shown
              } else {                
                alert("Succes");
                $.nyroModalRemove();          
                //document.location.href = downloadUrl;
              }
            }
          });
          */
          
        });
        }
      });
      return false;
    }

  });


/* Menu */        

  $('ul.sf-menu').superfish({ 
    delay:       0,
    animation:   {height:'show'},
    speed:       0,
    autoArrows:  false 
  }); 
  
/* Toggle */  

  $('.block-toggle .title a').toggle(
      function () {
    $(this).css({'background-image':'url(/static/gxmmxcorppresentation/_images/navigation/button_minus.gif)'});
    $(this).parent().next('.block-togglecontent').css({'display':'none','position':'relative','left':'0px'});
      },
      function () {
        $(this).css({'background-image':'url(/static/gxmmxcorppresentation/_images/navigation/button_plus.gif)'});
      }
    );
  $('.block-toggle .title a').click(function () {
    $(this).parent().next('.block-togglecontent').slideToggle('slow');
  });
  
/* Newsflash */
               
if($('.block-newsflash ul li').height()<30){
      $('.block-newsflash ul li a').css({'margin-top':'10px'});
}
$('.block-newsflash ul li a').css({'visibility':'visible'});

/* Call me back */  

  $('.block-callmeback-text a').click(function () {
    $('.image-out').toggle();
    $('.image-in').toggle();
    var $marginLefty = $('.form-callmeback');
    $marginLefty.animate({marginLeft: parseInt($marginLefty.css('marginLeft'),0) == 0 ? -$marginLefty.outerWidth() : 0});
    $('.block-callmeback-form .formtextbox-default input').focus();
  });
  $('.image-out a').click(function () {
    $('.image-out').hide();
    $('.image-in').show();
    var $marginLefty = $('.form-callmeback');
    $marginLefty.animate({marginLeft: parseInt($marginLefty.css('marginLeft'),0) == 0 ? -$marginLefty.outerWidth() : 0});
    $('.block-callmeback-form .formtextbox-default input').focus();
  });
  $('.image-in a').click(function () {
    $('.image-out').show();
    $('.image-in').hide();
    var $marginLefty = $('.form-callmeback');
    $marginLefty.animate({marginLeft: parseInt($marginLefty.css('marginLeft'),0) == 0 ? -$marginLefty.outerWidth() : 0});
  });
  
  // move facet search to the right
  $('#divsearchbycategory').appendTo($('#facetinfoRight'));
  
});


var client_1;
var client_2;
var client_3;
var client_4;
var client_5;
var traffic;
var content;
var conversie;

function flashCallback(identifier) {

}

// For being backwards compatible
function getCookie(name) {
  return getMyCookie(name);
}

