var eleId = "ctl00_";

//3rent is invalid naming convention.
//

// Javascript Document
var ie4 = document.all;
var dom = document.getElementById;

function set_action(frm, action) { object = ie4 ? eval('document.all.' + frm) : document.getElementById(frm); if (object != '' && object != null) { object.action = action; } }

//v1.0 //Copyright 2006 Adobe Systems, Inc. All rights reserved.
function AC_AddExtension(src, ext) { if (src.indexOf('?') != -1) { return src.replace(/\?/, ext + '?'); } else { return src + ext; } }

function AC_Generateobj(objAttrs, params, embedAttrs) { var str = '<object '; for (var i in objAttrs) { str += i + '="' + objAttrs[i] + '" '; } str += '>'; for (var i in params) { str += '<param name="' + i + '" value="' + params[i] + '" /> '; } str += '<embed '; for (var i in embedAttrs) { str += i + '="' + embedAttrs[i] + '" '; } str += ' ></embed></object>'; document.write(str); }

function AC_FL_RunContent() { var ret = AC_GetArgs(arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000", "application/x-shockwave-flash"); AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs); }

function AC_SW_RunContent() { var ret = AC_GetArgs(arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000", null); AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs); }

function AC_GetArgs(args, ext, srcParamName, classid, mimeType) { var ret = new Object(); ret.embedAttrs = new Object(); ret.params = new Object(); ret.objAttrs = new Object(); for (var i = 0; i < args.length; i = i + 2) { var currArg = args[i].toLowerCase(); switch (currArg) { case "classid": break; case "pluginspage": ret.embedAttrs[args[i]] = args[i + 1]; break; case "src": case "movie": args[i + 1] = AC_AddExtension(args[i + 1], ext); ret.embedAttrs["src"] = args[i + 1]; ret.params[srcParamName] = args[i + 1]; break; case "onafterupdate": case "onbeforeupdate": case "onblur": case "oncellchange": case "onclick": case "ondblClick": case "ondrag": case "ondragend": case "ondragenter": case "ondragleave": case "ondragover": case "ondrop": case "onfinish": case "onfocus": case "onhelp": case "onmousedown": case "onmouseup": case "onmouseover": case "onmousemove": case "onmouseout": case "onkeypress": case "onkeydown": case "onkeyup": case "onload": case "onlosecapture": case "onpropertychange": case "onreadystatechange": case "onrowsdelete": case "onrowenter": case "onrowexit": case "onrowsinserted": case "onstart": case "onscroll": case "onbeforeeditfocus": case "onactivate": case "onbeforedeactivate": case "ondeactivate": case "type": case "codebase": ret.objAttrs[args[i]] = args[i + 1]; break; case "width": case "height": case "align": case "vspace": case "hspace": case "class": case "title": case "accesskey": case "name": case "id": case "tabindex": ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i + 1]; break; default: ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i + 1]; } } ret.objAttrs["classid"] = classid; if (mimeType) ret.embedAttrs["type"] = mimeType; return ret; }

function printPage() {
    var sOption = "toolbar=yes,location=no,directories=yes,menubar=no,scrollbars=yes,width=550,height=500,left=100,top=25";
    var sTitle = document.title;
    var sUrl = document.location;

    var winprint = window.open("", "", sOption);
    var sTabs = '';
    winprint.document.open();

    /*
    objLogo=ie4? document.all.logo : document.getElementById('logo');
    objTestimonial=ie4? document.all.testimonial : document.getElementById('testimonial');
    objFooterPromo=ie4? document.all.footerpromo : document.getElementById('footerpromo');
    objInfoFooter=ie4? document.all.infofooter : document.getElementById('infofooter');
    if(objLogo != '' && objLogo != null){sLogo=objLogo.innerHTML;}else{sLogo="";}
    sTestimonial = "\n<div><br /><table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\" ><tr><td height=\"2\" align=\"left\" valign=\"top\" bgcolor=\"000000\"></td></tr>\n</table>\n</div><br />\n";
    if(objTestimonial != '' && objTestimonial != null){sTestimonial=objTestimonial.innerHTML+sTestimonial;}else{sTestimonial=""}
    sFooterPromo = "\n<div><br /><table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\" ><tr><td height=\"2\" align=\"left\" valign=\"top\" bgcolor=\"000000\"></td></tr>\n</table>\n</div><br />\n";
    if(objFooterPromo != '' && objFooterPromo != null){sFooterPromo=objFooterPromo.innerHTML+sFooterPromo;}else{sFooterPromo=""}
    sInfoFooter = "\n";
    if(objInfoFooter != '' && objInfoFooter != null){sInfoFooter=objInfoFooter.innerHTML+sInfoFooter;}else{sInfoFooter=""}
    <script type=\"text/JavaScript\">\nfunction turnoffreadlinks(){\nvar ie4=document.all;\nfor(i=1;i<5;i++){\nlinkobject=ie4? eval('document.all.enewslink'+i) : document.getElementById(\"enewslink\"+i);\nif(linkobject != '' && linkobject != null){linkobject.style.display='none';}}}</script>
    */

    objFooter = ie4 ? document.all.print_footer : document.getElementById('print_footer');
    if (objFooter != '' && objFooter != null) { sFooter = objFooter.innerHTML; } else { sFooter = ""; }

    objContent1 = ie4 ? document.all.print_content_one : document.getElementById('print_content_one');
    if (objContent1 != '' && objContent1 != null) { sContent1 = objContent1.innerHTML; } else { sContent1 = ""; }

    objContent2 = ie4 ? document.all.print_content_two : document.getElementById('print_content_two');
    if (objContent2 != '' && objContent2 != null) { sContent2 = "<hr noshade=\"noshade\" color=\"#335A83\" size=\"1px\" align=\"left\" class=\"no_padding\">" + objContent2.innerHTML + "<br /><br />"; } else { sContent2 = ""; }

    objContent3 = ie4 ? document.all.print_content_three : document.getElementById('print_content_three');
    if (objContent3 != '' && objContent3 != null) { sContent3 = objContent3.innerHTML; } else { sContent3 = ""; }

    winprint.document.write("<html>\n<head>\n<link rel=\"stylesheet\" type=\"text/css\" href=\"/css/print.css\" >\n<title>" + sTitle + "</title>\n</head>\n<body>\n");
    winprint.document.write("<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">\n<tr><td align=\"right\" valign=\"top\" id=\"strongprint\"><a href=\"javascript:window.print();\"><img src=\"/images/icons/printer.png\" border=\"0\" width=\"14\" height=\"14\" valign=\"bottom\"/></a></td><td width=\"13%\" align=\"right\"><a href=\"javascript:window.print();\">Print Page</a></td><td width=\"2%\" style=\"font-size:10px; font-weight:bold;\">&nbsp;|&nbsp;</td><td width=\"5%\"><a href=\"javascript:window.close();\">Close</a></td></tr></table>");
    winprint.document.write("<div><hr noshade=\"noshade\" color=\"#000000\" size=\"1px\" align=\"left\" class=\"no_padding\"></div>");
    /*
    winprint.document.write("<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">\n");
    winprint.document.write("<tr><td align=\"left\">"+sLogo+"</td>");
    winprint.document.write("<td align=\"left\">&nbsp;&nbsp;&nbsp;<strong>"+sTitle+"</strong></td></tr>");
    winprint.document.write("\n<div><br /><table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\" ><tr><td height=\"2\" align=\"left\" valign=\"top\" bgcolor=\"000000\"></td></tr>\n</table>\n</div><br />\n");
    winprint.document.write(sTabs);
    winprint.document.write("\n<div><br /><table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\" ><tr><td height=\"2\" align=\"left\" valign=\"top\" bgcolor=\"000000\"></td></tr>\n</table>\n</div><br />\n");
    winprint.document.write(sTestimonial);
    winprint.document.write(sFooterPromo);
    winprint.document.write(sInfoFooter);
    winprint.document.write("<br /><br /><br />\n");
    winprint.document.write("National Rural Recruitment &amp; Retention Network for Healthcare Professionals<br /><br />");
    */
    winprint.document.write(sContent1);
    winprint.document.write(sContent2);
    winprint.document.write(sContent3);
    //winprint.document.write("\n<p>&nbsp;</p>");
    winprint.document.write("<div><hr noshade=\"noshade\" color=\"#000000\" size=\"1px\" align=\"left\" class=\"no_padding\"></div>");
    winprint.document.write(sFooter);
    winprint.document.write("\n<div align=\"center\" class=\"website_address\">http://www.3rnet.org/</div>");
    winprint.document.write("\n</body>\n</html>");


    winprint.document.close();
    winprint.focus();
    //window.print()
    return false;
}
function check_uncheck(Val) {
    var ValChecked = Val.checked;
    var ValId = Val.id;
    var frm = document.forms[0];
    // Loop through all elements
    for (i = 0; i < frm.length; i++) {
        // Look for Header Template's Checkbox and Select/Deselect checkbox
        if (this != null) {
            if (ValId.indexOf('CheckAll') != -1 || ValId.indexOf('cboSelectDeselect') != -1) {
                // Check if checkbox is checked,
                // then select or deselect datagrid checkboxes
                if (ValChecked)
                    frm.elements[i].checked = true;
                else
                    frm.elements[i].checked = false;
            }
        }
    }
}
  
function professionSelected() {

    objSecialty = ie4 ? document.all.ctl00_divSpecialty : document.getElementById('ctl00_divSpecialty');
    objProfessionID = ie4 ? document.all.ctl00_ddlProfessionID : document.getElementById('ctl00_ddlProfessionID');
    objtrSpecialtyPAorNP = ie4 ? document.all.ctl00_trSpecialtyPAorNP : document.getElementById('ctl00_trSpecialtyPAorNP');
    objSpecialtyPAorNPID = ie4 ? document.all.ctl00_ddlSpecialtyPAorNP : document.getElementById('ctl00_ddlSpecialtyPAorNP');
    objPhysicianSpecialty = ie4 ? document.all.ctl00_ddlSpecialty : document.getElementById('ctl00_ddlSpecialty');
    objPhysicianStatus = ie4 ? document.all.ctl00_ddlProfessionalStatus : document.getElementById('ctl00_ddlProfessionalStatus');

    var professionlength;
    var professionid;
    var specialtylength;
    var specialtyid;

    //Praveena 10/15/2009 check objProfessionID is not null
    if (objProfessionID) {
        professionlength = objProfessionID.length;
        professionid = "";
        for (i = 0; i < professionlength; i++) {
            if (objProfessionID.options[i].selected) {
                professionid = objProfessionID.options[i].value;
            }
        }
    }

    if (objtrSpecialtyPAorNP)  //Praveena 10/14/2009 added this line to avoid  errors on Components/controls/PublicOppurtunitySearch.ascx
    {
        if (professionid == "169" || professionid == "34") {
            objtrSpecialtyPAorNP.style.display = 'table-row';
        } else {
            objtrSpecialtyPAorNP.style.display = 'none';
        }
    }

    if (objSecialty)  //Praveena 10/14/2009 added this line to avoid  errors on Components/controls/PublicOppurtunitySearch.ascx
    {
        if (professionid == "60") {
            objSecialty.style.display = 'table-row';
        } else {
            objSecialty.style.display = 'none';
        }
    }

    //Praveena 10/13/2009

    var objProfessionID = ie4 ? document.all.ctl00_ddlProfessionID : document.getElementById('ctl00_ddlProfessionID');

    if (objProfessionID) {
        ProfessionIDlength = objProfessionID.length;
        ProfessionID = "";
        for (i = 0; i < ProfessionIDlength; i++) {
            if (objProfessionID.options[i].selected) {
                ProfessionID = objProfessionID.options[i].value;
            }
        }
    }
    //Test this and delete the following
    //     else {
    //         objProfReq = ie4 ? document.all.ctl00_divSpecialty : document.getElementById('ctl00_reqProfessionID');
    //         if (objProfReq) {
    //             objProfReq.enabled = false;
    //         }
    //     }

    var objProfessionIDOther = ie4 ? document.all.ctl00_trProfessionOther : document.getElementById('ctl00_trProfessionOther');

    var objProfessionOtherrequired = ie4 ? document.all.ctl00_valProfessionOther : document.getElementById('ctl00_valProfessionOther');

    if (objProfessionIDOther) {
        if (ProfessionID == "37") {
            objProfessionIDOther.style.display = 'table-row';

            //Added for requiredfield validator 
            objProfessionOtherrequired.enabled = true;
            ValidatorUpdateDisplay(objProfessionOtherrequired)

        } else {
            objProfessionIDOther.style.display = 'none';
            //Added for requiredfield validator
            objProfessionOtherrequired.enabled = false;
            ValidatorUpdateDisplay(objProfessionOtherrequired)
        }
    }

    if (objPhysicianSpecialty) {
        var PhysicianSpecialityId = "";
        for (i = 0; i < objPhysicianSpecialty.length; i++) {
            if (objPhysicianSpecialty.options[i].selected) {
                PhysicianSpecialityId = objPhysicianSpecialty.options[i].value;
                break;
            }
        }
        var objPhysicianSpecialtyOther = ie4 ? document.all.ctl00_trSpecialtyOther : document.getElementById('ctl00_trSpecialtyOther');
        var objPhysicianOtherrequired = ie4 ? document.all.ctl00_reqSpecialtyOther : document.getElementById('ctl00_reqSpecialtyOther');
        if (PhysicianSpecialityId == "50") {
            objPhysicianSpecialtyOther.style.display = 'table-row';

            objPhysicianOtherrequired.enabled = true;
            ValidatorUpdateDisplay(objPhysicianOtherrequired);
        }
        else {
            objPhysicianSpecialtyOther.style.display = 'none';

            objPhysicianOtherrequired.enabled = false;
            ValidatorUpdateDisplay(objPhysicianOtherrequired);
        }
    }

    ///Should be added later

    if (objPhysicianStatus) {


        var PhysicianStatusId = ""
        for (i = 0; i < objPhysicianStatus.length; i++) {
            if (objPhysicianStatus.options[i].selected) {
                PhysicianStatusId = objPhysicianStatus.options[i].value;
                break;
            }
        }
        var objPhysicianSatusOther = ie4 ? document.all.ctl00_trProfessionStatusOther : document.getElementById('ctl00_trProfessionStatusOther');
        var objPhysicianStatusOtherrequired = ie4 ? document.all.ctl00_valProfessionalStatusOther : document.getElementById('ctl00_valProfessionalStatusOther');

        if (PhysicianStatusId == "41") {
            objPhysicianSatusOther.style.display = 'table-row';
            objPhysicianStatusOtherrequired.enabled = true;
            ValidatorUpdateDisplay(objPhysicianStatusOtherrequired);
        }
        else {
            objPhysicianSatusOther.style.display = 'none';
            objPhysicianStatusOtherrequired.enabled = false;
            ValidatorUpdateDisplay(objPhysicianStatusOtherrequired);

        }


    }
}



function doClear(theText) {
    if (theText.value == theText.defaultValue) {
        theText.value = ""
    }
}

//default namespace. lead 3 is not allowed
rnet = {

    Email: {

        isExistingEmail: false,

        //is true if an email exist in the system
        //rnet.Email.findEmailAddress(accountType, emailaddress)
        findEmailAddress: function(accountType, email, successFn) {


            $.ajax({
                type: "POST",
                url: "/handlers/registration.ashx",
                data: ({ email: escape(email), accountType: accountType }),
                dataType: 'json',
                success: successFn
            });


        },

        regExEmail: function() {

            //ToDo: Add email regular express to check if email address is valid format on the client
            return true;
        }

    },

    //an array of professions that can have a specialty associated with it.
    getProfessionSpecialtyList: function() {
        return ['Physician', 'Nurse Practitioner (NP)', 'Physician Assistant (PA)'];
    },

    //Test if a given profession is in the specialty list
    isSpecialtyVisible: function(profession) {

        return ($.inArray(profession, rnet.getProfessionSpecialtyList()) == -1) ? false : true;

    }


};

/*****************************************************************************************
*  facilities section. All facilities JS places here
******************************************************************************************/
facilities = {


    register: {

        init: function() {

            $('#isExistingEmail').hide();

            //add handler to email input onChange event
            $('#ctl00_txtEmailAddress').change(facilities.register.checkEmail);

        },

        //check email input value
        checkEmail: function() {
            //call function to check email
            rnet.Email.findEmailAddress("facilityAccount", this.value, facilities.register.doResponse);
        },

        //function to execute when server resp
        doResponse: function(data) {

            var isExistingEmail = document.getElementById('isExistingEmail');
            $(isExistingEmail).hide();
            if (data.isExistingEmail) {
                $(isExistingEmail).show();
            }
        }


    },

    faq: {

        isChanged: false,

        init: function() {


            $('#ctl00_bodyContent_faqEditPanel_saveBtn').hide();
            $('#editHtml').hide();

            //$('#editHtml').change(facilities.faq.change);

            $('#editBtn').click(facilities.faq.edit);


            $('#cancelBtn').click(facilities.faq.cancel);

            $('#previewBtn').click(facilities.faq.preview);

            $('#editHtml').change(facilities.faq.change);

            $('#editBtn').attr('disabled', false);

        },

        save: function() {

            return false;
        },

        edit: function() {


            $('#faqHtml').hide();

            $('#editHtml').val($('#faqHtml').html());

            $('#editHtml').show();

            $('#editBtn').attr('disabled', true);


        },

        cancel: function() {


            $('#faqHtml').show();

            $('#editHtml').val("");

            $('#editHtml').hide();

            $('#previewHtml').hide();

            $('#ctl00_bodyContent_faqEditPanel_finalHtml').val("");

            $('#editBtn').attr('disabled', false);
            $('#ctl00_bodyContent_faqEditPanel_saveBtn').hide();

        },

        preview: function() {

            var html = $('#editHtml').val();

            $('#faqHtml').hide();
            if (html == "")
                $('#previewHtml').html("There are no changes to preview. Click 'edit' or 'cancel' to continue.");
            else
                $('#previewHtml').html($('#editHtml').val());

            $('#previewHtml').show();

            $('#editHtml').hide();

            $('#ctl00_bodyContent_faqEditPanel_finalHtml').val(html);

            if (facilities.faq.isChanged)
                $('#ctl00_bodyContent_faqEditPanel_saveBtn').show();

        },

        change: function() {
            facilities.faq.isChanged = true;

        }

    },

    formInit: function() {

        var profession = $('#ctl00_ddlProfessionSpecialtyID :selected').text();

        if (!rnet.isSpecialtyVisible(profession))
            $('#ctl00_trSpecialtyPAorNP').hide();

        if (profession != 'Other')
            $('#ctl00_trProfessionOther').hide();


        $('#ctl00_ddlProfessionSpecialtyID').change(function() {

            profession = $('#' + this.id + ' :selected').text();


            var ddlSpecialtyPAorNP = document.getElementById('ctl00_ddlSpecialtyID');

            if (profession == 'Other') {

                $('#ctl00_trSpecialty').hide();
                $('#ctl00_trProfessionOther').show();
                ddlSpecialtyPAorNP.selectedIndex = 0
            }
            else if (!rnet.isSpecialtyVisible(profession)) {
                $('#ctl00_trProfessionOther').hide();
                $('#ctl00_trSpecialty').hide();
                ddlSpecialtyPAorNP.selectedIndex = 0
            }
            else {
                $('#ctl00_trProfessionOther').hide();
                $('#ctl00_trSpecialty').show();
            }
        });

    }

};

/*****************************************************************************************
*  candidates section. All facilities JS places here
******************************************************************************************/
candidates = {


    registrationFormInit: function() {



        $('#ctl00_trProfessionOther').hide();

        $('#ctl00_trSpecialtyPAorNP').hide();
        $('#ctl00_ddlProfessionID').change(function() {

            if ($('#' + this.id + ' :selected').text() == 'Other') {
                $('#ctl00_trSpecialtyPAorNP').hide();
                $('#ctl00_trProfessionOther').show();
            }
            else {
                $('#ctl00_trProfessionOther').hide();
                $('#ctl00_trSpecialtyPAorNP').show();
            }
        });



    }

};

// addded 10-16-2009  for candidate signup page
function otherSelected(controlid) {


    switch (controlid) {
        case 'ctl00_ddlVisaStatus':
            var objVisastatus = ie4 ? document.all.ctl00_ddlVisaStatus : document.getElementById('ctl00_ddlVisaStatus');

            if (objVisastatus) {
                visaStatuslength = objVisastatus.length;
                visaStatusid = "";
                for (i = 0; i < visaStatuslength; i++) {
                    if (objVisastatus.options[i].selected) {
                        visaStatusid = objVisastatus.options[i].value;
                    }
                }
            }
            var objVisastatusOther = ie4 ? document.all.ctl00_trVisastatusOther : document.getElementById('ctl00_trVisastatusOther');

            //11/06/2009 Added to  enable\disable Reqiredfield validator for VisaStatusOther textbox 
            var objVisastatusOtherrequired = ie4 ? document.all.ctl00_valVisaStatusOther : document.getElementById('ctl00_valVisaStatusOther');

            //Praveena 10/15/2009 check objVisastatusOther is not null
            if (objVisastatusOther) {
                if (visaStatusid == "56") {
                    objVisastatusOther.style.display = 'table-row';

                    //Added for requiredfield validator 
                    objVisastatusOtherrequired.enabled = true;
                    ValidatorUpdateDisplay(objVisastatusOtherrequired)

                } else {
                    objVisastatusOther.style.display = 'none';
                    //Added for requiredfield validator
                    objVisastatusOtherrequired.enabled = false;
                    ValidatorUpdateDisplay(objVisastatusOtherrequired)
                }
            }

            break;

        case 'ctl00_ddlHowHeard':

            var objHowHeard = ie4 ? document.all.ctl00_ddlHowHeard : document.getElementById('ctl00_ddlHowHeard');

            if (objHowHeard) {
                howHeardlength = objHowHeard.length;
                howHeardid = "";
                for (i = 0; i < howHeardlength; i++) {
                    if (objHowHeard.options[i].selected) {
                        howHeardid = objHowHeard.options[i].value;
                    }
                }
            }
            var objHowheardOther = ie4 ? document.all.ctl00_trHeardofOther : document.getElementById('ctl00_trHeardofOther');

            //11/06/2009 Added to  enable\disable Reqiredfield validator for HoeheardOther 
            var objHowheardOtherrequired = ie4 ? document.all.ctl00_valHearOfOther : document.getElementById('ctl00_valHearOfOther');

            //Praveena 10/15/2009 check objVisastatusOther is not null
            if (objHowheardOther) {
                if (howHeardid == "28") {
                    objHowheardOther.style.display = 'table-row';
                    objHowheardOtherrequired.enabled = true;
                    ValidatorUpdateDisplay(objHowheardOtherrequired);
                } else {
                    objHowheardOther.style.display = 'none';
                    objHowheardOtherrequired.enabled = false;
                    ValidatorUpdateDisplay(objHowheardOtherrequired);
                }
            }

            break;
    }
}


var hash = {
    'pdf': 1,
    'doc': 1
};

function check_extension(filename) {
    var re = /\..+$/;
    var ext = filename.match(re);
    if (hash[ext]) {
        return true;
    } else {
        alert("Invalid filename, please select another file");
        return false;
    }
}





function getQuerystring(key, default_) {
    if (default_ == null) default_ = "";
    key = key.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regex = new RegExp("[\\?&]" + key + "=([^&#]*)");
    var qs = regex.exec(window.location.href);
    if (qs == null)
        return default_;
    else
        return qs[1];
}
