//DD_belatedPNG.fix('.pngfix');

function ajaxcall(ajx_key,ajx_divname,ajx_filename) {
	$('#'+ajx_divname).toggle();
	$.ajax({
		type: "GET",
		url: ajx_filename,
		async: false,
		data: "key="+ajx_key+"&divname="+ajx_divname+'&tab='+tab,
		success: function(data)
		{
		   $("#"+ajx_divname).html(data);
		   set_faceboxes(ajx_divname);
		}	
	});
}

function isVisible(toggled_elem, change_elem, img_change){
	if( $(toggled_elem).is(':visible') ){
		$(change_elem).removeClass('step4');
		$(img_change).attr({
			src: "/images/more-options-up.jpg"
		});
		$(change_elem).addClass('step3');
	}else{
		$(change_elem).removeClass('step3');
		$(img_change).attr({
			src: "/images/more-options-down.jpg"
		});
		$(change_elem).addClass('step4');
	}
}

function isVisible2(toggled_elem){
	if( $(toggled_elem).is(':visible') ){
		$(toggled_elem).attr({
			src: "/images/minus.gif"
		});
	}else{
		$(toggled_elem).attr({
			src: "/images/plus.gif"
		});
	}
}

var set_faceboxes = function(divname)
{
	//alert(divname);
	$('#' + divname + ' a.face').facebox({loadingImage:'/images/loading.gif',closeImage:'/images/closelabel.gif',opacity:0.8});
}

function agreement(answer, obj, value){
	if(!value){
		value = false;
	}
	
	searchForm = value.jqiagreement;
	if(answer){
		document.forms[searchForm].submit();
		return true;
	}else{
		return false;
	}
}

function toggle_moreopts(type)
{
	$('#' + type + '-adv-search').toggle();
	return false;
}

function showDisclaimer(url,target){
	
	var disclaimer = "The Web site you are about to enter is provided as a courtesy to visitors of BCBSAZ\'s Web site." +
"Unless otherwise stated in the linked Web site, the entity delivering the linked Web site is not in " +
"any way affiliated with BCBSAZ.  BCBSAZ does not maintain, control, or direct the contents of the " + 
"linked Web sites and assumes no responsibility for any information or other content, products or " +
"services acquired as a result of the access to the linked Web site, or any subsequently linked-to " +
"Web site.  BCBSAZ does not endorse the entity sponsoring the linked Web site, or the products or " +
"services that it offers. " +
"\n By clicking OK below, I agree that I have read and understand the above important information.";
	
	var answer = confirm(disclaimer);
	
	if(answer){
		
		if(target == 'az_board'){
			window.open(url,target,'toolbar=1,scrollbars=1,height=500,width=800');
		}else{
			window.open(url,target);
		}
	}
	
}

function validate_compareform(formname)
{
	var count = $("input:checkbox:checked").length;
	if(!count)
	{
		alert("Please select more than one to compare");
		$("#compare-btn").attr("href","#");	
		return false;
	}
	else if(count < 2)
	{
		alert("Please select more than one to compare");
		$("#compare-btn").attr("href","#");
		return false;
	}	
	else if(count > 3)
	{
		alert("Please select up to 3 to compare");
		$("#compare-btn").attr("href","#");
		return false;
	}else{
		$("#"+formname).submit();
		return true;
	}
}

$(document).ready( function($)
{

//alert($('#crit_county').html());

	if($('#crit_county').html() !== null){
	if($('#crit_county').val().length > 0)
	{
		$('#city_address :input').attr('disabled', true);
		$('#fac-required :input').attr('disabled', true);		
	}}

	$('#crit_county').change(function(){

		if($('#crit_county').val().length > 0)
		{
			$('#city_address :input').attr('disabled', true);
			$('#fac-required :input').attr('disabled', true);			
		}
		else{
			$('#city_address :input').attr('disabled', false);
			$('#fac-required :input').attr('disabled', false);			
		}
	})

	
	
if($('#pref-errormsg').html() !== null){
	if($('#pref-errormsg').html().length > 0)
	{
		$('#pref-errormsg').hide();
		jQuery.facebox({ ajax: 'alpha_prefixerror.php' })
	}
}

$('#chk_alpha').hide();
$('#prov_dir_link').click(function(){
	if($('#prefix_inputtext').val().length > 0 )
	{
	$('#chk_alpha').show();
	return false;
	}	
})

$('#prov_dir_link2').click(function(){
	if($('#prefix_inputtext').val().length > 0 )
	{
	$('#chk_alpha').show();
	return false;
	}	
})

	$('#navTabs *').tooltip();
	
	set_faceboxes('content');
	set_faceboxes("content-searchpage");
	
	$("#small_font_size").click(function(){
		var size = $("body").css("font-size");
		
		$("body").css({
		      "font-size":  12
		});
	});
	
	$("#med_font_size").click(function(){
		var size = $("body").css("font-size");
		
		$("body").css({
		      "font-size":  14
		});
	});
	
	$("#lrg_font_size").click(function(){
		var size = $("body").css("font-size");
		
		$("body").css({
		      "font-size":  16
		});
	});

	$("#res_per_page").change(function(){
		var url_s = document.location.search;
		url_s = url_s.substring(1);	
		location.href='search.php?'+url_s+'&res_per_page='+$(this).val();
//		location.href='search.php?'+url_s+'&results='+$(this).val();
//		location.href='search.php';
	});
	
	
	
	

	
	/*$('.product_disclaim').change(function(){
		var str = "";
		var q = $.parseQuery();
		var link ="";
		
		
		str = $(this).text($('.product_disclaim option:selected'));
		
		if(str.indexOf('HMO') >= 0 && q.id == ''){
			var msg = '<p style="margin-bottom:12px;">Biodyne, the behavioral services administrator (BSA), is the exclusive network provider to manage and provide your behavioral and mental health care benefits. Refer to your Contract Booklet for further details.</p><p>If you have the Biodyne benefit, call (800) 224-2125. Services include psychological/ psychiatric counseling and treatment, individual and group counseling for substance abuse, personal and family problems, lifestyle education and stress management. The BSA services are only available in Arizona. </p>';

			$.prompt(msg,{ buttons: { OK : true}});
			$(this).toggleClass('product_disclaim', false);
			return false;
		}
		
		if(str.indexOf('HMO') >= 0){
			link += '<a href="disclaimer_chiro.php" target="_blank" class="face">Chiropractic</a><br>';
			link += '<a href="disclaimer_behavioral.php" target="_blank" class="face">Behavioral Health Services</a><br>';
//			link += '<a href="disclaimer_dental.php" target="_blank" class="face">Dental Services</a><br>';
//			link += '<a href="disclaimer_vision.php" target="_blank" class="face">Vision Services</a><br>';
		}
		
		else if(str.indexOf('PPO') >= 0 || str.indexOf('Senior') >= 0 || str.indexOf('Workers') >= 0){
//			link += '<a href="disclaimer_dental.php" target="_blank" class="face">Dental Services</a><br>';
//			link += '<a href="disclaimer_vision.php" target="_blank" class="face">Vision Services</a><br>';
			
		}
		
		if(str.indexOf('Dental') >= 0){
			
		}
		
		if(str.indexOf('Senior') >= 0){
			
		}
		
		if(str.indexOf('Workers') >= 0){
			
		}
		
		$("#disclaimer_links").attr('style','float:left;');
		return $("#disclaimer_links").html(link);
		
		
		
		$('#crit_specialty').val('');
		$('#crit_facility_type').val('');

	});*/
});
function resetbutton(val)
{
	if(val==2)
	{
	location.href = 'searchform.php?tab=facility';	
	}
	if(val==3)
	{
	location.href = 'searchform.php?tab=urgent';	
	}
}

