function extend(e) {

if(this.checkExtend(e)){
var tabelle = document.getElementById("eingabetable");
var tbody   = tabelle.getElementsByTagName("tbody")[0]; 


var tr = document.createElement("TR"); 

var td1 = document.createElement("TD"); 
tr.appendChild(td1);

var a = new Element('INPUT', { type: 'text', size: '17', name: 'zusatz[]', id: 'zusatz' + counttext});
var b = new Element('INPUT', { type: 'text', name: 'zusatzzahl[]', id: 'zusatzzahl' + counttext});
b.className = 'zusatzzahl';
a.className = 'zusatzname';





var select_drop = new Element('SELECT', { name: 'zusatzmenge[]', id: 'zusatzmenge' + counttext});
var option_drop1 = new Element('OPTION', { value: 'Flasche(n)'});
option_drop1.innerHTML = s1;
var option_drop2 = new Element('OPTION', { value: 'Kilo'});
option_drop2.innerHTML = s2;
var option_drop3 = new Element('OPTION', { value: 'Gramm'});
option_drop3.innerHTML = s3;
var option_drop4 = new Element('OPTION', { value: 'Kiste(n)'});
option_drop4.innerHTML = s4;
var option_drop5 = new Element('OPTION', { value: 'Packung(en)'});
option_drop5.innerHTML = s5;
var option_drop6 = new Element('OPTION', { value: 'Stück'});
option_drop6.innerHTML = s6;
var option_drop7 = new Element('OPTION', { value: 'NIX'});
option_drop7.innerHTML = s7;


select_drop.appendChild(option_drop1);
select_drop.appendChild(option_drop2);
select_drop.appendChild(option_drop3);
select_drop.appendChild(option_drop4);
select_drop.appendChild(option_drop5);
select_drop.appendChild(option_drop6);
select_drop.appendChild(option_drop7);






name = "zusatz" + (counttext -1);

a.onfocus = document.getElementById(name).onfocus;

name2 = "zusatzzahl" + (counttext -1);

b.onfocus = document.getElementById(name2).onfocus;



td1.appendChild(b);





var td2 = document.createElement("TD"); 
tr.appendChild(td2);
td2.appendChild(a);

var td3 = document.createElement("TD"); 
tr.appendChild(td3);
td3.appendChild(select_drop);


tbody.appendChild(tr);

counttext = counttext +1;
}

}



function extend_reverse(e) {

if(this.checkExtend(e)){
var tabelle = document.getElementById("eingabetable");
var tbody   = tabelle.getElementsByTagName("tbody")[0]; 


var tr = document.createElement("TR"); 

var td1 = document.createElement("TD"); 
tr.appendChild(td1);

var a = new Element('INPUT', { type: 'text', size: '17', name: 'zusatz[]', id: 'zusatz' + counttext});
var b = new Element('INPUT', { type: 'text', size: '2', name: 'zusatzzahl[]', id: 'zusatzzahl' + counttext});

var select_drop = new Element('SELECT', { name: 'zusatzmenge[]', id: 'zusatzmenge' + counttext});
var option_drop1 = new Element('OPTION', { value: 'Flasche(n)'});
option_drop1.innerHTML = "Flasche(n)";
var option_drop2 = new Element('OPTION', { value: 'Kilo'});
option_drop2.innerHTML = "Kilo";
var option_drop3 = new Element('OPTION', { value: 'Gramm'});
option_drop3.innerHTML = "Gramm";
var option_drop4 = new Element('OPTION', { value: 'Kiste(n)'});
option_drop4.innerHTML = "Kiste(n)";
var option_drop5 = new Element('OPTION', { value: 'Packung(en)'});
option_drop5.innerHTML = "Packung(en)";
var option_drop6 = new Element('OPTION', { value: 'Stück'});
option_drop6.innerHTML = "Stück";
var option_drop7 = new Element('OPTION', { value: 'NIX'});
option_drop7.innerHTML = " ";


select_drop.appendChild(option_drop1);
select_drop.appendChild(option_drop2);
select_drop.appendChild(option_drop3);
select_drop.appendChild(option_drop4);
select_drop.appendChild(option_drop5);
select_drop.appendChild(option_drop6);
select_drop.appendChild(option_drop7);





name2 = "zusatzzahl" + (counttext -1);

b.onfocus = document.getElementById(name2).onfocus;

name = "zusatz" + (counttext -1);

a.onfocus = document.getElementById(name).onfocus;


td1.appendChild(a);


var td3 = document.createElement("TD"); 
tr.appendChild(td3);

td3.appendChild(select_drop);




var td2 = document.createElement("TD"); 
tr.appendChild(td2);

td2.appendChild(b);
tbody.appendChild(tr);

counttext = counttext +1;
}

}








function checkExtend(e){

if(e == document.getElementById("zusatz" + (counttext -1)) || e == document.getElementById("zusatzzahl" + (counttext -1))){
return true;
}else{
return false;
}
}

function namefocus(e) {
if(e.value == 'Name') {
e.value = '';
e.style.color="black";
}

}
function nameblur(e) {
if (e.value == '') {
e.value = 'Name';

e.style.color="grey";
}

}




function notizfocus(e) {
if(e.value == 'Notiz?') {
e.value = '';
e.style.color="black";
}

}
function notizblur(e) {
if (e.value == '') {
e.value = 'Notiz?';

e.style.color="grey";
}

}

function emailfocus(e) {
if(e.value == 'Email') {
e.value = '';
e.style.color="black";
}

}
function emailblur(e) {
if (e.value == '') {
e.value = 'Email';

e.style.color="grey";
}

}


function set_namen(a1,a2,a3,a4,a5,a6,a7) {
s1 = a1;
s2 = a2;
s3 = a3;
s4 = a4;
s5 = a5;
s6 = a6;
s7 = a7;
}


function zusatzfocus(e) {
	if(e.readOnly == false){
this.extend(e);
	}
}
function zusatzfocus_reverse(e) {
this.extend_reverse(e);
}

function add(e) {
if(parseInt(e.parentNode.parentNode.parentNode.childNodes[0].childNodes[0].data) >= parseInt(e.parentNode.parentNode.childNodes[0].value)  + 1){
e.parentNode.parentNode.childNodes[0].value = parseInt(e.parentNode.parentNode.childNodes[0].value)  + 1;

}else{
if(high){
alert("Das ist mehr als Du mitbringen sollst!");
high = false;
}
e.parentNode.parentNode.childNodes[0].value = parseInt(e.parentNode.parentNode.childNodes[0].value)  + 1;
}
}

function subtract(e) {
if(0 <= parseInt(e.parentNode.parentNode.childNodes[0].value)  - 1){
e.parentNode.parentNode.childNodes[0].value = parseInt(e.parentNode.parentNode.childNodes[0].value)  - 1;
}else{
alert("ZUWENIG!!");
}
}

function highlightit(e) {
//e.style.backgroundColor = '#99CCFF'; 

}
function downlight(e) {
//e.style.backgroundColor = '#D9F2F2'; 

}







// zeigt die PopUp-Box
function popTip(a){



over="0";
if (navigator.family == "gecko") {padd="0"; borde="1 bordercolor=black";}
else {padd="1"; borde="0";}
desc = "<table cellspacing=0 cellpadding="+padd+" border="+borde+"  bgcolor=000000><tr><td>\n"
        +"<table cellspacing=0 cellpadding=10 border=0 width=100%><tr><td bgcolor=#DDFFFF><center><font size=-1>\n"
        +a
        +"\n</td></tr></table>\n"
        +"</td></tr></table>";

               document.getElementById("tip").innerHTML=desc;
        document.getElementById("tip").style.left=x+15;
        document.getElementById("tip").style.top=y-5;
      
  
}


//  versteckt die PopUp-Box
function hideTip(){
if (over == "0") {
document.getElementById("tip").style.top="-500";
        }
}




function handlerTip(e){
    


x = (Nav) ? e.pageX : event.clientX + document.body.scrollLeft;
y = (Nav) ? e.pageY : event.clientY + document.body.scrollTop;
     

}


function thumb(a){



overdiv="0";

desc = '<table width="100%" height="100%" align="center" valign="center">'
+"<tr>"
+"<td>"
+"image"
+"</td>"
+"</tr>"
+"</table>";
       

               document.getElementById("object1").innerHTML= desc;
        document.getElementById("object1").style.left="100px";
        document.getElementById("object1").style.top="150px";

    //  Effect.Grow('object1');
//document.getElementById("object1").style.visibility="show";
//alert(document.getElementById("object1").innerHTML);
  
}


//  versteckt die PopUp-Box
function hideThumb(){
if (overdiv == "0") {
document.getElementById("object1").style.top="-500";
document.getElementById("object1").innerHTML="";
        }
}

function radio_ausgrauen() {

if(!locked){
var auswahl = document.getElementsByName("auswahlzahl[]");
var plus = document.getElementsByName("plus");
var minus = document.getElementsByName("minus");

for (var i = 0; i < auswahl.length; i++){
auswahl[i].readOnly=true;
auswahl[i].style.color = "grey";
auswahl[i].parentNode.parentNode.style.backgroundColor ="#C0C0C0";
plus[i].disabled =true;
minus[i].disabled =true;
}

var zusatzzahl = document.getElementsByName("zusatzzahl[]");

var zusatzmenge = document.getElementsByName("zusatzmenge[]");

var zusatz = document.getElementsByName("zusatz[]");


for (var i = 0; i < zusatz.length; i++){
zusatzzahl[i].readOnly=true;
zusatzzahl[i].style.color = "grey";
zusatzzahl[i].parentNode.parentNode.style.backgroundColor ="#C0C0C0";
zusatzzahl[i].readOnly =true;

zusatzmenge[i].readOnly=true;
zusatzmenge[i].style.color = "grey";
zusatzmenge[i].parentNode.parentNode.style.backgroundColor ="#C0C0C0";
zusatzmenge[i].readOnly =true;

zusatz[i].readOnly=true;
zusatz[i].style.color = "grey";
zusatz[i].parentNode.parentNode.style.backgroundColor ="#C0C0C0";
zusatz[i].readOnly =true;

}

//document.getElementById("mitbring").style.backgroundColor ="gray";
locked = true;
}
}

function radio_aktiv() {

if(locked){

var auswahl = document.getElementsByName("auswahlzahl[]");
var plus = document.getElementsByName("plus");
var minus = document.getElementsByName("minus");

for (var i = 0; i < auswahl.length; i++){
auswahl[i].readOnly=false;
auswahl[i].style.color = "";
auswahl[i].parentNode.parentNode.style.backgroundColor ="";
plus[i].disabled =false;
minus[i].disabled =false;
}

var zusatzzahl = document.getElementsByName("zusatzzahl[]");

var zusatzmenge = document.getElementsByName("zusatzmenge[]");

var zusatz = document.getElementsByName("zusatz[]");


for (var i = 0; i < zusatz.length; i++){
zusatzzahl[i].readOnly=false;
zusatzzahl[i].style.color = "";
zusatzzahl[i].parentNode.parentNode.style.backgroundColor ="";
zusatzzahl[i].readOnly =false;

zusatzmenge[i].readOnly=false;
zusatzmenge[i].style.color = "";
zusatzmenge[i].parentNode.parentNode.style.backgroundColor ="";
zusatzmenge[i].readOnly =false;

zusatz[i].readOnly=false;
zusatz[i].style.color = "";
zusatz[i].parentNode.parentNode.style.backgroundColor ="";
zusatz[i].readOnly =false;

}


//document.getElementById("mitbring").style.backgroundColor ="gray";
locked = false;
}
}

function start_button(e) {

	if(!gray){
	Effect.SlideDown('slide_anmeldung');
	e.style.background = "url(../pics/layout/button_gray.png)";
	gray = true;
	$('counter4').value = (new Date()).getTime();
	$('cage').onMouseOver = "true;";
	$('startbutton').onMouseOver ="true;";
	$('startbutton').onMouseDown ="true;";
	$('startbutton').onClick ="true;";
	
}else{
	//alert("lol");

}

}

function test_area(e){
//alert(e.innerHTML);
//alert (e.type);
//alert(e.value);
val = e.value;
e.parentNode.removeChild(e);
var area = new Element('textarea', {  tabindex: '7', name:'beschreibung', cols:'40', rows:'4'});
area.value = val;
$('beschreibung').appendChild(area);
//area.innerHTML = e.innerHTML;
//alert(e.innerHTML);

area.focus();
	
}

function tooltest(obj, str){
var curleft = curtop = 0;
if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
} while (obj = obj.offsetParent);
}
$('tippy').style.left = curleft + "px";
$('tippy').style.top = curtop + 16 + "px";
//$('tippy').innerHTML = str;
if(str == null){
var a = new Element('a', { onclick: "window.open('check_map.php?place='+$('ort').value,'popup','width=500,height=500,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false",name: "ort_checker"} );
$('tippy').innerHTML = "";
a.innerHTML = "Hier";
$('tippy').appendChild(a);
var teeext = new Element('span');
teeext.innerHTML = " kannst du prüfen ob der Ort gefunden wurde.";
$('tippy').appendChild(teeext);
}else{
	$('tippy').innerHTML = str;
}
//$('tippy').innerHTML = a + 'kannst du prüfen ob der Ort gefunden wurde. ';




}


function tooltest2(obj, str1 , str2){
var curleft = curtop = 0;
if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
} while (obj = obj.offsetParent);
}
$('tippy').style.left = curleft + "px";
$('tippy').style.top = curtop + 16 + "px";
//$('tippy').innerHTML = str;

var a = new Element('a', { onclick: "window.open('check_map.php?place='+$('ort').value,'popup','width=500,height=500,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false",name: "ort_checker"} );
$('tippy').innerHTML = "";
a.innerHTML = str1;
$('tippy').appendChild(a);
var teeext = new Element('span');
teeext.innerHTML =  " " + str2;
$('tippy').appendChild(teeext);

//$('tippy').innerHTML = a + 'kannst du prüfen ob der Ort gefunden wurde. ';




}

function count1(){
//alert("lol");

if(!gray){
//alert("roflcopter");
if($('counter1').value == "" || $('counter1').value == null){
	$('counter1').value = 1;
}else{
	$('counter1').value = parseInt($('counter1').value) +1;
	
}
//alert("rofl");
}
}

function count2(){
//alert("lol");


//alert("roflcopter");
if(!gray){
if($('counter2').value == "" || $('counter2').value == null){
	$('counter2').value = 1;
}else{
	$('counter2').value = parseInt($('counter2').value) +1;
	
}
//alert("rofl");
}

}
function count3(){
if(!gray){
	$('counter3').value = (new Date()).getTime();
}

}


function hidetippy(obj,oEvent){
	
		if (!oEvent) var oEvent = window.event;
	var relTarg = oEvent.relatedTarget || oEvent.fromElement;
	//alert(relTarg.id);

if(!(relTarg.descendantOf(obj))){
obj.style.left = -300 +"px";
obj.style.top = -350 + "px";
}

}

function amplify(objstr){
document.getElementById(objstr).style.visibility="hidden";
document.getElementById(objstr).style.display="none";
}





            var Nav = (navigator.appName.indexOf("Netscape") !=-1);
        if (Nav){document.captureEvents(Event.MOUSEMOVE);}
   document.onmousemove = handlerTip;

high = true;
locked = false;
gray = false;






