function activate(el_id) { 
	var el = document.getElementById(el_id);
	el.className = 'active';
	Effect.Appear(el.id, {duration: 0.5});
	return(false);
}

function highlightList(el, img) {
	
	//var bigImg = document.getElementById('bigImage');
	//bigImg.style.backgroundImage = 'url('+img+')';
	
	
	if(el.className == 'inactive') {
		for(i=1; i<=3; i++) {
			if('list_'+i !== el.id) {
				tmp = document.getElementById('list_'+i);
				if(tmp.className == 'active') {
					tmp.className = 'inactive';
				}
				//var bigImg = document.getElementById('bigImage_'+i);
				//bigImg.style.display = 'none';
				Effect.Fade('bigImage_'+i, {duration: 0.15});
			}
			else {
				Effect.Appear('bigImage_'+i, {duration: 0.5});
				Effect.Fade('list_'+i, {duration: 0.15, from: 1, to: 0.1});
				setTimeout("activate('list_"+i+"')", 150);
			}
		}
		
		return(false);
	}
}

function playList() {
	for(i = 1; i<= 3; i++) {
		el = document.getElementById('list_'+i);
		if(el.className == 'active') { 
			if(i == 1) {
				list = document.getElementById('list_2');
			}
			if(i == 2) {
				list = document.getElementById('list_3');
			}
			if(i == 3) {
				list = document.getElementById('list_1');
			}
			
			highlightList(list);
		}
	}
	
}

function playNews() {
	
	for(var i = 1; i <= 100; i++) {
		var j = i+1;

		if((first = document.getElementById('news_'+i)) && (second = document.getElementById('news_'+j))) {
			
			if((first.style.display !== 'none') && (second.style.display !== 'none')) {				
				Effect.Fade('news_'+i, {duration: 0.5});
				Effect.Fade('news_'+j, {duration: 0.5});
				
				Effect.Fade('info_'+i, {duration: 0.5});
				Effect.Fade('info_'+j, {duration: 0.5});
		
				var k = i+2;
				var l = i+3;
			}
			else
				continue;
			
			if((third = document.getElementById('news_'+k)) && (fourth = document.getElementById('news_'+l))) {
				setTimeout("Effect.Appear('news_"+k+"', {duration: 0.5})", 500);
				setTimeout("Effect.Appear('news_"+l+"', {duration: 0.5})", 500);
				setTimeout("Effect.BlindDown('info_"+k+"', {duration: 0.5})", 500);
				setTimeout("Effect.BlindDown('info_"+l+"', {duration: 0.5})", 500);
			}
			else {
				setTimeout("Effect.Appear('news_1', {duration: 0.5})", 500);
				setTimeout("Effect.Appear('news_2', {duration: 0.5})", 500);
				setTimeout("Effect.BlindDown('info_1', {duration: 0.5})", 500);
				setTimeout("Effect.BlindDown('info_2', {duration: 0.5})", 500);
			}
			
			break;
		}
	}
	
}


window.onload = function() {
	if(window.opener && !window.opener.closed && window.opener.document) {
		if(window.opener.document.URL.indexOf('http://autocommunity.de') >= 0) {
			window.opener.location.reload();
			window.close();
		}
	}

	if(document.getElementById('flashMessage'))
		document.getElementById('flash').style.display = 'block';
		
	Effect.Pulsate('flash', {pulses: 5, duration: 15, from: 0.5 });
	
	listInterval = setInterval("playList()", 10000);
	newsInterval = setInterval("playNews()", 17500);
	
}

function popUp(url, width, height) {
	var x 	= screen.width; 
	var y 	= screen.height; 
	var xps = ((x/2)-(width)); 
	var yps = ((y/2)-(height/2));
	
	var popUp = window.open(url, 'fbConnectPopUp', 'width='+width+',height='+height+',top='+yps+',left='+xps+',scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no,dependent=no');
	popUp.focus();
	return(fbConnectPopUp);
}
	

function nurZahlen(el_id) {
	var el = document.getElementById(el_id);
	var val = el.value.replace(/[^\.^,\d]/g, '');
	el.value = val; 
} 

function ps2kw(ps_id, kw_id) {
	var ps_el = document.getElementById(ps_id);
	var kw_el = document.getElementById(kw_id);

	kw_el.value = Math.round(ps_el.value*0.735499);
}

function kw2ps(kw_id, ps_id) {
	var kw_el = document.getElementById(kw_id);
	var ps_el = document.getElementById(ps_id);

	ps_el.value = Math.round(kw_el.value*1.359622);
}

function print_r(theObj){
  if(theObj.constructor == Array ||
     theObj.constructor == Object){
    document.write("<ul>")
    for(var p in theObj){
      if(theObj[p].constructor == Array||
         theObj[p].constructor == Object){
			document.write("<li>["+p+"] => "+typeof(theObj)+"</li>");
        document.write("<ul>")
        print_r(theObj[p]);
        document.write("</ul>")
      } else {
			document.write("<li>["+p+"] => "+theObj[p]+"</li>");
      }
    }
    document.write("</ul>")
  }
}