// JavaScript Document

function openCloseItem(id) {
	
	if($('item_' + id) != null) {
		var previousSibling = $('item_' + id).getPrevious();
		//alert(previousSibling);
		if(previousSibling.hasClass('liste1')) {
			previousSibling.removeClass('liste1');
			previousSibling.addClass('liste1Aktiv');
		} else if(previousSibling.hasClass('liste1Aktiv')) {
			previousSibling.removeClass('liste1Aktiv');
			previousSibling.addClass('liste1');
		}
		
		if($('item_' + id).hasClass('close')) {
			$('item_' + id).removeClass('close');
		} else {
			$('item_' + id).addClass('close');
		}
	}
}

function showHideProductInfo(id, evt) {
	var productInfoAktiv = productInfoAktivStart;

	if(evt == 'over') {
		$('product' + productInfoAktiv).removeClass('active');
		$('info' + productInfoAktiv).removeClass('visible');
		$('product' + productInfoAktivLast).removeClass('active');
		$('info' + productInfoAktivLast).removeClass('visible');
		
		productInfoAktiv = id;

		$('product' + id).addClass('active');
		$('info' + id).addClass('visible');
	}
	
	if(evt == 'out') {
		productInfoAktiv = id;
		productInfoAktivLast = id
		$('product' + id).removeClass('active');
		$('info' + id).removeClass('visible');
		
		$('product' + productInfoAktiv).addClass('active');
		$('info' + productInfoAktiv).addClass('visible');
	}

}

function showHideProductCategory(id) {
	if($('innerCatWrapper_' + id) != null) {
		if($('innerCatWrapper_' + id).hasClass('open')) {
			$('innerCatWrapper_' + id).removeClass('open');
			if($('h3_' + id) != null) {
				$('h3_' + id).removeClass('open');
			}
			if($('h4_' + id) != null) {
				$('h4_' + id).removeClass('open');
			}
		} else {
			$('innerCatWrapper_' + id).addClass('open');
			if($('h3_' + id) != null) {
				$('h3_' + id).addClass('open');
			}
			if($('h4_' + id) != null) {
				$('h4_' + id).addClass('open');
			}
		}
	}
}

var pagecall = function(strGet, strData)
{
   var tp = "";
   var tmp = new Request.JSON({method: 'post', encoding: 'utf-8', data: strData, url: strGet ,async: false, onComplete: function(response){
      tp = response;
   }}).get();
   return tp;
}



function prev_news()
{
	var tmp = pagecall("/ajax/calls/getnews.php","type=prev&news_id=" + news_init );
	$('newscontent').innerHTML = tmp.html;
	news_init = tmp.data.id;
}

function next_news()
{
	var tmp = pagecall("/ajax/calls/getnews.php","type=next&news_id=" + news_init );
	$('newscontent').innerHTML = tmp.html;
	
	if ( tmp.data.id == null )
	{
		$('news_nextid').innerHTML = '&nbsp;';
	}
	else
	{
		news_init = tmp.data.id;
		$('news_nextid').innerHTML = '<a onclick="next_news();" href="#">next</a>';		
	}

}

   //var tmp = pagecall("chkr","pageid=" + $('pageid').value );
   
   
/* Anfahrtsrechner */

function checkRouting(){
	f = document.getElementById("formRouting");
	saddr = f.routeStrasse.value + ",+" + f.routeOrt.value + ",+" + f.routeLand.value;
	f.saddr.value = saddr;
	return false;
}   
