﻿var pathRoot = 'http://www.busconexpo.com';

var axel = Math.random() + "";
var ord = axel * 1000000000000000000;

function PopUpWindow(page, window_name, window_width, window_height, window_features) {
    window_features = window_features + ", width=" + window_width + ", height=" + window_height;
    //document.CtrlWindow.close;
    OpenWin = window.open(page, window_name, window_features);
}

function PrintPopUp(page) {
    PopUpWindow(page, 'Print', 700, 600, 'toolbar=yes,menubar=yes,location=no,scrollbars=yes,resizable=yes');
}

function PhotoGalleryImageViewer(image, title) {
    PopUpWindow(pathRoot + '/PhotoGallery/ImageViewer.aspx?title=' + title + '&image=' + image, 'PhotoGalleryImage', 950, 575, 'toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no');
}
//height:685



// Menu
var timeout = 5000;
var closetimer = 0;
var closetabtimer = 0;
var menuitem = 0; // represents the bottom menu
var tabmenuitem = 0;
var startmenuitem_left = 0;
var startmenuitem_right = 0;

function menu_open(item) {

    menu_canceltimer();
    menu_canceltabtimer();
    menu_close();
    menuitem = $(item).find('ul').css('visibility', 'visible'); // show bottom menu, get jquery object that represents the <ul> element

    menuitem.find('a').removeClass('selected'); // removed selected class from all <a> tags
}

function menu_close() {
    if (menuitem) {
        menuitem.css('visibility', 'hidden');
    }
}

function tab_close() {
    $('#menu a').removeClass('selected');
    $('#menu li').removeClass('selected');
    startmenuitem_left.addClass('selected');
    startmenuitem_right.addClass('selected');
}

function menu_timer() {
    closetimer = window.setTimeout(menu_close, timeout);
}

function tab_timer() {
    closetabtimer = window.setTimeout(tab_close, timeout);
}

function menu_canceltimer() {
    if (closetimer) {
        window.clearTimeout(closetimer);
        closetimer = null;
    }
}

function menu_canceltabtimer() {
    if (closetabtimer) {
        window.clearTimeout(closetabtimer);
        closetabtimer = null;
    }
}

function menu_select(parentID, url, externalLink) {
    $.cookie('parentID', parentID, { path: '/', expires: 1 });
    if (externalLink === "true") {
        window.open(url, "", "", "");
    }
    else {
        window.location.href = url;
    }
}

function bottommenu_select(parentID, menuID, url, externalLink) {
    $.cookie('parentID', parentID, { path: '/', expires: 1 });
    $.cookie('menuID', menuID, { expires: 1 });
    if (externalLink === "true") {
        window.open(url, "", "", "");
    }
    else {
        window.location.href = url;
    }
}

$(document).ready(function() {
    $('.menuListItem').bind('mouseover', function() {
        $('#menu a').removeClass('selected'); // remove 'selected class from all <a> tags
        $('#menu li').removeClass('selected'); //remove 'selected' class from all <li> tags
        $(this).addClass('selected'); // change <li> tag class to 'selected' (rounded corner)
        $(this).find(':first-child').addClass('selected'); // change <a> tag class to 'selected' (rouned corner)
        $('#menu li ul li').removeClass('selected'); // remove the selected class that carries over from the parent <li>
        menu_open(this);
    });

    $('.menuListItem').bind('mouseout', function() {
        $(this).find(':first-child').addClass('selected');
        $(this).find('ul li a').removeClass('selected');
        $('#menu li ul li').removeClass('selected'); // remove the selected class that carries over from the parent <li>
        tab_timer();
        menu_timer();
    });

    startmenuitem_left = $('#menu a.selected');
    startmenuitem_right = $('#menu li.selected');
});

document.onclick = menu_close;


