﻿////imgLeftID
//imgRightID
//brochureID
//imgLeftLargeID 
//imgRightLargeID 
var modalPopUp;
var tempHeight;
var postbackElement;
var bEmailOk;

tempHeight=-1;
bEmailOk = false;
postbackElement = null;

 function openTextWindow(sFilename) {
     window.open(sFilename, 'planWindow', 'width=550,height=330,buttons=no,left=200,top=200'); }
function saveScrollPos()
{
    document.getElementById("<%=scrollPos%>").value = 
                document.getElementById("divScroll").scrollTop;
                }
                
function openFolder(brochureName)
{
    $get(brochureID).value=brochureName;
    $get(imgLeftID).src="/images/loadingsmall.jpg";
    $get(imgRightID).src="/images/loadingsmall.jpg";
    $get(imgLeftLargeID).src="/images/loadinglarge.jpg";
    $get(imgRightLargeID).src=="/images/loadinglarge.jpg";
    $get(labelCurrentPage).innerText = "(Loading)";
    $get(btnDummyButton1).click();
    hidePlayer();
    $find(folderToShow).show();
    Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(startLeftAnimation);    
    Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(getPostBackElement);    
}

 function getPostBackElement(sender, args) {
            postbackElement = args.get_postBackElement();
        }
      
                
function startLeftAnimation(sender, args)
{
    if (postbackElement!=null)
    {
        if ((postbackElement.type=="button") && (btnSendId==postbackElement.id))
        {
            animations = $find('pageLeftZoom')._onClick._animation._animations;
            
            animations[0]._duration=0.000001;
            animations[0]._animations[2]._duration=0.000001;
            $find('pageLeftZoom').OnClick();
            animations[0]._duration=0.2;
            animations[0]._animations[2]._duration=0.2;

            if (bEmailOk)
            {
                alert('De email is verzonden.');
            }
         }

        if ((postbackElement.type=="button") && (rightbtnSendId==postbackElement.id))
        {
            animations = $find('pageRightZoom')._onClick._animation._animations;
            
            animations[0]._duration=0.000001;
            animations[0]._animations[2]._duration=0.000001;
            $find('pageRightZoom').OnClick();
            animations[0]._duration=0.2;
            animations[0]._animations[2]._duration=0.2;

            if (bEmailOk)
            {
                alert('De email is verzonden.');
            }
         }
        postbackElement = null;
    }
}

function CloseFolder()
{
    var swf = document.getElementById("player");
    $find(folderToShow).hide();
    if (swf != null) {
        swf.style.visibility = "";
    }
}

function hidePlayer() {

    var swf = document.getElementById("player");

    if (swf != null) {

        swf.style.visibility = "hidden";
        if (swf.childNodes[0].getConfig().state == 'PLAYING')
            swf.childNodes[0].sendEvent('PLAY');
    }


}

function openCallMeBackPopUp(pnlID) {
    hidePlayer();
    
}
function closeCallMeBackPopUp(id, elementToShow, pnlID) {
    $find(id).hide();
    var swf = document.getElementById("player");
    if (swf != null) {
        swf.style.visibility = "";
    }
    
    __doPostBack(pnlID, '');
}

function setHeightTemp(objectToGetValueFrom)
{
    
    if (tempHeight==-1)
    {
        if (objectToGetValueFrom.parentNode.clientHeight)
            tempHeight = objectToGetValueFrom.parentNode.clientHeight+18;
        else
            tempHeight = objectToGetValueFrom.parentNode.offsetHeight+18;
    }
}

function GetHeightTemp(behaviourToSet)
{
    var animation = behaviourToSet._onClick._animation._animations[1]._animations[0];
    
    animation._height=tempHeight;
    tempHeight=-1;
}


function checkRadioButtons(object,args)
{
    radioButtonList = $get(rdblReason).getElementsByTagName("INPUT");
    if ((radioButtonList[0].checked==false) && (radioButtonList[1].checked==false) && (radioButtonList[2].checked==false) && (radioButtonList[3].checked==false))
    {
        args.IsValid = false;
    }
    else
    {
        if (((radioButtonList[1].checked==true) || (radioButtonList[2].checked==true) || (radioButtonList[3].checked==true)) && ($get(txtEmailText).value==''))
        {
         args.IsValid= false;
        }   
        else
        {
            args.IsValid= true;
        }
     }

}

function checkRadioButtonsRight(object,args)
{
    radioButtonList = $get(rightrdblReason).getElementsByTagName("INPUT");
    if ((radioButtonList[0].checked==false) && (radioButtonList[1].checked==false) && (radioButtonList[2].checked==false) && (radioButtonList[3].checked==false))
    {
        args.IsValid = false;
    }
    else
    {
        if (((radioButtonList[1].checked==true) || (radioButtonList[2].checked==true) || (radioButtonList[3].checked==true)) && ($get(righttxtEmailText).value==''))
        {
         args.IsValid= false;
        }   
        else
        {
            args.IsValid= true;
        }
     }

}

function closeZoomWindow()
{
    document.getElementById('light').style.display='none';
    document.getElementById('fade').style.display='none';
}
function showDetailImage(url,imgheight,imgwidth)
{
 
 document.getElementById('light').style.display='block';
 document.getElementById('fade').style.display='block'   
  document.getElementById('imageZoomImg').src=url;
  document.getElementById('imageZoomImg').width=imgwidth;
  document.getElementById('imageZoomImg').height=imgheight;
  document.getElementById('light').style.width=imgwidth+20;
  document.getElementById('light').style.height=imgheight+37;
  document.getElementById('fade').style.left=0;
  document.getElementById('fade').style.top=0;
    setWidthAndHeight();
  
  document.getElementById('btnClose1').style.width=imgwidth+20;
    
    
}

function getWindowHeight()
{
 var functionReturn = 0;

 if ( (document.documentElement) && (document.documentElement.clientHeight) )
  functionReturn = document.documentElement.clientHeight;
 else if ( (document.body) && (document.body.clientHeight) )
  functionReturn = document.body.clientHeight;
 else if ( (document.body) && (document.body.offsetHeight) )
  functionReturn = document.body.offsetHeight;
 else if ( window.innerHeight )
  functionReturn = window.innerHeight - 18;

 functionReturn = parseInt(functionReturn);
 if ( (isNaN(functionReturn) == true) || (functionReturn < 0) )
  functionReturn = 0;

 return functionReturn;
};



function getWindowWidth()
{
 var functionReturn = 0;

 if ( (document.documentElement) && (document.documentElement.clientWidth) )
  functionReturn = document.documentElement.clientWidth;
 else if ( (document.body) && (document.body.clientWidth) )
  functionReturn = document.body.clientWidth;
 else if ( (document.body) && (document.body.offsetWidth) )
  functionReturn = document.body.offsetWidth;
 else if ( window.innerWidth )
  functionReturn = window.innerWidth - 18;

 functionReturn = parseInt(functionReturn);
 if ( (isNaN(functionReturn) == true) || (functionReturn < 0) )
  functionReturn = 0;

 return functionReturn;
};

function setWidthAndHeight()
{
    document.getElementById('fade').style.height=getWindowHeight();
    document.getElementById('fade').style.width=getWindowWidth();

}

window.onresize=setWidthAndHeight;