/////////////////////////////////////////////////////////////////
// $Id: scripts.js,v 2.11 2009/05/15 10:50:23 ph Exp $
/////////////////////////////////////////////////////////////////
 /**
  * Open a connection to the specified URL, which is
  * intended to respond with an XML message.
  * 
  * @param string method The connection method; either "GET" or "POST".
  * @param string url    The URL to connect to.
  * @param string toSend The data to send to the server; must be URL encoded.
  * @param function responseHandler The function handling server response.
  */
var req;

//document.domain= "n2day.com"; 

//var nummer = 0;
var nummer = new Array();

// Werte zwischenspeichern beim erstellen neuer listen
var neulistname;
/*var neuanzahl;
var neuthemen = new Array();*/

function nummerinc(ulid) {
	if(nummer[ulid] == null) { nummer[ulid] = 0; }
	nummer[ulid]++;
	return nummer[ulid];
}
function nummerdec(ulid) {
	if(nummer[ulid] == null) { nummer[ulid] = 0; }
		if(nummer[ulid] > 0) {
			nummer[ulid]--; }
	return nummer[ulid]; 
}

 function hideFeedback() {
   //  document.getElementById('feedback').style.display="none";
 }

function getneuelisteinhalte() {
	var elem1 = document.getElementById('neueliste_name').value;		
	neulistname = elem1;
/*	var elem2 = document.getElementById('neueliste_anzahl').value;
	neuanzahl = elem2;
	var e3 = document.getElementById('neueliste_elem');
	var e3_1 = e3.getElementsByTagName("input");
	var len = e3_1.length;
			
	for(var j=0;j<len;j++) {
		if(e3_1[j].checked == true) {
			neuthemen[j] = 'checked';
		}
	}*/
//	alert(neuanzahl);
}

function setneuelisteinhalte() {
	var elem = document.getElementById('liste_neu_name');
	elem.value = neulistname;
}


 function xmlOpen(method, url, toSend, responseHandler)
 {
	  hideFeedback();
     if (window.XMLHttpRequest)
     {
         // browser has native support for XMLHttpRequest object
         req = new XMLHttpRequest();
			if (req.overrideMimeType) {
				req.overrideMimeType('text/xml');
         }
     }
     else if (window.ActiveXObject)
     {
         // try XMLHTTP ActiveX (Internet Explorer) version
         req = new ActiveXObject("Microsoft.XMLHTTP");
     }
     
     if(req)
     {
         req.onreadystatechange = responseHandler;
         req.open(method, url, true);
		 // wegen OPERA 8 auskommentiert!
			try {
	         req.setRequestHeader("content-type","application/x-www-form-urlencoded");
			}
			catch(e) {
			}
         req.send(toSend);
     }
     else
     {
//         alert('Your browser does not seem to support XMLHttpRequest.');
     }
 } 

function ajax_back() {
     if (req.readyState == 4)
     {
         // Make sure the status is "OK"
         if (req.status == 200)
         {
             var ajax = req.responseXML.getElementsByTagName('ajax');

			 var html_teil = req.responseXML.getElementsByTagName('html');
			 var js_teil = req.responseXML.getElementsByTagName('js');

			for(i=0; i < html_teil.length; i++) {
				var node = html_teil.item(i); 
				var node_id = node.getAttribute('html_id'); 
				var append_node = node.getAttribute('append');
				if(document.getElementById(node_id)) {					
					if(append_node==1) {
						document.getElementById(node_id).innerHTML += node.firstChild.nodeValue
					}
					else {
						document.getElementById(node_id).innerHTML = node.firstChild.nodeValue
					}
				}
			}

			for(i=0; i < js_teil.length; i++) {
				var node = js_teil.item(i); 
				var node_id = node.getAttribute('call'); 
				//eval("document.X_"+node_id+" = 'sss' ;"); 
				jscode = node.firstChild.nodeValue.replace(/\n/g,';'); 
				jscode = jscode.replace(/\r/,';'); 
				jscode = jscode.replace(/"/g,'\\"'); 
				eval(node_id+" = new Function('"+jscode+"');"); 
				eval(node_id+"()");
			}
		 
		 }
         else
         {
//             alert("There was a problem retrieving the XML data:\n" + req.statusText);
         }
     }
 } 

 function ajax_call(url,mode){
		var Jetzt = new Date();

		if(url.indexOf("?")>0) {
		    url=url + "&t="+Jetzt.getTime();
		}
		else {
			url=url + "?t="+Jetzt.getTime();
		}
	 //  xmlOpen("GET", url, null, ajax_back);
	 new IREDS_URL(url,{method:'get'}).call(); 
	 if(mode != '1') {
		 pageTracker._trackPageview(url);
	 } 
 }


 function ajax_call_single(url){
		var Jetzt = new Date();

		if(url.indexOf("?")>0) {
		    url=url + "&t="+Jetzt.getTime();
		}
		else {
			url=url + "?t="+Jetzt.getTime();
		}
	   xmlOpen("GET", url, null, ajax_back);
	 //new IREDS_URL(url,{method:'get'}).call(); 
	 pageTracker._trackPageview(url);
 }


 function ajax_post(url,post_data) {
     post_data += '&_REFERER='+escape(this.location.href); 
     xmlOpen("POST",url,post_data,ajax_back);
 }

 function ajax_form(obj) {
   if(obj) {
    if(obj.tagName == 'FORM') {
	var values = new Array();
	for (var i = 0; i < obj.elements.length; i++) {
   	   var elem = obj.elements[i];
	   if(elem.name != '') {
		var t = 'NOB'; 
		if(elem.type) { t = elem.type }; 
		if(elem.tagName == 'SELECT' ) { t = "select" }; 
		switch(t) {
			case "NOB": 
				break;
			case "radio": 
				if (elem.checked) {
				  values.push(elem.name+"="+encodeURI(elem.value));
				}
				break;
			case "checkbox":
				if (elem.checked) {
					 values.push(elem.name+"=on");
				} else {
					 values.push(elem.name+"=off");
				}
				break; 
			case "select":
				for(var ii = 0; ii < elem.options.length; ii++ ) {
					if(elem.options[ii].selected) {
						values.push(elem.name+"="+encodeURI(elem.options[ii].value)); 
					} 
				}
	
			break;
                        default:
				values.push(elem.name+"="+encodeURIComponent(elem.value));
			break;
		}
	    }
	}
	ajax_post(obj.action, values.join("&")) ;
    } else {
	alert("Use 'ajax_form' just in formtags "); 
    } 
   } 
 } 



function i_getLeft(ireds_l) {
        if (ireds_l.offsetParent) return (ireds_l.offsetLeft + i_getLeft(ireds_l.offsetParent));
        else return (ireds_l.offsetLeft);
}

function i_getTop(ireds_l) {
        if (ireds_l.offsetParent) return (ireds_l.offsetTop + i_getTop(ireds_l.offsetParent));
        else return (ireds_l.offsetTop);
}


function popContentBox(from,nid,opt) {
	var cn = document.getElementById('contentBox'); 
	var left =  (i_getLeft(from)+100); 
	var top =  (i_getTop(from)-30);
	if(opt != 'nopos') {
		contentWin.setPosition(left,top); 
	} else {
		 contentWin.hide(); 
	} 
	contentWin.show();
	contentWin.toFront(); 
	ajax_call("a_news.php?N_ID="+escape(nid));	
	contentTab.activate("cnews");
}

function getTag(w,id) {
	// document.getElementById("av_tags").innerHTML = w
	ajax_call_single("/ajax/av/gettags/"+encodeURI(w)); 
}

function addsuggest(tid,tword) {
	if($('ule_tag_list')) {
		$('ule_tag_list').value += tid+","; 
		$("av_select_tag").innerHTML += '<a href="?" onclick="delsuggest(this);return false;" id="avs_tag_'+tid+'">'+tword+'</a><br />'; 
	}
	
}

function delsuggest(e) {
	var t = e.id.replace(/avs_tag_/,''); 
	var rep = ','+t+','; 
	$('ule_tag_list').value = $('ule_tag_list').value.replace(rep,','); 
	var p = e.parentNode; 
	var s = e.nextSibling; 
	p.removeChild(e); p.removeChild(s);

} 

function delallsuggests() {
	var sp = document.getElementById('av_select_tag');
	sp.innerHTML = "";
	$('ule_tag_list').value = null;
}

function uncheckall() {
	var sl = document.getElementById('ule_channel_edit');
	var sk = sl.getElementsByTagName("div").length;
	var sb = sl.getElementsByTagName("div");
	var zi = '';
	var z = '';
	var len = '';
	var i = '';
	var j = '';
	for(i=0;i<sk;i++) {
		zi = sb[i];
		z = zi.getElementsByTagName("input");
		len = z.length;

		for(j=0;j<len;j++) {
			if(z[j].checked == true) {
				z[j].checked = false;
			}
		}
	}
}

function uncheckmedien() {
/*	var zh =	document.getElementById("medienliste1");
	var zg = zh.getElementsByTagName("option");	*/
	var zh = '';
	var zg = '';
	var zi = '';
	var len = '';
	var i = '';
	var j = '';
	var zj = '';
	for(i=1;i<=2;i++) {
		zh = document.getElementById("medienliste"+[i]);
		zg = zh.getElementsByTagName("option");
		len = zg.length;
		zi = zg[0].selected = true;
		for(j=1;j<len;j++) {
			zj = zg[j].selected = false;
		}
	}
}

/////////////////////////////////////////////////////////////////////


var pins = {
	pinlist:[],   
	add:function(lt,lg,t) {
		var p = this.pinlist.length; 
		this.pinlist[p] = {lat:lt,long:lg,items:[],txt:"<div style='color:white;padding:5px;'><b>"+t+"</b></div><br />" }	; 
		return p; 
	   },  
	addItem: function(p,titel,id,color) {
//		var t = '<span style="background-color:'+color+'">&nbsp;</span> <a href="javascript:;" onclick="popContentBox(this,'+id+')">'+ titel+"</a><br>"; 
//		var pp = this.pinlist[p].items.length; 
//		this.pinlist[p].items[pp] = {titel:titel,id:id}; 
//		this.pinlist[p].txt = this.pinlist[p].txt+t; 
	  }, 
	drawMarkers: function() {
		for(var i = 0; i < this.pinlist.length;i++) {
		  var pin = this.pinlist[i]; 
		  pin.marker = new GMarker(new GLatLng(pin.lat, pin.long)); 
		  pin.marker.TXT = pin.txt; 
		  GEvent.addListener(pin.marker, "click", function () {
			var c  = document.getElementById('goverlay'); 
			pos = this.getPoint();
			l = map.fromLatLngToContainerPixel(pos); 
			// c.style.top = (85+l.y) + 'px'; 
			// c.style.left = (262+l.x) + 'px'; 
			c.innerHTML = this.TXT; 
		  }); 
		  map.addOverlay(pin.marker); 
		  
		} 
	  },
	  i:0 
	}


function place_pin(lat,long) {
	var p = new GLatLng(lat, long); 
	pin.setLatLng(p);
	pin.show(); 
	
	map.setCenter(p); 
}

function setTagCloud(id,max) {
	if (document.getElementById(id)) {
		var n = document.getElementById(id).childNodes; 
		for(var i = 0; i < n.length;i++) {
			if(n[i].tagName == 'A') {
				var f = n[i].getAttribute('pattern');
				var fontSize = (150.0*(1.0+(1.5*f-max/2)/max))+'%';
				n[i].style.fontSize = fontSize;
				
			}
		}
	} 
}

function boxslideup() {
   setTimeout('Effect.SlideUp(\'notiz\', { duration: 1.0 });', 20000);
}

var uliste = {last:0, items : new Array()} ; 

function add_uliste(i) {
	if(i.indexOf('-') < 1) {
		uliste.items[uliste.items.length] = i; 
	}
}


function move_deep(id) {
	if($('deep_'+id)) {
		$(id).innerHTML = $('deep_'+id).innerHTML; 
		$('deep_'+id).innerHTML = ''; 

	}
}


var breport = ''; 
var active_liste = new Array(); 


function detail(id,o,opt) {
	if(breport != '') {
		id = id + "?REPORT="+breport; 
	}
	if(opt != 'bl') {
		var p = o.parentNode; 
		var l = ''; 
		if(p.getAttribute('items')) {
			l = p.getAttribute('items'); 
		} else {
		  p  = p.parentNode;
		  if(p.getAttribute('items')) {
			l = p.getAttribute('items'); 
		  }
		}
		active_liste = l.split(','); 
	}
	if(opt == 'suche_print') {
		new IREDS_URL('/ajax/detail/presse/'+id,{method:'get'}).call();
	} else { 
		if(opt == 'suche_online') {
			new IREDS_URL('/ajax/detail/online/'+id,{method:'get'}).call();
		} else {
			new IREDS_URL('/ajax/detail/view/'+id,{method:'get'}).call();
		}
	}

	$('detail_banner').src="/ajax/googlebanner.php?ID="+id; 
	do_oewa(); 
	if(o.href) {
		pageTracker._trackPageview(o.href);  
	} else {
		pageTracker._trackPageview("/ajax/detail/view/"+o);
	}
	if(opt == 'suche' || opt == 'suche_print') {
	 	var left = 500;
		var h = window.innerWidth ;
		if(typeof(h) != 'number') {
			 var h = document.documentElement.clientWidth;
		}
		var currpos = $("detail_box").style.left.replace(/px/,'');
		if(currpos < 650) {
			left = Math.max(500,Math.min(h-715,700));
			$("detail_box").style.left = left+'px';
		}
	}
}


function clickUrl(o) {
	var url = o.href; 
	var breite = 960;  
	if(o.getAttribute('mode') == 'frame') {		
		var id = o.id.replace('linkto_','')
		url = "/do/detail/artikel/"+id+"?URL=" + escape(o.href)+"&LIST="+active_liste; 	
		// alert(url); 
	} 
	var w = window.open(url, "Zweitfenster", "width=1000,height=650,left=50,top=100,scrollbars=yes,resizable=yes,location=yes");
	w.focus(); 
	return false; 
} 


function isinarray(was,a) {
	for(var i=0;i<a.length;i++) {
		if(was == a[i]) return i; 
		
	}
	return -1; 
}


function getnextpre(id,wie) {
	var pos = isinarray(id,active_liste); 
	pos = pos + wie; 
	if(pos >= 0 && pos < active_liste.length) {
		return active_liste[pos]; 				
	}
	return false; 
}

function detailnext(id,wie) {
	var nid = getnextpre(id,wie); 
	if(nid) {
		detail(nid,'','bl'); 
	}
} 



function suche() {

}


/// Tooltip 
/// 
/// onmouseover="showtt(this)" onmouseout="hidett(this)" title="Tooltip Text" 
///  

function showtt(a) {
	var t = a.title ;
	if(t != '') {
		var b = document.getElementById("tooltip");
		b.style.display = "block";
		document.getElementById("tooltip_text").innerHTML = t; 
		var hoh = document.getElementById("tooltip").offsetHeight;
		b.style.top = (i_getTop(a)-hoh)+"px"; 
		b.style.left = i_getLeft(a)-50+"px";
		b.style.zIndex = 1000;
	}
} 


function hidett(a) {
	document.getElementById("tooltip").style.display = "none";
}

/// 
/// test img src
/// 

function ShowImage2(a) {
	var w = a.width; ; 
	var h = a.height;
	if(w == 0) w = 120;  
	var id = a.id; 
	var iid = document.getElementById('i_'+id);
	if(iid) {
	  is_ie6 = (navigator.userAgent.indexOf('MSIE 6') > 0); 
 	  // if(! is_ie6) {	 
			if (w > 120) {
				a.width = 120; 		
			} else {
              				a.width = w; 
					if(h > 90) {
					//iid.height = 90; 
					} else {
						if (h > 0) a.height = h; 
					}		 
	    // }
	  }
  	  a.style.display="inline"; 
	} 
}


// http://code.google.com/p/png-hack/
// Distributed under MIT X11 License
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// 
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
document.write('<!--[if lte IE 6]><style type="text/css">.hack-png{visibility:hidden}</style><![endif]-->');
var PNGHack = function(spacer) {
        var remoteUrl = 'http://pnghack.googlepages.com/spacer.gif';
        var hackMethod = function(obj, method, that) {
                // browser check
                if (that.checkIE && !navigator.userAgent.match(that.checkIE))
                        return;
                
                // settings
                if (!obj) obj = {};
                var d   = obj.scope || document;
                var elm = (!obj.elm && method != 2) ? d.all : d.getElementsByTagName(obj.elm);
                var src = obj.src || 'src';
                var ext = new RegExp((obj.ext) ? '\\w+.'+obj.ext.toUpperCase() : '\.PNG$');

                // hack core
                var hack = function(elm, source) {
                        var style = elm.style;
                        if (!elm.pngsrc)
                                that.elements.push(elm);
                        elm.pngsrc = elm.getAttribute(source);
		
			if(elm.pngsrc.indexOf('spacer.gif') > 0 ) return ; 			

                        style.width = elm.clientWidth;
                        style.height = elm.clientHeight;
                        style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+elm.pngsrc+"',sizingMethod='scale')";
                        
                        // using hosted spacer, set it up to rescue local spacer or cancel remotehost
                        if (that.remotehost == true)
                                spacer = remoteUrl;
                        else if (that.remotehost != false) {
                                var rescueSpacer = function() {
                                        elm.setAttribute(source, remoteUrl);
                                };
                                var setRescueSpacer = function() {
                                        if (elm.readyState == 'complete') {
                                                elm.detachEvent('onerror', rescueSpacer);
                                                elm.detachEvent('onreadystatechange', setRescueSpacer);
                                        }
                                };
                                elm.attachEvent('onerror', rescueSpacer);
                                elm.attachEvent('onreadystatechange', setRescueSpacer);
                        }
                        
                        // displaying element / removing hack-png class
                        elm.setAttribute(source, spacer || 'images/spacer.gif');
                        if (elm.className.match(/\bhack-png\b/))
                                var x = setTimeout(function(){elm.className = elm.className.replace(/hack-png/g,'');clearTimeout(x);},300);
                };
                
                // hack method
                if (method == 2) {
                        hack(obj.elm, src);
                        return;
                }
                

	
                // go and crush method
                for (var i = 0; i < elm.length; ++i) {
                        var isrc = elm[i].getAttribute(src) || '';
                        if (method == 0 && elm[i].className.match(/\bhack-png\b/)
                        || (method == 1 && isrc.toUpperCase().match(ext)))
                                hack(elm[i], src);
                }
        };
        return {
                hackClass : function(obj) {
                        hackMethod(obj, 0, this);
                },
                hackExtension : function(obj) {
                        hackMethod(obj, 1, this);
                },
                hackElement : function(obj) {
                        hackMethod(obj, 2, this);
                },
                elements : [],
                checkIE : 'MSIE 5\.5|MSIE 6',
                remotehost : null
        };
};


pnghck = new PNGHack("/bilder/leer.gif");

/////////////////////////////////////////////


// ticker_start();

function ticker_start() {
	var tickerSupported = false;
	TICKER_WIDTH = document.getElementById("TICKER").style.width;
	var img = "<img src=/bilder/ticker_space.gif width="+TICKER_WIDTH+" height=0>";

	// Firefox
	if (navigator.userAgent.indexOf("Firefox")!=-1 || navigator.userAgent.indexOf("Safari")!=-1) {
		document.getElementById("TICKER").innerHTML = "<TABLE style='padding-top:4px;' cellspacing='0' cellpadding='0' width='100%'><TR><TD nowrap='nowrap'>"+img+"<SPAN style='"+TICKER_STYLE+"' ID='TICKER_BODY' width='100%'>&nbsp;</SPAN>"+img+"</TD></TR></TABLE>";
		tickerSupported = true;
	}
	// IE
	if (navigator.userAgent.indexOf("MSIE")!=-1 && navigator.userAgent.indexOf("Opera")==-1) {
		document.getElementById("TICKER").innerHTML = "<DIV nowrap='nowrap' style='width:100%;padding-top:4px;'>"+img+"<SPAN style='"+TICKER_STYLE+"' ID='TICKER_BODY' width='100%'></SPAN>"+img+"</DIV>";
		tickerSupported = true;
	}
 	document.getElementById("TICKER").style.visibility='visible'; 
	if(!tickerSupported) document.getElementById("TICKER").outerHTML = ""; else {
		document.getElementById("TICKER").scrollLeft = TICKER_RIGHTTOLEFT ? document.getElementById("TICKER").scrollWidth - document.getElementById("TICKER").offsetWidth : 0;
		document.getElementById("TICKER_BODY").innerHTML = TICKER_CONTENT;
		document.getElementById("TICKER").style.display="block";
		TICKER_tick();
	}
}

function TICKER_tick() {
	if(!TICKER_PAUSED) document.getElementById("TICKER").scrollLeft += TICKER_SPEED * (TICKER_RIGHTTOLEFT ? -1 : 1);
	if(TICKER_RIGHTTOLEFT && document.getElementById("TICKER").scrollLeft <= 0) document.getElementById("TICKER").scrollLeft = document.getElementById("TICKER").scrollWidth - document.getElementById("TICKER").offsetWidth;
	if(!TICKER_RIGHTTOLEFT && document.getElementById("TICKER").scrollLeft >= document.getElementById("TICKER").scrollWidth - document.getElementById("TICKER").offsetWidth) document.getElementById("TICKER").scrollLeft = 0;
	window.setTimeout("TICKER_tick()", 30);
}

/////////////////////////////////////////

function reloadbanner(mode) {
  if(mode) {
	$('detail_banner').src="/ajax/googlebanner.php?ID="+id;
  }
  if(document.getElementById('banner_full')) {
	  var html="<iframe src='/ajax/banner.php' width=728 height=90 frameborder=0 scrolling=no></iframe>"; 	
	  document.getElementById('banner_full').innerHTML = html; 
  }
}

// fuer channels top navigation

var channelstop_currentsub = 99999;

function change_submenu(id,color) {
	$('topchannel_subnavigation_' + id).style.display="block";
	$('topchannel_' + id).style.background=color;
	$('topchannel_' + id).style.color='white'; 
	if(channelstop_currentsub != 0 && channelstop_currentsub!=id) {
		$('topchannel_subnavigation_' + channelstop_currentsub).hide();
		$('topchannel_' + channelstop_currentsub).style.background='';
		$('topchannel_' + channelstop_currentsub).style.color='black';
	}
	channelstop_currentsub = id;
}


function do_oewa(was ) {
	 var OEWAd = (new Date()).getTime()
	 var c = OEWACODE; 
	 try {
		 if(was == 'Service') c = was; 
	 } catch(e) {}
	 var OEWA="http://salzburg.oewabox.at/cgi-bin/ivw/CP/RedCont/Nachrichten/NachrichtenUeberblick/vienna.com";
	 var url = OEWA+"?r="+escape(document.referrer)+"&d="+OEWAd
	 var im = new Image;
	 im.src = url;
	 var im2 = new Image;
	 im2.src = '/ajax/pi.php?r='+escape(document.referrer)+"&late=1&d="+(Math.random()*100000);
	 // var xx = 1; 	
}


//////////////// BOX SIZE //////////////////

var boxSize = {
	up:function(id) {
		size=boxSize.getSize(id);
		if(size<3) {
			boxSize.doField(id,size+1);
		}
		
	},

	down:function(id) {
		size=boxSize.getSize(id);
		if(size>1) {
			boxSize.doField(id,size-1);
		}
	},

	doField:function(id,size) {
		nodes = $('listSpalte_'+id).childNodes; 			
		for(i=0;i<nodes.length;i++) {
			editNodes=nodes[i].childNodes;
			for(j=0;j<editNodes.length;j++) {
				boxSize.doNode(editNodes[j],size);
			}
		}
		boxSize.setSize(id,size,true);
	},

	doNode:function(editNode,size) {
		if(editNode.nodeType==1) {
			switch(editNode.getAttribute("name")) {
				case 'artikel-image':
					if(size<3) {
						$(editNode).hide();
					}
					else {
						$(editNode).show();
					}
				break;

				case 'artikel-data':
					if(size<2) {
						$(editNode.firstChild).hide();
					}
					else {
						$(editNode.firstChild).show();
					}
				break;
			}
		}
	},

	getSize:function(id) {
		size=parseInt($('listitem_'+id).getAttribute("box-size"));

		return size;
	},

	setSize:function(id,size,save_status) {
		$('listitem_'+id).setAttribute("box-size",size);
		if(save_status) {
			ajax_call('/ajax/liste/saveListSizeToCookie/'+id+'/'+size);
		}
	}
}
//////////////// BOX IMAGES //////////////////
var boxImages = {
	prefere:function(id) {
	}
}

//////////////// USERLIST LAYER //////////////////

var userListLayer = {
	hover:false,
	timeout:null,
	active:0,
	storeC: new jsHash(), 
	mode:null, 
	myid:0, 

	store_only: function(id,mode) {
		this.storeC.setItem(mode+'_'+id,$("userListEdit_content").innerHTML);
	},

	store:function(id,mode) {
		// called my /ajax/liste/getminiform/
		if(! this.storeC.hasItem(mode+'_'+id)) {
			this.storeC.setItem(mode+'_'+id,$("userListEdit_content").innerHTML);
			// ajax_call('/ajax/liste/getminiform/'+mode); 
		}
		 editLayers.show('listitem_'+id,'userListEdit');
	}, 

	show:function(id,mode) {
	   if(! this.storeC.hasItem("userList")) {
		this.storeC.setItem("userList",$("userListEdit_content").innerHTML);
	   }
	   if(mode) {
		if(! this.storeC.hasItem(mode+'_'+id)) {
			ajax_call('/ajax/liste/getminiform/'+mode+'/'+id);
		} else {
			$("userListEdit_content").innerHTML = this.storeC.getItem(mode+'_'+id); 
			editLayers.show('listitem_'+id,'userListEdit');
		}
		
	   } else {
	        if( this.storeC.hasItem("userList")) {
			if($("userListEdit_content").innerHTML.length != (this.storeC.getItem("userList").length)) {
				$("userListEdit_content").innerHTML = this.storeC.getItem("userList"); 
			}
		}
		ajax_call('/ajax/liste/preferImageStatus/'+id,"1");
		editLayers.show('listitem_'+id,'userListEdit');
	   }
	   this.mode = mode; 
	   this.myid = id; 

	},
	getActiveId:function() {
		return parseInt(editLayers.active.replace(/listitem_/,''));
	},

	edit:function() {
		if(userListLayer.getActiveId() !=0) {
			ajax_call('/ajax/user_liste/edit_small/'+userListLayer.getActiveId());	
			editLayers.hide(true);
		}
	},

	add:function() {
		if(userListLayer.getActiveId()!=0) {
			ajax_call('ajax/user_liste/addliste/A'+userListLayer.getActiveId());
			editLayers.hide(true);
		}
	},

	remove:function() {
		if(userListLayer.getActiveId()!=0) {
			ajax_call('/ajax/user_liste/delete/'+userListLayer.getActiveId());
			editLayers.hide(true);
		}
	},

	getParams:function() {
		params="";
		regTest=new RegExp('^'+userListLayer.getActiveId()+'/');
		for(i=0;i<uliste.items.length;i++) {
			if(uliste.items[i].match(regTest)) {
				params=uliste.items[i];
			}
		}
		return params;
	},

	preferImages:function(pref) {
		params=userListLayer.getParams();
		if(params!="") {
			ajax_call('/ajax/liste/preferImages/'+params+'?pref='+pref);
		}
		editLayers.hide(true);
	},
	showPreferImage:function(pref) {
		if(pref==1) {
			$('userListEdit_ignoreImages').style.display="inline";
			$('userListEdit_preferImages').style.display="none";
		}
		else {
			$('userListEdit_ignoreImages').style.display="none";
			$('userListEdit_preferImages').style.display="inline";
		}
		getBiggestSortable();
	}
}

var wetterLayer = {
	show:function() {
		editLayers.show('myWetter','wetterEdit');		
	},
	add:function() {
		if(editLayers.active!="") {
			if($('wetterEditDelete')) {
				$('wetterEditDelete').style.display="none";
			}
			$('wetterEditNeu').style.display="inline";
			new Ajax.Autocompleter("wetterNeuCompleter","wetterNeuCompleters", "/ajax/av/view/wetterort", {
				paramName: "word",
				minChars: 2,
				afterUpdateElement: editLayers.over()
			});  
		}
	},
	remove:function() {
		if(editLayers.active!="") {
			$('wetterEditNeu').style.display="none";
			$('wetterEditDelete').style.display="inline";
		}
	},
	doRemove:function(id) {
		ajax_call('/ajax/wetter/remove/'+id);
		editLayers.hide(true);
	}
}


var editLayers = {
	hover:false,
	timeout:null,
	active:0,
	layer:'',

	show:function(atId,showId) {
		this.hide(true);
		if(Draggables.activeDraggable) return;

		pos=(Position.cumulativeOffset($(atId)));
		dim=$(showId).getDimensions();
		dim2=$(atId).getDimensions();

		diff=dim2.width-dim.width;

		$(showId).style.left=(pos[0]+diff)+"px";
		$(showId).style.top=pos[1]+"px";

		$(showId).style.display="inline";

		this.hover=true;
		this.active=atId;
		this.layer=showId;
	},
	over:function() {
		this.hover=true;
		if(this.timeout) {
			window.clearTimeout(this.timeout);
		}
	},
	try_hide:function() {
		this.hover=false;
		if(parseInt(arguments[0])>0) {
			doTime=parseInt(arguments[0]);
		}
		else {
			doTime=200;
		}
		this.timeout=window.setTimeout("editLayers.hide(false)",doTime);
	},
	hide:function(force,hideId) {
		if(!this.hover || force) {
			if($(this.layer)) {
				$(this.layer).style.display="none";
			}
			this.active=0;
		}
	}
}	


function jsHash()
{
	this.length = 0;
	this.items = new Array();
	for (var i = 0; i < arguments.length; i += 2) {
		if (typeof(arguments[i + 1]) != 'undefined') {
			this.items[arguments[i]] = arguments[i + 1];
			this.length++;
		}
	}
   
	this.removeItem = function(in_key)	{
		var tmp_previous;
		if (typeof(this.items[in_key]) != 'undefined') {
			this.length--;
			var tmp_previous = this.items[in_key];
			delete this.items[in_key];
		}
		return tmp_previous;
	}

	this.getItem = function(in_key) {return this.items[in_key];
	}

	this.setItem = function(in_key, in_value)	{
		var tmp_previous;
		if (typeof(in_value) != 'undefined') {
			if (typeof(this.items[in_key]) == 'undefined') {this.length++;	}
			else {	tmp_previous = this.items[in_key];	}
			this.items[in_key] = in_value;
		}
		return tmp_previous;
	}

	this.hasItem = function(in_key)	{ 
		return typeof(this.items[in_key]) != 'undefined';
	}
}