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 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(){
}


function pre_fill_order() {

  // rewrite hidden_bestellfeld_id  
  var c = 0; var e = 0; var a = [{}];   
  $('#forms table.warenkorb tr').each(function() {
    switch(++c) {
      case 1:     
        a[e].name = jQuery.trim($(this).find('td:first').text());
        break;
      case 2:
        a[e].num = $(this).find('td:first select').val();
        break;
      case 3:
        e++; a[e] = {}; c=0;                
        break;
    }
  });
  var output = "";
  for(var i in a) if (typeof(a[i].num) == 'string' && a[i].num > 0) output += a[i].num + '-' + a[i].name + '#';
  $('#'+hidden_bestellfeld_id).val(output);
  
  // info from cookie
  $('#forms label').each(function() {
    var k = IM_cleanlabel($(this).text());
    var v;
    if (v = $.cookie('of_'+k)) {
      $('#'+$(this).attr('for')).val(v);
    }
  });
}

function IM_cleanlabel(label) {
  label = jQuery.trim(label);
  if (label.lastIndexOf('*') > 0 && label.lastIndexOf('*') == label.length-1) label = jQuery.trim(label.substr(0, label.length-1));
  return label;
}

function fill_order() {

  // locally remember user information
  //console.log("fill_order");
  $('#forms label').each(function() {
    var k = IM_cleanlabel($(this).text());
    var v = $('#'+$(this).attr('for')).val();
    $.cookie('of_'+k, v, { path: '/'  });
  });
}


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 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";
			}
		}
	}
}

/* Check 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;
}

