//functions for interval delay
jQuery.fn.slideFadeToggle = function(speed, easing, callback) {
	return this.animate({opacity: 'toggle', height: 'toggle'}, speed, easing, callback);  
};
jQuery.fn.fadeToggle = function(speed, easing, callback) {
 return this.animate({opacity: 'toggle'}, speed, easing, callback);  
};
jQuery.fn.slideDownFade = function(speed, easing) {
	return this.animate({opacity:'.9', height: 'show'}, speed, easing);	
};
jQuery.fn.slideUpFade = function(speed, easing) {
	return this.animate({opacity:'0', height: 'hide'}, speed, easing);		
};

jQuery.fn.clearHiddenFields = function() {
	return this.each(function(){
		$("input[type='hidden']", this).each(function(){
			this.value = '';
		});
	});		
};
	
	
$(document).ready(function() {
	// Turn off current link
	var noClick = 'a.pageCurrent, a.detailsLnk, a.serviceLnk, a.exceptLnk';
	$(noClick).live("click", function() {
		return false;														 
	});	
	
	// create a fade/slide toggle switch
	
	// hide dynamic elements
	$('.detailsWrap, .nextDef').hide();
	
	// Show Case Details
	$('a.detailsLnk').live("click", function(){
		$(this).toggleClass('collapse');
		$(this).next().slideFadeToggle(500);
		$(this).blur();																	
	});
	
	// Show minor details
	$('a.serviceLnk').live("click", function(){
		$(this).next().slideFadeToggle(500);
		$(this).blur();																			
	});
	
	$('a.exceptLnk').live("click", function(){
		//var $except = $(this).attr('href');
		$(this).parent().parent().next('a').addClass('collapse');
		$(this).parent().parent().next().next('.detailsWrap').slideDownFade(500);
		$(this).blur();
		
	});
	

	//For provider search
	$('.pSrch .altForm ul li').hover(function() {
		$(this).css('cursor', 'pointer');
	}, function () {
		$(this).css('cursor', 'default');
	});
	$('.pSrch .altForm ul li.liOpen').css('cursor','default');
	$('.pSrch .altForm ul li').click(function() {
		$(this).addClass('liOpen');
		$(this).children('.fset-invisible').slideDown(250);
	});
	/*$('li.addOptionsLnk a').click(function() {
		$(this).addClass('optionsOpen');
		$('#addOptions').slideDown(450);
		$(this).blur();
		return false;
	});
	*/
	
	
	//AJAX Call for Definitions
	$('.nextDef').addClass('addDef');
	$('.copayp').live("click", function() {
		$(this).next().load($('base').attr("href") + 'definitions.html #primaryCare span');
		$(this).next().slideToggle(200);		
		$(this).next('.addDef').removeClass('.addDef');
		$(this).blur();
		return false;
	});
	$('.copays').live("click", function() {
		$(this).next().slideToggle(200);
		$(this).next('.addDef').load($('base').attr("href") + 'definitions.html #specialtyCare span'); //This is the ajax load call - turned off for demo
		$(this).next('.addDef').removeClass('.addDef');
		$(this).blur();
		return false;
	});
	$('.copayr').live("click", function() {
		$(this).next().slideToggle(200);
		$(this).next('.addDef').load($('base').attr("href") + 'definitions.html #rehabCare span'); //This is the ajax load call - turned off for demo
		$(this).next('.addDef').removeClass('.addDef');
		$(this).blur();
		return false;
	});
	$('.copaym').live("click", function() {
		$(this).next().slideToggle(200);
		$(this).next('.addDef').load($('base').attr("href") + 'definitions.html #mentalHealth span'); //This is the ajax load call - turned off for demo
		$(this).next('.addDef').removeClass('.addDef');
		$(this).blur();
		return false;
	});
	
	
	// When the print link is clicked then show the print dialog
	$("#printLink").live("click", function(){
		window.print();
		return false;	
	});
	
	// When links are clicked show popup
	var popupLinks = 'a#verifyInfLink, a#specialtyLink, a#helpLink, a#aboutLink';
	
	$(popupLinks).click(function() {
		showPopup($(this).attr("href"), 1000, 700);
		return false;
	});
	
	//End functions
});
