/* Predefined variables */
$(document).ready(function() {	
	
	/* Lightbox for jQuery */
	$("a[rel=fancybox],a[rel=lightbox]").fancybox();

	// Show/hide Shoes
	$('a[rel=bigshoe]').click(function(){ showShoe($(this).attr('href')) });

  // Show/hide Agents
  $('ul#preselect li a').click(function(){ 
    showAgent($(this).attr('href'))
    $(this).addClass('active');
  });


 $("#previewButton,#preview").addClass('clickable');
 $("#previewButton").click(function(){ showPreview() });
 $("#preview").click(function(){ hidePreview() });


 $("#fairsButton,#fairs .close").addClass('clickable');
 $("#fairsButton").click(function(){ showFairs() });
 $("#fairs .close").click(function(){ hideFairs() });

  // Add extras
  bindRichInteraction();

  // External links in new window
	ExternalLinks();
});


function showPreview()
{		
 $('#preview').css({ 'display':'block', 'opacity':0, 'zIndex': 200 });
	$('#preview').animate({ opacity: 100	},1000, function(){	
		                                          $('#preview').css({ 'display':'block', 'zIndex': 200 });
	})	
}
  
function hidePreview()
{
	$('#preview').animate({ opacity: 0 },500, function(){	
		                                          $('#preview').css({ 'display':'none', 'zIndex': 100 });
	})	
}


function showFairs()
{		
 $('#fairs').css({ 'display':'block', 'opacity':0, 'zIndex': 200 });
	$('#fairs').animate({ opacity: 100	},1000, function(){	
		                                          $('#fairs').css({ 'display':'block', 'zIndex': 200 });
	})	
}
  
function hideFairs()
{
	$('#fairs').animate({ opacity: 0 },500, function(){	
		                                          $('#fairs').css({ 'display':'none', 'zIndex': 100 });
	})	
}


/************************/
/* Bind Interaction     */
/************************/

function bindRichInteraction()
{
  // Hide all obtrusive elements
  $('.hidden').addClass('jsHide');
/*
  $('.note').addClass('clickable');
  $('.note').attr('title','Meer informatie over deze clipping?');
  $('.note').click( function(){ $('.note').toggleFade({ speedIn : 350, speedOut : 150 }); });
*/
}

/************************/
/* Supporting Functions */
/************************/

function ExternalLinks() 
{ 
  var hostname=window.location.hostname;hostname=hostname.replace("www.","").toLowerCase();	var a=document.getElementsByTagName("a"); this.check=function(obj){ var href=obj.href.toLowerCase(); return(href.indexOf("http://")!=-1&&href.indexOf(hostname)==-1)?true:false; }; this.set=function(obj){ obj.target="_blank"; }; for(var i=0;i<a.length;i++){ if(check(a[i])) set(a[i]); }; 
};


/* Agents */
function hideAgent(e)
{
  if (e)
  {
    $('li'+e).css({'display':'none'});
  }else{
    $('ul#info').children().css({'display':'none'});
  }
  $('ul#preselect li a').removeClass('active');
}

function showAgent(e)
{
  hideAgent();
  $('li'+e).css({'display':'block'});
}


/* Shoes */
function showShoe(e)
{		
  $(e).fadeIn({ opacity: 100 },1000, function(){ $(e).css({ 'display':'block', 'z-index':'1000' }); });
}

function hideShoe(e)
{
	$(e).animate({ opacity: 0  },1000, function(){ $(e).css({ 'display':'none', 'z-index':'100' }); })	
}