//Function to show radiireport
var locWin = null;
var ArcWebWin = null;

function displayArcWebWin(addr, comm, state, zip, lon, lat) {
      if (locWin != null) {
            if (!locWin.closed) {
                  locWin.close();
            }
      }
      if (ArcWebWin != null) {
            if (!ArcWebWin.closed) {
                  ArcWebWin.close();
            }
      }
      
      var scrWidth = screen.width;
      var scrHeight = screen.height;

      var w = 700;
      var h = 490;
      if (scrHeight > 700) 
      {
            w = 780;
            h = 640;
      }

      var po = addr.indexOf("#");
      if (po > -1) {
            addr = addr.substr(0,po);
      }

      po = addr.indexOf("/");
      if (po > -1) {
            addr = addr.substr(0,po);
      }

      po = addr.indexOf(",");
      if (po > -1) {
            addr = addr.substr(0,po);
      }
	  
      ///////////////////////////////////
      // Added for Wisconsin place names.
      ///////////////////////////////////
      po = comm.indexOf(",");
      if (po > -1) {
            comm = comm.substr(0,po);
      }
      ///////////////////////////////////

      var loc = "";
      loc += "?streetaddress=" + escape(addr);
      loc += "&city=" + escape(comm);
      loc += "&state=" + escape(state);
      loc += "&zip=" + escape(zip);
      loc += "&lon=" + escape(lon);
      loc += "&lat=" + escape(lat);

      var left = (scrWidth - (w + 10));
      var winAttr = "menubar=yes,toolbar=no,width="+w+",height="+h+",location=yes,scrollbars=yes,resizable=yes,status=yes,top=0,left=" + left;

      //locWin = window.open("/lois/getLocation.htm" + loc, "", winAttr);
      window.history.back();
      locWin = window.open("https://secure.locationone.com/lois/getLocation.htm" + loc, "", winAttr);
      locWin.focus();
}

//Function ends

//Function to show the image popup
function ShowImagePopUp(LocationType,LocationId,SelectedSequence)
{
    if(LocationType == "Building")
    {
        window.open("../ImagePopUp.aspx?BuildingId="+LocationId+"&SequenceNo="+SelectedSequence,null,"menubar=no width=525 height=500");
    }
    else if(LocationType == "Site")
    {
        window.open("../ImagePopUp.aspx?SiteId="+LocationId+"&SequenceNo="+SelectedSequence,null,"menubar=no width=525 height=500");
    }    
    return false;
}


// Verifies search entry before submitting search
function chkSearchFrm(frmQ) {
	if (document.getElementById(frmQ).value == "Search Site..." || document.getElementById(frmQ).value == "")
		{ alert("Please enter your search query!"); return false; }
	else { return true; }
}

function SetParentContentPage(framename,page,image)
{
    window.parent.location = page;
    //document.getElementById("imgSideImage").src = image;
    return false;
}

function SetWindowContentPage(pagename)
{
    window.parent.location.href = pagename;
}

function SetContentPage(framename,page,image) {
    try {
        if (document.getElementById(framename) != null) {
            document.getElementById(framename).src = page;
            try {
                if (top.frames[framename] != undefined && top.frames[framename].location != null) {
                    top.frames[framename].location = page;
                }
            }
            catch (err) {
                //Don't alert error because we're getting one trying to access .location on nearly every pageclick on iframed sites in firefox
            }
            if (document.getElementById('HiddenCurrentPage') != null) {
                document.getElementById('HiddenCurrentPage').value = page;
            }
        }
        else if (window.parent.document.getElementById(framename) != null) {
            window.parent.document.getElementById(framename).src = page;
            if (window.parent.document.getElementById('HiddenCurrentPage') != null) {
                window.parent.document.getElementById('HiddenCurrentPage').value = page;
            }
        }
    }
    catch (err) {
        alert(err);
    }
    return false;
}

function SetContentForSearchResults(framename) {
    document.getElementById(framename).contentWindow.reloadSearchResults();
}

function SetContentForSearchPanel(framename,page,type,image,e)
{
    
    window.location.href = page;

    return false;
}

function SetHeight(framename) {    
    document.getElementById(framename).height = document.getElementById(framename).contentWindow.document.body.offsetHeight + 30;
    if (document.getElementById(framename).height < 400)
        document.getElementById(framename).height = 400;

}
function SetHeightV2(framename) {
    // updated 1/29/2010 - base height off of form found in frame - cody
    // note - does not seem to work with property search
    var height = 400;
    if (document.getElementById(framename).contentWindow.document.forms[0].offsetHeight != null) {
        height = document.getElementById(framename).contentWindow.document.forms[0].offsetHeight + 30;
    }
    else {
        height = document.getElementById(framename).contentWindow.document.body.offsetHeight + 30;
    }
    document.getElementById(framename).height = height + "px";
    document.getElementById(framename).style.height = height + "px";
    if (height < 400) {
        document.getElementById(framename).height = 400 + "px";
        document.getElementById(framename).style.height = 400 + "px";
    }

}
function SetProfileName(profilename)
{
    var label =window.parent.document.getElementById("lblProfile");
    if (label != null)
    {
        label.innerText = profilename;
    }
}
function SetBreadCrumbLocationName(strValue) {
    // method to detect IE (Firefox, Safari ! support innerText) -JG
    var hasInnerText = (window.parent.document.getElementsByTagName("html")[0].innerText != undefined) ? true : false;

    window.parent.document.getElementById("lblProfile").innerHTML = strValue.split(":")[0]+": <a href=\"#\" onclick='SetContentPage(\"pagecontentframe\",\"General/Overview.aspx\",\"\");SetHeight(\"pagecontentframe\");'>"+ strValue.split(":")[1] +"</a>";
    if (!hasInnerText)
    {
        if (window.parent.document.getElementById("ltlStateNm1")) window.parent.document.getElementById("ltlStateNm1").textContent = strValue.split(":")[1]; 
        if (window.parent.document.getElementById("ltlStateNm2")) window.parent.document.getElementById("ltlStateNm2").textContent = strValue.split(":")[1];
    }
    else 
    {
        if (window.parent.document.getElementById("ltlStateNm1")) window.parent.document.getElementById("ltlStateNm1").innerText = strValue.split(":")[1]; 
        if (window.parent.document.getElementById("ltlStateNm2")) window.parent.document.getElementById("ltlStateNm2").innerText = strValue.split(":")[1];
    }
}

function HideCommunityPanel() {
    /*if request is coming from the hanlder display the searchdiv*/
    var appsection = document.getElementById('hdDisplaySection');
    if (appsection.value != "" && (appsection.value == "county" || appsection.value == "metro" || appsection.value == "community" || appsection.value == "state")) {
        var searchlabeldiv = document.getElementById('communityProfilesLink');
        ShowCommunityPanel();
        DisplaySearchData(appsection.value, null);
        appsection.value = "";
        return;
    }
    if (appsection.value != "" && appsection.value == "browsecommunity") {
        var searchlabeldiv = document.getElementById('communityProfilesLink');
        ShowCommunityPanel();
        appsection.value = "";
        return;
    }

    /******************************************************/
    var oDivCommElement = document.getElementById('searchdiv');
    if (oDivCommElement != null)
        oDivCommElement.style.display = "none";
    var commlabeldiv = document.getElementById('communityProfilesLink');
    if (commlabeldiv != null) {
        commlabeldiv.style.backgroundImage = "url('images/downArrow.gif')";
    }

    if (document.getElementById("countydiv") != null) document.getElementById("countydiv").style.visibility = "hidden";
    if (document.getElementById("communitydiv") != null) document.getElementById("communitydiv").style.visibility = "hidden";
    if (document.getElementById("metrodiv") != null) document.getElementById("metrodiv").style.visibility = "hidden";
    if (document.getElementById("statediv") != null) document.getElementById("statediv").style.visibility = "hidden";
}

function HideSearchPanel() {

    var oDivSearchElement = document.getElementById('searchRequestDiv');
    if (oDivSearchElement != null)
        oDivSearchElement.style.display = "none";

    var searchlabeldiv = document.getElementById('divSearchLink');

    if (searchlabeldiv != null) {
        searchlabeldiv.style.backgroundImage = "url('images/downArrow.gif')"
    }
}

function ShowCommunityPanel() {
    HideSearchPanel();

    if (document.getElementById("lblCounty") == null) {
        document.getElementById("labelcountyrow").style.display = "none";
        document.getElementById("imagecountyrow").style.display = "none";
    }
    if (document.getElementById("lblMetro") == null) {
        document.getElementById("labelmetrorow").style.display = "none";
        document.getElementById("imagemetrorow").style.display = "none";
    }
    if (document.getElementById("lblCommunity") == null) {
        document.getElementById("labelcommunityrow").style.display = "none";
        document.getElementById("imagecommunityrow").style.display = "none";
    }


    var oDivCommElement = document.getElementById('searchdiv');
    var commlabeldiv = document.getElementById('communityProfilesLink');
    if(oDivCommElement.style.display=='none'){
        commlabeldiv.style.backgroundImage = "url('images/upArrow.gif')";
        oDivCommElement.style.display = "";
    }
    else {
        HideCommunityPanel();
    }
}


function ShowSearchPanel() {
    HideCommunityPanel();
    var oDivSearchElement = document.getElementById('searchRequestDiv');
    
    var searchlabeldiv = document.getElementById('divSearchLink');
    if(oDivSearchElement.style.display=='none'){
        searchlabeldiv.style.backgroundImage = "url('images/upArrow.gif')";
        oDivSearchElement.style.display = "";
    }
    else {
        HideSearchPanel();
    }
}

        function DisplaySearchData(type,e)
        {
            if (!e && window.event!=null) var e = window.event;

            var oDivElement=document.getElementById(type+'div');     
            if (oDivElement.style.visibility != "visible")
            {
                oDivElement.style.visibility = "visible";
            }
            else
            {
               oDivElement.style.visibility = "hidden";     
               return;
            }
            var countydiv =  document.getElementById("countydiv");
            var communitydiv = document.getElementById("communitydiv");
            var metrodiv = document.getElementById("metrodiv");
            var statediv = document.getElementById("statediv");
            
            if (countydiv!=null)   countydiv.style.visibility = "hidden";
            if (communitydiv!=null)  communitydiv.style.visibility = "hidden";
            if (metrodiv!=null) metrodiv.style.visibility = "hidden";
            if (statediv!=null) statediv.style.visibility = "hidden";
            
            var countylabel = document.getElementById("lblCounty");
            var metrolabel = document.getElementById("lblMetro");
            var communitylabel = document.getElementById("lblCommunity");
            var statelabel = document.getElementById("lblStateLabel");
            
            oDivElement.style.height = "155px";
            oDivElement.style.width = "288px";
            oDivElement.style.display ="block";
            //oDivElement.style.border = "1";
            oDivElement.style.visibility = "visible";
            oDivElement.style.position="absolute";
                        
			//var y = e.clientY-100;
            //var a = y + "px";
            //oDivElement.style.top= a ;
            
            if(type == 'county')
            {
                if (statelabel == null)
                    oDivElement.style.top= '58px';
                else
                    oDivElement.style.top = '80px';
            }
            else if(type == 'metro')
            {
                if (countylabel !=null)
                    if (statelabel == null)
                        oDivElement.style.top = '80px';
                    else    
                        oDivElement.style.top= '105px';
                else
                    if (statelabel == null)
                        oDivElement.style.top = '58px';
                    else
                        oDivElement.style.top = '80px';
                            
            }
            else if(type == 'community')
            {
                
                if (countylabel!=null && metrolabel !=null)
                    if (statelabel == null)
                        oDivElement.style.top = '105px';
                    else    
                        oDivElement.style.top= '130px';
                else if (countylabel==null && metrolabel ==null)
                    if (statelabel == null)
                        oDivElement.style.top = '58px';
                    else
                        oDivElement.style.top = '80px';
                else    
                    if (statelabel == null)
                        oDivElement.style.top= '80px';
                    else
                        oDivElement.style.top = '105px';
            }
            else
            {
                oDivElement.style.top = '58px';
            }
            oDivElement.style.right = '0px'; // changed from left to right -- Cody - 12/27/2010
            oDivElement.className = "communitysearchresultsDiv";
            return false;
        }

        function printPage() {
            window.top.print();
        }

        
