/*
 * @version: 081031
 */

/********************/
/* expander       	*/
/********************/
jQuery.fn.slide = function(speed, easing, callback) {
	return this.animate({height: 'toggle'}, speed, easing, callback); 
}


// hide and visible share forms, toggle selected
function show_share_form(form)
{
	// hide other forms
	if ( form == "#share-form-email" ) {
		$("#share-form-share").hide();
		$("#share-form-contact").hide();
	} else if ( form == "#share-form-share" ) {
		$("#share-form-email").hide();
		$("#share-form-contact").hide();
	} else if ( form == "#share-form-contact" ) {
		$("#share-form-share").hide();
		$("#share-form-email").hide();
	}
	$(form).toggle();
}

var txt_search = true;
var txt_newsletter = true;

//run on doc load
$(document).ready(function()
{
	//clear txt fields on click
	$("#jq-input-search").click(function()
	{
		if (txt_search ) {
			$(this).val("");
			txt_search = false;
		}
	});
	$("#jq-input-newsletter").click(function()
	{
		if (txt_newsletter ) {
			$(this).val("");
			txt_newsletter = false;
		}
	});
	
	// hide expanded title boxes
	$(".jq-minimise").hide();
	
	//expand click
	$(".jq-expand").click(function()
	{
		$(this).hide(); // hide element
		$(this).next().show(); // show alt
		$(this).next().next().slide('slow'); // hide content
		return false;
	});
	//minimise click
	$(".jq-minimise").click(function()
	{
		$(this).hide(); // hide element
		$(this).prev().show(); // show alt
		$(this).next().slide('slow');	// show content
		return false;
	});
	
	
	/***** share forms *****/
	//hide descriptions
	$(".share-desc-txt").hide();
	//print functionality
	$("#share-icon-print").hover(
		function () {
			$("#share-desc-print").show();
		}, 
		function () {
			$("#share-desc-print").hide();
		}
	);
	$("#share-icon-print").click(function()
	{
		window.print();
		return false;
	});
	
	//email functionality
	$("#share-icon-email").click(function()
	{
		show_share_form("#share-form-email");
		return false;
	});
	$("#share-icon-email").hover(
		function () {
			$("#share-desc-email").show();
		}, 
		function () {
			$("#share-desc-email").hide();
		}
	);
	
	//share functionality
	$("#share-icon-share").click(function()
	{
		show_share_form("#share-form-share");
		return false;
	});
	$("#share-icon-share").hover(
		function () {
			$("#share-desc-share").show();
		}, 
		function () {
			$("#share-desc-share").hide();
		}
	);
	
	//contact functionality
	$("#share-icon-contact").click(function()
	{
		show_share_form("#share-form-contact");
		return false;
	});
	$("#share-icon-contact").hover(
		function () {
			$("#share-desc-contact").show();
		}, 
		function () {
			$("#share-desc-contact").hide();
		}
	);
	
	
	//share form close btn
	$(".share-close").click(function()
	 {
		$(this).parent().parent().parent().hide();
		return false;
	 });
	/***** /shares *****/
	
	
	//collapse specified blocks - set in html class
	$(".jq-collapse .jq-minimise").show();
	$(".jq-collapse .jq-expand").hide();
	$(".jq-collapse .content").hide();
	
	//show minimise buttons
	$(".block .max .icon").show();
	
	//show print icon
	$("#share-icon-print").show();
});
