﻿var myWidth = 0, myHeight = 0;
var btnaddedd = null;
function getParentWndResolution() {
    //Code to set radwindow in center of the screen (regardless of screen resolution)        
    if (typeof (window.innerWidth) == 'number') {
        //Non-IE
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
    } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;
    } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;
    }
//    window.alert('Width = ' + myWidth);
//    window.alert('Height = ' + myHeight);
}

function customTitleBarButton(oWnd, Lang) {
    var TitleBar = oWnd.GetTitlebar();
    var parent = TitleBar.parentNode;

    var oUL = parent.getElementsByTagName('UL')[0];

    //CLOSE Button
    oUL.style.bordercolor = "#FFFFFF";
    var oLI = document.createElement("LI");
    oLI.id = "closebuttonID"
    var A = document.createElement("A");
    oLI.appendChild(A);

    if (Lang == "1") {
        A.className = "closebutton";
    } else {
        A.className = "closebuttones";
    }

    A.href = "javascript:void(0)";
    A.title = "Close";
    A.onclick = function JustClose() { oWnd.Close(); }
    oUL.insertBefore(oLI, oUL.firstChild);
}

function setRadWindowStyle(x, y, oWnd, Title) {
    
    oWnd.SetWidth(x);
    oWnd.SetHeight(y);
    
    //Statusbar
    //oWnd.GetStatusbar().style.cssText = "display: none;";
    oWnd.set_visibleStatusbar(false);

    //Titlebar
    //oWnd.GetTitlebar().style.cssText = "visibility: hidden;";
    oWnd.set_visibleTitlebar(true);
    oWnd.GetTitlebar().style.backgroundColor = "#860C6F";
    oWnd.GetTitlebar().style.borderColor = "#860C6F";

    oWnd.SetTitle(Title);
    oWnd.set_behaviors(Telerik.Web.UI.WindowBehaviors.Move);

    oWnd.set_modal(true);
    oWnd.moveTo(((myWidth - x) / 2), (myHeight - y) / 2);
    oWnd.set_destroyOnClose(true);
}

function customTitleBarButtonCommercial(oWnd, Lang) {
    var TitleBar = oWnd.GetTitlebar();
    var parent = TitleBar.parentNode;
    var oUL = parent.getElementsByTagName('UL')[0];
    var ulParentTD = oUL.parentNode;


    //LEFT Buttons
    var divButtonsLeft = document.createElement("DIV");
    divButtonsLeft.className = "divLeft";
    
    //English Button
    var btnLeft1 = document.createElement("A");
    btnLeft1.className = "btnLeft1";
    btnLeft1.href = "javascript:CommerialWindow(745, 560, 1)";
    btnLeft1.title = "English";
    btnLeft1.innerHTML = ""
    divButtonsLeft.appendChild(btnLeft1);
    
    var buttonClick = Function.createCallback(LoadVideoEN, 1, oWnd);
    $addHandler(btnLeft1, "click", buttonClick);

    //Espanol Button
    var btnLeft = document.createElement("A");
    btnLeft.className = "btnLeft";
    btnLeft.href = "javascript:CommerialWindow(745, 560, 2)";
    btnLeft.title = "Espanol";
    btnLeft.innerHTML = ""
    divButtonsLeft.appendChild(btnLeft);
    
    var buttonClick = Function.createCallback(LoadVideoES, 2, oWnd);
    $addHandler(btnLeft, "click", buttonClick);

    ulParentTD.insertBefore(divButtonsLeft, ulParentTD.firstChild);
}

function customeTitleCloseButton(oWnd, Lang) {

    var TitleBar = oWnd.GetTitlebar();
    var parent = TitleBar.parentNode;
    var oUL = parent.getElementsByTagName('UL')[0];
    var ulParentTD = oUL.parentNode;
    
    //RIGHT Buttons
    var divButtonsRight = document.createElement("DIV");

    divButtonsRight.className = "divRight";

    var btnRight = document.createElement("A");
    
    //Code to hide English "Close" button for Spanish video
    if (document.getElementById("btnRightES") != null) {
        document.getElementById("btnRightES").parentNode.style.display = "none";
        document.getElementById("btnRightES").parentNode.innerHTML = "";
    }
    //Code to hide Spanish "Close" button for English video
    if (document.getElementById("btnRightEN") != null) {
        document.getElementById("btnRightEN").parentNode.style.display = "none";
        document.getElementById("btnRightEN").parentNode.innerHTML = "";
    }
  
    if (Lang == "1") {
        btnRight.className = "btnRightEN";
        btnRight.title = "Close";
        btnRight.id = "btnRightEN";      
       
    } else {
        btnRight.className = "btnRightES";
        btnRight.title = "Cerrar";
        btnRight.id = "btnRightES";
    }
    btnRight.href = "javascript:void(0)";
    btnRight.innerHTML = "";

    divButtonsRight.appendChild(btnRight);

    // Define a callback by passing a method and an object.
    var buttonClick = Function.createCallback(closeWindow, oWnd);

    // A handler for the click event.
    $addHandler(btnRight, "click", buttonClick);

    ulParentTD.appendChild(divButtonsRight);
}

function LoadVideoEN(evt, Lang, oWnd) {
    //alert(Lang);
}

function LoadVideoES(evt, Lang, oWnd) {
    //alert(Lang);
}

function closeWindow(evt, oWnd) {
    oWnd.Close();
}
