function MM_swapImgRestore()
{ //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages()
{ //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d)
{ //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage()
{ //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function isLowRes()
{
	if (self.screen) return (screen.width < 1024);
	else if (navigator.javaEnabled && navigator.javaEnabled()) return (java.awt.Toolkit.getDefaultToolkit().getScreenSize().width < 1024);
	else return true;
}

function in_array(needle,haystack)
{
	// function in_array(needle,haystack)
	// craig heydenburg 4/8/02
	// this function is similar to the PHP function of the same name
	var bool = false;
	for (var i=0; i<haystack.length; i++)
	{
		if (haystack[i]==needle) { bool=true; }
	}
	return bool;
}

function findObj(n, d) { //v4.0
	var p,i,x;
	if(!d) d=document;
	if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n];
	for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && document.getElementById) x=document.getElementById(n);
	return x;
}

function prop(obj) { 
	var str = '';
	for (p in obj) {
		str += ('<div><font size=\"-1\"><b>' + p + '</b> '+ obj[p] + '</font></div>\n');
	}
	return str;
}

function trim(inputString)
{
	// Removes leading and trailing spaces from the passed string. Also removes
	// consecutive spaces and replaces it with one space. If something besides
	// a string is passed in (null, custom object, etc.) then return the input.
	if (typeof inputString != "string") { return inputString; }
	var retValue = inputString;
	var ch = retValue.substring(0, 1);
	while (ch == " ")
	{
		retValue = retValue.substring(1, retValue.length);
		ch = retValue.substring(0, 1);
	}
	ch = retValue.substring(retValue.length-1, retValue.length);
	while (ch == " ")
	{
		retValue = retValue.substring(0, retValue.length-1);
		ch = retValue.substring(retValue.length-1, retValue.length);
	}
	while (retValue.indexOf("  ") != -1)
	{
		retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
	}
	 return retValue;
}

function roundIt(val, q) {
	if (!q) q = 2;
	mul = Math.pow(10, Math.round(q));
	if ( isNaN(val) ) return '';
	return (Math.round(parseFloat(val)*mul)/mul);
}

function in_array(needle,haystack)
{
	// function in_array(needle,haystack)
	// craig heydenburg 4/8/02
	// this function is similar to the PHP function of the same name
	var bool = false;
	for (var i=0; i<haystack.length; i++)
	{
		if (haystack[i]==needle) { bool=true; }
	}
	return bool;
}


// ---------------------------------------------------
// ShowHint, v.1.2
// Pavel Shouryguin (psion@mail.ru)
// 06.11.2003-12.11.2003
// you can use it without any limitations
//
// a lot of thanks to Peter-Paul Koch,
// http://www.xs4all.nl/~ppk/js/doctype_on.html

document.write("<style type=\"text/css\">");
document.write("#hintmessage { position:absolute; visibility:hidden; border: 0px solid black; font-family: Arial; font-size:8pt; padding: 2px 5px; margin: 0; text-align: left }");
document.write("</style>");

img1 = new Image; img1.src = '/images/map_lay_left.gif';
img2 = new Image; img2.src = '/images/map_lay_right.gif';
img3 = new Image; img3.src = '/images/map_lay_bg.gif';

var crossobj=false;
var timerId = 0;
var pos_X = 0;
var pos_Y = 0;
var tpl = '<div class="floaty" style="border: 2px solid #DFA015; width: 150px; height: 60px; background-color: white; vertical-align: middle; padding: 4px">~t~</div>';
var oldtpl = '<table width="150" border="0" cellspacing="0" cellpadding="0"><tr><td width="8"><img src="/images/map_lay_left.gif" width="8" height="54"></td><td background="/images/map_lay_bg.gif" class="floaty">~t~</td><td width="8"><img src="/images/map_lay_right.gif" width="8" height="54"></td></tr></table>';

/**
 * Show the hint message
 *
 * @param   string      Text of hint message (html, backslash-escaped)
 * @param   object      event
 * @param   int         delay showing the hint for xxxx msec, 0 - immediately
 * @param   int         force hiding hint after xxxx msec, 0 - do not force
 * @access  public
 */

function showhint(text, e, delay, timeout) {
    var crossobj=document.getElementById? document.getElementById("hintmessage") : document.all.hintmessage;

	text = tpl.replace("~t~", text);

    if (typeof delay == 'undefined')
        delay = 0;
    if (typeof timeout == 'undefined')
        timeout = 0;

    if ( typeof e == "object" ) {
        if ( typeof(e.pageX) == 'number' ) {
            pos_X = e.pageX;
            pos_Y = e.pageY;
        }
        else if ( typeof(e.clientX) == 'number' ) {
            pos_X = e.clientX;
            pos_Y = e.clientY;
            if ( document.body && ( document.body.scrollTop || document.body.scrollLeft ) && !( window.opera || window.debug || navigator.vendor == 'KDE' )) {
                pos_X += document.body.scrollLeft;
                pos_Y += document.body.scrollTop;
            }
            else if ( document.documentElement && ( document.documentElement.scrollTop || document.documentElement.scrollLeft ) && !( window.opera || window.debug || navigator.vendor == 'KDE' ) ) {
                pos_X += document.documentElement.scrollLeft;
                pos_Y += document.documentElement.scrollTop;
            }
        } else {
            pos_X = -1;
            pos_Y = -1;
        }

        if ((pos_X >= 0) && (pos_Y >= 0)) {

            var scroll_X = 0;
            var scroll_Y = 0;

            if ( document.body && ( document.body.scrollTop || document.body.scrollLeft ) && !( window.debug || navigator.vendor == 'KDE' )) {
                scroll_X = document.body.scrollLeft;
                scroll_Y = document.body.scrollTop;
            }
            else if ( document.documentElement && ( document.documentElement.scrollTop || document.documentElement.scrollLeft ) && !( window.debug || navigator.vendor == 'KDE' )) {
                scroll_X = document.documentElement.scrollLeft;
                scroll_Y = document.documentElement.scrollTop;
            }

            var win_size_X = 0;
            var win_size_Y = 0;

            var win_size_X = 0;
            var win_size_Y = 0;

            if (window.innerWidth && window.innerHeight) {
                win_size_X = window.innerWidth;
                win_size_Y = window.innerHeight;
            }
            else if (document.documentElement && document.documentElement.clientWidth && document.documentElement.clientHeight) {
                win_size_X = document.documentElement.clientWidth;
                win_size_Y = document.documentElement.clientHeight;
            }
            else if (document.body && document.body.clientWidth && document.body.clientHeight) {
                win_size_X = document.body.clientWidth;
                win_size_Y = document.body.clientHeight;
            }

            pos_X += 15;
            pos_Y += 15;
        }
    }

    crossobj.innerHTML=text;

    if (crossobj.offsetWidth > 300) {
        crossobj.style.width = 300;
    }

    if (crossobj.offsetWidth && crossobj.offsetHeight) {

        if (pos_X - scroll_X + crossobj.offsetWidth + 5 > win_size_X)
            pos_X -= (crossobj.offsetWidth + 15);
        if (pos_Y - scroll_Y + crossobj.offsetHeight + 5 > win_size_Y)
            pos_Y -= (crossobj.offsetHeight + 15);
    }

    crossobj.style.left = pos_X + "px";
    crossobj.style.top = pos_Y + "px";

    if (delay > 0) {
        if (timerId == 0)
            timerId = window.setTimeout("showhint('"+text+"', 0, 0, "+timeout+")", delay);
    } else {
        if (timerId != 0) {
            window.clearTimeout(timerId);
            timerId = 0;
        }
        crossobj.style.visibility = "visible";
        if (timeout > 0)
            timerId = window.setTimeout('hidehint()', timeout);
    }
}

/**
 * Hide hint message
 *
 * @access  public
 */

function hidehint()
{
    if (!crossobj)
        crossobj=document.getElementById? document.getElementById("hintmessage") : document.all.hintmessage;
    crossobj.innerHTML='';
    crossobj.style.visibility="hidden";
    crossobj = false;
    window.clearTimeout(timerId);
    timerId = 0;
}
