var imgplus="images/plusik.gif";
var imgminus="images/minus.gif";
var imghr="images/hr.gif";
var divwidth=0;
var divheight=0;

function image(iPath) {
	var myWindowOptions;
	myWindowOptions="width=800,height=500,screenX=20,screenY=20,top=20,left=20,scrollbars=0,locationbar=0,menubar=0";
	window.open(iPath,"image",myWindowOptions);
}

function getentries(sentry)
{
	if (window.document.images['img'+sentry].src.search(imgminus)>0)
	{
		document.getElementById(sentry).style.display = "none";
		window.document.images['img'+sentry].src=dirhome+imgplus;
	}
	else
	{
		window.document.images['img'+sentry].src=dirhome+imgminus;
		if (document.getElementById(sentry)) document.getElementById(sentry).style.display = "inline";
	}
}

function lmssetup(lmselected)
{
	var myWindowOptions;
	lmselected=lmselected.replace(/#/g,"__");
	myWindowOptions="width=670,height=650,screenX=30,screenY=30,top=30,left=30,scrollbars=1,locationbar=0,menubar=0";
	if (dirhome=="") window.open("http://www.lernmodule.org/coursesetup/default.aspx?lms="+lmselected,"lernmodulelmssetup",myWindowOptions);
	else window.open("http://www.lernmodule.org/coursesetup/default.aspx?lms="+lmselected+"&org=zum","lernmodulelmssetup",myWindowOptions);
}


function CountModulesSelected()
{
	var outputtmp="";
	outputtmp=getCookie("lernmoduleselected");
	if (outputtmp=="") outputtmp="Kurs einrichten (0) Erst Lernmodul ausw&auml;hlen!";
	else
	{
		outputtmp=outputtmp.substring(1,outputtmp.length-1).replace(/##/g,"#");
		outputtmp="<a href=\"javascript:lmssetup('"+outputtmp+"')\">Kurs einrichten ("+outputtmp.split("#").length+")</a>";
		CountModulesBlink(0);
	}
	document.getElementById("modulesselected").innerHTML=outputtmp;

}
function CountModulesBlink(bcounter)
{

	var cmdisplay="normal";
	if (bcounter%2==0) cmdisplay="bold";
	document.getElementById("modulesselected").style.fontWeight=cmdisplay;
	if (bcounter<18) setTimeout("CountModulesBlink("+(bcounter+1)+")",500);
}


function getCookie(name)
{
	var i=0;
	var suche = name + "=";
	while (i<document.cookie.length)
	{
		if(document.cookie.substring(i, i + suche.length) == suche)
		{
			var ende = document.cookie.indexOf(";", i + suche.length);
			ende = (ende > -1) ? ende : document.cookie.length;
			var cook = document.cookie.substring(i + suche.length, ende);
			return unescape(cook);
		}
		i++;
	}
	return "";
}

function modulchange(cat,ident,tit)
{
		var theform;
		var toalert;
		if (window.navigator.appName.toLowerCase().indexOf("netscape") > -1) {theform = document.forms["Form1"];}
		else {theform = document.Form1;}
		var selmodules="";
		selmodules=getCookie("lernmoduleselected");
		if (selmodules.indexOf("#"+cat+"_"+ident+"#")!=-1)
		{
			selmodules=selmodules.replace("#"+cat+"_"+ident+"#","");
			toalert='Das Lernmodul\n'+tit+'\nwurde aus Ihrer Auswahl entfernt.';
		}
		else
		{
			selmodules=selmodules+="#"+cat+"_"+ident+"#";
			toalert="Das Lernmodul\n"+tit+"\nwurde Ihrer Auswahl hinzugefügt.\nWenn Sie keine weiteren Module hinzufügen wollen,\nklicken Sie auf 'Kurs einrichten'.";
		}

		setCookie("lernmoduleselected",selmodules);
		CountModulesSelected();

		alert(toalert);
}

function setCookie(name, cvalue)
{
	var cook = name + "=" + unescape(cvalue);
	document.cookie = cook;
}

function posNavM()
{
//	if (document.getElementById('overall').offsetHeight && (document.getElementById('overall').offsetHeight!=divheight|| document.getElementById('overall').offsetWidth!=divwidth))
//		{bubbles(divheight,divwidth);}

	var w3c=(document.getElementById)?true:false;
	var ns4=(document.layers)?true:false;
	var ie4=(document.all && !w3c)?true:false;
	var ie5=(document.all && w3c)?true:false;
	var ns6=(w3c && navigator.appName.indexOf("Netscape")>=0)?true:false;

	var navEl=(ie4)?document.all['navM']:document.getElementById('navM');
	var addtop=390;
	if (window.location.href.indexOf("/?d=I")!=-1)
	{
		navEl=(ie4)?document.all['navI']:document.getElementById('navI');
		addtop=155;
	}
	
	var y=parseInt(navEl.style.top);
	var sy=(ie4||ie5)?document.body.scrollTop:window.pageYOffset;

	if (sy>parseInt(margintop)+addtop && !ns4) navEl.style.top=((sy-parseInt(margintop)-addtop+10-y)/5)+y+'px';
	else navEl.style.top='0px';
}
function bubbles()
{
	if (document.getElementById('overall').offsetHeight)
	{
		divheight=document.getElementById('overall').offsetHeight;
		divwidth=document.getElementById('overall').offsetWidth;
		var gifheight=115;
		var gifwidth=118;
		var spacetop=parseInt(margintop)+200;
		var spaceleft;
		var spacebottom=30;
		var countvertical=Math.ceil((divheight-spacetop-spacebottom)/gifheight);
		var output="<img src=\""+dirhome+"images/blaseLinksOben.gif\" style=\"position:absolute; left:0px; top:"+(parseInt(margintop)+50)+"px; z-index: 1\">"
		+"<img src=\""+dirhome+"images/blaseRechtsOben.gif\" style=\"position:absolute; right:0px; top:"+(parseInt(margintop)+10)+"px; z-index: 1\">";
		for (i=0; i<=countvertical; i++)
		{	
			spaceleft=10+Math.floor(gifwidth*Math.random());
			for (j=0; j<=Math.floor(divwidth/gifwidth); j++)
			{	
				if((divwidth-gifwidth-20)>spaceleft)
				{
				output+="<img src=\""+dirhome+"images/blaseLinksUnten.gif\" style=\"position: absolute; left:"+spaceleft+"px; top:"+spacetop+"px; z-index: 1\">";
				spaceleft = spaceleft+Math.round(gifwidth + 300*Math.random());
				}
			}
			spacetop = spacetop+gifheight;
		}
		document.getElementById('bubbles').innerHTML=output;
	}
}

function login()
{
	width = screen.availWidth;
	if (width > 1600) width = 1024;
	window.open('http://www.lernmodule.org/1/default.htm','lmlogin','width='+(width-8)+',height='+(screen.availHeight-26)+',screenX=0,screenY=0,top=0,left=0,scrollbars=0,locationbar=0,menubar=0');
//	window.open('http://www.lernmodule.org/1/default.htm','lmlogin','width=225,height=150,screenX=30,screenY=30,top='+margintop+',left=10,scrollbars=0,locationbar=0,menubar=0');
}

function setupvideo()
{
	window.open('http://lms.lernmodule.net/infos/images/anmeldung.htm','anmeldung','width=1004,height=700,screenX=0,screenY=0,top=0,left=0,scrollbars=0,statusbar=0,locationbar=0,menubar=0');
}

function details(catalog,identifier)
{
	window.open(dirlm+'md/?c='+catalog+'&i='+identifier,'_blank','width=680,height='+screen.availHeight+',screenX=0,screenY=0,top=0,left='+Math.round(Math.random()*300)+',scrollbars=1,statusbar=0,locationbar=0,menubar=0');
}

function demo(catalog,identifier)
{
	window.open('http://lernmodule.net/demo/?c='+catalog+'&i='+identifier,'_blank','width=950,height=610,screenX=0,screenY=0,top=0,left='+Math.round(Math.random()*30)+',scrollbars=0,statusbar=0,locationbar=0,menubar=0');
}
