﻿function doHighlight(elem,hilite)
{
    if(hilite == 1)
        elem.style.backgroundColor = "#5c7aa5";
    else
        elem.style.backgroundColor = "#ffffff";
}
function goTo(elem,loc)
{
    showProgressBar();
    elem.style.backgroundColor = "#5c7aa5";
    window.location = loc;
}
function showProgressBar()
{
    var btn = document.getElementById("progressWindow");
    btn.style.display  = "block";
    document.cookie = "ipResume=;expires=Thu, 01-Jan-70 00:00:01 GMT";
}
function hideProgressBar()
{
    var btn = document.getElementById("progressWindow");
    btn.style.display  = "none";
}
function doClick(elem,btnName)
{
    elem.style.backgroundColor = "#5c7aa5";
    var btn = document.getElementById(btnName);
    if (btn)
        btn.click();
 }
 function getMap(elem,url)
 {
    if(confirm("Display this listing in Google Maps?"))
    {
        elem.style.backgroundColor = "#5c7aa5";
        window.location = url;
    }
 }
//global variables that can be used by ALL the function son this page. 
var inputs; 
var imgFalse = 'images/cbOff.png'; 
var imgTrue = 'images/cbOn.png'; 

//this function runs when the page is loaded, put all your other onload stuff in here too. 
function init() { 
    replaceChecks(); 
    pageSlideIn();
} 

function replaceChecks() { 
    return;     // Bypassing this routine as it screws up the CSS for the rows, and hinders AutoPostback on checkboxes
    //get all the input fields on the page 
    inputs = document.getElementsByTagName('input'); 

    //cycle trough the input fields 
    for(var i=0; i < inputs.length; i++) { 

        //check if the input is a checkbox 
        if(inputs[i].getAttribute('type') == 'checkbox') { 
            if($(inputs[i]).getStyle('display') != "none")
            {
                //create a new image 
                var img = document.createElement('img'); 
                 
                //check if the checkbox is checked 
                if(inputs[i].checked) { 
                    img.src = imgTrue; 
                } else { 
                    img.src = imgFalse; 
                } 

                //set image ID and onclick action 
                img.id = 'checkImage'+i; 
                //set image 
                img.onclick = new Function('checkChange('+i+')'); 
                //place image in front of the checkbox 
                inputs[i].parentNode.insertBefore(img, inputs[i]); 
                 
                //hide the checkbox 
                inputs[i].style.display='none'; 
            }
        } 
    } 
}
 
function formatPhone(num)
{ 
  var _return = "";

  switch(num.length)
  { 
    case 7: 
	    _return= num.substring(0,3) + "-" + num.substring(3,7);
	    break;
    case 10: 
	    _return= "1 (" + num.substring(0,3) + ") " + num.substring(3,6) + "-" + num.substring(6,10);
	    break;
    case 11: 
	    _return= num.substring(0,1) + " (" + num.substring(1,4) + ") " + num.substring(4,7) + "-" + num.substring(7,11);
	    break;
    default:
	    _return=num;
	    break;
  }
  return _return; 
} 

//change the checkbox status and the replacement image 
function checkChange(i) { 

    if(inputs[i].checked) { 
        inputs[i].checked = ''; 
        document.getElementById('checkImage'+i).src=imgFalse; 
    } else { 
        inputs[i].checked = 'checked'; 
        document.getElementById('checkImage'+i).src=imgTrue; 
    } 
} 
function trim(sString) 
{
    while (sString.substring(0,1) == ' ')
    {
        sString = sString.substring(1, sString.length);
    }
    while (sString.substring(sString.length-1, sString.length) == ' ')
    {
        sString = sString.substring(0,sString.length-1);
    }
    return sString;
}

window.onload = init;

