﻿// JScript File
function MM_findObj(n, d) 
{ //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d .forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}   

/* Funktionen für Min, Max Leuchtkasten + speichern der gewählten Grösse */
function RefreshLeuchtkasten()
{
    document.location.replace("../leuchtkasten/pgLeuchtkasten.aspx");
}

function HideMinMaxLeuchtkasten()
{
    document.getElementById("iMin").style.display = "none";
    document.getElementById("iMax").style.display = "none";    
}

function SizeLeuchtkasten()
{
    if (lHeight == 0)
    {
        MaximizeLeuchtkasten();
    }
    else
    {
        if (lHeight > 51)
        {
            document.getElementById("iMin").style.display = "inline";
            document.getElementById("iMax").style.display = "none";            
        }
        else                
        {
            document.getElementById("iMin").style.display = "none";
            document.getElementById("iMax").style.display = "inline";              
        }

        window.top.document.getElementById("mms_fs").rows =  "101,*," + lHeight;
    }
}

function MinimizeLeuchtkasten()
{
    document.getElementById("iMin").style.display = "none";
    document.getElementById("iMax").style.display = "inline";  

    window.top.document.getElementById("mms_fs").rows =  "101,*,51";
    
    SaveLeuchtkastenHeight(51);
}

function MaximizeLeuchtkasten()
{
    document.getElementById("iMin").style.display = "inline";
    document.getElementById("iMax").style.display = "none";
    
    window.top.document.getElementById("mms_fs").rows =  "101,*,150";
    
    SaveLeuchtkastenHeight(150);
}

function SaveLeuchtkastenHeight(height)
{
    ajaxPostObject = new AxpObject();
    ajaxPostObject.post(height);
}
/* --------------------------------------------------------------------- */

/* Funktionen welche das ein einzelnes Event nach dem ändern der Grösse auswirft => zum speichern der gewählten Grösse */
var resizeTimeout = undefined;
var resizeInProgress = false;

function resizeComplete()
{
    clearTimeout(resizeTimeout);
    resizeInProgress = false;
    
    ajaxPostObject = new AxpObject();
    ajaxPostObject.post(window.top.document.getElementById("mms_fs").children[2].offsetHeight);    
}

function resetHandler()
{
    if (isBrowser("IE") && resizeInProgress == false)
    {
        if (resizeTimeout != undefined)
        {
            clearTimeout(resizeTimeout);
        }
        resizeTimeout = setTimeout("resetSize();", 500);
    }
    else if (isBrowser("FF"))
    {
        resetSize();
    }
} 

function resetSize(obj)
{
    var w; 
    var h;
    var deductW = 210;
    var deductH = 110;  
    
    var myWidth = 0, myHeight = 0;
    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;
    }
    
    if (isBrowser("IE"))
    {
        clearTimeout(resizeTimeout);
        resizeTimeout = setTimeout("resizeComplete();", 500);
        w = myWidth - deductW;
        h = myHeight - deductH;
        resizeInProgress = true;
        //alert("w "+w+", h"+h);
        try
        {
            navFrame.resizeTo(200,h);
            mainFrame.resizeTo(w,h);
        }
        catch(e)
        {
            //alert(e.message);
        }
    }
    else if (isBrowser("FF"))
    {
        var obj = MM_findObj("navFrame");   
        var obj2 = MM_findObj("mainFrame");
        w = myWidth - deductW;
        h = myHeight - deductH;
        obj.setAttribute("height", h );      
        obj2.setAttribute("width", w );  
        obj2.setAttribute("height", h );                
    }   
}

function isBrowser(which)
{
    var toCheck;
    switch (which)
    {
        case "IE" : toCheck = "MSIE";
                    break;
        case "FF" : toCheck = "Firefox";
                    break;          
    }
    if (undefined != toCheck)
    {
        return (navigator.userAgent.indexOf(toCheck) != -1)
    }
    return false;
}    
/* --------------------------------------------------------------------- */    