var filePathIcons = "./weka/images/IconsWeka/";
var currentPopup = 0;
var marginalOpen = 1;
var moveSpeed = 500; 
var g_iSizeOfMarginalPopup = 150;
var _htmlGeneratorMarginal = new generateMarginalHTML(filePathIcons);




function buildMarginalArea() {
    var sInsert = "<div class=\"marginalPopup\" style=\"display:none;border: 2px solid #AAAAAA;z-index:100;\" id=\"explode\"> </div>";
    sInsert += "<iframe  style=\"display:none;z-index:2;vertical-align: top;width: 300px;position: absolute;top: 0px;background: #d6d6d6;padding: 0px;margin: 0px;\" id=\"explodeIframe\"></iframe>";
    
    var indexOfArray = 0;
    var sizeOfArray = 0;
    var isAnyInfoSet = 0;
    var _iMarginalWidth = getCookie(g_sCookieFieldNameColumnRight);
    
    var _infoPlusValue = "";
    var _marginalMoveBar = "";
    var _marginalHead = "";
    var _docInfo = "";
    var _modulValue = "";
    
    //-- Generate elements_dazugehoert --
    _dazuGehoert = _htmlGeneratorMarginal.getDazuGehoert();
    if(_dazuGehoert!=""){ 
        isAnyInfoSet=1; 
        _modulValue += _dazuGehoert;
        _modulValue += _htmlGeneratorMarginal.getSpacing();
    }
    //------------------------------------
    
    //-- Generate elements_docinfo --
    _docInfo = _htmlGeneratorMarginal.getMarginalDocInfo();
    if(_docInfo!=""){ 
        isAnyInfoSet=1; 
        _modulValue += _docInfo;
        _modulValue += _htmlGeneratorMarginal.getSpacing();
    }
    //------------------------------------
    
    //-- Generate Info Plus --
    _infoPlusValue += _htmlGeneratorMarginal.getInfoPlus();
    if(_infoPlusValue!=""){ 
        isAnyInfoSet=1; 
        _modulValue +=  _infoPlusValue;
        _modulValue += _htmlGeneratorMarginal.getSpacing();
    }
    //--------------------------------------
    
    
    
    
    
    sInsert += _htmlGeneratorMarginal.beginMarginalArea();
    
    sInsert += _htmlGeneratorMarginal.getMarginalMoveBar();
    sInsert += _htmlGeneratorMarginal.beginContexColumn();
    sInsert += _htmlGeneratorMarginal.getMarginalHead();
    sInsert += "<div class=\"marginalScrollDiv\" style=\"overflow:auto;\">";
    sInsert += _htmlGeneratorMarginal.getSpacing();
    sInsert += _modulValue;  
    sInsert += "</div>";
    sInsert += _htmlGeneratorMarginal.endContextColumn();
    
    sInsert += _htmlGeneratorMarginal.endMarginalArea();
    
    document.getElementById("addinfo").innerHTML = sInsert;
    
    document.getElementById('marginalDiv').style.display = "inline"; 
    
    
    if(isAnyInfoSet != 1){
        g_iActualColumnRightWidth = 0;
        
    }
}




function changeMarginalStatus() {
    var _iWidth = getCookie(g_sCookieFieldNameColumnRight);
    
    if(_iWidth < 100) {
        setColumnActiveSize(g_shiSliderRightID,g_iActualColumnRightWidth);
        return;
    }
    else {
        setColumnClose(g_shiSliderRightID);
    }
}





function changePopupStatus(start,popupNumber)
{
        var startElement = document.getElementById('marginalOpenCloseButton'); 
        var popupWidth = 300;
	var popupDiv = document.getElementById('explode');
        var popupIframe = document.getElementById('explodeIframe');
        if((popupIframe==null) || (popupDiv==null)){
            return;
        }
	popupIframe.style.top = popupDiv.style.top = getPosTop(startElement) +"px";
	popupIframe.style.left = popupDiv.style.left = (getPosLeft(start) - 80 - popupWidth)+"px";
        popupDiv.innerHTML = "";
        if(popupNumber==-1){
            popupDiv.innerHTML = _htmlGeneratorMarginal.getDocInfoPopup();
        }else{
            popupDiv.innerHTML = _htmlGeneratorMarginal.getPopupValue(popupNumber);
	}
       popupIframe.style.height = _htmlGeneratorMarginal.getPopupHeight()+"px";
        if(popupDiv.style.display=='none')
	{
            shiFadeElementOut('documentwindow');
            dojo.lfx.explode(startElement,"explodeIframe", moveSpeed).play();
            dojo.lfx.explode(startElement,"explode", moveSpeed).play();    
	}
	else
	{
                var explodeIframeEl = document.getElementById("explodeIframe");
                if(explodeIframeEl!=null)
                    explodeIframeEl.style.display = "none";
                shiFadeElementIn('documentwindow');
		dojo.lfx.implode("explode", startElement, moveSpeed).play();
                if(popupNumber!=currentPopup)
		{
                        shiFadeElementOut('documentwindow');
			dojo.lfx.explode(startElement,"explodeIframe", moveSpeed).play();
			dojo.lfx.explode(startElement,"explode", moveSpeed).play();
		}
		currentPopup=popupNumber;
	}
	currentPopup=popupNumber;   
}

function closePopUp(linkElement,moveSpeed){
    var startElement = document.getElementById('marginalOpenCloseButton'); 
    shiFadeElementIn('documentwindow');
    dojo.lfx.implode('explodeIframe', startElement ,moveSpeed).play();
    dojo.lfx.implode('explode', startElement, moveSpeed ).play();
    
}
