var activeObject = null;
var activeLoSource = null;
var activeTabLoSource = null;
var activeTab = null;
var glossarOpen = false;
var glossarReOpen = false;



function clickBtn (SenderObject, Source) {
    if (activeObject != SenderObject) {
    activeTab.src = activeTabLoSource;
    activeObject = SenderObject;
    activeLoSource = Source;
    }
}

function clickTab (SenderObject, Source) {
    if (activeObject != null && activeObject != SenderObject) {
    activeObject.src = activeLoSource;
    activeObject = SenderObject;
    activeLoSource = Source;
    }
}


function swapImage(SenderObject, Source) {
    if (activeObject != SenderObject) {
        SenderObject.src = Source;
    }
}

function swapActiveImage(SenderObject, Source) {
        
    if (activeObject != SenderObject && activeObject != null) {
    SenderObject.src = Source;
    }
}

function glossar(word, desc) {
    //alert(word+" "+desc);
    document.getElementById("flashcontent").style.display = "block";
    var glossarMovie;
    
    word = word.replace(/&/g, "~");
    desc = desc.replace(/&/g, "~");
    
    if(!glossarOpen) {
	// <![CDATA[
	// SWFObject(nameDesFlashFilms, eindeutigeTextId, Breite, Höhe, minimalBenötigteFlashVersion, Hintergrundfarbe);
	var so = new SWFObject("/global/swf/ecke_bildSequenz.swf", "flash", "551", "531", "8", "#ffffff");
	so.addParam("allowScriptAccess", "sameDomain");
	//so.addParam("allowScriptAccess", "always");
	so.addParam("allowFullScreen", "true");
	so.addParam("quality", "high");
	so.addParam("wmode", "transparent");
    so.addVariable("word", word); 
    so.addVariable("desc", desc); 
    so.useExpressInstall('/global/swfobject/expressinstall.swf');
	so.write("flashcontent");
	// ]]>
	} else {
    	glossarReOpen = true;
	    if (document.getElementById) {
	    glossarMovie = document.getElementById("flash");
	    }
	    
	    if (glossarMovie) glossarMovie.resetGlossar(word, desc);
	    
	}
	glossarOpen = true;
}

function hideGlossar() { 
        document.getElementById("flashcontent").style.display = "none"; 
        glossarOpen = false;
}

function showPDF(pdfname)
{
    location.href ="/DownloadHandler.ashx?section=pdf&file=" + pdfname ,"_blank";
}

function showImage(picPath,ID) {
        popup = window.open("/ShowImage.aspx?img="+picPath+"img_gross_"+ID+".jpg", "Popup", "width=499,height=700,left=100,top=200");
        popup.focus();


}

function moveInputFocus(actObj, maxVal, nextField){
               var t = actObj.value, s = getSelectionStart(actObj), e = getSelectionEnd(actObj)
               if(s>=maxVal){
                  document.getElementById(nextField).focus();
               }
        }
// Author: Diego Perini <dperini@nwbox.com>
function getSelectionStart(o) {
        if (o.createTextRange) {
               var r = document.selection.createRange().duplicate()
               r.moveEnd('character', o.value.length)
               if (r.text == '') return o.value.length
               return o.value.lastIndexOf(r.text)
        } else return o.selectionStart
}

function getSelectionEnd(o) {
        if (o.createTextRange) {
               var r = document.selection.createRange().duplicate()
               r.moveStart('character', -o.value.length)
               return r.text.length
        } else return o.selectionEnd
}
