function startSlide2()
{
  $('#slide-2 ul').innerfade({
	 	timeout: '3000'
	});
}

function startSlide3()
{
  $('#slide-3 ul').innerfade({
	 	timeout: '3000'
	});
}

function startSlide4()
{
  $('#slide-4 ul').innerfade({
	 	timeout: '3000'
	});
}

function startSlide5()
{
  $('#slide-5 ul').innerfade({
	 	timeout: '3000'
	});
}

$(document).ready(function() {

// Slideshow Init
	$('.slideshow').innerfade({
	 	timeout: '5000'
	});
  $('.slideshow a').click(function(){return false});

  startSlide2();
  window.setTimeout(startSlide3, 500);
  window.setTimeout(startSlide4, 1300);
  window.setTimeout(startSlide5, 2100);


// Mettre la page dans une variable
	var url = document.location.toString().split('.ca')[1].split('#')[0];
// Ajouter la selection css au lien courant
	url && $('.main a[href="' + url + '"]').parent('li').addClass('active');	
	


// Menu du Slideshow
	$('ul.images a').click(function(){
		$(this).html('view content »');
		$('.slideshow').toggleClass('active');
		$('#content, .sub').fadeToggle('slow');
		$(this).toggleClass('active');
		return false;
	});
	$('ul.images a.active').click(function(){
		$(this).html('view slideshow »');
	});
	
// Fading des quotes
  $('#header').hoverIntent({
      over: function(){
              $('blockquote', this).css('filter','progid:DXImageTransform.Microsoft.gradient(startColorStr="#80000000", EndColorStr="#80000000");');
              $('blockquote', this).fadeIn('slow');
            },
      out: function(){$('blockquote', this).fadeOut('slow');},
  });
  
// IE polyfill
if($.browser.msie)
	$('body').append('<div id="ie-opacity">&nbsp;</div>');	
	
// Scroll animé
  $('.sub a').click(function(){
    var ancre = $(this).attr('href');
    $.scrollTo($(''+ancre+''), 1000);
    return false;
  });
  
// Activation des ancres
  	$(window).scroll(function(){ 
  		var ancre = $('#content h2:in-viewport:first').attr('id');
      if(ancre && ancre != $('.sub a.active').attr('href')){
        $('.sub a.active').removeClass('active');
        $('.sub a[href="#'+ancre+'"]').addClass('active');
      }
    });
	
// Fancybox Init
	$('a.fancybox').fancybox({
		'overlayOpacity': 0.8,
		'hideOnContentClick': true,
		'margin': 100,
		'centerOnScroll': true,
		'showCloseButton': false
	});
	$('.tax-credit').click(function(){
		$('#tax-table').fadeIn('slow');
	});
	$('#tax-table a').click(function(){
		$('#tax-table').fadeOut('slow');
	});
	
// Credit calculation	
  
  var obj = { 31670:0.75, 32840:0.74, 34020:0.73, 35185:0.72, 36360:0.71, 37525:0.70, 38710:0.69, 39880:0.68, 41045:0.67, 42215:0.66, 43395:0.65, 44570:0.64, 45745:0.63, 46910:0.62, 48090:0.61, 86785:0.60, 124595:0.57, 125775:0.54, 126955:0.52, 128135:0.50, 129320:0.48, 130500:0.46, 131680:0.44, 132860:0.42, 134040:0.40, 135220:0.38, 136400:0.36, 137580:0.34, 138765:0.32, 139945:0.30, 141125:0.28, 10000000:0.26 };
  
/*
  $('#income').val('yearly income');
  $('#fees').val('base tuition fees');
*/
  
  
    $('#income, #fees').click(function(){
       if(this.value == this.defaultValue)
       $(this).val(""); 
    });

  
  $('#submit').click(function(){
    var strSalaire = $('#income').val();
    var strFees = $('#fees').val();
    strSalaire = strSalaire.replace(/ /g, "");
    strFees = strFees.replace(/ /g, "");
    var salaire = parseInt(strSalaire);
    var fees = parseInt(strFees);
    if(!isNaN(salaire) && !isNaN(fees))
    {
        var taxe;
        $.each(obj, function(i, val) {
            taxe = val;
            return (salaire-1 >= i);
        });
        var realFee = Math.round(fees - (fees*taxe+fees*0.15));
        $('#cost').html(''+realFee+'$'); 
    }
    else
    {
      $('#cost').html("Please enter valid values");
    }
    $('.calculator p').fadeIn('fast')
  });
	
 });
