var current_num_row=1;

function dropDownMenuInit(ul_id){
	var obj=document.getElementById(ul_id);
	var list=obj.getElementsByTagName('li');
	for (i=0;i<list.length;i++){
		list[i].onmouseover=function(){
			obj=this.getElementsByTagName('span');
			if (obj[0]) obj[0].style.display='block';
			obj2=this.getElementsByTagName('img');
			if (obj2[0] && obj2[1]) {
				obj2[0].style.display='none';
				obj2[1].style.display='block';
			}	
		}
		list[i].onmouseout=function(){
			obj=this.getElementsByTagName('span');
			if (obj[0]) obj[0].style.display='none';
			obj2=this.getElementsByTagName('img');
			if (obj2[0] && obj2[1]) {
				obj2[1].style.display='none';
				obj2[0].style.display='block';
				
			}
		}				
	}
}

function isset(varname){
  return(typeof(window[varname])!='undefined');
}

function showBlock(id){
	$(id).style.display='block';
}

function setActiveShowPrice(active){
	if (active=='netto'){
		$('a_min_price_netto').className="active";
		$('a_min_price_brutto').className="";
		$('block_min_price_netto').style.display='block';
		$('block_min_price_brutto').style.display='none';
		$('list_price_p_netto').style.display='block';
		$('list_price_p_brutto').style.display='none';
		$('summ_price_netto').style.display='inline';
		$('summ_price_brutto').style.display='none';
		
	}
	else{
		$('a_min_price_netto').className="";
		$('a_min_price_brutto').className="active";
		$('block_min_price_netto').style.display='none';
		$('block_min_price_brutto').style.display='block';
		$('list_price_p_netto').style.display='none';
		$('list_price_p_brutto').style.display='block';
		$('summ_price_netto').style.display='none';
		$('summ_price_brutto').style.display='inline';
	}
}

function checkProductRowNext(id, num){
	
	getPriceSelProducts(id);
	
	if ( $('product_sel_color_'+num).value!=0 && $('product_sel_size_'+num).value!=0 ){
		changePriceProduct(id, $('product_sel_color_'+num).value, $('product_sel_size_'+num).value);
	}
		
	if (num==current_num_row && $('product_sel_color_'+num).value!=0 && $('product_sel_size_'+num).value!=0 && $('product_count_'+num).value!=''){
		if (num==1) checkStyleFirtRow();
		current_num_row=current_num_row+1;		
		addProductRowNext(id, current_num_row);
	}
}

function checkStyleFirtRow(){
	$('product_sel_color_1_div_mm').style.border="0px solid #B8030A";
	$('product_sel_size_1_div_mm').style.border="0px solid #B8030A";
	$('product_count_1').style.border="1px solid #CCC";			
	$('id_product_message').innerHTML='';
}

function addProductRowNext(id, num){
	var url = 'index.php?type=color_size_row&id='+id+"&num="+num;			
	var myAjax = new Ajax.Request(url,{method: 'get',onComplete: showResponse});
			
	function showResponse(ret){
		var div=document.createElement("div");
		div.innerHTML=ret.responseText;				
		$('color_size_row').appendChild(div);				
	}
}

function changePriceProduct(id, color, size){
	var url = 'index.php?type=get_price_info_product_cs&id='+id+"&color="+color+"&size="+size;			
	var myAjax = new Ajax.Request(url,{method: 'get',onComplete: showResponse});
			
	function showResponse(ret){
		if (ret.responseText){
			var mas=ret.responseText.split("||");
			$('p_c_price_n').innerHTML=mas[0];
			$('p_c_price_b').innerHTML=mas[1];
			if ($('p_economy_n')) $('p_economy_n').innerHTML=mas[2];
			if ($('p_economy_b')) $('p_economy_b').innerHTML=mas[3];
			$('list_price_p_netto').innerHTML=mas[4];
			$('list_price_p_brutto').innerHTML=mas[5];
		}										
	}
}

function getPriceSelProducts(id){
	var url = 'index.php?type=get_price_info_products&id='+id;
	var pars = '';
	for(i=1;i<=current_num_row;i++){
		if ($('product_count_'+i))
		if ($('product_sel_color_'+i).value!=0 && $('product_sel_size_'+i).value!=0 && $('product_count_'+i).value!='')
			pars+="&color["+i+"]="+$('product_sel_color_'+i).value+"&size["+i+"]="+$('product_sel_size_'+i).value+"&count["+i+"]="+$('product_count_'+i).value;
	}
	if (pars!='')			
	var myAjax = new Ajax.Request(url,{method: 'post', parameters: pars, onComplete: showResponse2});
	
	function showResponse2(ret){		
		if (ret.responseText){
			var mas=ret.responseText.split("|");
			$('summ_price_netto').innerHTML=mas[0]+" &euro;";
			$('summ_price_brutto').innerHTML=mas[1]+" &euro;";
			if (mas[2]!=0) 
				$('price_economy_next').innerHTML='(ab '+mas[2]+' St&uuml;ck sparen Sie '+mas[3]+'%)';
			else
				$('price_economy_next').innerHTML='';	
		}			
	}
}

function DropDownChangeClass(li){
	if ($(li).className=='')
		$(li).className='active';
	else	
		$(li).className='';
}

function setDropDownActive(mass){
	var n=mass.length;
	for(i=0;i<n;i++){
		name=$('list_dd_li_'+mass[i]).getAttribute('name');
		if (location.hash=='#'+name) $('list_dd_li_'+mass[i]).className='active';
	}
}

function setAllDropDownActive(id){
	eval('var mass=mas_li_'+id);
	var n=mass.length;
	for(i=0;i<n;i++){
		$('list_dd_li_'+mass[i]).className='active';
	}	
	$('list_dd_show_hide_'+id).innerHTML='alle schließen';
}
function setAllDropDownNotActive(id){
	eval('var mass=mas_li_'+id);
	var n=mass.length;
	for(i=0;i<n;i++){
		$('list_dd_li_'+mass[i]).className='';
	}
	$('list_dd_show_hide_'+id).innerHTML='alle anzeigen';
}

function show_property_info_text(link){
	window.open(link,'window','width=830, height=600, scrollbars=yes,status=no,toolbar=no,menubar=no,resizable=yes,location=no');
}	

function left_block_menu_click(obj_a, id_text){
	if ($(id_text).style.display=='none'){
		obj_a.className='link_a';
		$(id_text).style.display='block';
	}
	else{
		obj_a.className='link';
		$(id_text).style.display='none';
	}
}

function show_info_pop(link){
	window.open(link,'window','width=830, height=600, scrollbars=yes,status=no,toolbar=no,menubar=no,resizable=yes');
}


/*function loadTeaserUnter(){        
    return 0;
    if ($('unter_teaser_content') && $('teaser_unten_inner')){
        var top_b=$('bottom').offsetTop;
        var top_e=$('unter_teaser_content').offsetTop;
        var h=$('unter_teaser_content').offsetHeight;    
    
            $('teaser_unten_inner').innerHTML=$('unter_teaser_content').innerHTML;        
            $('unter_teaser_content').innerHTML="";
            $('unter_teaser_content').style.height=h+"px";        
    }
}*/

var currentlyOpendZettelTeaser = "";

function show_zettel_teaser(divName){
	var e = document.getElementById(divName);
	if (e){
		if (currentlyOpendZettelTeaser != "" && currentlyOpendZettelTeaser != divName){
			var oe = document.getElementById(currentlyOpendZettelTeaser);
			if (oe){
				oe.style.display='none';
			}
		}
		if (e.style.display !='block'){
			e.style.display='block';
			var x = tempX;
			var y = tempY;
		
			e.style.top = (y+20)+'px';
			e.style.left = '410px';
			currentlyOpendZettelTeaser = divName;
		}
		else{
			e.style.display='none';
			currentlyOpendZettelTeaser = "";
		}
		
		
		
	}
}


// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false;

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE);

// Temporary variables to hold mouse x-y pos.s
var tempX = 0;
var tempY = 0;

// Set-up to use getMouseXY function onMouseMove
document.onmousemove = getMouseXY;

function getMouseXY(e) {
  	if (!e) var e = window.event;
		if (e.pageX || e.pageY) 	{
			tempX = e.pageX;
			tempY = e.pageY;
		}
		else if (e.clientX || e.clientY) 	{
			tempX = e.clientX + document.body.scrollLeft
				+ document.documentElement.scrollLeft;
			tempY = e.clientY + document.body.scrollTop
				+ document.documentElement.scrollTop;
		}
		// posx and posy contain the mouse position relative to the document
		// Do something with this information

  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}
  return true;
}