﻿//fade in and fade out of popover
//uses jquery
var specialtypopover = new Array();
var specialtypopout = new Array();
var prevmyelement = null;
function popover(myelement,myaction, delaytime, fadetime, divname)
{
    if(delaytime==null)
        delaytime=700;
    if(fadetime==null)
        fadetime=500;
        
    if(myaction=='clearall')
    { 
        specialtypopout[myelement] = setTimeout('$(\".'+divname+'\").fadeOut('+fadetime+')',delaytime);
        specialtypopover[myelement] = setTimeout('$(\"#'+myelement+'\").fadeIn('+fadetime+')',delaytime);
    }
    else if(myaction=='clearclass')
    { 
        specialtypopout[myelement] = setTimeout('$(\".'+myelement+'\").fadeOut('+fadetime+')',delaytime);
    }
    else if(myaction=='popclass')
    { 
        specialtypopout[myelement] = setTimeout('$(\".'+myelement+'\").fadeIn('+fadetime+')',delaytime);
    }
    else if(myaction=='mouseover')
    {
        clearTimeout(specialtypopover[prevmyelement]);
        specialtypopover[myelement] = setTimeout('$(\"#'+myelement+'\").fadeIn('+fadetime+')',delaytime);
    }
    else if(myaction=='mouseout')
    {
        clearTimeout(specialtypopout[prevmyelement]);
        clearTimeout(specialtypopover[myelement]); 
        specialtypopout[myelement] = setTimeout('$(\"#'+myelement+'\").fadeOut('+fadetime+')',delaytime);
    }
    else if(myaction=="slideover")
    {
        clearTimeout(specialtypopout[myelement]);
        clearTimeout(specialtypopover[myelement]);
        clearTimeout(specialtypopout[prevmyelement]);
        clearTimeout(specialtypopover[prevmyelement]);
    }
    else if(myaction=="slideout")
    {
        specialtypopout[myelement] = setTimeout('$(\"#'+myelement+'\").fadeOut('+fadetime+')',delaytime);
    }
    else if(myaction=="temporary")
    {
        specialtypopover[myelement] = setTimeout('$(\"#'+myelement+'\").fadeIn('+fadetime+')',0);
        specialtypopout[myelement] = setTimeout('$(\"#'+myelement+'\").fadeOut('+fadetime+')',delaytime);
    
    }
    else if(myaction=="popup")
        specialtypopover[myelement]=setTimeout('$(\"#'+myelement+'\").fadeIn('+fadetime+')',delaytime);
    else if(myaction=="popout")
        specialtypopout[myelement]=setTimeout('$(\"#'+myelement+'\").fadeOut('+fadetime+')',delaytime);
        
    prevmyelement = myelement;
} 

//loading screen
window.onload=function(){
    //if(document.getElementById("myloadingscreen")!=null)
        //document.getElementById("myloadingscreen").className = "loading-invisible";   
}
window.onunload=function(){	
    //if(document.getElementById("myloadingscreen")!=null)
        //document.getElementById("myloadingscreen").className = "loading-visible";	   
}
function changingpages()
{
    //if(document.getElementById("myloadingscreen")!=null)
        //document.getElementById("myloadingscreen").className = "loading-visible";
}

//depricate these babies
if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent))
{
    HTMLElement.prototype.click = function() {
    var evt = this.ownerDocument.createEvent('MouseEvents');
    evt.initMouseEvent('click', true, true, this.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
    this.dispatchEvent(evt);
    }
}
function showHint(hintname)
{
    
    hintname = hintname.substr(hintname.lastIndexOf("_")+1);
    document.getElementById(hintname+'_iframe').style.display="block";
    document.getElementById(hintname+'_hint').style.display="block";
    
}
function hideHint(hintname)
{
    hintname = hintname.substr(hintname.lastIndexOf("_")+1);
    document.getElementById(hintname+'_hint').style.display="none";
    document.getElementById(hintname+'_iframe').style.display="none";
}
function tabSelect(elementNameShow, elementNameHide1, elementNameHide2)
{
    if(elementNameShow!='')
        document.getElementById(elementNameShow).className = document.getElementById(elementNameShow).className.replace("Off", "On");
    if(elementNameHide1!='')
        document.getElementById(elementNameHide1).className = document.getElementById(elementNameHide1).className.replace("On", "Off");
    if(elementNameHide2!='')
        document.getElementById(elementNameHide2).className = document.getElementById(elementNameHide2).className.replace("On", "Off");
}
function pageSelect(pageNameShow, pageNameHide1, pageNameHide2)
{
    if(pageNameShow!="" && pageNameShow!=null)
    {
        if(document.getElementById(pageNameShow)){document.getElementById(pageNameShow).style.display='show';}
        document.getElementById('ctl00_submenu').value = pageNameShow;
    }
    if(pageNameHide1!="" && pageNameHide1!=null)
        if(document.getElementById(pageNameHide1)){document.getElementById(pageNameHide1).style.display='none';}
    if(pageNameHide2!="" && pageNameHide2!=null)
        if(document.getElementById(pageNameHide2)){document.getElementById(pageNameHide2).style.display='none';}
}







// form checks
function CheckForm()
    {
        
        //If no required elements are filled in stop and show errors
        if(document.getElementById('ctl00_ContentPlaceHolder1_TextBoxLastName')!=null && document.getElementById('ctl00_ContentPlaceHolder1_TextBoxLastName').value == '' 
            && document.getElementById('ctl00_ContentPlaceHolder1_DropDownState')!=null && document.getElementById('ctl00_ContentPlaceHolder1_DropDownState').value == ''
            && document.getElementById('ctl00_ContentPlaceHolder1_TextBoxCity').value == '' && document.getElementById('ctl00_ContentPlaceHolder1_TextBoxZip').value == ''
            && document.getElementById('ctl00_ContentPlaceHolder1_TextBoxFirstName')!=null && document.getElementById('ctl00_ContentPlaceHolder1_TextBoxFirstName').value == '')
        {
            //showHint('nofields');
            popover('nofieldspopup', 'temporary',3000,null,null);
            return false;
        }
        //if state is selected but nothing else
         else if(document.getElementById('ctl00_ContentPlaceHolder1_DropDownState')!=null && document.getElementById('ctl00_ContentPlaceHolder1_DropDownState').value != ''
            && document.getElementById('ctl00_ContentPlaceHolder1_TextBoxCity')!=null && document.getElementById('ctl00_ContentPlaceHolder1_TextBoxCity').value == '' && document.getElementById('ctl00_ContentPlaceHolder1_TextBoxZip').value == '')
        {
            //showHint('TextBoxLastName');
            popover('TextBoxCitypopup', 'mouseover',0,null,null);
            //showHint('TextBoxCity');
            return false;
        }
        //if last name but no state or zip
         else if(document.getElementById('ctl00_ContentPlaceHolder1_TextBoxLastName')!=null && document.getElementById('ctl00_ContentPlaceHolder1_TextBoxLastName').value != '' && document.getElementById('ctl00_ContentPlaceHolder1_DropDownState').value == '' && document.getElementById('ctl00_ContentPlaceHolder1_TextBoxZip').value == '')
        {
            //showHint('DropDownState');
            popover('DropDownStatepopup', 'mouseover',0,null,null);
            return false;
        }
        //if first name but no lastname
         else if(document.getElementById('ctl00_ContentPlaceHolder1_TextBoxFirstName')!=null && document.getElementById('ctl00_ContentPlaceHolder1_TextBoxFirstName').value != '' && document.getElementById('ctl00_ContentPlaceHolder1_TextBoxLastName').value == '')
        {
            //showHint('TextBoxLastName');
            popover('TextBoxLastNamepopup', 'mouseover',0,null,null);
            return false;
        }
        //if city but no state and no zip
         else if(document.getElementById('ctl00_ContentPlaceHolder1_TextBoxCity')!=null && document.getElementById('ctl00_ContentPlaceHolder1_TextBoxCity').value != '' 
            && document.getElementById('ctl00_ContentPlaceHolder1_DropDownState')!=null && document.getElementById('ctl00_ContentPlaceHolder1_DropDownState').value == ''
            && document.getElementById('ctl00_ContentPlaceHolder1_TextBoxZip')!=null && document.getElementById('ctl00_ContentPlaceHolder1_TextBoxZip').value == '')
        {
            //showHint('DropDownState');
            popover('DropDownStatepopup', 'mouseover',0,null,null);
            return false;
        }
         else
        {
            return true;
        }
   }
function feedbackCheck(myelement)
    {
        if(document.getElementById(myelement).value == undefined || document.getElementById(myelement).value == '')
        {
            popover('feedbackerror', 'mouseover',null,null,null);
            return true;
        }
        else
            return false;
   }
   function findPhysicianCheck()
    {
        
        //If no required elements are filled in stop and show errors
        if(document.getElementById('ctl00_ContentPlaceHolder1_TextBoxLastName').value == '' && document.getElementById('ctl00_ContentPlaceHolder1_DropDownState').value == ''
            && document.getElementById('ctl00_ContentPlaceHolder1_TextBoxCity').value == '' && document.getElementById('ctl00_ContentPlaceHolder1_TextBoxZip').value == ''
            && document.getElementById('ctl00_ContentPlaceHolder1_TextBoxFirstName').value == '')
        {
            showHint('nofields');
            setTimeout('hideHint(\'nofields\')', 3000);
            return false;
        }
        //if state is selected but nothing else
         else if(document.getElementById('ctl00_ContentPlaceHolder1_DropDownState').value != ''
            && document.getElementById('ctl00_ContentPlaceHolder1_TextBoxCity').value == '' && document.getElementById('ctl00_ContentPlaceHolder1_TextBoxZip').value == '')
        {
            //showHint('TextBoxLastName');
            showHint('TextBoxCity');
            return false;
        }
        //if last name but no state or zip
         else if(document.getElementById('ctl00_ContentPlaceHolder1_TextBoxLastName').value != '' && document.getElementById('ctl00_ContentPlaceHolder1_DropDownState').value == '' && document.getElementById('ctl00_ContentPlaceHolder1_TextBoxZip').value == '')
        {
            showHint('DropDownState');
            return false;
        }
        //if first name but no lastname
         else if(document.getElementById('ctl00_ContentPlaceHolder1_TextBoxFirstName').value != '' && document.getElementById('ctl00_ContentPlaceHolder1_TextBoxLastName').value == '')
        {
            showHint('TextBoxLastName');
            return false;
        }
        //if city but no state and no zip
         else if(document.getElementById('ctl00_ContentPlaceHolder1_TextBoxCity').value != '' && document.getElementById('ctl00_ContentPlaceHolder1_DropDownState').value == ''
            && document.getElementById('ctl00_ContentPlaceHolder1_TextBoxZip').value == '')
        {
            showHint('DropDownState');
            return false;
        }
         else
        {
            return true;
        }
   }