﻿function SubmitForm() {

    var zip = document.getElementById('txtZipCode');
    if (zip != null) {
	pic1 = new Image(1, 1); pic1.src = "http://www.relocation.com/clicktrack.aspx?type=trackpartnerclick&url=" + location.href + "&serviceProv=USRealEstate.com";
        window.open('http://www.usrealestate.com/find_agent.asp?z=' + zip.value +'&search_type=direct_zip');
    }
}

function ChangePointer(ctr) {
    ctr.style.cursor = 'hand';
}
function CreateForm() {
    var html = "";
    html += "<div class='fpinner'>";
    html += "   <div class='fpinner-top'>";
    html += "       <div class='fpinner-bottom'>";
    html += "           <div class='smartquote'>";
    html += "               <div class='quoteform'>";
    html += "                   <div class='qftiem_short' style='padding-left: 3px;'>";
    html += "                       <label for='hezp'>Enter Zip Code:</label><br />";
    html += "                       <span>";
    html += "                           <input type='text' maxlength='5' class='txtStyle' id='txtZipCode' />&nbsp;<span id='Span4' onclick='ShowZipFinder(this)' class='js_field_zipfinder'>Zip Finder</span> ";
    html += "                       </span>";
    html += "                   </div>";
    html += "                   <div class='qftiem_short'>";
    html += "                       <img src='http://www.relocation.com/files/buttons/button_submit.jpg' onclick='SubmitForm()' onmouseover='ChangePointer(this)'  />";
    html += "                   </div> <!-- qftiem_short -->";
    html += "               </div> <!-- quoteform -->";
    html += "           </div> <!-- smartquote -->";
    html += "       </div> <!-- fpinner-bottom -->";
    html += "   </div> <!-- fpinner-top -->";
    html += "</div> <!-- fpinner -->";
    html += "<div class='sf_rb'><!-- --></div>";
    html += "</div>";


    document.write(html);
    HideDhtml();
}

document.write('<div id="DhtmlDiv" class="js_form_zipfinder"><div class="jsf_close"><span onclick="HideDhtml()">Close</span></div><div class="jsf_iframe"><iframe src="/MiscPages/ZipCodeFinder.aspx?FromJS=true" id="iFrameZipFinder" frameborder="0" width="250" height="250"></iframe></div></div>');
function ShowZipFinder(obj) {
    findPosition(obj, "DhtmlDiv");
}

function findPosition(oElement, dhtmlDiv) {
    oDiv = document.getElementById(dhtmlDiv);
    if (typeof (oElement.offsetParent) != 'undefined') {
        for (var posX = 0, posY = 0; oElement; oElement = oElement.offsetParent) {
            posX += oElement.offsetLeft;
            posY += oElement.offsetTop;
        }
        oDiv.style.top = posY;
        if (dhtmlDiv == 'DhtmlDiv') {
            oDiv.style.top = posY - 70 + 'px';
        }

        oDiv.style.left = posX + 115 + 'px';
    }
    else {
        oDiv.style.top = oElement.y + 'px';
        oDiv.style.left = oElement.x + 'px';
    }
    oDiv.style.visibility = 'visible';
}

function HideDhtml() {
    document.getElementById('DhtmlDiv').style.visibility = 'hidden';
}

function SetZipOfParent(zipCode) {

    var zip = document.getElementById('txtZipCode');
    if (zip != null) {
        zip.value = zipCode;
    }

    HideDhtml();
}
