var ns = (document.layers) ? true : false;
var ie = (document.all) ? true : false;

//=============================================================================
// window
//=============================================================================

function setHomePage (src)
{
    src.style.behavior = 'url(#default#homepage)';
    src.setHomePage('http://www.JeepTrip.com');
}

function addFavorite (src)
{
    window.external.AddFavorite(location.href, document.title);
}

function initPage ()
{
    //openOnTop();
}

function openOnTop ()
{
    if (top.location != self.location)
        top.location = self.location;
}

function openWindow (url, name, params)
{
	win = window.open(url, name, params);
	win.focus();
}

function closeWindow ()
{
	window.close();
}

function setDocument (url)
{
	document.location = url;
}

function printDocument () 
{
	window.print();
}

function openLink (url)
{
	openWindow(url, "", "toolbar=yes, location=yes, directories=yes, status=yes, menubar=yes, scrollbars=yes, resizable=yes");
}

function openFloat (url)
{
	openWindow(url, "", "toolbar=no, location=no, directories=no, status=yes, menubar=no, scrollbars=yes, resizable=yes, width=520, height=520");
}

function openPrint (url)
{
	openWindow(url + "&print=1", "", "toolbar=yes, location=no, directories=no, status=no, menubar=yes, scrollbars=yes, resizable=yes");
}

function openChat ()
{
	openWindow("page.asp?div=Chat&float=1", "Chat", "toolbar=no, location=no, directories=no, status=yes, menubar=no, scrollbars=no, resizable=no, width=652, height=506");
}

//=============================================================================
// query
//=============================================================================

function queryString ()
{
    queryVar = this.location.href;
    inq      = queryVar.indexOf("?");
    queryVar = queryVar.substring(inq + 1);

    if (inq > 0)
    {
        text1     = "&";
        strLength = queryVar.length;
        txtLength = text1.length;

        i = queryVar.indexOf(text1);

        while (i + txtLength < strLength)
        {
        	if (i > 0)
        		querySplit(queryVar.substring(0, i), "=");
        	else
        		querySplit(queryVar, "=");

        	queryVar = queryVar.substring(i + txtLength, strLength);
        	var i = queryVar.indexOf(text1);

        	if (i < 1)
        		i = strLength + 1;
        }

        querySplit(queryVar, "=");
    }
}

function querySplit (string, text)
{
	name  = string.substring(0, string.indexOf(text));
	value = string.substring(string.indexOf(text) + 1);
	eval("query_" + name + " = unescape(value);");
}

//=============================================================================
// images
//=============================================================================

function imagesPreload ()
{
    var d = document; 

    if (d.images)
    {
        if(!d.MM_p)
            d.MM_p = new Array();
        var i;
        var j = d.MM_p.length;
        var a = imagesPreload.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 imageRestore ()
{
    var i;
    var x;
    var a = document.MM_sr;
    for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++)
        x.src = x.oSrc;
}

function imageSwap ()
{
    var i;
    var j = 0;
    var x;
    var a = imageSwap.arguments;
    document.MM_sr = new Array;
    for (i = 0; i < (a.length - 2); i += 3)
    if ((x = findObject(a[i])) != null)
    {
        document.MM_sr[j++] = x;
        if(!x.oSrc)
            x.oSrc = x.src; 
        x.src = a[i + 2];
    }
}

function findObject (n, d)
{
    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 = findObject(n, d.layers[i].document);
    if (!x && document.getElementById)
        x = document.getElementById(n); 
    return x;
}

//=============================================================================
// mouse
//=============================================================================

var mouseX  = 0;
var mouseY  = 0;

function activateMouse ()
{
    window.onload = function()
    {
        if (ns)
            document.captureEvents(Event.MOUSEMOVE);
        document.onmousemove = getMousePosition;
    }
}

function getMousePosition (e)
{
    if (ns)
    {
        mouseX = e.pageX;
        mouseY = e.pageY;
    }
    else 
    {
        mouseX = event.clientX;
        mouseY = event.clientY;
    }
    return true;
}

//=============================================================================
// popup
//=============================================================================

var popupItem;
var popupShowEdge = 0;
var popupHideEdge = -374;

function popupInit ()
{
    popupItem = (ns) ? document.getElementById("popup_menu").style : document.all.popup_menu.style;
}

function popupShow ()
{
    if (window.doHide)
        clearInterval(doHide)
    doShow = setInterval("popupShowEngine()", 4);
}

function popupHide ()
{
    clearInterval(doShow);
    doHide = setInterval("popupHideEngine()", 4);
}

function popupShowEngine ()
{
    if (ie && popupItem.pixelTop < popupShowEdge)
        popupItem.pixelTop += 5;
    else if (ns && parseInt(popupItem.top) < popupShowEdge)
        popupItem.top = parseInt(popupItem.top) + 2;
    else if (window.doShow)
        clearInterval(doShow);
}

function popupHideEngine ()
{
    if (ie && popupItem.pixelTop > popupHideEdge)
        popupItem.pixelTop -= 5;
    else if (ns && parseInt(popupItem.top) > popupHideEdge)
        popupItem.top = parseInt(popupItem.top) - 2;
    else if (window.doHide)
        clearInterval(doHide);
}

