﻿function showHelpDiv(propertyId) {
    //alert("Div to show is: " + propertyId);
    var helpDiv = "helpDiv_" + propertyId;
    document.getElementById(helpDiv).style.display = "block";
    
}

//SyndicationDiv
function showSyndicationHelp(msg,e)
{
        var tempX = 0;
        var tempY = 0;
        var IE = document.all?true:false

        if (IE)
        {
                //alert('IE');
                tempX = event.clientX + document.documentElement.scrollLeft
                tempY = event.clientY + document.documentElement.scrollTop
                //alert(document.documentElement.scrollTop);
        } else {
                //alert('Firefox - Not IE');
                tempX = e.pageX
                tempY = e.pageY
        }
        //alert(tempX + " " + tempY);
        messageDiv = document.getElementById("SyndicationDiv");
        //alert(document.getElementById("msgDiv"));
        //messageDivBody = document.getElementById("msgBoardText");
        messageDiv.style.visibility="visible";
        messageDiv.style.top = (tempY - 50) + 'px';
        messageDiv.style.left = (tempX + 18) + 'px';
        //messageDivBody.innerHTML = "<br />&nbsp;&nbsp;&nbsp;&nbsp;Look how cool!";

}

function showQuickSearchHelp(msg,e)
{
        var tempX = 0;
        var tempY = 0;
        var IE = document.all?true:false

        if (IE)
        {
                //alert('IE');
                tempX = event.clientX + document.documentElement.scrollLeft
                tempY = event.clientY + document.documentElement.scrollTop
        } else {
                //alert('Firefox - Not IE');
                tempX = e.pageX
                tempY = e.pageY
        }
        //alert(tempX + " " + tempY);
        messageDiv = document.getElementById("msgQuickCheckDiv");
        //alert(document.getElementById("msgDiv"));
        //messageDivBody = document.getElementById("msgBoardText");
        messageDiv.style.visibility="visible";
        messageDiv.style.top = (tempY - 50) + 'px';
        messageDiv.style.left = (tempX + 18) + 'px';
        //messageDivBody.innerHTML = "<br />&nbsp;&nbsp;&nbsp;&nbsp;Look how cool!";

}

function showPropDetails(e, imageUrl, address1, address2, city, state, zip)
{
    var tempX = 0;
    var tempY = 0;
    var IE = document.all?true:false

    if (IE)
    {
         //alert('IE');
         tempX = event.clientX + document.documentElement.scrollLeft
         tempY = event.clientY + document.documentElement.scrollTop
    } else {
         //alert('Firefox - Not IE');
         tempX = e.pageX
         tempY = e.pageY
    }
        //alert(tempX + " " + tempY);
        addressDiv = document.getElementById("addressDetailsDiv");
        addressDiv = document.getElementById("addressDetailsDiv");
        addressDiv.style.visibility="visible";
        addressDiv.style.top = (tempY) + 'px';
        addressDiv.style.left = (tempX - 200) + 'px';
        //alert(imageUrl);
        document.getElementById("streetAddress1Span").innerHTML = address1;
        document.getElementById("streetAddress2Span").innerHTML = address2;
        document.getElementById("citySpan").innerHTML = city;
        document.getElementById("stateSpan").innerHTML = state;
        document.getElementById("zipSpan").innerHTML = zip;
        document.getElementById("propertyThumb").src = imageUrl
}

function closePropDetails()
{
    addressDiv = document.getElementById("addressDetailsDiv");
    addressDiv.style.visibility='hidden';
}

function hideSyndicationHelp()
{
        messageDiv = document.getElementById("SyndicationDiv");
        messageDiv.style.visibility='hidden';
}

function hideQuickCheckHelp()
{
        messageDiv = document.getElementById("msgQuickCheckDiv");
        messageDiv.style.visibility='hidden';
}

function hideHelpDiv(propertyId) {
    //alert("Div to show is: " + propertyId);
    var helpDiv = "helpDiv_" + propertyId;
    document.getElementById(helpDiv).style.display = "none";
    
}

function showValues(e, propertyId) {
     var posx = 0;
     var posy = 0;

     if (!e)
          var e = window.event;

     if (e.pageX || e.pageY) {
            //alert("Page X/Y");
          posx = e.pageX;
          posy = e.pageY;
     } else if (e.clientX || e.clientY) {
           // alert("client X/Y  " + document.documentElement.scrollTop);
          posx = e.clientX + document.body.scrollLeft;
          posy = e.clientY + document.documentElement.scrollTop;
     }
     
     // posx and posy contain the mouse position relative to the document
     // Do something with this information
     // alert('posX = ' + posx + '\nposY = ' + posy);
     var helpDiv = document.createElement("div");
     helpDiv.setAttribute('id', 'help_Div');
     helpDiv.style.cssText = 'position: absolute; left: ' + (posx -140) + 'px; top: ' + posy  + 'px; border: solid 1px #000; background-color: #c6c6c6;  width: 240px; padding: 0px 8px 8px 8px; color: #fff;';
     helpDiv.style.zIndex = '2';
     
     
     document.body.appendChild(helpDiv);
     
     helpDiv.innerHTML = createHelpMenuBar() + '<p>Although you can set a property to active you must checkout before it will show up in the search as an available property</p>';
     helpDiv.innerHTML += '<p>However, if you have purchased a 30 day listing and you are still within that 30 day window you can set the property active or inactive during that'; 
     helpDiv.innerHTML += 'period as many times as you need to and you will not be charged agian.</p><p>If you need further assistance please contact us.. (link)</p>';
     
}

function createHelpMenuBar()
{
    var menuBarDiv = "<div style='height: 15px; width: 248px; background-color: #84a2ec; color: #fff'>";
    menuBarDiv += "<a href='#' style='text-decoration: none; color: #fff;' onclick='removeElement(); return false;'>[x]</a>";
    menuBarDiv += "</div>";
    return menuBarDiv;
}

function removeElement() {
  //var d = document.getElementById('myDiv');
  //var olddiv = document.getElementById(divNum);
  //d.removeChild(olddiv);
  document.body.removeChild(document.getElementById('help_Div'));
}

function showOtherOptionsDiv(divName) {
    document.getElementById(divName).style.display = "block";
}
function hideOtherOptionsDiv(divName) {
    document.getElementById(divName).style.display = "none";
}


function showOtherListings()
{
    document.getElementById('moreListingsDiv').style.display = "block";
}

function hideOtherListings()
{
    document.getElementById('moreListingsDiv').style.display = "none";
}

function clearText()
{
    
    //alert(document.getElementById('ctl00_Main_PropertyListingRepeater_ctl00_HttpLinkTextBox').value);
    //document.getElementById('ctl00_Main_PropertyListingRepeater_ctl00_HttpLinkTextBox').value = "";
    //ctl00_Main_PropertyListingRepeater_ctl00_CgHtmlTextArea
    //alert("I am about to clear ctl00_Main_PropertyListingRepeater_ctl00_CgHtmlTextArea");
    document.getElementById('ctl00_Main_CraigListTextarea').value = "";
}

function checkTermsOfService()
{
    if(document.getElementById('ctl00_Main_TermsOfUseCheckBox').checked == false)
    {
        alert ('You must agree to the terms of service.');
		return false;
    } else {
        return true;
    }
    
}

function showHideLandlordContent(divName)
{
    var link = divName + "_Link";
    if(document.getElementById(divName).style.display == "block")
    { 
        document.getElementById(link).innerHTML = "[+]";
        document.getElementById(divName).style.display = "none";
    } else {
        document.getElementById(link).innerHTML = "[-]";
        document.getElementById(divName).style.display = "block";
    }
}

function copySelect() {
    
    var tempval = eval(document.getElementById('ctl00_Main_PropertyListingRepeater_ctl00_CgHtmlTextArea'))
    tempval.focus()
    tempval.select()
    therange = tempval.createTextRange()
    therange.execCommand("Copy")
}

