﻿function postdata() {
    var pidValue = document.getElementById("pid").value;
    var searchValue = document.getElementById("searchtext").value;
    if (searchValue == "Enter an item or keyword:" || searchValue == "Enter a make, model, or zip code:" || searchValue == "Enter a city, neighborhood or keyword:") {
        searchValue = "";
    }
    var regionValue = document.getElementById("region").value;
    postwith("http://secure.adpay.com/search.aspx", { pid: pidValue, search: searchValue, region: regionValue });
}

function postwith(to, p) {
    var myForm = document.createElement("form");
    myForm.method = "post";
    myForm.action = to;
    for (var k in p) {
        var myInput = document.createElement("input");
        myInput.setAttribute("name", k);
        myInput.setAttribute("value", p[k]);
        myForm.appendChild(myInput);
    }
    document.body.appendChild(myForm);
    myForm.submit();
    document.body.removeChild(myForm);
}



function textClear(input) {
    if (input.value == input.defaultValue) {
        input.value = "";
    }
}
function textRestore(input) {
    if (input.value == "") {
        input.value = input.defaultValue;
    }
}
function highlight(image) {
    document.getElementById(image).src = 'http://the570.com/images/classifieds/' + image.toString().replace('.jpg','highlighted.jpg');
}
function unhighlight(image) {
    document.getElementById(image).src = 'http://the570.com/images/classifieds/' + image.toString().replace('highlighted.jpg', '.jpg');
}