/*
 Author: Roy Lindauer
 Project: UHN
 Date: July 2009
 Version: 1.0
*/

$(document).ready(function(){
	/* xhtml valid target=_blank alternative */
	$('.popup').click(function(){
		window.open($(this).attr('href'));
		return false;
	});
	
	/* provider search form */
	$('.ps_form').hide(); // hide all forms to start
	$('#ps_nevada').show(); // show first form
	$('.ps_tab[rel=ps_nevada]').addClass('active'); // start with first tab active
	
	$('.ps_tab').click(function(){ // show forms
		$('.ps_form').hide();
		$('.ps_tab').removeClass('active');
		var elem = $(this).attr('rel');
		$(this).addClass('active');
		$('#'+elem).fadeIn();	
		return false;
	});
	
	$('#messaging').cycle({
		timeout: 5000,
		speed: 2000
	});
	
	// inlined labels

	
		$("label.inlined + input.basic").each(function (type) {
			
			if ($(this).val())
			{
				$(this).prev("label.inlined").addClass("has-text").removeClass("focus");
			}
			
			$(this).focus(function () {
				$(this).prev("label.inlined").addClass("focus");
			});
			 
			$(this).keypress(function () {
				$(this).prev("label.inlined").addClass("has-text").removeClass("focus");
			});
			 
			$(this).blur(function () {
				if($(this).val() == "") {
					$(this).prev("label.inlined").removeClass("has-text").removeClass("focus");
				}
			});
		});


	// form results
	$('.result_extra').hide();
	$('.result_expand_link').click(function(){
		$(this).parent().find('a').toggle();
		$(this).parent().parent().find('.result_extra').toggle('slideDown');
		return false;
	});
	$('.expand_all').click(function(){
		$('.expand_btns').toggle();
		$('.result_more_info').hide();
		$('.result_less_info').show();
		$('.result_extra').slideDown();
		return false;
	});
	$('.collapse_all').click(function(){
		$('.expand_btns').toggle();
		$('.result_more_info').show();
		$('.result_less_info').hide();
		$('.result_extra').slideUp();
		return false;
	});
	
});


startList = function() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("nav");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
		}
	}
}
window.onload=startList;
