$(document).ready(function(){

var setw = $('#pikaholder').attr('width');
$('.pika_main2').css('width', setw+'px');
$('.jcarousel-skin-tango').css('width', setw+'px');

$("<style type='text/css'>.jcarousel-skin-tango .jcarousel-container-horizontal  {width:"+setw+"px; padding:25px 0 0 0;} .jcarousel-skin-tango .jcarousel-clip-horizontal { width:"+setw+"px; height: 64px;}</style>").appendTo("head");

$('#mycarousel li img').click(function(){
  var item = $(this).attr('longdesc');
  var captions = $(this).attr('alt');
  var loaditem = "images/"+item;
  $('.fancy').attr('href', loaditem);
  $('.fancy').attr('title', captions);
});

 $(".fancy").fancybox({
	'autoScale' : true,
	'transitionIn' : 'fade',
	'transitionOut' : 'fade',
	'overlayOpacity' : '0.5',
	'titlePosition': 'over',
	'overlayColor' : '#000'
 });

$("#mycarousel").PikaChoose({
 auto_play:false,
 show_prev_next: false,
 show_captions: false,
 thumb_width: 78,
 thumb_height: 78,
 transition:[0]
 });
 
 $('#mycarousel').jcarousel();


	/* **************************************** */
	/* Interactive map */
	
	$('.map').maphilight({strokeColor: 'fdab0e', fillColor: 'fdab0e'});

	
	/* tooltips for map */
	
	$.fn.qtip.styles.mystyle = { // Last part is the name of the style
	   color: 'black',
	   textAlign: 'center',
	   tip: 'topLeft',
	   name: 'green' // Inherit the rest of the attributes from the preset dark style
	}
	
	$("area[title]").qtip({
	   style: 'mystyle' // The name of the newly created custom style above
	});
	
	/* **************************************** */
	/* Event Calendar */
	
	$('#transitionii').innerfade({
		speed: 750,
		timeout: 6000,
		type: 'sequence',
		containerheight: '66px'
 	});
 
 //do the AJAX bit
  	$("a.eventLink").click(function () { 
  		$('#evt').jqm({ajax: $(this).attr('rel'), trigger: 'a.eventLink'});
	});

	function showEvent(aLink) {
		void(0);
	}

				  
	/* **************************************** */
	/* PNG fix */
	
	$(document).pngFix(); 
						   					   
	/* **************************************** */
	/* Superfish menu */
	
	$("ul.sf-menu").superfish({ 
        animation: {opacity:'show',height:'show'},   // slide-down effect with fade-in 
		speed:         'fast', 
		dropShadows:   false,
		autoArrows:  false,        // disable generation of arrow mark-up 
        delay:     0               // delay on mouseout 
     }); 					   
						   
	/* **************************************** */
	/* Align menu to centre */

	navwidth = $(".sf-menu").width();
	parentwidth = $(".sf-menu").parent().width();
	newmargin = (parentwidth-navwidth)/2;
	$(".sf-menu").css("margin-left", newmargin);
	
	
	/* **************************************** */
	/* Hover effect */
	
	$(".rollover").hover(
		function(){ // When mouse pointer is above the link
			// Make the image inside link to be transparent
			$(this).animate(
				{opacity:"0.5"},
				{duration:300}
			);
		},
		function(){ // When mouse pointer move out of the link
			// Return image to its previous state
			$(this).animate(
				{opacity:"1"},
				{duration:300}
			);
		}
	);
	
	
	//Google maps
	
	$("#ranuimassey").html('<iframe frameborder="0" height="288" id="mapframe" marginheight="0" marginwidth="0" scrolling="no" src="http://maps.google.co.nz/maps/ms?hl=en&amp;ie=UTF8&amp;msa=0&amp;msid=117716522498159758644.00048f4edd3b45e34bbef&amp;t=h&amp;ll=-36.858924,174.59594&amp;spn=0.02817,0.053954&amp;output=embed" width="350"></iframe>');
	$("#ranuimassey").show();

});

