


function fnTrap(btnid,ev)
{
if(ev == null)
	ev = event;
	
     if (ev.keyCode == 13)
     {
		var btn = document.getElementById(btnid);
		
		if(btn != null)
		{ 
			ev.returnValue=false;
			ev.cancel = true;
			btn.click();
        }
      }
 }
 
function popup(url, name){
	if(name = "") name == "popup";
	var fenster = window.open(url, name, "width=" + (screen.Width-15) + ", height=" + (screen.Height-100) + ", left=0, top=0, menubar=0, fullscreen=1, resizable=1, status=1");	
	fenster.focus();
}


function hideImage(img){
	if(img != null)
		img.style.display = "none";
}

function changeImage(img){
	if(img != null)
		img.src = "grafik/backgrounds/nicht_vorhanden.gif";
		
}

function changeImageFront(img){
	if(img != null)
		img.src = "http://archiv.volksblatt.li/grafik/backgrounds/Nicht_Vorhanden_g.gif";
		
}

var currwidth = 0;
var step = 0;

function smoothWidth(divid, maxwidth,direction)
{
	step += 3;
	if(direction == "+")
		currwidth += step;
	else
		currwidth -= step;
		
	var div = document.getElementById(divid);
	if(div != null){
		div.style.width = currwidth + "px";

	if(direction == "+"){
		if(currwidth <= maxwidth)
			window.setTimeout("smoothWidth('" + divid + "'," + maxwidth + ",'" + direction + "')",20);
		else
			currwidth = 0;
	} else {
		if(currwidth >= 0)
			window.setTimeout("smoothWidth('" + divid + "'," + maxwidth + ",'" + direction + "')",20);
		else
			currwidth = maxwidth;
	}
	}

}


var isOutActive = true;

function overButton(img)
{
	if(img != null)
	{
		img.src = img.src.toLowerCase().replace("_off.gif","_on.gif");
	}
}

function outButton(img)
{
	if(img != null && isOutActive)
	{
		img.src = img.src.toLowerCase().replace("_on.gif","_off.gif");
	}
}



function switchDiv(sourceid,divid,imgid,noneimgsrc,blockimgsrc)
{

var div = document.getElementById(divid);
var source = document.getElementById(sourceid);
var img = document.getElementById(imgid);

if(div != null)
{
	if(source.value == "none")
	{
		div.style.display = "block";
		img.src = blockimgsrc;
	
		if(source != null)
			source.value = "block";
	}else {
		div.style.display = "none";
		img.src = noneimgsrc;
		
		if(source != null)
			source.value = "none"
	}

}

neuAufbau();

}

function setDiv(sourceid,divid,imgid,noneimgsrc,blockimgsrc)
{
	var div = document.getElementById(divid);
	var source = document.getElementById(sourceid);
	
	if(source != null && div != null)
	{
		div.style.display = source.value;
	
		var img = document.getElementById(imgid);
		if(img != null){
			if(source.value == "block")
				img.src = blockimgsrc;
			else
				img.src = noneimgsrc;
			
		}
		
	}
}

function showBookmark(rb)
{
	var bookdiv = dom.gI("bookmarktable");
	
	if(bookdiv != null)
	{
	
		if(rb.checked){
			bookdiv.style.display = "block";
			dom.gI("ucBookmarks_hiddenVisibility").value = "True";
		}
		else{
			bookdiv.style.display = "none";
			dom.gI("ucBookmarks_hiddenVisibility").value = "false";
		}
			
		
	
		var caldiv = dom.gI("calendartable");
		if(caldiv != null)
			caldiv.style.display = "none";
		else
			alert("null");
			
		
	}
}


function setLoginButton(){
	var loginbt = document.getElementById('profilbutton');
	var hidden = document.getElementById('hiddenLoggedIn');
	
	if(loginbt != null && hidden != null)
	{
	
		if(hidden.value.toLowerCase() == "true")
			loginbt.src = loginbt.src.replace("login_","login_offen_");
	}
}


/* PRINTING */


var gAutoPrint = false; // Flag for whether or not to automatically call the print function

function printscreen(aid)
{
	if (document.layers){
	//Netscape 4 specific code
		pre = 'document.';
		post1 = '';
	}
	if (document.getElementById){
		//Netscape 6 specific code
		pre = 'document.getElementById("';
		post1 = '")';
	}
	if (document.all){
		//IE4+ specific code
		pre = 'document.all.';
		post1 = '';		
	}
	
	var content = dom.gI("newarticle" + aid);
	if(content == null){
		content = dom.gI("contentdiv2");
	}
	var aufmachertext = "";
	if(dom.gI("aufmacherdiv") != null)
		aufmachertext = dom.gI("aufmacherdiv").innerHTML;
	
	
		
	today = new Date();
	var strDateTime = today.getDate() + "." + (today.getMonth()+1) + "." + today.getFullYear() + ", " + today.toLocaleTimeString() + " Uhr";
	
	var parameter = "menubar=yes,toolbar=yes,scrollbars=yes,statusbar=no,location=no,resizable=yes,width=750px,height=520px";
	var printWin = window.open("","printSpecial",parameter);
	
	if(content != null){
		var header = "<table id=printheader><tr><td valign=bottom align=left><img src=\"grafik/logo_print.gif\" width=\"400px\"></td><td valign=bottom align=right>Tageszeitung vom " + dom.gI("lblstatus").innerHTML + "</td></tr></table>";
		var text = "";
		text = "<html><head><link rel=\"stylesheet\" href=\"css/print.css\"></head><body>" + header + aufmachertext + content.innerHTML + "</body></html>";
	}

	printWin.document.open();	
	printWin.document.write(text);
	printWin.document.close();
	printWin.focus();
	if (gAutoPrint)
		printWin.print();
}

function replaceAll( str, from, to ) {
    var idx = str.indexOf(from);

	var i = 0;
    while (idx > -1 && i<100) {
		i++;
        str = str.replace(from, to); 
        idx = str.indexOf(from);
    }
    return str;
}



/* FOR POPUPS */

var wmtt = null;


function fly_move(e) {

	//if(navigator.userAgent.toLowerCase().indexOf('firefox') < 0){
		if (wmtt != null) {
			wmtt.style.left = (window.event.clientX + document.body.scrollLeft) + 15;
			wmtt.style.top 	= (window.event.clientY + document.body.scrollTop) + 15;
			
			//var x=event.x+top.document.body.scrollLeft;	var y=document.body.scrollTop + event.clientY
			
			//var x=e.clientX+self.pageXOffset;var y=e.clientY+self.pageYOffset;
			
			//wmtt.style.left = x;
			//wmtt.style.top = y;
		}
	//}
}



/* 
text ==> text that will be written into the div 
divname ==> name of div that will be shown 
*/

function fly_start(img) {

	if(img != null){
		if(img.alt != ""){
		if (document.layers){
			//Netscape 4 specific code
			pre = 'document.';
			post = '';
			post1 = '';		
			scr_h = window.innerHeight;
		}
		if (document.getElementById){
			//Netscape 6 specific code
			pre = 'document.getElementById("';
			post = '").style';
			post1 = '")';		
			scr_h = window.innerHeight;

		}
		if (document.all){
			//IE4+ specific code
			pre = 'document.all.';
			post = '.style';
			post1 = '';		
			scr_h = document.body.clientHeight;
		}
		
		// standard is overdiv
		if(divname == "")
			divname = "overdiv";
			
		wmtt = null;
		wmtt = eval(pre + divname + post1);	
		
		
		if (wmtt != null) 
		{
			// if text is default, take text that is already in div, else set text
			wmtt.innerHTML = img.alt;
			wmtt.style.display = "block";	
		}
		
		// if you take text in div, but there is nothing in it, then cancel
		if(wmtt.innerHTML == ""){
			wmtt.style.display = "none";
			wmtt == null;
		}
		}
	}
}


function fly_stop() {
	if (wmtt != null) {
		wmtt.style.display = "none";
		wmtt = null;
		}
}

/* Mozilla Bub - This method enables scrolling */

function enableScrolling()
{
	if(navigator.userAgent.toLowerCase().indexOf("mozilla") > -1){
		if (document.body.addEventListener) {
			var divs = document.getElementsByTagName('DIV');
			for (var d in divs) {
				if (divs[d].style.overflow = "auto") { // all divs mit classname "scroll"
					try {
						divs[d].addEventListener('DOMMouseScroll', scrollMe, false);
					} catch (ex) {}
				}
			}
		}
	}

}

function scrollMe(event)
{
        var st = event.currentTarget.scrollTop + (event.detail * 12);
	event.currentTarget.scrollTop = st < 0 ? 0 : st;
	event.preventDefault();
}






