// Progressive-Enhancement.js
//
// Responsible JavaScript enhancements.
// The aim of this file is to provide functionality niceties in the event that JavaScript is enabled on the client.
// In no case should JavaScript be required for the website to work. In no case should any JavaScript be in-line or embeded in HTML.

$(document).ready(function(){
  // Open links to external websites in a new window using Event Delegation
  //   Event Delegation ensures the function will work inside AJAX loads
  //   [ http://docs.jquery.com/Tutorials:AJAX_and_Events ]
  $("body").click(function(event) {
    if ($(event.target).is("a[@rel*=external]") ||
        $(event.target).is("a[@rel*=newtab]")) {
      $(event.target).attr('target','_blank');
    }
  });
    
  
	if($("a.fancybox").length) {
		$("a.fancybox").fancybox({					
		}); 		
	}
	
		if($("a.fancybox_frame").length) {
		$("a.fancybox_frame").fancybox({					
			'frameWidth': 250,
			'frameHeight': 250
		});		 		
	}
	
	if ($(".datepicker").length) {
		$(document).ready(function(){
			$(".datepicker").datepicker({ 
				showOn: "button", 
				buttonImage: "../assets/datepicker/calendar.gif", 
				buttonImageOnly: true 
			});
		});
	}
	
	if ($(".form").length) {
		$(document).ready(function(){
			$(".form").validate();
		});
	}
	
	jQuery('#mycarousel').jcarousel({
        wrap: 'circular',
        itemVisibleInCallback: {onBeforeAnimation: mycarousel_itemVisibleInCallback},
        itemVisibleOutCallback: {onAfterAnimation: mycarousel_itemVisibleOutCallback}
    });


 
});