/* 	Demo toggle, for frontend use only
============================================================= */

$(document).ready(function() {
	$('div.searchCol2 input[type="radio"]').click(function(){
		$('#searchMonthSelect').hide();
	});
						   
	$('#searchMonthToggle').click(function(){
		$('#searchMonthSelect').toggle();						   
	});
});

/* 	Superfish jQuery dropdown menu - http://users.tpg.com.au/j_birch/plugins/superfish/#options
============================================================= */

$(document).ready(function() { 

	$('ul.sf-menu').superfish({
		delay:        0,				                // the delay in milliseconds that the mouse can remain outside a submenu without it closing 
		animation:   {opacity:'show',height:'show'},  	// fade-in and slide-down animation 
		speed:       'fast',                          	// faster animation speed 
		autoArrows:  false,                           	// disable generation of arrow mark-up 
		disableHI:   false,								// set to true to disable hoverIntent detection 
		dropShadows: true                            	// disable drop shadows 
	}); 
});

/* 	jQuery alternating row colors (zebra_stripe_tables) 
	adds a 'odd' or 'even' classnames on all tables which have a classname of 'p80_zebra_table'
============================================================= */

$(document).ready(function(){										// body.onload()
	$("table.p80jq_zebra_table tbody tr").each(function(index) {	// to all tr-tags
		$(this).addClass(index % 2 == 0 ? "odd" : "even");			// add an 'odd' or 'even' classname
	});
});


/* 	jQuery FAQ like expanding list
============================================================= */

$(document).ready(function(){									// body.onload()
	var aExpandingList = "dl.p80jq_expandinglist"; 				// dl-tag classname to trigger
	$(aExpandingList+" dt").click(function () { 				// add click function to dt-tags
		if($(this).hasClass('open')) {							// check to see if item is already open
			$(this).removeClass('open'); 						// remove the classname 'open' on all dt-tags
			$(this).next('dd').slideUp('fast');					// animate the dd-tag when clicked
		} else {
			$(aExpandingList+" dd:visible").slideUp('fast'); 	// hide the dd-tag
			$(aExpandingList+" dt").removeClass('open'); 		// remove the classname 'open' on all dt-tags
			$(this).toggleClass('open'); 						// toggle the classname 'open' on dt-tags
			$(this).next('dd').slideDown('fast'); 				// animate the dd-tag when clicked
		}
	});
});

/*	Restore defaultValue on form elements onblur
============================================================= */

$(document).ready(function() {
	$("input:text.p80jq_element_restore_value, textarea.p80jq_element_restore_value").each(function() {
		$(this).attr('p80_org_formvalue', $(this).val());
		$(this).addClass('p80_form_label');
	})
	.focus(function () {
		if($(this).val() != '' && $(this).val() == $(this).attr('p80_org_formvalue')) {
			$(this).val('');
			$(this).removeClass('p80_form_label');
		}					
	 })
	.blur(function() {
		if($(this).val() == '') {
			$(this).val($(this).attr('p80_org_formvalue'));
			$(this).addClass('p80_form_label');
		}
	});
}); 

/*	Thumbnail list
============================================================= */

function p80jq_toggle_thumbs(){
	$("img.index_thumb").each(function() {					// img-tags with 'index_thumb' classnames
		$(this).toggleClass("index_thumb_show"); 			// toggle the classname
	});
}

/*	Unobtrusive Flash embedding using jQuery and SWFObject
============================================================= */
/*
$(document).ready(function(){
	var flashvars = {
		name1: "hello",
		name2: "world",
		name3: "foobar"
	};
	
	var params = {
		wmode: "transparent",
		menu: "false"		
	};
	
	var attributes = {
		id: "myDynamicContent",
		name: "myDynamicContent"
	};
	swfobject.embedSWF("/path/to/movie.swf", "theDivID", "300", "120", "8.0.0","/swf/expressInstall.swf", flashvars, params, attributes);
});
*/

/*	UReturn a key/value array of the URL query-string
============================================================= */

function p80_get_query_string() {
	var querystring = new Array; 
	// parse current url into an array with the keys/values
	var q = String (document.location).split ('?')[1];
	// return if there is no url query string
	if (!q) return false;
	q = q.split ('&');	
	for (var i = 0 ; i < q.length; i++)	{
		// for each key/value, split them at the '='
		// and add them to the qerystring array
		var o = q[i].split('=');		
		// create the array and url decode the string
		querystring[o[0]] = unescape(o[1]);
	}	
	// return the querystring array
	return querystring;
}