
var sid = null;
var mx = 0;
var my = 0;

var moving_object = null;

wmtt = null;
sourceTB = null;
//document.onmousemove = updateWMTT;
function updateWMTT(e) {  
    var sL;
    var sT;
    
    // -------------------------------------------------------------------------------------
    // Ermitteln der ScrollLeft und ScrollTop Postition, also der Information, wie weit der 
    // Inhalt des Fensters bereits gescrollt wurde... Gilt für den IE - weitere Infos unter
    // http://de.selfhtml.org/javascript/objekte/window.htm
    if(document.documentElement) {
      sL = document.documentElement.scrollLeft;
      sT = document.documentElement.scrollTop;
    } else if(document.body) {
      sL = document.body.scrollLeft;
      sT = document.body.scrollTop;
    }
    // -------------------------------------------------------------------------------------
    
    mx = (document.all) ? (event.clientX + sL) : e.pageX;
    my = (document.all) ? (event.clientY + sT)  : e.pageY;
    
    // -------------------------------------------------------------------------------------
    // Mittels des document.all Objekts wird festgestellt, ob es sich um den akt.
    // Browser um einen IE handelt, der die Scroll-Komponente mit eingerechnet bekommen
    // muss. Beim FF und Co. ist dies nicht notwendig, da die Top/Left Position unab-
    // hängig von der gescrollten Entfernung dargestellt wird.
    x = (document.all) ? (event.clientX + sL) : e.pageX;  
    y = (document.all) ? (event.clientY + sT)  : e.pageY;
    
    if (wmtt != null) {
      if(wmtt.style.display == 'block') {
          // wmtt.innerHTML = 'sL = ' + sL + ' - sT = ' + sT;
          wmtt.style.left = (x + 92) + "px";  
          wmtt.style.top  = (y - 200) + "px";  
      }
    }
    
    
    if(moving_object != null) {
      if(moving_object.style.display == 'block') {
          moving_object.style.left = (x + 10) + "px";  
          moving_object.style.top  = (y + 10) + "px";  
      }
    
    }
    // -------------------------------------------------------------------------------------
}  
function showWMTT(id) {
  var current_id = 'text' + id;
  sourceTB = document.getElementById(current_id);
  wmtt = document.getElementById('infotext');
  wmtt.innerHTML = sourceTB.innerHTML;
  wmtt.style.display = "block";
}  
function hideWMTT() {  
    wmtt.style.display = "none";  
}








var dropdown_id = 0;
var mouseover_id = 0;
var disable_hide = false;
function display_dropdown_navi(id) {
  var html_object = null;
  
  if(dropdown_id > 0) {
    hide_dropdown_navi(true);
  }
  
  if(id) {
    dropdown_id = id;
    disable_hide = true;
    
    object_id = 'dropdownnavi' + dropdown_id;
    dobject = null;
    
    if(document.getElementById) {
      dobject = document.getElementById(object_id);
    } else if(document.all) {
      dobject = document.all[object_id];
    }
    if(dobject) {
      dobject.style.display = 'block';
    } else {
      alert('Objekt irgendwie immer noch null');
    }
  }
}

function hide_dropdown_navi(force) {
  object_id = 'dropdownnavi' + dropdown_id;
  dobject = null;
  if(document.getElementById) {
    dobject = document.getElementById(object_id);
  } else if(document.all) {
    dobject = document.all[object_id];
  }
  if(dobject) {
    if(disable_hide != true || force == true) {
      dobject.style.display = 'none';
      dropdown_id = 0;
      disable_hide = false;
    }
  }
}

function set_hide(mode) {
  disable_hide = mode;
}



function set_mouseover(id) {
  if(id) {
    mouseover_id = id;
  }
}









function display_navibubble(id) {
  if(id) {
    var bubble_id = 'bubble-' + id;
    moving_object = document.getElementById('navibubble');
    var contentbubble = document.getElementById(bubble_id);

    
    if(contentbubble.innerHTML != '') {
      moving_object.style.left = mx + 'px';
      moving_object.innerHTML = contentbubble.innerHTML;
      moving_object.style.display = 'block';
    }
  }
}



function hide_navibubble(id) {
  if(id) {
    var bubble_id = 'bubble-' + id;
    moving_object = document.getElementById('navibubble');
    moving_object.style.display = 'none';
    moving_object.innerHTML = '';
    
    moving_object = null;
    
  }
}


function mod(div,base) {
  return Math.round(div - (Math.floor(div/base)*base));
}
  
function calcBmi() {
  var w = document.bmi.size1.value * 1;
  var h = document.bmi.size2.value * 1;
  displaysize = h;
  var rvalue = true;
  if ( (w < 63) || (w > 132)) {
  alert ("Fehler bei der Dateneingabe. Bitte wiederholen Sie die Eingabe!");
  document.forms[0].elements[0].select();
  document.forms[0].elements[0].focus();
  rvalue = false;
  }
  if ( ((h < 73) || (h > 152)) && (rvalue==true)) {
  alert ("Fehler bei der Dateneingabe. Bitte wiederholen Sie die Eingabe!");
  document.forms[0].elements[1].select();
  document.forms[0].elements[1].focus();
  rvalue = false;
  }
  if (((h-8) < w) && (rvalue==true)) {
  alert ("Fehler bei der Dateneingabe. Überbrustweite muss mindestens 8cm größer sein als Unterbrustweite. Bitte wiederholen Sie die Eingabe!");
  document.forms[0].elements[0].select();
  document.forms[0].elements[0].focus();
  rvalue = false;
  }
  if (((h-30) > w) && (rvalue==true)) {
  alert ("Fehler bei der Dateneingabe. Überbrustweite zu groß. Bitte wiederholen Sie die Eingabe!");
  document.forms[0].elements[0].select();
  document.forms[0].elements[0].focus();
  rvalue = false;
  }
  if (rvalue) {
  size_ger = (50 + Math.round((w-50)/5) * 5);
  size1 = Math.round(((h-8+1) - w) / 2);
  
  
  if (size1==1)      size2_ger = "AAA" 
  else if (size1==2) size2_ger = "AA"
  else if (size1==3) size2_ger = "A";
  else if (size1==4) size2_ger = "B";
  else if (size1==5) size2_ger = "C";
  else if (size1==6) size2_ger = "D";
  else if (size1==7) size2_ger = "E";
  else if (size1==8) size2_ger = "F";
  else if (size1==9) size2_ger = "G";
  else if (size1==10) size2_ger = "H";
  else if (size1==11) size2_ger = "I";
  else if (size1==12) size2_ger = "J";
  else if (size1==13) size2_ger = "K";
    // document.bmi.size2_ger.value = size_ger + " " + size2_ger;
    document.bmi.size_ger.value = size_ger + " " + size2_ger;
    document.getElementById("bmierg").style.display = "block";
  }
  return rvalue;
}

var products_prices_net = new Array();
var products_prices_gross = new Array();
var products_actionprices_net = new Array();
var products_actionprices_gross = new Array();

function change_product_price(has_actionprice, document_id) {
	var price_div = null;
	
	var html_id = null; //(parseInt(has_actionprice) == 0) ? 'innerprice' : 'inneractionprice';
	
	var name_key = 'product_id[' + document_id + ']';
	var product_id = document.forms['shopform'].elements[name_key].value;
	var current_price = 0; //= (parseInt(has_actionprice) == 0) ? products_prices_gross[product_id] : products_actionprices_gross[product_id];
	var current_actionprice = 0;
	
	if(products_actionprices_gross[product_id]) {
		has_actionprice = 1;
		html_id = 'inneractionprice';
		current_price = products_prices_gross[product_id];
		current_actionprice = products_actionprices_gross[product_id];
	} else if(products_prices_gross[product_id]) {
		has_actionprice = 0;
		current_price = products_prices_gross[product_id];
		current_actionprice = 'n.a.';
		html_id = 'innerprice';
	} else {
		alert('Für dieses Produkt ist kein Preis definiert.');
		exit;
	}
	
	
	
	
	
	
	
	
	if(document.all) {
		if(document.all['innerprice']) document.all['innerprice'].innerHTML = current_price;
		if(document.all['inneractionprice']) document.all['inneractionprice'].innerHTML = current_actionprice;
		if(has_actionprice == 1) {
			document.all['actionprice'].className = 'actionprice1';
			document.all['price'].className = 'price1';
		} else {
			document.all['actionprice'].className = 'actionprice0';
			document.all['price'].className = 'price0';
		}
	} else if(document.getElementById) {
		if(document.getElementById('innerprice')) document.getElementById('innerprice').innerHTML = current_price;
		if(document.getElementById('inneractionprice')) document.getElementById('inneractionprice').innerHTML = current_actionprice;
		if(has_actionprice == 1) {
			document.getElementById('actionprice').className = 'actionprice1';
			document.getElementById('price').className = 'price1';
		} else {
			document.getElementById('actionprice').className = 'actionprice0';
			document.getElementById('price').className = 'price0';
		}
	} else {
		alert('Bitte beachten Sie, dass sich der Preis von Größe zu Größe ändern kann, dies aber ggf. aufgrund fehlender Browserkmpatibilität nicht in der Website dargestellt werden kann!');
	}
}


var current_brand = 0;
var interval = null;
var previous_brand = null;
function start_switch_brands() {
	var dobject = null;
	if(document.getElementById) {
	  if(document.getElementById('infobox-brands0')) {
	  	previous_brand = document.getElementById('infobox-brands0');
	  	interval = window.setInterval('switch_brands()', 3000);
	  } else {
	  	return false;
	  }
	} else if(document.all) {
	  if(document.all['infobox-brands0']) {
	  	previous_brand = document.all['infobox-brands0'];
	  	interval = window.setInterval('switch_brands()', 3000);
	  } else {
	  	return false;
	  }
	} else {
		return false;
	}
}


function switch_brands() {
  var brand_id = null;
  if(previous_brand != null) {
  	previous_brand.style.display = 'none';
  }
  current_brand++;
  if(current_brand == num_brands - 1) current_brand = 0;
  brand_id = 'infobox-brands' + current_brand;
  // document.getElementById('testausgabe').innerHTML = num_brands + ' - ' + brand_id;
  if(document.getElementById) {
	  if(document.getElementById(brand_id)) {
	  	previous_brand = document.getElementById(brand_id);
	  } else {
	  	return false;
	  }
	} else if(document.all) {
	  if(document.all[brand_id]) {
	  	previous_brand = document.all[brand_id];
	  } else {
	  	return false;
	  }
	} else {
		return false;
	}
  	if(previous_brand != null) {
		previous_brand.style.display = 'block';
	}
}

var zoomimagediv = null;
function display_image(img_src, width, height) {
	width = parseInt(width);
	height = parseInt(height);

	if(document.getElementById) {	
		if(document.getElementById('zoomimage-div')) {
			zoomimagediv = document.getElementById('zoomimage-div');
		} else {
			return false;
		}
	} else if(document.all) {
		if(document.all['zoomimage-div']) {
			zoomimagediv = document.all['zoomimage-div'];
		} else {
			return false;
		}
	} else {
		return false;
	}
	
	if(zoomimagediv != null) {
		zoomimagediv.style.display = 'block';
		zoomimagediv.style.width = width + 'px';
		zoomimagediv.style.height = (height + 20) + 'px';
		zoomimagediv.style.marginLeft = (-1 * parseInt(width/2)) + 'px';
		zoomimagediv.style.marginTop = (-1 * parseInt((height + 20)/2)) + 'px';
		document.images['zoomimage'].src = img_src;
	}

}


function hide_image() {
	if(zoomimagediv != null) {
		zoomimagediv.style.display = 'none';
	}
}

function set_delivery_radiobutton(radio_id) {
	
	
	// if(sid == 'dee2c2e7ee083b5f36d3e655359dd8a1') {
		
		/* var object_id = 'delivery_address_id' + radio_id;
		if(document.getElementById) {
			document.getElementById(object_id).checked = true;		
		} else if(document.all) {
			document.all[object_id].checked = true;
		} */
		
		for(i=0; i<document.forms['shopform'].elements.length; i++) {
			
			if(document.forms['shopform'].elements[i].name == 'delivery_address_id') {
				if(parseInt(document.forms['shopform'].elements[i].value) == parseInt(radio_id)) {
					document.forms['shopform'].elements[i].checked = true;
					break;
				}
			}
		}
	// }
}