/*
 *  Project:    REALTOR 747
 *  Author(s):  Frank Oh
 *  Website:    www.it747.com
 *  Copyright:  This is the property of IT747.COM
 *              You are not allowed to change anything in this file
 *              without the permission of the owner.
 */


function
win( name, msg )
{
    var w = window.open( '', name, '' );
    var d = w.document;

    d.open();
    d.write( msg );
    d.close();
}


function
dump_obj( obj )
{
    var o = get_object( obj )
    if ( ! o ) {
        alert( o + " is not an object !" );
        return;
    }

    var msg = '';
    for ( var p in o ) {
        msg += "<b>" + p + "</b>" + ": " + typeof( o[ p ]) + ":" + o[ p ] + "<br>" + "\n";
    }
    // alert( msg );
    win( 'dump', msg );

}


function
random( max )
{
    var d = Math.floor( Math.random() * max );

    return ( d );
}

function
get_absolute_left( obj_id )
{
    var obj = document.getElementById( obj_id );
    var left = obj.offsetLeft;

    while ( obj.offsetParent ) {
        var parent = obj.offsetParent;
        left += parent.offsetLeft;
        obj = parent;
    }

    return ( left );

}


function
get_absolute_top( obj_id )
{
    var obj = document.getElementById( obj_id );
    var top = obj.offsetTop;

    while ( obj.offsetParent ) {
        var parent = obj.offsetParent;
        top += parent.offsetTop;
        obj = parent;
    }

    return ( top );
}


function
show_it( left, top, target_obj_id, no_zindex )
{
    var obj = document.getElementById( target_obj_id );
    var style = obj.style;

    if ( no_zindex === undefined ) no_zindex = false;   // default

    if ( ! no_zindex ) style.zIndex     = 100;
    style.position   = 'absolute';
    style.left       = left + 'px';
    style.top        = top  + 'px';
    style.visibility = 'visible';

}

function
hide_it( target_obj_id )
{
    var obj = document.getElementById( target_obj_id );
    var style = obj.style;

    style.visibility = 'hidden';
}

function
resize_it( width, height, target_obj_id )
{
    var obj = document.getElementById( target_obj_id );
    var style = obj.style;

    style.width      = width + 'px';
    style.height     = height + 'px';

}

function
nothing()
{
}

function
not_object( obj )
{
    var ret = false;

    if ( typeof( obj ) === typeof( 'string' ) ) {
        ret = true;
    }

    return ( ret );
}

function
get_object( obj )
{
    var o = obj;

    if ( not_object( o ) ) {
        var o = document.getElementById( o );
    }

    return ( o );
}


function
clear_once( obj )
{
    var o = get_object( obj );

    if ( o && ! o.done ) {
        o.value = '';
        o.done = true;
    }

}

function
clear_value( obj, focus )
{
    if ( focus === undefined ) focus = true; // default

    var o = get_object( obj );

    if ( o ) {
        if ( o.value ) o.value = '';
        if ( focus ) o.focus();
    }
}

function
startup()
{
    enableMenu();
    easy_read_table();
}

function
shutdown()
{
}

function
pdf_view( href )
{
    var w = open( href, 'pdf_view', 'toolbar=no,scrollbars=yes,resizable=yes,width=800' );
    w.moveTo( 0, 0 );
    w.focus();
}

function
easy_read_table()
{
  // window.onload = function()
   var elem = "TR"; // Object you want to affect: TR or TD
   var rClick;

  if(document.getElementsByTagName){
   var el = document.getElementsByTagName(elem);
    for(var i=0; i<el.length; i++){
      if(el[i].childNodes[0].tagName != "TH"
      && el[i].parentNode.parentNode.className.indexOf("easy_read_table") != -1){
     if(i%2 == 1){
      el[i].className = "on";
      el[i].oldClassName = "on";
      el[i].onmouseout  = function(){
         this.className = "on";
      }
    } else {
      el[i].className = "off";
      el[i].oldClassName = "off";
      el[i].onmouseout  = function(){
         this.className = "off";
      }
    }
      el[i].onmouseover = function(){
         if(this.className == this.oldClassName)
           {this.className = "hover";}
         if(this.onmouseout == null && this.className != "click"){
            this.onmouseout = function(){
                this.className = this.oldClassName;
            }
         }
      }
      el[i].onclick = function(){
          if(this.className != "click"){
             this.className = "click";
          } else {
             this.className = this.oldClassName;
          }
        this.onmouseout = null;
       }
    }
   }
 }
}

function
get_radio_button_value( form, button_name )
{
    var value = false;

    for (var n=0; n<form[ button_name ].length; n++)
    {
        if ( form[ button_name][n].checked ) {
            value = form[ button_name][n].value;
        }
    }

    return ( value );
}



/* vim: set expandtab sw=4 ts=4 sts=4: */

