function execJS(node)
{

        var bSaf = (navigator.userAgent.indexOf('Safari') != -1);
        var bOpera = (navigator.userAgent.indexOf('Opera') != -1);
        var bMoz = (navigator.appName == 'Netscape');

        if (!node)
                return;

        /* IE wants it uppercase */
        var st = node.getElementsByTagName('SCRIPT');
        var strExec;
        for(var i=0;i<st.length; i++) {
                if (bSaf) {
                        strExec = st[i].innerHTML;
                        st[i].innerHTML = "";
                } else if (bOpera) {
                        strExec = st[i].text;
                        st[i].text = "";
                } else if (bMoz) {
                        strExec = st[i].textContent;
                        st[i].textContent;
                } else {
                        strExec = st[i].text;
                        st[i].text = "";
                }

                try {
					eval(strExec);
                } catch(e) {
                        alert(e);
                }
        }
};

function show_more(divid) {
	
	var stretchers = document.getElementById('more'+divid); //div that stretches

	stretchers.style.display= "block";   
	//accordion effect
	var myEffect = new Fx.Height($('more'+divid),{duration: 500});
	myEffect.toggle();

}

function trigger_error() {
		diverror = document.getElementById('error');
		var myEffect = new fx.Opacity(diverror , {transition:fx.Transitions.bounceIn, duration: 2000});
		myEffect.custom(0,1);
}


function delete_feed_from_list(id) {
	divname = 'feed_' + id;

	divfeed = document.getElementById(divname);
// Scriptaculous here, no Sortable in mootools :'(
	Effect.Fade(divname, {duration:1, afterFinish:function() {
		divfeed.style.padding = 0;
		divfeed.style.margin = '-2px';
		feedcontainer = document.getElementById('feedsarrangeinner');
		feedcontainer.removeChild(divfeed);
		savelist();
	}});
}

function permdelete_feed_from_list(id) {
	divname = 'e' + id;

	divfeed = document.getElementById(divname);
	var myEffect = new fx.Height(divfeed, {duration: 1000, onComplete: function() {
		divfeed.style.padding = 0;
		divfeed.style.margin = '-2px';
		feedcontainer = document.getElementById('arrangecatlist');
		feedcontainer.removeChild(divfeed);
		$('divedit').setHTML('');
	}
	});
	myEffect.toggle();
}

function delete_links_from_list(id) {
	divname = 'b' + id;
	divfeed = document.getElementById(divname);
	$(divname).setStyle('overflow', 'hidden');
	var myEffect = new fx.Styles(divfeed, {duration: 1000, onComplete: function() {
		divfeed.style.padding = 0;
		divfeed.style.margin = '-2px';
		feedcontainer = document.getElementById('linkslisting');
		feedcontainer.removeChild(divfeed);
	}
	});
	
	myEffect.custom({'height': [$(divname).offsetHeight,0], 'opacity': [1,0]})

}

function replaceTag(newtag) {
	taglist = document.getElementById('linktags');
	taglist.value = newtag;
}

function search(user) {
	criteria = document.frmsearch.search_criteria.value;
	if ( document.frmsearch.where ) {
		area = document.frmsearch.where.options[document.frmsearch.where.selectedIndex].value;
	}
	else {
		area = '';
	}
	if ( criteria.length > 1 ) {
		if ( area == 'my' ) {
			document.frmsearch.where.options[document.frmsearch.where.selectedIndex].value;
			document.location = 'http://' + user + '.kreuzz.com/links/search/' + encodeURIComponent(criteria) + '/';
		}
		else {
			document.location = 'http://www.kreuzz.com/links/search/' + encodeURIComponent(criteria) + '/';
		}
	}
	else {
		alert(trad_search_criteria);

	}
}

//
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.org
//
function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}

// -----------------------------------------------------------------------------------

//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function CA(frmname, item){
	collection = eval('window.document.' + frmname);
	memory = 'window.document.' + frmname + '.' + 'chkbox_' + item;
	memory_html = eval(memory);
	
	for (var i = 0; i < collection.elements.length; i++) {
		var e = collection.elements[i];
		
	
		if (e.type=='checkbox') {
			tmpname = e.name.substring(0, e.name.indexOf('['));
			if ( tmpname == item ) {
				if ( memory_html.value == "true") {
					e.checked = true;
				}
				else {
					e.checked = false;
				}
			}
		}
		
		
		
	}

	if ( memory_html.value == "true" ) {
		memory_html.value = "false";
	}
	else {
	 	memory_html.value= "true";
	}

					
}


function spyruntime(div, url_refresh, tmpdiv, arrayvar) {
	if ( busy_newscroll == 1 ) {
		setTimeout("spyruntime('"+div+"', '"+url_refresh+"', '"+tmpdiv+"', '"+arrayvar+"')", 100);
		return false;
	}
	if ( eval(arrayvar+".length") == 0 ) {
		postvars = '';
		new Ajax(url_refresh, {update: tmpdiv, evalScripts: true}).request();		
		setTimeout("spyruntime('"+div+"', '"+url_refresh+"', '"+tmpdiv+"', '"+arrayvar+"')", 1000);
		busy_newscroll = 1;
		return false;
	}

	
	content_raw = eval(arrayvar+".shift()");
	content = '<a href="'+content_raw['link'] +'" target="_blank">'+content_raw['title']+'</a>';
	recipient = document.getElementById(div);
	nb_nodes = recipient.childNodes.length;
	new_elt = document.createElement('div');
	new_elt.setAttribute('id', div+nb_nodes);
	new_elt.style.width = '350px';
	new_elt.style.backgroundColor = document.getElementById('loginbox').style.backgroundColor;
	
	new_elt.innerHTML = content;
	
	firstNode = recipient.firstChild;
	recipient.insertBefore(new_elt, firstNode);

	var resetOpacity = new fx.Style(new_elt, 'opacity', {duration:1000});
	resetOpacity.custom(0.1,1);


	if ( nb_nodes >= 5 ) {
		divfeed = new_elt.nextSibling;
		for ( i = 0; i < 5; i++) {
			divfeed = divfeed.nextSibling;
		}
		for ( i = 0; i < (nb_nodes - 5); i++ ) {
			divfeed.setOpacity(0.6 - (i*0.1));
			divfeed = divfeed.nextSibling;

		}
	}
	if ( nb_nodes > 10 ) {
		recipient.removeChild(recipient.lastChild);
	}
	
	setTimeout("spyruntime('"+div+"', '"+url_refresh+"', '"+tmpdiv+"', '"+arrayvar+"')", 2000);
}

function reader_update_toolbar(inner) {
	parent.document.getElementById('toolbar').innerHTML = document.getElementById('toolbarinfo').innerHTML;
	
}

function reader_frame(feed,hash,archive) {
	document.getElementById('preview').src='/news/frame/'+feed+'/'+hash+'/'+archive;
}	