﻿var pathRoot = 'http://www.carconference.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; 
var tabmenuitem = 0;
var startmenuitem = 0; 

function menu_open(item) {

    menu_canceltimer();
    menu_canceltabtimer();
    menu_close();
    menuitem = $(item).find('ul').css('visibility', 'visible'); 
    
    menuitem.find('a').removeClass('selected'); 
}

function menu_close() {
    if (menuitem){
        menuitem.css('visibility', 'hidden');    
    }
}

function tab_close() {
    $('#menu a').removeClass('selected');
    startmenuitem.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) {
    $.cookie('parentID', parentID, { path: '/', expires: 1 });   
    window.location.href = url;
}

function bottommenu_select(parentID, menuID, url) {
    $.cookie('parentID', parentID, { path: '/', expires: 1 });
    $.cookie('menuID', menuID, { expires: 1 });
    window.location.href = url;
}

$(document).ready(function() {
    $('#menu > li').bind('mouseover', function() {
        $('#menu a').removeClass('selected'); 
        $(this).find(':first-child').addClass('selected'); 
        menu_open(this);
    });
    $('#menu > li').bind('mouseout', function() {
        $(this).find(':first-child').addClass('selected');
        $(this).find('ul li a').removeClass('selected');  
        tab_timer();
        menu_timer();
    });

    startmenuitem = $('#menu a.selected');
});

document.onclick = menu_close;


