$(function() {
    
	// homepage cycling tabs
	$('div.h_slide').tabs({ fx : { opacity: "toggle", duration: 200 }}).tabs("rotate", 7000, true);

	// superfish
	$('ul.m_menu').superfish({
		delay:       0,                         // one second delay on mouseout 
		animation:   { opacity:'show' },  		// fade-in and slide-down animation 
		speed:       0                     		// faster animation speed 
	});
	
	// google map
	if ($("#map_canvas").length) initialize();

	// slide show carousel
	var counter = -1;
	$("ul.slideshow").each(function(){
		counter++;
	    $(this).jcarousel({
	    	scroll: 1,
	    	initCallback: function(carousel){
	    		carousel.order = counter;
	    	},
	    	itemVisibleInCallback: {
	            onBeforeAnimation: function(carousel){
	            	if ( $("ul.slideshow:eq("+carousel.order+") li.jcarousel-item:eq("+carousel.first+") span.image_holder img").length == 0 ) {
	    	    		var src = $("ul.slideshow:eq("+carousel.order+") li.jcarousel-item:eq("+carousel.first+") span.image_holder").html();
	    	    		$("ul.slideshow:eq("+carousel.order+") li.jcarousel-item:eq("+carousel.first+") span.image_holder").html("<img src='"+src+"' alt='' />");
	    	    	}
	            }
	        }
	    });
	});
    
	// main menu ie6 hover
	$('.m_menu > li').hover(function(){
		$(this).addClass('hover');
	}, function() {
		$(this).removeClass('hover');
	});
	
	// more news details
	$('div.main_content ul li a.wrap').toggle(function(){
		$(this).addClass("active").next("div.more").removeClass("hidden");
	}, function(){
		$(this).removeClass("active").next("div.more").addClass("hidden");
	});
	
	// accordion
	$("div.acc").accordion({
		autoHeight: false,
		collapsible: true
	});
	
	// toggle grey images to colour
	$("ul.partners li").live("mouseover", function(){
		$(this).find("img.grey").stop().fadeTo("normal","0")
	}).live("mouseout", function(){
		$(this).find("img.grey").stop().fadeTo("normal","1")
	});
	
	// enquiry form validation
    if ($('.validate').length > 0) {
    	$('.validate').validate({
    		errorPlacement: function(error, element) {
        		error.appendTo( element.parent() );
      		}
    	});
    }
    
});

