﻿var menuMainActive = 0;
var menuOn = 0;
var onLayer;
var timeOnMain = null;
function HightlightMainMenu(id) {
    clearTimeout(timeOnMain);
    menuMainActive = 1
    var list = document.getElementsByTagName("td");
    var itemId = id.replace("menuItem_", "");
    for (var i = 0; i < list.length; i++) {
        if (list[i].id.indexOf("menuItem_") >= 0) {
            {
                list[i].className = "MenuinNotselected";
            }
        }
        if (list[i].id.indexOf("menuItemCell1_") >= 0) {
            {
                list[i].className = "X";
            }
        }
        if (list[i].id.indexOf("menuItemCell2_") >= 0) {
            {
                list[i].className = "X";
            }
        }
    }

    list = document.getElementsByTagName("table");
    for (var i = 0; i < list.length; i++) {
        if (list[i].id.indexOf("SubCategories_") >= 0) {
            {
                list[i].style.display = "none";
            }
        }
    }

    var menuItem = document.getElementById(id);
    menuItem.className = "MenuItemMid";
    document.getElementById("menuItemCell1_" + itemId).className = "MenuItemRight";
    document.getElementById("menuItemCell2_" + itemId).className = "MenuItemLeft";
    document.getElementById("SubCategories_" + itemId).style.display = "";
}

function UnHightlightMainMenu(id) {
    menuMainActive = 0
    timeOnMain = setTimeout("UnHightlight()", 1200);
}

function UnHightlight() {
    if (menuMainActive == 0) {
        var list = document.getElementsByTagName("td");
        for (var i = 0; i < list.length; i++) {
            if (list[i].id.indexOf("menuItem_") >= 0) {
                {
                    list[i].className = "MenuinNotselected";
                }
            }
            if (list[i].id.indexOf("menuItemCell1_") >= 0) {
                {
                    list[i].className = "X";
                }
            }
            if (list[i].id.indexOf("menuItemCell2_") >= 0) {
                {
                    list[i].className = "X";
                }
            }
        }

        list = document.getElementsByTagName("div");
        for (var i = 0; i < list.length; i++) {
            if (list[i].id.indexOf("SubCategories_") >= 0) {
                {
                    list[i].style.display = "none";
                }
            }
        }

        RestoreDefault();
    }
}


if (document.layers) { // Netscape
    document.captureEvents(Event.MOUSEMOVE);
    document.onmousemove = captureMousePosition;
} else if (document.all) { // Internet Explorer
    document.onmousemove = captureMousePosition;
} else if (document.getElementById) { // Netcsape 6
    document.onmousemove = captureMousePosition;
}
// Global variables
xMousePos = 0; // Horizontal position of the mouse on the screen
yMousePos = 0; // Vertical position of the mouse on the screen
xMousePosMax = 0; // Width of the page
yMousePosMax = 0; // Height of the page

function captureMousePosition(e) {
    if (document.layers) {
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth + window.pageXOffset;
        yMousePosMax = window.innerHeight + window.pageYOffset;
    } else if (document.all) {
        xMousePos = window.event.x + document.body.scrollLeft;
        yMousePos = window.event.y + document.body.scrollTop;
        xMousePosMax = document.body.clientWidth + document.body.scrollLeft;
        yMousePosMax = document.body.clientHeight + document.body.scrollTop;
    } else if (document.getElementById) {
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth + window.pageXOffset;
        yMousePosMax = window.innerHeight + window.pageYOffset;
    }
}
// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all ? true : false
// attach getMouseCoordinates function onMouseMove
//	document.onmousemove = getMouseCoordinates;
// Variables to hold mouse x,y positions
var MOUSE_X = 0
var MOUSE_Y = 0

// This function will be called along with mouse-move
function getMouseCoordinates(e) {
    if (IE) { // get mouse x,y positions for IE
        MOUSE_X = event.clientX - document.body.scrollLeft; // + window.screenLeft;
        MOUSE_Y = event.clientY - document.body.scrollTop; // + window.screenTop;
    }
    else {  // x-y pos if browser is say, Netscape
        MOUSE_X = e.pageX;
        MOUSE_Y = e.pageY;
    }
}
var oPopup = window.createPopup();
function closeWindow() {
    oPopup.hide();
}

function openWindow(id, caption) {
    var val = id;
    var width = 180;
    var PopBody = oPopup.document.body;
    PopBody.style.backgroundColor = "#eee7ef";
    PopBody.style.border = "solid #a5a4aa 1px";
    PopBody.style.color = "#ae899e";
    PopBody.style.fontWeight = "bold";
    PopBody.style.fontFamily = "Times New Roman";
    PopBody.style.fontSize = "15px";
    var text = val;
    PopBody.style.textAlign = "center";
    PopBody.innerHTML = "<span style='padding:5px;FONT-WEIGHT: bold; FONT-SIZE: 15px; COLOR: blue; FONT-FAMILY: Arial; TEXT-ALIGN: center'>" + caption + "</span>";

    oPopup.show(window.event.x - width, window.event.y + 5, width, 80, document.body);
}

function OpenUrl(id) {

    window.open('VideoPreview.aspx?id=' + id, null, 'height=460,width=640,top=120,left=200,menubar=0,resizable=0,toolbar=0');
}

function ShowScreenshot(id) {
    //            GetRequest(id);
}

function GetRequest(id) {
    //            var url = "GenerateScreenshot.aspx?id=" + id;

    //            var objXmlHttp = GetXmlHttpObject();

    //            objXmlHttp.onreadystatechange = function () { ChangeHandlerRelated(objXmlHttp) };

    //            XmlHttpGet(objXmlHttp, url);
}

function ChangeHandlerRelated(objXmlHttp) {
    if (objXmlHttp.readyState == 4 || objXmlHttp.readyState == 'complete') {
        if (objXmlHttp.status == 200) {
            var sResponse = objXmlHttp.responseText;
            var values = sResponse.split('|');
            if (values.length > 0) {
                var aImg = document.getElementById("aImg_" + values[1]);
                aImg.rel = values[0];
            }
        }
    }
}

function GetXmlHttpObject() {
    var objXmlHttp = null;

    if (window.XMLHttpRequest) {
        objXmlHttp = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) {
        try {
            objXmlHttp = new ActiveXObject('Msxml2.XMLHTTP');
        }
        catch (e) {
            objXmlHttp = new ActiveXObject('Microsoft.XMLHTTP');
        }
    }
    return objXmlHttp;
}

function XmlHttpGet(xmlhttp, url) {
    xmlhttp.open('GET', url, true);
    xmlhttp.send(null);
}

function Body_OnLoad() {
    if (document.images)
        for (var i = 0; i < document.images.length; i++)
            document.images[i].oncontextmenu = new Function("return false");
}

