﻿var shown = false;

function Resize() {
    var h = 0;
    var w = 0;
    fd = document.getElementById('fade');
    ob = document.getElementById('outerBoxCropping');

    //IE
    if (!window.innerWidth) {
        //strict mode
        if (!(document.documentElement.clientWidth == 0)) {
            h = document.documentElement.clientHeight;
            w = document.documentElement.clientWidth;
        }
        //quirks mode
        else {
            h = document.body.clientHeight;
            w = document.body.clientWidth;

        }
        //alert('setting IE to '+h);
        fd.style.height = h + 'px';
        //fd.style.width=w+'px';
        ob.style.position = 'relative';
        ob.style.height = h + 'px';
        ob.style.width = w + 'px';
        ob.style.overflow = 'hidden';
        anchClose.href = 'javascript:closeMicro()';

    }
    //w3c
    else {
        h = window.innerHeight;
        w = window.innerWidth;

        var agt = navigator.userAgent.toLowerCase();
        var is_opera = (agt.indexOf("opera") != -1);
        if (!is_opera)//most browsers need "px"
        {
            //alert('setting w3c' +h);        
            fd.style.height = h + 'px';
            //fd.style.width=w+'px';
            ob.style.height = h + 'px';
            ob.style.width = w + 'px';
            ob.style.overflow = 'hidden';
        }
        else {
            //alert('setting opera 8.5+ ' + h);
            fd.style.height = h;
            //fd.style.width=w;
            document.body.style.height = h;
            document.body.style.width = w;
            document.body.style.overflow = 'hidden';
        }
    }
}

function showFlashAndClose() {
    document.getElementById('light').style.display = 'block';
    document.getElementById('closeButton').style.display = 'block';
    //som.write("light");
    Resize();
}

function showMicro() {
    // Prevent double click
    if (!shown) {
        shown = true;
        Resize();
        document.getElementById('fade').style.display = 'block';
        //Effect.Grow('fade', { duration: 1 });

        // Wait until animation is complete the show close, div and flash
        //setTimeout('showFlashAndClose()', 1100);
        showFlashAndClose();


    }
}

function closeMicro() {
    shown = false;
    document.getElementById('closeButton').style.display = 'none';
    document.getElementById('light').style.display = 'none';
    document.getElementById('fade').style.display = 'none';

    // Reset croping for all browser types
    var agt1 = navigator.userAgent.toLowerCase();
    var is_opera1 = (agt1.indexOf("opera") != -1);
    if (is_opera1) {
        document.body.style.height = 'auto';
        document.body.style.width = 'auto';
        document.body.style.overflow = 'visible';
    }

    bc = document.getElementById('outerBoxCropping');
    bc.style.height = 'auto';
    bc.style.width = 'auto';

    if (agt1.indexOf("firefox") == -1) {
        bc.style.overflow = 'visible';
        bc.style.position = 'static';
    }
    // clear events for sizeing outerBoxCropping and deep link querystring check
    window.onload = null;
    window.onresize = null;

    if (document.location.hash.length > 0) {
        document.location.hash = "#";
    }
}

function closeMicroShowEditPanel() {
    closeMicro();
}

function loadVideo() {

    showMicro();
    window.onresize = Resize;
}