// initialise shadowbox
Shadowbox.init({
    continuous: true,
	overlayColor: "#000",
	overlayOpacity: 0.8,
	slideshowDelay: 5
});

// jump menu functonality
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

// jquery goodies
$(document).ready(function() {
	$("p.thumbnailbox input:checkbox").click(function() {
	  $(this).parents("p.thumbnailbox").toggleClass("selected",this.checked);
	});
	
	//history plugin
		$.history.init(callback);
    $("a[@rel='history']").click(function(){
        $.history.load(this.href.replace(/^.*#/, ''));
        return false;
    });
	
	// fade out completed tasks after a few seconds
	setTimeout(function(){
		$(".completedtask").slideUp("slow", function () {
			$(".completedtask").remove();
		});
	}, 2000);
	
	// sortable settings
	$("#sortable").sortable({ 
		connectWith: ['#sortable2'],
		opacity: 0.6,
		cursor: 'move',
		placeholder: 'placeholder',
		forcePlaceholderSize: true,
		update : function () { 
		  $("input#neworder").val($('#sortable').sortable('serialize'));
		  $("#submitsort").fadeIn("normal");
		} 
	});  
	$("#sortable2").sortable({ 
		connectWith: ['#sortable'],
		cursor: 'move',
		opacity: 0.6,
		placeholder: 'placeholder',
		forcePlaceholderSize: true,
		update : function () { 
		  $("input#neworder2").val($('#sortable2').sortable('serialize'));
		  $("#submitsort").fadeIn("normal");
		} 
	});
	$("#sortableimages, #sortableimagesnotactive").disableSelection();
  
	
	$("p.revealonload").hide();
	$("p.revealonload").fadeIn(5000);
	
	$("#accordion").accordion({
		autoHeight: false
	});
	
	$("img.inactive").fadeTo("slow", 0.2);
	
	$("#showload").click(function () {
		$("#loading").fadeIn('slow');
		$(".bloglink").hide();
		$(".TabbedPanels").fadeOut(3000);
	});
	
	
	//-- footer links fading --//
	$("#footer a").fadeTo("slow", 0.3);
	$("#footer a").hover(function(){
		$(this).stop().fadeTo("normal", 1.0);
		},function(){
			$(this).stop().fadeTo("slow", 0.3);
	});

	//-- gallery thumbnail fading --//
	$(".gallery-thumbnails a img").fadeTo("slow", 0.2);
	$(".gallery-thumbnails a img").hover(function(){
		$(this).stop().fadeTo("fast", 1.0);
		},function(){
			$(this).stop().fadeTo("slow", 0.2);
	});

	//-- menu drop down tags --//
	$("ul#nav-main a").hover(function() {
		$(this).next("span").stop(true, true).animate({opacity: "show", top: "-35"}, "slow");
		}, function() {
			$(this).next("span").animate({opacity: "hide", top: "-80"}, "fast");
	});

	//-- menu drop down tags --//
	$("li.TabbedPanelsTab").hover(function() {
		$(this).find("span").stop(true, true).animate({opacity: "show", top: "30"}, "slow");
		}, function() {
			$(this).find("span").animate({opacity: "hide", top: "60"}, "fast");
	});


	//-- form optional areas --//
	$("#wordofmouth").hide();
	$("#wordofmouth input").attr("disabled","disabled");
	$("#other").hide();
	$("#other input").attr("disabled","disabled");
	
	<!--If option 'Other is selected" for institution type, show text field for 'Other'-->
	$("#hearaboutme").change(function() {
		var val = $(this).val();
		$("#wordofmouth input").attr("disabled",(val=="Word of mouth")?"":"disabled");
		$("#other input").attr("disabled",(val=="Other")?"":"disabled");
		(val=="Word of mouth")?$("#wordofmouth").show():$("#wordofmouth").hide();
		(val=="Other")?$("#other").show():$("#other").hide()
	});
	

	//-- datepicker defaults --//
	$("#photographydate").datepicker({
		dateFormat: 'd/m/yy',
		minDate: 0,
		showAnim: 'slide',
		showOptions: {direction: 'up' },
		duration: 300,
		changeMonth: true,
		changeYear: true,
		firstDay: 1,
		altField: '#photographydatewords',
		altFormat: 'DD, d MM, yy'
	});

	//-- form validation --//
    $("#talktome").validate({
		rules: {
			name: {
				required: true,
				minlength: 3
			},
			email: {
				required: true,
				email: true
			},
			password: {
				required: true
			},
			captchaword: {
				required: true
			}
		},
		messages: {
			name: {
				required: "Please enter your name.",
				minlength: jQuery.format("Must be at least {0} characters long.")
			},
			email: {
				required: "Please enter an email address.",
				email: "Email format must be name@yourdomain"
			},
			password: {
				required: "You forgot to type in your password."
			},
			captchaword: {
				required: "Please enter the letters shown above."
			}
		}
	});

	//-- input mask for forms --//
	$("#phone").mask("(99) 9999 9999");
	$("#mobile").mask("9999 999 999");

	// enable tabs
	$("#tabs").tabs();
});


/*$(document).ready(function(){
	$("#accordion").accordion({
		autoHeight: false
	});
});*/


//$(document).ready(function() {
//   $("#loginarea").hide();
//   $(".hide_button").hide();
//   
//   var speed = 600;
//   
//   $(".show_button").click(function(){
//		$("div#loginarea").slideDown(speed, 'easeOutBounce');
//		$(".show_button").hide();
//		$(".hide_button").show();
//	
//	});	
//	
//   
//   $(".hide_button").click(function(){
//		$("div#loginarea").slideUp(speed, 'easeOutBounce');
//		$(".show_button").show();
//		$(".hide_button").hide();
//   });	
//	
//});

/*$(document).ready(function(){
	$("img.inactive").fadeTo("slow", 0.2);
	});


$(document).ready(function(){
      $("#showload").click(function () {
	    $("#loading").fadeIn('slow');
	    $(".bloglink").hide();
	    $(".TabbedPanels").fadeOut(3000);
	});
});*/



