﻿var displayed_detail_row = 0
var successful_basic_search = 0
var successful_basic_dentist_search = 0

function WebTrendsSearchDetail() {
    var WT = _tag.WT;
    WT.si_x = 3;

    _tag.dcsCollect();
}

function showDetail(line_num) {
    //Setup browser dependent display style definition variable
    if (navigator.appName.indexOf("Microsoft") > -1) {
        var canSee = 'block'
    } else {
        var canSee = 'table-row';
    }
    //display the detail for this row
    document.getElementById('rowopen' + line_num).style.display = canSee;
    //hide the row 
    document.getElementById('row' + line_num).style.display = "none";
    //check to see if another detail row is displayed
    if (displayed_detail_row != 0) {
        //hide the detail for this row
        document.getElementById('rowopen' + displayed_detail_row).style.display = "none";
        //display the row
        document.getElementById('row' + displayed_detail_row).style.display = canSee;
    }
    //save the row number for the displayed detail row
    displayed_detail_row = line_num
    WebTrendsSearchDetail()
}
function eraseDetail(line_num) {
    //Setup browser dependent display style definition variable
    if (navigator.appName.indexOf("Microsoft") > -1) {
        var canSee = 'block'
    } else {
        var canSee = 'table-row';
    }
    //hide the detail for this row
    document.getElementById('rowopen' + line_num).style.display = "none";
    //display the row
    document.getElementById('row' + line_num).style.display = canSee;
    //reset the displayed detail row variable to 0, because all detail rows are hidden
    displayed_detail_row = 0;
}
function loadClientSideScript() 
{
   Validate();
   Sys.WebForms.PageRequestManager.getInstance().add_endRequest(Validate);
}
function Validate() {	if (document.getElementById('lastName').value != 'Last Name:') {
		document.getElementById('lastname_label').style.display = 'block';
	}    //	if (document.getElementById('specialty').value != '0') {
//		document.getElementById('specialty_label').style.display = 'block';
//	}    	if (document.getElementById('city').value != 'City:') {
		document.getElementById('city_label').style.display = 'block';
	}    	if (document.getElementById('state').value != 'State:') {
		document.getElementById('state_label').style.display = 'block';
	}    	if (document.getElementById('network').value != '1') {
		document.getElementById('network_label').style.display = 'block';
	}    	if (document.getElementById('radius').value != '0') {
		document.getElementById('radius_label').style.display = 'block';
	}    	if (document.getElementById('zip').value != 'ZIP Code:') {
		document.getElementById('zipcode_label').style.display = 'block';
	}    	if (document.getElementById('gender').value != 'Gender:') {
		document.getElementById('gender_label').style.display = 'block';
	}    	if (document.getElementById('language').value != '0') {
		document.getElementById('language_label').style.display = 'block';
	}    }function validate_rSearch() {       //radius value is supplied and state and city are not both supplied    var zipcode = $("#zip").val();
    
    if (document.advanced_search_form.radius.value!="0" && zipcode == $("#zip").attr("title") && (document.advanced_search_form.city.value=="City:" && document.advanced_search_form.state.value=="State:")) {
        //zip code needs to be supplied
        if (zipcode == "ZIP Code:")  {
            alert("City and State values, or a Zipcode value, must be provided on a Radius search");
            $("#zip").focus();
            return false;
        }
        //zip code supplied
        else {
            displayed_detail_row = 0
            LogWebTrendsPhysician();
            return true;
        }
    }
    //state is supplied and city is not supplied    else if (document.advanced_search_form.city.value=="City:" && document.advanced_search_form.state.value!="State:") { 
        alert("Both City and State values must be provided for a City/State search");
        document.getElementById("city").focus();
        return false;
    }    
    //city is supplied and state is not supplied    else if (document.advanced_search_form.city.value!="City:" && document.advanced_search_form.state.value=="State:") { 
        alert("Both City and State values must be provided for a City/State search");
        document.getElementById("state").focus();
        return false;
    }    
    //check for remaining required input fields (lastname, zip, city, state, or specialty)
    else if (document.advanced_search_form.lastName.value=="Last Name:" && document.advanced_search_form.zip.value=="ZIP Code:" && document.advanced_search_form.specialty.value=="0" && document.advanced_search_form.city.value=="City:" && document.advanced_search_form.state.value=="State:") {        alert("Minimum selection criteria has not been provided.");
        document.getElementById("lastName").focus();
        return false    }
    // Check for valid specialty selection
    else if ($("#specialty").val() == "-1")
    {
        alert("Please choose a valid specialty.");
        return false;
    }
    else if (zipcode.length != 0 && zipcode != $("#zip").attr("title") && zipcode.length != 5) 
    {
        alert("A 5-digit ZIP Code is required. Please re-enter your ZIP code.");
        return false;
    }    
    else {
        displayed_detail_row = 0
        LogWebTrendsPhysician();
        return true;
    }         }function CancelEnterKey(btn)

{

    if (event.keyCode == 13) 

    {

       alert("enter was pressed");

       event.returnValue=false;

       event.cancel = true;

       //alert(document.getElementById('dummyButton').text);

       document.getElementById(btn).click();

       //btn.click();

       //return false;

    }

}

function hideDiv() {
		document.getElementById('message_box').style.display = 'none';
		document.getElementById('iframe_box').style.display = 'none';
}

function clearInput(textbox_value, textbox_default_value, textbox_id, label_id) {
	document.getElementById(textbox_id).value='';
	$("#"+label_id).css("visibility", "visible");
}

function restoreInput(textbox_value, textbox_default_value, textbox_id, label_id) {
	if (textbox_value=="") {
		$("#" + textbox_id).val(textbox_default_value);
		$("#" + label_id).css("visibility", "hidden");
	}
	else {
		$("#" + label_id).css("visibility", "visible");
	}
}

function clearDropdown(dropdown_id, label_id) {
	$("#"+dropdown_id).attr("selectedIndex", 0);
	$("#" + label_id).css("visibility", "hidden");	
}

function restoreInputDropdown(dropdown_value, default_value, label_id) {
	if (dropdown_value!=default_value) {
		document.getElementById(label_id).style.display = 'block';
		$("#" + label_id).css("visibility", "visible");
	}
	else {
		$("#" + label_id).css("visibility", "hidden");
	}	
}

function moveDiv() {
	document.getElementById('progress').style.position = 'absolute';
	document.getElementById('iframe_box_progress').style.position = 'absolute';
	document.getElementById('progress').style.bottom = '40%';
	document.getElementById('iframe_box_progress').style.bottom = '40%';
}

function ShowErrorPopup() {
    $('#errorMessage').text($("#errorMsgText").text());
    $('#popupError').dialog('open');
}
        
function NewSearch() {
    restoreInput('','Last Name:','lastName','lastname_label');
    restoreInput('','City:','city','city_label');
    restoreInput('','ZIP Code:','zip','zipcode_label');
    
    clearDropdown('state', 'state_label');
    clearDropdown('radius', 'radius_label');
    clearDropdown('gender','gender_label');
    clearDropdown('specialty', 'specialty_label');
    clearDropdown('network', 'network_label');
    clearDropdown('language','language_label');
    clearDropdown('county', 'county_label');

    $("#DenteMax").hide();
   
    $('#acceptingnewpatients').attr('checked', false);
}

function WebTrendsBasicPhysicianSearchSetSuccessfulFlag() {
    successful_basic_search = 1;
}
function WebTrendsBasicDentistSearchSetSuccessfulFlag() {
    successful_basic_dentist_search = 1;
}
function clearTextInput(sender) {
    sender.value = "";
    var label = "#" + sender.id + "_label";
    $(label).css('visibility', 'visible');
}

function restoreTextInput(sender, defaultValue) {
    if (typeof defaultValue == "undefined") defaultValue = "";
    var label = "#" + sender.id + "_label";
    $(label).css('visibility', $(sender).val() == defaultValue || $(sender).val() == "0" ? 'hidden' : 'visible');
}

function CancelPropogation(e) {
    //http://www.quirksmode.org/js/events_order.html
    if (!e) var e = window.event;
	e.cancelBubble = true;
	if (e.stopPropagation) e.stopPropagation();
}
