﻿function zoomRandomImage()
{
    if (navigator.userAgent.indexOf("MSIE") > 0)
    {
        $('TeamRinoPortal_Wrapper').style.height = "100%";
        $('Div_BlackOut').style.height = $('TeamRinoPortal_Wrapper').clientHeight + "px";
    }
    else
        $('Div_BlackOut').style.height = ViewPortSize('body') + "px";
    
    $('Div_BlackOut').style.width =  ViewPortSize('width') + "px";
    $('Div_BlackOut').style.backgroundColor = "Black";
    $('Div_BlackOut').style.top = 0 + "px";
    $('Div_BlackOut').style.left = 0 + "px";
    $('Div_BlackOut').style.visibility = "visible";
    $('Div_BlackOut').style.display = "block";
    
    var Blackout = new Fx.Style('Div_BlackOut', 'opacity',
    {
        duration: 500,
        transition: Fx.Transitions.Quart.easeInOut
    });
    Blackout.set(.7);
    
    $('Div_innerBlackOut').style.visibility = "visible";
    $('Div_innerBlackOut').style.display = "block";
    //$('Div_innerBlackOut').style.top = (ViewPortSize('height') / 2) - ($('Div_innerBlackOut').clientHeight / 2) + "px";
    $('Div_innerBlackOut').style.top = ViewPortSize('pageOffset') + (ViewPortSize('height') / 2) - ($('Div_innerBlackOut').clientHeight / 2) + "px";
    $('Div_innerBlackOut').style.left = ((ViewPortSize('width') / 2) - ($('Div_innerBlackOut').clientWidth / 2)) + "px";
    Blackout.start(.5).chain(function() {Blackout.start(.6);});
    var innerBlackout = new Fx.Style('Div_innerBlackOut', 'opacity',
    {
        duration: 500,
        transition: Fx.Transitions.Quart.easeInOut
    });
    innerBlackout.set(0);
    innerBlackout.start(0,1);
}



function UnLoadZoomedImage()
{
    //var iMiddleHeight = ViewPortSize('height') / 2;
    var iMiddleHeight = ViewPortSize('pageOffset') + ViewPortSize('height') / 2;
    var iMiddleWidth = ViewPortSize('width') / 2; 
    var BlackOutHeight = new Fx.Style('Div_BlackOut', 'height',
    {
        duration: 300, 
	    transition: Fx.Transitions.Quart.easeInOut
    }); 
    var BlackOutWidth = new Fx.Style('Div_BlackOut', 'width',
    {
        duration: 300, 
	    transition: Fx.Transitions.Quart.easeInOut
    });
    var BlackOutTop = new Fx.Style('Div_BlackOut', 'top',
    {
        duration: 300, 
	    transition: Fx.Transitions.Quart.easeInOut
    });
    var BlackOutLeft = new Fx.Style('Div_BlackOut', 'left',
    {
        duration: 300, 
	    transition: Fx.Transitions.Quart.easeInOut
    });
   
   var Div_BlackOut_clientHeight = $('Div_BlackOut').clientHeight - 10;
   if (Div_BlackOut_clientHeight < 0)
    Div_BlackOut_clientHeight = 0;
    
    $('Div_innerBlackOut').effect('opacity').start(1, 0);
    BlackOutTop.start(0, iMiddleHeight);
    BlackOutHeight.start(Div_BlackOut_clientHeight, 5).chain
    (
        function()
        {
            BlackOutLeft.start(0, iMiddleWidth);
            BlackOutWidth.start($('Div_BlackOut').clientWidth - 10, 5).chain
            (
                function()
                {
                    BlackOutWidth.start(5, 0);
                    BlackOutHeight.start(5, 0).chain
                    (
                        function ()
                        {
                            $('Div_BlackOut').style.visibility = "hidden";
                            $('Div_BlackOut').style.display = "none";
                        }
                    );
                }
            );
        }
    );
}



function ViewPortSize(sDimension)
{
    var iViewportHeight, iViewportWidth, iBodyHeight, iPageYOffset = 0;
    
    if (sDimension == "height")
    {
        if (window.innerHeight)
            iViewportHeight = window.innerHeight;
        else if (document.documentElement.clientHeight)
            iViewportHeight = document.documentElement.clientHeight; 
        else if (document.body.clientHeight)
            iViewportHeight = document.body.clientHeight;
            
        return iViewportHeight;
    }
    else if (sDimension == "width")
    {
        if (window.innerWidth)
            iViewportWidth = window.innerWidth;
        else if (document.documentElement.clientWidth)
            iViewportWidth = document.documentElement.clientWidth; 
        else if (document.body.clientWidth)
            iViewportWidth = document.body.clientWidth;
        
        return iViewportWidth;
    }
    else if (sDimension == "pageOffset")
    {
        if (window.pageYOffset)
            iPageYOffset = window.pageYOffset;
        else if (document.documentElement.scrollTop)
            iPageYOffset = document.documentElement.scrollTop;
        else if (document.body.scrollTop)
            iPageYOffset = document.body.scrollTop;
            
        return iPageYOffset;
    }
    else if (sDimension == "body")
    {
        if (document.documentElement.clientHeight)
            iBodyHeight = document.documentElement.clientHeight; 
        else if (document.body.clientHeight)
            iBodyHeight = document.body.clientHeight;
            
        return iBodyHeight;
    }
}