//var menuDrop = document.getElementById( "menuDrop" );
var hTimer;

// ------------------------------------------------------------------------
//
// ------------------------------------------------------------------------
function getTop( obj ) {
    var res = obj.offsetTop;
    var p = obj.offsetParent;
    while ( p != null ) {
        res += p.offsetTop;
        p = p.offsetParent;
    }
    return res;
}

// ------------------------------------------------------------------------
//
// ------------------------------------------------------------------------
function getLeft( obj ) {
    var res = obj.offsetLeft;
    var p = obj.offsetParent;
    while ( p != null ) {
        res += p.offsetLeft;
        p = p.offsetParent;
    }
    return res;
}

// ------------------------------------------------------------------------
//
// ------------------------------------------------------------------------
function menuHorOnMouseOver( Index, obj ) {
    if ( hTimer != null ) {
        clearTimeout( hTimer );
        menuHorHide();
    }
    var sample = "<div class=\"menuVert\" onMouseOver=\"clearTimeout( hTimer );\" onMouseOut=\"menuHorOnMouseOut()\" onClick=\"LoadFunc( process, '@1@' );\">@2@</div>"
    switch ( Index ) {
        case 0 : 
            menuDrop.innerHTML = 
                sample.replace( "@1@", "http://jasper.com.ua/photo_pictures/articles.php?haveheader=without" ).replace( "@2@", "Статьи" ) +
                sample.replace( "@1@", "http://jasper.com.ua/photo_pictures/about_production.php?haveheader=without" ).replace( "@2@", "О продукции" );
            break;

        case 1 : 
            menuDrop.innerHTML =
                sample.replace( "@1@", "http://jasper.com.ua/banners/banner_examples.php?haveheader=without" ).replace( "@2@", "Примеры работ" ) +
                sample.replace( "@1@", "http://jasper.com.ua/banners/banner_price.php?haveheader=without" ).replace( "@2@", "Цены" );
            break;

        case 2 : 
            menuDrop.innerHTML =
                sample.replace( "@1@", "http://jasper.com.ua/just-in-time_print/faq.php?haveheader=without" ).replace( "@2@", "FAQ" );
            break;
    }

    menuDrop.style.top = getTop( obj ) + obj.offsetHeight + "px";
    menuDrop.style.left = getLeft( obj ) + "px";
//    menuDrop.style.width = obj.offsetWidth + "px";
//    menuDrop.style.display = "block";

    menuDrop.style.width = "auto";
    menuDrop.style.display = "block";

    if ( menuDrop.offsetWidth < obj.offsetWidth )
        menuDrop.style.width = obj.offsetWidth + "px";

}

// ------------------------------------------------------------------------
//
// ------------------------------------------------------------------------
function menuHorHide() {
    menuDrop.style.display = "none";
}

// ------------------------------------------------------------------------
//
// ------------------------------------------------------------------------
function menuHorOnMouseOut() {
    hTimer = setTimeout( menuHorHide, 500 );
}

/**************************************************************************************

**************************************************************************************/
var xmlDoc;

// ------------------------------------------------------------------------
//
// ------------------------------------------------------------------------
function LoadFunc( ProcessFunc, URLStr )
{
    if ( typeof window.ActiveXObject != 'undefined' ) {
        xmlDoc = new ActiveXObject("Microsoft.XMLHTTP");
        xmlDoc.onreadystatechange = ProcessFunc;
    }
    else {
        if( xmlDoc == null ) xmlDoc = new XMLHttpRequest();
        xmlDoc.onload = ProcessFunc;
    }
    xmlDoc.open( "GET", URLStr, true );
    xmlDoc.send( null );
}

// ------------------------------------------------------------------------
//
// ------------------------------------------------------------------------
function process() {
    div = document.getElementById( "loadDiv" );
    div.innerHTML = xmlDoc.responseText;
}
