var filePathIcons = "./weka/images/IconsWeka/";
var g_currentPopup = "";
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;height: 200px;z-index:100;\" id=\"explode\"> </div>";
    sInsert += "<iframe  style=\"display:none;z-index:2;vertical-align: top;width: 400px;height: 190px;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 = "";
    var _webLinks = "";
    
    //-- 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();
    }
    //--------------------------------------
    
    //-- Generate weblinks --
    _webLinks += _htmlGeneratorMarginal.getWebLinks();
    if(_webLinks != "") {
    	isAnyInfoSet = 1;
    	_modulValue += _webLinks;
    	_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();

	if(document.getElementById("addinfo") != null)
	    document.getElementById("addinfo").innerHTML = sInsert;
	if(document.getElementById('marginalDiv') != null)
	    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,popupid,maxLinkCount)
{
	var startElement = document.getElementById('minimizeMarginal'); 
	var popupWidth = 400;
	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) - 40 - popupWidth)+"px";
	popupDiv.innerHTML = _htmlGeneratorMarginal.getPopupContent(popupNumber,popupid,maxLinkCount);

    if(popupDiv.style.display=='none')
	{
		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";
		dojo.lfx.implode("explode", startElement, moveSpeed).play();
        if(popupid + popupNumber != g_currentPopup)
		{
			dojo.lfx.explode(startElement,"explodeIframe", moveSpeed).play();
			dojo.lfx.explode(startElement,"explode", moveSpeed).play();
		}
	}
    
    g_currentPopup = popupid + 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();
    
}
