$(document).ready(function() {
  
  //For the FAQ functionality
  $(".expand h3").toggle(function() {
    $('h3.expanded').siblings().slideUp('fast');
    $('h3.expanded').removeClass('expanded');
	  var theAnswer = $(this).siblings();
	  $(theAnswer).slideDown('fast');
	  $(this).addClass("expanded");
  }, function() {
    var theAnswer = $(this).siblings();
  	$(theAnswer).slideUp('fast');
  	$(this).removeClass("expanded");
  });
  
  //For the gallery
  $(function() {
    $('#gallery a').lightBox();
  });
  
  //Contact form validate
  $("#contactform").validate({
    rules : {
  		'contactname' : {
  			required : true
  		},
  		'email' : {
  			required : true,
  			email : true
  		}			
  	}
  });
  
  //Ad rotator
  /*var adsConfig = {
    'ads': [{
      'image': 'Special-Sept.png',
      'link': 'http://www.microsoft.com'
    },{
      'image': 'Special-Oct.png',
      'link': 'http://www.windowsphone.com'
    }]
  };
  
  var specials = '';
  
  for(var i=0;i<adsConfig['ads'].length;i++){
    href = adsConfig['ads'][i]['link'];
    image = '<img src="images/specials/'+adsConfig['ads'][i]['image']+'"/>';
    specials += '<a href="'+href+'">'+image+'</a>';
  }
  
  $('#specials').html(specials);*/
  
  $('#specials').cycle({
    fx:      'scrollDown', 
    speed:    300, 
    timeout:  7000
  });
  
  
  
});

$(window).load(function() {
	$('#slider').nivoSlider({
    effect:'sliceDown',
    controlNav:false,
    directionNav:false,
    pauseTime:7000
  });
});
