// save as utf8
//
wmtt = null;

document.onmousemove = updateWMTT;

function updateWMTT(e) {
  if (wmtt != null) {
    x = (document.all) ? window.event.x + wmtt.offsetParent.scrollLeft : e.pageX;
    y = (document.all) ? window.event.y + wmtt.offsetParent.scrollTop  : e.pageY;
    wmtt.style.left = (x + 20) + "px";
    wmtt.style.top   = (y + 20) + "px";
  }
}

function showWMTT(id) {
  wmtt = document.getElementById(id);
  wmtt.style.display = "block"
}

function hideWMTT() {
  wmtt.style.display = "none";
}

// Lupe End


function baerenpost_intro2doccheck() {
  document.getElementById('bpintro_anim').style.visibility = 'hidden';
  document.getElementById('bpintro_skip').style.visibility = 'hidden';

  document.getElementById('bpintro_ring').style.display = 'block';
  document.getElementById('bpintro_ring').style.visibility = 'visible';

  document.getElementById('bpintro_pat_info').style.display = 'block';
  document.getElementById('bpintro_pat_info').style.visibility = 'visible';
}

function baerenpost_h1 () {
  var sup_copy=document.getElementById('h1text').innerHTML.replace(/®/,'<sup>®</sup>');
  document.getElementById('h1text').innerHTML = sup_copy;
}

function h3popupwindow() {
    window.open('/onlinebefragung_bp/frage.php?baerchen=3','Onlinebefragung','height=700,width=600,left=100,top=10,status=no,resizable=no,scrollbars=yes');
}

function CountLetters(txt,max)
{
  el=document.getElementById('LetterCount');
  if (txt.value.length>max) txt.value=txt.value.substr(0,max);
  el.innerHTML=String(max-txt.value.length);
}



function DisplayFlashObject(v_movie, v_width, v_height, v_object, v_quality, v_play)
{
    var oeTags = '<object codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0"'
  + 'width="'+v_width+'" height="'+v_height+'" id="'+v_object+'">'
  + '<param name="movie" value='+v_movie+' />'
  + '<param name="quality" value="'+v_quality+'" />'
  + '<param name="play" value="'+v_play+'" />'
  + '<param name="loop" value="'+v_loop+'" />'
  + '<param name="wmode" value="transparent" />'
  + '<embed src="'+v_movie+'"'
    + 'type="application/x-shockwave-flash"'
    + 'quality="'+v_quality+'" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"'
    + 'width="'+v_width+'" height="'+v_height+'" play="'+v_play+'"'
    + 'loop="'+v_loop+'" wmode="transparent" name="'+v_loop+'">'
        + '</embed>'
  + '</object>';

  document.write(oeTags);
}

function SelectOrderCheckbox(){

  search=decodeURI(window.location.search.substr(1));
  //Cookie setzen
  for (i=0;i<document.forms.length;i++){
    for (j=0;j<document.forms[i].elements.length;j++){
      e=document.forms[i].elements[j];
      if (e.type=='checkbox' && e.value==search) {
        document.cookie=e.value;
        e.checked=true;
      }
    }
  }
  //window.alert(search);
  //Checkbox markieren
  for (i=0;i<document.forms.length;i++){
    for (j=0;j<document.forms[i].elements.length;j++){
      e=document.forms[i].elements[j];
      if (e.type=='checkbox' && e.value==document.cookie) {
        e.checked=true;
      }
    }
  }

}


function pre_fill_order() {

  if (document.getElementById(hidden_bestellfeld_id).value != "") {

    var c_value = document.getElementById(hidden_bestellfeld_id).value;
    var broschueren = c_value.split(", ");

    for (var a = 0; a < broschueren.length; a++) {
      if (broschueren[a] != "") {

        for (i=0;i<document.forms.length;i++){
        for (j=0;j<document.forms[i].elements.length;j++){
          e=document.forms[i].elements[j];

          if (e.type=='checkbox' && e.value == broschueren[a]) {
          e.checked=true;
          }
        }
        }

      }
    }

  }


//  if (document.orderform.ContentObjectAttribute_ezstring_data_text_531.value != "") {
//    var c_value = document.orderform.ContentObjectAttribute_ezstring_data_text_531.value;
//
//    var broschueren = c_value.split(", ");
//
//    for (var a = 0; a < broschueren.length; a++) {
//      if (broschueren[a] != "") {
//        for (var i=0; i < document.orderform.Broschuere_Bestellung.length; i++) {
////          if (document.orderform.Broschuere_Bestellung[i].value == broschueren[a]) {
//            document.orderform.Broschuere_Bestellung[i].checked = true;
//          }
//        }
//      }
//    }
//  }
}

function fill_order() {

  var c_value = "";

  for (i=0;i<document.forms.length;i++){
  for (j=0;j<document.forms[i].elements.length;j++){
    e=document.forms[i].elements[j];
    if (e.type=='checkbox' && e.checked) {
    c_value = c_value + e.value + ", ";
    e.checked=true;
    }
  }
  }


//  for (var i=0; i < document.orderform.ContentObjectAttribute_bcorder_data_text_5624.length; i++) {
//    if (document.orderform.Broschuere_Bestellung[i].checked) {
//      c_value = c_value + document.orderform.Broschuere_Bestellung[i].value + ", ";
//    }
//  }
  document.getElementById(hidden_bestellfeld_id).value = c_value;

//  alert(document.getElementById(hidden_bestellfeld_id).value);

  //document.orderform.submit();
}


function check_garantieregistrierung(f) {
  for (i=0;i<f.elements.length;i++){
    e=f.elements[i];
    if (e.type=='select-one' && e.value==0 && e.options[0].text=='Bitte wählen'){
    window.alert("Bitte wählen Sie ein Gerät aus.");
    return false;
    }
  }
  return true;
}




function open_popup_window(url) {
  if(window.bcpopupwindow&&(!bcpopupwindow.closed)) bcpopupwindow.focus();
  else {
    bcpopupwindow=window.open(url,'bcpopupwindow','width=500,height=600,left=50,top=50,resizable=no,scrollbars=no,location=no,menubar=no,status=no,toolbar=no');
  }
}

// popup productoverview_doctors
function open_popup_window_scrolling(url) {
  if(window.bcpopupwindow&&(!bcpopupwindow.closed)) bcpopupwindow.focus();
  else {
    bcpopupwindow=window.open(url,'bcpopupwindow','width=500,height=600,left=50,top=50,resizable=no,scrollbars=yes,location=no,menubar=no,status=no,toolbar=no');
  }
}


// BP2 Homepage Teaser
function changeColor(id, color) {
	element = document.getElementById(id);
	element.style.background = color;
}

function getAndgo(el,level) {
	/*
	var Knoten = el.firstChild;
	while (Knoten != null) {
	  if (Knoten.nodeName == "A") {
  }
	  Knoten = Knoten.nextSibling;
	}*/
	var myas = el.getElementsByTagName('a');
	for (i=0;i<myas.length;i++) {
		document.location.href = myas[i].href;
	}
}
function leftmenuStyleOver(el,vstat,level,activestate) {
	el.style.cursor = "url(3DArrow.cur), pointer" ;
	if (activestate =='') {
		var myas = el.getElementsByTagName('a');
		for (i=0;i<myas.length;i++) {
			if (level == 0) {
				if (vstat == 'over') myas[i].style.color = "#ffffff";
				if (vstat == 'out') myas[i].style.color = "#2BA6CC";
			}

		}
		var myspans = el.getElementsByTagName('span');
		for (i=0;i<myspans.length;i++) {
			if (level == 0) {
				if (vstat == 'over') myspans[i].style.color = "#ffffff";
				if (vstat == 'out') myspans[i].style.color = "#6B7579";
			}
		}
	}
}

/* Überprüfung des Newsletters */
/* Garantiereg, BP2 Vorbestellen */
function checkNewsletter(form_ids){

	var action;

	chkNL_elem = document.getElementById(form_ids['newsletter']);

	if(typeof(chkNL_elem) !== 'undefined' && chkNL_elem != null) {
		if ( (chkNL_elem.checked) && (document.getElementById(form_ids['email']).value.length < 3 ) ){
			alert(unescape("Um den E-Mail-Newsletter zu beziehen, geben Sie bitte eine E-Mail Adresse an!"));
			action = false;
		} else{
			action = true;
		}
	} else action = true;

	return action;
}