﻿/*
' **************************************************
' © VWA Software Development 2008
' Release: 1.01.0000
' Changed: Okt 15, 2008
' **************************************************
*/

var iVisitID          = 0;
var timer             = null;
var bEventBubbleFirst = true; // Om te controleren of het om het eerste event gaat, of een bubble up.
var Menu              = null; // Timer voor het verbergen van het menu

// Vertraging van de even gedult melding in ms.
var tHourGlassShow = 500;

/*----------------------------------------------------------------------------------
                              menu code 
-----------------------------------------------------------------------------------*/
var oMenu =  function(){
    this.ActiveRootMenuId   = null;  // Het ID van het active root menu
    this.ActiveButton       = null;  // de knop onder de muis. 
    this.ActiveMenuId       = null;  // Het menu onder de muis
    this.PreviousButton     = null;  // Laatst geselecteerde knop
    this.PreviousMenu       = null;  // Laatste geselecteerd menu
    this.FixedDisplay       = 0;     // Submenu blijvend tonen  0 = nee
                                     //                         1 = Knop in submenu geselecteerd
                                     //                         2 = Ouder knop geselecteerd
                                     
    this.HoverTime         = 2000;  // Vertraaging van verbergen submenuus
}

Menu = new oMenu();

// Set het actieve menu, wanneer de muis over het menu gaat.
function mnuRootOver(Sender){
    Menu.ActiveRootMenuId = Sender.id;    
    Menu.FixedDisplay = toNumber($get(Sender.id + 'FD').value);
    Menu.HoverTime = toNumber($get(Sender.id + 'HT').value);   
}

function OnEndRequest(){
    HourGlassHide();
    return true;
}

function onSubmit(e) {  
    HourGlassShow();
    return true;
}  

var __BackReqId = '';

function Page_load(){
    var manager = Sys.WebForms.PageRequestManager.getInstance();
    
   // Controleren of het een asyncpostback is
   if (!manager.get_isInAsyncPostBack()){
       // End en Beginrequest handlers toevoegen
       manager.add_endRequest(OnEndRequest);
       manager.add_beginRequest(onSubmit);
       if (theForm.action.Contains('?')){
           theForm.action = ''; 
           theForm._initialAction =  theForm.action;
       }
      // manager._onFormSubmitCompleted = onSubmit;
    }
    
    // NEWBID leegmaken ter voorkoming dat de NEWBID bewaard blijft in geval van terug navigatie in browser.
    $get("__NEWBID").value = '';
    
    var oReq = $get('Request');
    if (oReq) {
        var iRequestID = Number(getCookie('Request',0));
        var iReqFromServer = Number($get('Request').value); 
        iRequestID += 1;
        
        if (iRequestID > 2000000)
            iRequestID = 0;
                    
        setCookie('Request', iRequestID, 1);
         
        if (iReqFromServer < iRequestID -1){
            oReq = $get('__pbFromBack');
            if (oReq)
                oReq.value = '1';                
            __doPostBack(__BackReqId,'');
            __BackReqId = '';
        }
    }

    // Lightbox img bestanden opzoeken.
    var aImg = document.getElementsByTagName("IMG");

    for (var i = 0; i < aImg.length; i++) {
        var oImg = aImg[i];
        if (oImg.className.Contains('AutoScale')) {
        
            var sURL = oImg.src;
            oBoxImageColl.push(removeSys(sURL) + '~' + oImg.alt);
            oImg._largeURL = removeSys(sURL);
            $addHandler(oImg,'click', box_click_pre);
        }        
    }
}

function __doVwaPB(sID, sPar, iButtonID, sRwrthPath) {

    // Parameter controleren
	if ((typeof(iButtonID) != 'undefined') && (iButtonID != null))
		$get('__NEWBID').value = iButtonID;
   
	if (sRwrthPath && sRwrthPath.length > 0) 
	    theForm.action = sRwrthPath;
	else
	    theForm.action = sHostName;
		
    return __doPostBack(sID,sPar);        
}

// MenuClick (Echte menu knoppen)
function mClk(Sender, iButtonID, sRwrPath ,e){
    MenuClick(Sender, iButtonID, sRwrPath ,e, true);
}

// Postback maken met juiste knop info!!
function MenuClick(Sender, iButtonID, sRwrPath ,e, bFromMenu){
    if (!bFromMenu) 
        bFromMenu = false;
        
	if (!iButtonID || iButtonID === '0')
	    iButtonID = 0; 
	
	if (!e) var e = window.event;
	if(e){	
	    if (e.cancelBubble || !e.cancelBubble)
	        e.cancelBubble = true;
	    if (e.stopPropagation)
	        e.stopPropagation();
	}
	
	__doVwaPB((bFromMenu ? "__VwaMenu" : ""), "", iButtonID, sRwrPath);   
	    
    onSubmit();    
    // False retouneren zodat click event op link niet geactiveerd wordt.
    return false;    
}


function OpenObject(sURL, iButtonID, iLinkID ,e){
        
    if (!iLinkID)
        return false;
   
    var oFp = getOrCreateHidden("__OpenObject");
    oFp.value = iLinkID;
    
    MenuClick(null,iButtonID, sURL ,e, false);
    
    return false;  
}

// Onmouseover handler
function buttonover(Sender){
    if(bEventBubbleFirst){
        // Aktieve knop + menu onthouden
        Menu.ActiveButton = Sender;
    }
    bEventBubbleFirst = false;
}

function MenuExpand(Sender, sSubMenuID, iLevel, bForceVisible){
    // Para's
    // Sender          : Knop onder muis
    // sSubmenuID      : ID van submenu die uitgeklapt moet worden.
    // iLevel          : level van submenu.
    // bNoExpand       : Eenmaal uitgeklapt niet meer verbergen (in geval van alleen submenus tonen)
    
    var sClassName = '';
    var bCollapse = true;
    var oTargetMenu;
    
    if (!bForceVisible)
        bForceVisible = false;
 
   
//  Bijbehorend parent menu opzoeken.    
//  if(!Sender.ParentMenu)
//        Sender.ParentMenu = Menu.GetParentMenu(Sender);      
//             
//  Menu.ActiveMenuId = Sender.ParentMenu.id;        
  
    oTargetMenu = $get(sSubMenuID);
    
    Sender.ForceVisible = bForceVisible;    
    Sender.ChildMenuId = sSubMenuID;   
    Sender.Expanded = true;
    if (oTargetMenu) 
        ShowMenu(oTargetMenu);
    
    //oSubjectMenu.onMouseOut = HideMenu(oSubjectMenu,true);
    Menu.PreviousButton = Sender;                
    Menu.PreviousMenu = oTargetMenu;
    return true;
}


//maakt menu zichbaar
function ShowMenu(oSubMenu){
    oSubMenu.isMenu = true;
    oSubMenu.style.display='block';
}

// onmouse out handler.. (menu collapse)
function mc(Sender){
    bEventBubbleFirst = true;
    //Menu.SetParentMenuToHover(Sender,false);    
    Menu.ActiveButton = null;
    Menu.ActiveMenuId = '';
    
    if(timer){
        clearTimeout(timer);        
    }
    timer=setTimeout("HideMenu('" + Menu.ActiveRootMenuId + "')",  Menu.HoverTime);          
}

// alles verwijderen behalve de boom waar Menu.ActiveButton in staat
// Root UL = Sub0
function HideMenu(sMenuID){

    var RootMenu = document.getElementById(sMenuID);
    if (RootMenu){
        var RootButton;
        
        if(timer){
            clearTimeout(timer);        
        }
                
        // Door root knoppen lopen! ( van onderaf beginnen )
        for(var x=0; x<RootMenu.childNodes.length; x++){
            RootButton = RootMenu.childNodes[x];    
            RootButton.isRoot = true;  
                       
            // Controleren of Menu tak ingeklapt mag worden
            if(RootButton.childNodes)          
                  HideChildMenuNodes(RootButton);
        
        }     
    }
}


function HideChildMenuNodes(oParent, bParentVisible){
    var child = null;
      
    var bShow = false;
    
    // Controleren of oParent niet de actieve knop is, zoja niet verbergen.
    if (oParent == Menu.ActiveButton)
        bShow = true;  
   
   // alert(Menu.FixedDisplay);
   
    // Controleren of oParent de geselecteerde root knop is.
    if (oParent.tagName == 'LI' && oParent.className.substring(0,1) == 'S' && oParent.isRoot && Menu.FixedDisplay == 2)
        bShow = true;       
            
    if (oParent.ForceVisible)
        bShow = true;    
 
    if (oParent.ChildMenuId){
        child = $get(oParent.ChildMenuId);
        if (child){
             if (child.ForceVisible)
                bShow = true;
             
              // Controleren of oParent de geselecteerde root knop is.
              if (child.className.substring(0,1) == 'S' && Menu.FixedDisplay == 1)
                  bShow = true;   
                  
               // Child kan een li of een ul zijn (knop of submenu)        
               if (child == Menu.ActiveButton)
                    bShow = true;
                
               // tonen als in dit menu een active knop is, of als parent een actieve knop is.
               if(child.childNodes)          
                     bShow = (HideChildMenuNodes(child) || bShow);   
        }   
    }               
        
                
    // Door sub knoppen (menu's heen lopen)
    for(var x=0; x<oParent.childNodes.length; x++){
        child = oParent.childNodes[x];
        
        // Alleen iets doen met knoppen of menu's, de rest overslaan.
        if(child.tagName == 'LI' || child.tagName == 'UL'){
            //if (!child.isMenu)
           if (child.ForceVisible)
                bShow = true;
          
            // Controleren of oParent de geselecteerde root knop is.
            if (child.tagName == 'LI' && child.className.substring(0,1) == 'S' && Menu.FixedDisplay == 1)
               bShow = true;     
                      
            // Child kan een li of een ul zijn (knop of submenu)        
            if (child == Menu.ActiveButton)
                bShow = true;
             
            // tonen als in dit menu een active knop is, of als parent een actieve knop is.
            if(child.childNodes)          
                 bShow = (HideChildMenuNodes(child) || bShow);   
        }       
    }
        
    // het menu bij deze knop (on) zichtbaar maken
    if (oParent.ChildMenuId && !bShow && $get(oParent.ChildMenuId))
        $get(oParent.ChildMenuId).style.display='none';
        
    return bShow;    
}

function OpenButton(sBtnID, sRwrPath){
    var iPos = sBtnID.indexOf('ButtonID=');
	if (iPos >= 0) {
		var iButtonID = sBtnID.substring(iPos + 9, sBtnID.length);
		iPos = iButtonID.indexOf('&');
		if (iPos < 0)
			iPos = iButtonID.indexOf('?');
		if (iPos < 0)
			iPos = iButtonID.indexOf('#');
		if (iPos >= 0)
			iButtonID = iButtonID.substring(0, iPos);
			
	    MenuClick(this, iButtonID, sRwrPath, null,true);           
     }
}


function OpenMenu(sURL) {
	// Ga naar opgegeven menu
	var iMenuID = 0;
	var iPos = sURL.indexOf('MenuID=');
	if( iPos >=0 ) {
	    iMenuID = sURL.substring(iPos + 7, sURL.length);
		iPos = iMenuID.indexOf('&');
		
		if (iPos < 0)
			iPos = iMenuID.indexOf('?');
		if (iPos < 0)
			iPos = iMenuID.indexOf('#');
		if (iPos >= 0)
			iMenuID = iMenuID.substring(0, iPos);
			
	    // Negatieve knop wordt als menu verwerkt.
        MenuClick(this, iMenuID * -1);
	 
	}
	// MenuClick(this,sURL,-99);		
}
function GotoA(sURL) {
	// Spring naar juiste plek
	location.href = '#' + sURL;
}
function FindA() {
	var oFrame = this;
	var sURL = '', sPrefFrame = '';
	
	// Controleren of deze pagina al interne link heeft
	sURL = oFrame.location.href;
	
	if (sURL.indexOf('#') >= 0)
		return;
	
	GotoA(sURL);
		
	// Frame naam onthouden
	sPrefFrame = oFrame.name;
	
}
function OpenURL(sURL, bOpenInContent) {
	if (!bOpenInContent) {
	    // Nieuw browser venster
	    window.open(sURL); 
	} else {
	    // Open de pagina in dit frame
		self.location.href = sURL;
	}
}

function OpenDoc(sURL, iPopupWidth, iPopupHeight, iPopupType) {
	// Naar content dir verwijzen
	var sDir = '';
	if (!(typeof(sContentDir) == 'undefined') || (sContentDir == null))
		sDir = sContentDir;
	if (sDir.length == 0)
		sDir = '../content/';
	OpenExtern(sDir + sURL, iPopupWidth, iPopupHeight, iPopupType);
}

function OpenExtern(sURL, iPopupWidth, iPopupHeight, iPopupType) {
	// Open de pagina in popup venster
	if (!iPopupWidth)
		iPopupWidth = screen.availWidth * (2/3);
	if (!iPopupHeight)
		iPopupHeight = screen.availHeight * (2/3);
	if (!iPopupType)
		iPopupType = 0;
	
	// Juiste venstertype openen
	switch (iPopupType) {
	case -1: // Zelfde scherm
		document.location.href = sURL;
		break;
	case 1: // Normaal popup venster
		oWin = window.open(sURL, 'Popup', 'width=' + iPopupWidth + ',height=' + iPopupHeight + ',left=' + (screen.availWidth - iPopupWidth) / 2 + ',top=' + (screen.availHeight - iPopupHeight) / 2 + ',status=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=yes');
		if (oWin)
			oWin.focus();
		break;
	case 2: // Modaal popup venster
		if (window.showModalDialog)
			oWin = window.showModalDialog(sURL, 'Popup', 'dialogWidth:' + iPopupWidth + 'px;dialogHeight:' + iPopupHeight + 'px;font-family:Verdana;font-size:12;status:no;scroll:no;center:yes;edge:raised;resizable:no;help:no;unadorned:yes;');
		else
			window.open(sURL, 'Popup', 'width=' + iPopupWidth + ',height=' + iPopupHeight + ',left=' + (screen.availWidth - iPopupWidth) / 2 + ',top=' + (screen.availHeight - iPopupHeight) / 2 + ',status=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=no,modal=yes');
		break;
	default: // Normaal venster
		oWin = window.open(sURL, 'Popup', 'width=' + iPopupWidth + ',height=' + iPopupHeight + ',left=' + (screen.availWidth - iPopupWidth) / 2 + ',top=' + (screen.availHeight - iPopupHeight - 140) / 2 + ',status=yes,toolbar=yes,menubar=yes,location=yes,resizable=yes,scrollbars=yes');
		try{
		 if (oWin && oWin.focus)
			oWin.focus();
		}
		catch(e) {}		
		break;
	}
}


/*---------------------------------------------------------------------------------------------
    PopUp voor product
---------------------------------------------------------------------------------------------*/
function ProductPopUp(GroupID, PrdGroupID, ItemID){
            var sSrc = sHostName + 'Modules/ProductPopUp.aspx?GroupID=' + GroupID;
            sSrc += '&PrdGroupID=' + PrdGroupID;
            sSrc += '&ItemID=' + ItemID;
             
            ModalPopupOpen("Producten", "75", "52", sSrc, null, null, true, false); 
            }

/*---------------------------------------------------------------------------------------------
    Functies voor het tonen van foto's
---------------------------------------------------------------------------------------------*/
var sLargeImgUrl = '';
var oBoxImageColl = null;
var boxTimer;

function box_click_pre(e) {
    var sender = e.target;
    box_click(sender._largeURL, sender, sender.src);
}

function box_click(sURL, Sender, sOrgUrl, sCaption){
    var oBounds;
    var bSenderIsImg = (Sender.tagName && Sender.tagName.toLowerCase() == 'img');
  
     // Eventuele dubbele // vervangen.   
    sURL = sURL.replace(/:\/\//,"t_p");
    sURL = sURL.replace(/\/\//g, "/");
    sURL = sURL.replace(/t_p/,"://");
    
    if (!sCaption)
        sCaption = ''; 
  
    oBounds = new Sys.UI.Bounds(0, 0, 200, 200);     
  
    sLargeImgUrl = sURL;

    sHTML = '<div id="boxImageWrp" >';
    
  //  sHTML += '<div  style="width:100%;height:4px;overflow:hidden;"></div>';
    
  
    sHTML += '<center><img id="imgSmall" align="absmiddle" id="boxImage" src="buttons/loadingpic.gif" />';
    sHTML += '<img id="imgLarge" onclick="ModalPopupClose()" style="display:none" align="absmiddle" src="' + sLargeImgUrl + '" /></center>';

    // Navigatie in/onder de foto in de style sheet regelen.
    sHTML += '<span id="boxNav" class="boxNav"></span>';               
     
    // Begeleidende tekst, in afbeelding.
    sHTML += '<div class="imgCaption" style="width:100%;heigth:40px;overflow:hidden;">'
    sHTML += '<span id="boxCaption" class="boxCaption">' + sCaption + '</span></div>';
    sHTML += '</div>';
    sHTML += '<img class="boxImgClose" onmouseover="this.src=\'buttons/imgClose_over.png\'" onmouseout="this.src=\'buttons/imgClose.png\'"';
    sHTML += ' onclick="ModalPopupClose()" id="btnCancel" src="buttons/imgClose.png" />'; 

    // Popup openen met moment hourglass afbeelding.
    ModalPopupOpen('Box', oBounds.width + 20, oBounds.height + 20, sHTML, 'btnCancel');
    
    // Afbeelding Eerst volledig transparant maken.
    var oAnimation = $find('BoxAnimation');
    if (oAnimation) {
        oAnimation = oAnimation._onMouseOut._animation;
        oAnimation.set_target($get('boxImageWrp'));
        oAnimation.play();
    }
    
    oPopup.pendingAnimation = true;
    Box_Out();
    box_imgLoaded();
    if ($get('btnCancel'))
        $get('btnCancel').style.visibility = 'hidden';

    $addHandler($get(oPopup.sOpenerId), "mousemove", Box_MouseMove);
   
    // Resize handler toevoegen
    $addHandler(window, "resize", SetPosition);

    oPopup.onCloseHandler = function() { $removeHandler(window, "resize", SetPosition) };
    
}



function Box_MouseMove(e) {
    if (oPopup.pendingAnimation)
        return false;

    var sender = e.target;
    var iCnt = 0;
    
    // Controleren of we over de afbeelding hoveren
    while (sender && sender.id != 'imgSmall' && sender.id != 'boxImageWrp' && iCnt < 15) {
        sender = VWABrowserInfo.IsGecko ? sender.parentNode : sender.parentElement;
        iCnt += 1;
    }

    if (!sender || sender.id != 'imgSmall')
        return false;

    // window.status = "offset=" + e.offsetX + " grens=" + (oPopup.iWidth / 2);
      
    if (e.offsetX < (oPopup.iWidth / 2)) {
        // Pref zichtbaar maken
        $get('boxNavNext').style.visibility = 'hidden';
        $get('boxNavPrev').style.visibility = 'visible';
    } else {
        // Next zichtbaar maken.
        $get('boxNavPrev').style.visibility = 'hidden';
        $get('boxNavNext').style.visibility = 'visible';
    }
    if (boxTimer)
        clearTimeout(boxTimer);
    boxTimer = window.setTimeout(Box_Out, 2000);
}


function Box_Loaded(e) {
    oPopup.pendingAnimation = false;
    $get('btnCancel').style.visibility = 'visible';
}

function Box_Out(e) {
    if ($get('boxNavNext')) {
        $get('boxNavPrev').style.visibility = 'hidden';
        $get('boxNavNext').style.visibility = 'hidden';
    }
}

// Functie controleerd of afbeelding geladen is, zo ja 
// Dan wordt de popup gerezised naar de afmeting van de afbeelding.
function box_imgLoaded(){
       
    // popup opnieuw opzoeken
    var oPopupDiv = $get(oPopup.sOpenerId);    
    
    // Grote en kleine afbeelding opzoeken.
    var LargeImg = $get('imgLarge',oPopupDiv);
    var SmallImg = $get('imgSmall',oPopupDiv);
    
    if (!LargeImg)
        return;
    
    // Controleren of grote afbeelding klaar is met laden.
    if (!(LargeImg.complete == null || LargeImg.complete) ){
        setTimeout(box_imgLoaded, 500); 
        return false;
    }
       
   // $get('boxImageWrp').style.visibility = 'visible';
    
    // SmallImg dezelfde afbeelding geven, zodat largeimg straks weer 
    // gebruikt kan worden om de volgende afbeelding te laden.
    SmallImg.src = LargeImg.src;    
    LargeImg.style.display = 'block';
    SmallImg.style.display = 'none';   
          
    // Afmeting van de afbeelding.
    var oBounds = Sys.UI.DomElement.getBounds(LargeImg);
    var iWidth = oBounds.width;
    var iHeight = oBounds.height;

    // Navigatie
    var sNavTxt = '';
    var sCaptiontxt = '';
    
    // Controleren of er nog meer afbeeldingen zijn.
    if (typeof(oBoxImageColl) != 'undefined'){       
        var iLength = oBoxImageColl.length;
        if (iLength > 0) {
            var bEnabled = true;
            var src = LargeImg.src;
            var iLastIndexOf = src.toLowerCase().lastIndexOf('content/');  
            var index = 1;
             
            src = src.substr(iLastIndexOf);
            
            // Controleren of er nog meer afbeeldingen geregisteerd zijn.         
            for(i=0; i < iLength; i++){
                // Huidige positie bepalen.
                if (oBoxImageColl[i].Contains(src)){
                    index = i + 1;
                    break;
                }
            }
            
            sCaptiontxt = index.toString() + ' van ' + iLength.toString();

            // Vorige knop aktief ?
            bEnabled = (index > 1);          
            sNavTxt += '<span style="visibility:hidden" id="boxNavPrev" class="nav';            
            if (bEnabled) {
                sNavTxt += '" onclick="box_goto(' + (index - 2 ).toString() + ')"';
            }
            else {
                //nav wel laten zien maar niet klikbaar en andere class megeven voor opmaak
                sNavTxt += ' dis"';
            }
            sNavTxt += '><span class="NavText">Vorige</span></span>';

            // Volgende knop aktief ?
            bEnabled = (index < iLength);
            sNavTxt += '<span style="visibility:hidden"  id="boxNavNext" class="nav';
            if (bEnabled) {
                // Volgende vast laden.
                var aURLn = oBoxImageColl[index].split('~');
                LargeImg.src = aURLn[0];
                sNavTxt += '" onclick="box_goto(' + index + ')"'
            }
            else {
                //nav wel laten zien maar niet klikbaar en andere class megeven voor opmaak
                sNavTxt += ' dis"';
            }
            sNavTxt += '><span class="navText">Volgende</span></span>';
          
                                    
            var aURL = oBoxImageColl[index - 1].split('~');
            if (aURL.length > 1)
                $get('boxCaption', oPopupDiv).innerHTML = aURL[1] + '<br/>' + sCaptiontxt;
                           
            oPopup.sOkId = 'boxNavNext'; 
        }
    }
    
    $get('boxNav').innerHTML = sNavTxt;    
    
    LargeImg.style.display = 'none';
    SmallImg.style.display = 'block';
    SmallImg.style.width = iWidth + 'px';
    SmallImg.style.height = iHeight + 'px';

   // $get('boxNav').innerHTML = sNavTxt;
    var oAnimation = null;
    
   // alert(oBoxImageColl.length);
 
    // Juiste animatie opzoeken.
    oAnimation = $find('BoxAnimation');
    
    oPopupDiv.style.overflow = 'hidden';

    if (oAnimation) {
    
        oAnimation = oAnimation._onClick._animation;
        oAnimation.set_target(oPopupDiv);
    
        // Fade in animatie instellen.
        if (oAnimation) {

            var oBounds = CheckPosition({ 'MarginWidth': 20, 'MarginHeight': 60, 'InnerHeight': iHeight, 'InnerWidth': iWidth, 'PopupWidth': 0, 'PopupHeight': 0 });

            var oChildAnimation = oAnimation._animations[2];
            if (oChildAnimation) {
                oChildAnimation.set_target($get('boxImageWrp'));
            }
            //Hoogte.
            oChildAnimation = oAnimation._animations[0]._animations[0];
            if (oChildAnimation) {
                oChildAnimation.set_endValue(oBounds.PopupHeight - 40);
                oChildAnimation.set_startValue(oPopupDiv._bounds.PopupHeight);
            }
            // y - positie (top)
            oChildAnimation = oAnimation._animations[0]._animations[1];
            if (oChildAnimation) {
                oChildAnimation.set_endValue((iWindowHeight / 2) - ((oBounds.PopupHeight) / 2) - oBounds.offsetY);
                oChildAnimation.set_startValue(oPopupDiv._top);
            }
            //breedte.
            oChildAnimation = oAnimation._animations[1]._animations[0];
            if (oChildAnimation) {
                oChildAnimation.set_endValue(oBounds.PopupWidth);
                oChildAnimation.set_startValue(oPopupDiv._bounds.PopupWidth);
            }
            //x -postitie (left).
            oChildAnimation = oAnimation._animations[1]._animations[1];
            if (oChildAnimation) {
                oChildAnimation.set_endValue((iWindowWidth - oBounds.PopupWidth) / 2);
                oChildAnimation.set_startValue(oPopupDiv._left);
            }
            //Hoogte Caption
            oChildAnimation = oAnimation._animations[3];
            if (oChildAnimation) {
                oChildAnimation.set_startValue(oBounds.PopupHeight - 40);
                oChildAnimation.set_endValue(oBounds.PopupHeight);
                oChildAnimation.add_ended(Box_Loaded);
            }
        }
    }


    // Popup op maat maken. = animatie aanroepen.
    SetPosition(oPopupDiv, oBounds.PopupWidth, oBounds.PopupHeight, null, null, oAnimation);

    oAnimation = null;
    
    oPopup.iWidth = iWidth + 20;
    oPopup.iHeight = iHeight + 20;    

    $get('boxImageWrp').style.visibility = 'visible';
    $get('boxImageWrp').style.width = iWidth + 'px';
}

function box_goto(iIndex, Caption){
    if(!Caption)
        Caption = '';
        
    // Vorige/volgende verbergen.
    Box_Out();

    if ($get('btnCancel'))
        $get('btnCancel').style.visibility = 'hidden';       
    
    // Hiermee voorkomen we dat de knoppen tijdens de animatie niet zichtbaar worden.
    oPopup.pendingAnimation = true; 
    
    // Grote afbeelding opzoeken.
    var LargeImg = $get('imgLarge',$get(oPopup.sOpenerId));
      
    // Nieuwe url zetten.
    aURL = oBoxImageColl[iIndex].split('~');
    LargeImg.src = aURL[0];
    
    // Uitfaden.
    var oAnimation = $find('BoxAnimation');
    if (oAnimation) {
        oAnimation = oAnimation._onMouseOut._animation;
        oAnimation.set_target($get('boxImageWrp'));
        oAnimation.play();
    }
    
    // Controleren of de afbeelding klaar is met laden.  
    setTimeout(box_imgLoaded, 200);
}


// Webservice aanroepen om conversie op te slaan.
function ConversionReached(sConversionName) {
    VWA.FrontService.OnConversionReachedString(iSiteID, sConversionName, iOptimizerID);
    return true;
}


