function favorite() {
	window.external.AddFavorite("http://www.avanando.de", "Avanando - Mediensuchmaschine");
}

var cookieInhalt = new Array();
var splitt='|';

/*MERKLISTE*/
function Get_Cookie(name) { 
   var start = document.cookie.indexOf(name+"="); 
   var len = start+name.length+1; 
   if ((!start) && (name != document.cookie.substring(0,name.length))) return null; 
   if (start == -1) return null; 
   var end = document.cookie.indexOf(";",len); 
   if (end == -1) end = document.cookie.length; 
   return unescape(document.cookie.substring(len,end)); 
} 

function Set_Cookie(name,value,days,path,domain,secure) { 
    var today = new Date(); 
    var cookie_expire_date = new Date(today.getTime() + (days * 86400000))
    
    var cookieString = name + "=" +escape(value) + 
       ( (cookie_expire_date) ? ";expires=" + cookie_expire_date.toGMTString() : "") + 
       ( (path) ? ";path=" + path : "") + 
       ( (domain) ? ";domain=" + domain : "") + 
       ( (secure) ? ";secure" : ""); 
    document.cookie = cookieString; 
} 

function Delete_Cookie(name,path,domain) { 
   if (Get_Cookie(name)) document.cookie = name + "=" + 
      ( (path) ? ";path=" + path : "") + 
      ( (domain) ? ";domain=" + domain : "") + 
      ";expires=Thu, 01-Jan-70 00:00:01 GMT"; 
} 

function savemerkliste(element){
	
	var str = '';
	
	//Aktivieren
	if(element.childNodes[0].name == 'off'){
		if(cookieInhalt.length<=20){
			cookieInhalt[cookieInhalt.length] = element.id;
			document.getElementById(element.id).innerHTML="<img src=\"/img/checked.gif\" width=\"14\" height=\"13\" name=\"on\" style=\"cursor: pointer;\"> Merkliste";
		}
		else {
			alert("Bitte maximal nur 20 Artikel in Merkliste abspeichern!");
		}
	}
	//Deaktivieren
	else {
		for(x in cookieInhalt) {
			if(cookieInhalt[x]==element.id) {
				cookieInhalt.splice(x, 1);
				break;
			}
		}
		document.getElementById(element.id).innerHTML="<img src=\"/img/site_pfeil.gif\" width=\"14\" height=\"12\" name=\"off\" style=\"cursor: pointer;\"> Merkliste";
		
	}

	if(cookieInhalt.length>0) {
		for(y in cookieInhalt) {
			str += cookieInhalt[y];
			if(y<cookieInhalt.length-1)
				str += splitt;	
		}
	
	}
	
	Set_Cookie("ML",str,30,"/");
/*	
	if(cookieInhalt.length>0){
		document.getElementById("position_merkliste").style.visibility = "visible";
	}
	else {
		document.getElementById("position_merkliste").style.visibility = "hidden";
	}
*/
}

function loadMerkliste() {
	var cookieWert=Get_Cookie("ML");
	if(cookieWert&& cookieWert != "empty"){
      		cookieInhalt = cookieWert.split(splitt);
   	}
}

loadMerkliste();

function merkliste(id){
	var inCookie = 0;
	
	for(x in cookieInhalt)
	{
		if(cookieInhalt[x]==id) {
			inCookie = 1;
			break;
		}
	}

	if(inCookie == 1){
		document.write("<span id=\""+id+"\" onClick=\"javascript:savemerkliste(this)\" style=\"cursor: pointer; font-size:11px;\"><img src=\"/img/checked.gif\" width=\"13\" height=\"13\" name=\"on\"> Merkliste</span>");
	}
	else{
		document.write("<span id=\""+id+"\" onClick=\"javascript:savemerkliste(this)\" style=\"cursor: pointer; font-size:11px;\"><img src=\"/img/site_pfeil.gif\" width=\"14\" height=\"12\" name=\"off\"> Merkliste</span>");	
	}

}

/*Checkbox komplett markieren*/
var checkbox=0;
function select_checkbox(id){
	
	if(checkbox == 0){
		for(x=0; x<document.forms[id].elements.length; x++){
			document.forms[id].elements[x].checked = true;
		}
		checkbox=1;
	}
	else {
		for(x=0; x<document.forms[id].elements.length; x++){
			document.forms[id].elements[x].checked = false;
		}		
		checkbox=0;
	}
}
/*Auswahl Multi Select-Box komplett aufheben*/
function clearSelected(obj) {
	for (i=0; i<obj.options.length; i++) {
		if (obj.options[i].selected) {
			obj.options[i].selected = false;
		}
	}
}

function ebayad(url, div) {
	http_request = false;
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
			http_request = new XMLHttpRequest();
			
	} else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
			http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}

	if (!http_request) {
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}
		
	http_request.onreadystatechange = function(){handleRequest(div, http_request)};	
	http_request.open('GET', url);
	http_request.setRequestHeader('Content-Type', 'text/html; charset=utf-8');
	//http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	//strSubmit='cid='+sel.options[sel.selectedIndex].value+'&cat1='+cat1+'&cat2='+cat2;
	http_request.send(null);
}

function handleRequest(div, http_request) {
	if (http_request.readyState == 4) {		
		if (http_request.status == 200) {
			//document.write(http_request.responseText);
			document.getElementById(div).innerHTML = http_request.responseText;
		} else {
			alert('There was a problem with the request.');
		}
	}

}