// JavaScript Document





var stepGoWhen;
var stepToGo;
var nextStep =0;
var alert_send = 0;

// shows the alert part (for debug use a value higher then 1);
function yd_alert(text, send) {
	if (!send) { 
		alert(text);
	} else {
		if(send <= alert_send)
			alert(text);
	}
return 1;
}
/** 
* Switches between the pages in the assistant mode
* @param    Step you come from, Step to go, [back to confirmation page]
* value stay inside the <script>-Part
* step_div_text : is an array to hold the title of the assistant page
* step_div : each step has its own color, so here we declare the class
*/

function moveStep(fromStep,stepToGo, stepGoWhen) {	

	nextStep = fromStep <= 0 ? nextStep : fromStep ;
	nextStep++;
	yd_alert(fromStep + " :: "+ nextStep + "::" + countSteps,'2');
	//fill_form = fill_form_copy;
	for (var i = 1; i <= countSteps; i++) {
		// check if current step
		if(nextStep == i) {
			//yd_alert(step_div_text[i-1], '2');
			// load assistant title and bgcolor
			//changeDivText('step_to', step_div_text[i-1]);
			//document.getElementById("step_to_span").className = step_div[i-1];
		}
		// show/ hide the div we lod by nextStep function
		if(document.getElementById("step_" + i)) {
	    	document.getElementById("step_" + i).style.visibility = nextStep  == i ? 'visible' : 'hidden';
			document.getElementById("step_" + i).style.overflow = nextStep  == i ? 'visible' : 'hidden';
			//document.getElementById("step_" + i).style.heigh = nextStep  == i ? '100%' : '1px';
			document.getElementById("step_" + i).style.display = nextStep  == i ? 'block' : 'none';
		}
	}	
	if(document.getElementById("next_step")) {
	// if we reach the end of the assistant page, we will show/hide the STEP/SENDform part
	 document.getElementById("next_step").style.visibility = nextStep  == countSteps ? 'hidden' : 'visible';
	 document.getElementById("next_step").style.overflow =  nextStep  == countSteps ? 'hidden' : 'visible';
	 document.getElementById("next_step").style.display = nextStep  == countSteps ? 'none' : 'block';			
	}
	if(document.getElementById("preview_next_step")) {
	// show form sender
	 document.getElementById("preview_next_step").style.visibility = nextStep  == countSteps ?'visible' : 'hidden';
	 document.getElementById("preview_next_step").style.overflow =  nextStep  == countSteps ? 'visible' : 'hidden';
	 document.getElementById("preview_next_step").style.display = nextStep  == countSteps ? 'block' : 'none';					
	} 
	if(stepGoWhen) {
		nextStep = stepGoWhen-1;
		stepGoWhen = '';
	}
   yd_alert(nextStep + "=="+ countSteps,'2');
 // on the end, we prepare the preview part, to confirm the data befor sending them
	if(nextStep == countSteps && nextStep > 1) {
	 	showVorschau();			// nextStep > 1 angepasst um zu testen ob alles in Orndung ist, da sonst vorshcaui geladen wird
	} else {
		changeDivImg('reg', '/images/design.0/Bilder/' + lang + '_' + formname +'_'+ sitio + '.png');
		if(document.getElementById("goSubmit")) {
			document.getElementById("goSubmit").disabled = true;		
		}
	}
	// disable again the button so the user has to fill-up the form and can pass a page
	//document.getElementById("goStep").disabled = false;
}	

/** 
* Steps one step back, usuing the StepBack button
* @param    Step to go, [back to confirmation page]
* value stay inside the <script>-Part
*/
function stepBack(stepToGo, stepGoWhen) {
	//check the page where you stay
	if(!stepToGo) stepToGo = 2 ;
	//Set nextStep never lower then the 1° page 
	nextStep = nextStep - stepToGo < 0 ? 0 : nextStep - stepToGo;
	moveStep(nextStep,stepToGo, stepGoWhen);
	
	// depending on the position inside the assistant, handle the behaviour 
	if(document.getElementById("assistant_link")) {
	    if(document.getElementById("assistant_link").href == "javascript:stepBack();") {
	       document.getElementById("assistant_link").href="javascript:closeAssistant();";
	       changeDivText('assistant_close', error_text[error_text.length-1]);
		   changeDivImg('assistant_close', tgl[5]);
			// save the cookie values if assistant is in use or not
	       save_collapsed('yes', false,'assistant_close');       
			document.getElementById("step_to_span").style.visibility = 'visible';
			document.getElementById("step_to_img_1").style.visibility = 'visible';
			document.getElementById("step_to_img_2").style.visibility = 'visible';       
	    }
	}
}	

/** 
* closeAssistant()
* @param    NULL
* unloads the assistant
*/

function closeAssistant() {

	nextStep =0;
	
	for (var i = 1; i <= countSteps; i++) {
    	document.getElementById("step_" + i).style.visibility = countSteps  > i ? 'visible' : 'hidden';
		document.getElementById("step_" + i).style.overflow = countSteps  > i ? 'visible' : 'hidden';
		document.getElementById("step_" + i).style.heigh = countSteps  > i ? '100%' : '1px';
		document.getElementById("step_" + i).style.display = countSteps  > i ? 'inline' : 'none';
	}	
	if(isFakeAssist != 'yes') {
	//  hide the Assistent part for stepping forward/backward
		document.getElementById("step_to_span").style.visibility = 'hidden';
		document.getElementById("step_to_img_1").style.visibility = 'hidden';
		document.getElementById("step_to_img_2").style.visibility = 'hidden';		
	   	document.getElementById("send_step").style.visibility = 'hidden';
		document.getElementById("send_step").style.overflow =  'hidden';
		document.getElementById("send_step").style.display = 'none';			
	// show form sender part
	   	document.getElementById("send_form").style.visibility =  'visible';
		document.getElementById("send_form").style.overflow = 'visible';
		document.getElementById("send_form").style.display = 'inline';

		// Disable the Step Part button, so is not accessable even by TAB jump 
		document.getElementById("goStep").disabled = false;
	    //changeDivText('assistant_close', error_text[error_text.length-2]);
	    // CHange the Close assistant Link to be able to reactivate the assistant
		//document.getElementById("assistant_link").href="javascript:stepBack();";
		//changeDivImg('assistant_close', tgl[4]);
		// Save Cookie value
	    save_collapsed('yes', true,'assistant_close');
    }
}

function stepCancel() {
	// stepCancel bringt den besucher wieder zur Seite zurück wo er her gekommen ist, 
	// ohne POST Daten zur Sicherheit wegen doppel absenden
	// || OR befehl falls es kein referrent gibt und ihr zur startseite senden
	http_ref =  http_ref || '/';

	window.location.href= http_ref;
}

function showQuit() {
	if(document.getElementById("reg_quit")) {
		changeDiv('reg_quit','DIV_open');
		showHideSelect('hidden');
	}
}
		
function checkCondition(value) {
// prüfen ob die condition gesetzt ist, on in use by register
if(document.getElementById("condition").checked == true) {
	document.getElementById("goStep").src = '/images/design.0/Bilder/next_'+ lang + '_' + value + '.png';
	document.getElementById("goStep").onclick = function(){ return fillup(); };

} else {
	document.getElementById("goStep").src = '/images/design.0/Bilder/next_' + lang + '_gris.png';
	document.getElementById("goStep").onclick = function() { };	
 }

}

// ---------------------------------------------------------- //
// VERSION = 0.1

/** 
* 	(1,2,3,4,5);
* @param    CheckAgainst, "This Value as String", ElementID, ErrorMessage(fromArray), [no function yet]
* Check a value against a special kind of regex to find out if the value has a value we allow
* Values who are not insde the range will be changed to [SPACE]
*/
var allowSigns ="\W";
var allowSpace ="\s";
var allowMail = "\w+?\@\w+?";
var Suche ;
var results = false;
var yetsend;

function notAllowSigns(AS_type, AS_string, AS_id, AS_error_msg, eventis) {

	eventis = eventis || 'error_part';	
	
	if(document.getElementById("goStep")) {
		document.getElementById("goStep").disabled = false;
	}
	// difine the diferent regEx values, depending on AS_type
	if(AS_type == 'hard_string') {
		Suche = /\W/g;
//		var results = 	Suche.test(AS_string);

	} else if(AS_type == 'string') {
		// string could be every value from the std. keyboard
		Suche = /[^\w\.\´\`\'\ßsüÜäÄöÖñÑíÍóÓáÁéÉçÇ\¿\,\(\)\:\-\_\+\.\¡\?\!\&\"\'\´\`\+\-\@\[\]\;\,\\\/\%\*\s\n\r\=\§\²\~$]/ig;
	} else if(AS_type == 'password') {
		// string could be every value from the std. keyboard
		Suche = /^[\d\w\.\´\`\'\ßsüÜäÄöÖñÑíÍóÓáÁéÉçÇ\¿\,\(\)\:\-\_\+\.\¡\?\!\&\"\'\´\`\+\-\@\[\]\;\,\\\/\%\*\s\=\§\²\~]{7,}$/ig;
	} else if(AS_type == 'string_int') {
		// string_int can be a letter and number
		Suche = /[^a-z\s\ßsüÜäÄöÖñÑíÍóÓáÁéÉçÇ\d$]/ig;		
	}  else if(AS_type == 'number') {
		// number, can only be a number (with out any signes)
		Suche = /[^\d$]/g;
	}  else if(AS_type == 'phone') {
		// number, can only be a number (with out any signes)
		Suche = /[^\+\s\d$]/g;		
	}  else if(AS_type == 'price') {
		Suche = /[^(\d|\.|\,)$]/g;	
    // NEU 15:24 29.05.2007
    // mit aufgenommen um ein besser teste bei email angaben zu haben	
	} else if(AS_type == 'email') {
	    Suche = /[^a-z\.\-\_\d\@$]/ig; 
	} else if(AS_type == 'mail') {
		Suche = /^[a-z\_\-\.\d]{1,64}\@[a-z\-\.\d]{1,255}\.[a-z\.]{2,6}$/i;		
		//Suche = /^[\w\.\_\-\d]@[\w\.\-\d]$/ig;	
	} else if(AS_type == 'checkbox') {
		results = document.getElementById(AS_id).checked;
	}


	if(AS_type != 'checkbox' && AS_type != 'password') {
		// starte mitdem prüfen der werte!

		results = Suche.test(AS_string);
	}
    var docElm = document.getElementById(AS_id).id ? document.getElementById(AS_id) : document.forms[formname].elements[AS_id];
	// IE7 BUG : document.getElementById("description") does not seems to exists
    // in the FF the value gets return right
    // RR is to use the doc.form.elems STUFF
	
	var bo_error = 0;
	if ((AS_type == 'mail' || AS_type == 'password2') && results == false) {
		 bo_error = 1;
	} else if (AS_type == 'checkbox' && String(results) != AS_string) {
		  bo_error = 2;
	} else if ((AS_type != 'mail' && AS_type != 'checkbox' && AS_type != 'password') && results == true) {
		 bo_error = 3;
	} else if (AS_type == 'password' && docElm.value.length < 7 ) {
		 bo_error = 4;		 
	}
	if(bo_error > 0)  {
		// 14:09 29.05.2007
		//document.getElementById(AS_id).value = cur_text.substr(0,cur_text.length-1);
        //ist noch nicht sicher dahernoch alpha 1		
		if(AS_type != 'mail' || AS_type == 'mail') {
				
				if(bo_error < 4)
                docElm.value = docElm.value.replace(Suche, "") ;
				
				//document.getElementById(AS_id).focus();
		   		// 15:10 19.08.2008 outaken becaus ne design
		   		//yd_alert(bo_error,0);
		   		
		   		changeDivText(eventis,AS_error_msg);
		   		changeDiv(eventis,'DIV_open');
				pos = docElm.style.backgroundImage.indexOf(".png");
				bgImage = docElm.style.backgroundImage.substr(0,pos);

				if(bgImage.indexOf('_er') == -1 && AS_type != 'checkbox') {
					//alert(bgImage + "_" + sitio + "_er.png)");
	  				docElm.style.backgroundImage = bgImage + "_" + sitio + "_er.png)";
	  			}

				if(document.getElementById("goStep"))
					document.getElementById("goStep").disabled = true;
			if(step_done.length) {
				for(i=0;i<=step_done.length;i++) {
					if(step_done[i] == AS_id) {						
						step_done.splice(i,1);

					}
				}
			}
			return 1;			
        }
	} else 	if (bo_error == 0)  {
		// das funktioniert nchgar nicht so wie ich es haben will	
		// ich muß mir nch etwas überlegen wegen der freistellung der buttons,
		// so wie es jetzt ist, ist es nur ein notbehelf
		//JS_fill_form(-1);
		// entfern weil es jetzt über den button gehandhabt wird
		
		// 22/07/09 neue verhalten weil der error part weg geht
		if(error == -1) {
			changeDiv(eventis,'DIV_hidden');
		}
		
		if(step_1_feld.inArray(AS_id,0) > -1) {
			if(step_done.length > 0) {
				
				var is_in =0;
				var i  = 0;
				for(i = 0; i <= step_done.length; i= i +1) {
					if(step_done[i] == AS_id) 
						is_in =1;
				} 	
				if(is_in ==0) 
					step_done.push(AS_id);
			}  else {
				step_done.push(AS_id);				
			}
		}
	}

		if(document.getElementById("goStep") || document.getElementById("goSend") ) {
			if(step_done.length == step_1_feld.length) {
				if(document.getElementById("goSend")) {
					document.getElementById("goSend").src = '/images/design.0/Bilder/'+ lang + '_send_' + sitio + '.png';
					document.getElementById("goSend").onclick = function(){ return sendSubmit(); };						
				} else {					
					document.getElementById("goStep").src = '/images/design.0/Bilder/next_'+ lang + '_' + sitio + '.png';
					document.getElementById("goStep").onclick = function(){ return fillup(); };						
				}
						

			} else {
				if(document.getElementById("goSend")) {
					document.getElementById("goSend").src = '/images/design.0/Bilder/'+ lang + '_send__griss.png';
					stepToGo = "goSend";
				} else {
					document.getElementById("goStep").src = '/images/design.0/Bilder/next_'+ lang + '_gris.png';
					stepToGo = "goStep";
				}
				document.getElementById(stepToGo).onclick = function() {};	
			}			
		}
	//yd_alert(AS_type + "\n" +  AS_string + "\n" +  AS_id + "\n" +  AS_error_msg + "\n" +  eventis,2);		
		if(document.getElementById(AS_id).type != 'hidden'){
			pos = document.getElementById(AS_id).style.backgroundImage.indexOf("_" + sitio + "_er.png");
			if(!pos) {
				pos = document.getElementById(AS_id).style.backgroundImage.indexOf("_er.png");			
			}
			if(docElm.type == 'select-one' || docElm.type == 'textarea'){
				if(document.getElementById("div_" + AS_id).className.indexOf('_er') != -1) {
					document.getElementById("div_" + AS_id).className = document.getElementById("div_" + AS_id).className.substr(0,document.getElementById("div_" + AS_id).className.indexOf('_er'));
					document.getElementById("div_" + AS_id).className = document.getElementById("div_" + AS_id).className;
				//	alert(document.getElementById("div_" + docElm.id).className);
					if(document.getElementById(AS_id).className) 
					   document.getElementById(AS_id).className = document.getElementById(AS_id).className.substr(0,document.getElementById(AS_id).className.indexOf('_er'));				
				}
			}
			
			
			if(pos > -1) {
				bgImage = document.getElementById(AS_id).style.backgroundImage.substr(0,pos);
				document.getElementById(AS_id).style.backgroundImage = bgImage + ".png)";
			}
		}
}

/** 
* JS_fill_form(INTEGER);
* @param    INTEGER (page inside the assistent)
* the values step_X_feld are save in the <script> -parte of the current page
* 
* All the must fields have to be writen down in the step_x_feld as an JS-array
*/
function JS_fill_form(values) {

var FORSTEP ='';
if(nextStep == 1) {
	FORSTEP	= step_1_feld;
} else if(nextStep == 2) {
	FORSTEP	= step_2_feld;
} else if(nextStep == 3) {
	FORSTEP	= step_3_feld;		
} else if(nextStep == 4) {
	FORSTEP	= step_4_feld;
}
////yd_alert(nextStep + "::" +FORSTEP.length,'2');
var openStep =0;
var select_value;
var radio_value = -1;
/**
* FORSTEP gets fill-up with the value from the step_X_feld
* passing to the fields we count5 down the openStep value.
*/
for(i=0;i<=FORSTEP.length-1;i++) {
    
	var docElm = document.getElementById(FORSTEP[i]);
	// IE7 BUG : document.getElementById("description") does not seems to exists
    // in the FF the value gets return right
    // RR is to use the doc.form.elems STUFF
	var docOldElm = document.forms[formname].elements[FORSTEP[i]];
	var opt=0;
	select_value =0;

    //yd_alert(FORSTEP[i] + ": " + docElm.type + " ( " + docOldElm.type + " ) : "+ docElm.value + " :: " + select_value + " :: " + radio_value + "(" + openStep + ")",'2');    
	if(!docElm) docElm = docOldElm; // weggenommen wegen BUGGY CODE // continue ; 	
		//yd_alert(FORSTEP[i] + ": " + docElm.type + " ( " + docOldElm.type + " ) : "+ docElm.value + " :: " + select_value + " :: " + radio_value + "(" + openStep + ")",'2');
	// check each value against selected action
	if(docElm.type == 'select-one') {
		for(opt=0;opt<docElm.options.length;++opt) {
			if (docElm.options[opt].selected == true) {
				select_value = docElm.options[opt].value;
			}
		}
	}
	// check each value against selected action
    if(docElm.type == 'select-multiple') {
		for(opt=0;opt<docElm.options.length;++opt) {
			if (docElm.options[opt].selected = true) {
				select_value += docElm.options[opt].value;
			}
		}
	}
   
	// handhabe ob das zu prüfende feld ein radio button ist
	if(docElm.type == 'radio') {
		for(opt=0;opt<docOldElm.length;++opt) {
			//yd_alert(docOldElm[opt].checked,'2');
			// wenn radio ausgwählt ist übernimm den Wert
			if (docOldElm[opt].checked== true) {
				radio_value = docOldElm[opt].value;
			}
		}
	}
    
	//yd_alert(radio_value,'2');
	//prüfen der felder ansich
	// wenn die felder ausgefüllt sind, zähl den openStep hoch
	// openStep wird abgeglichen mit dem array value 
	if((docElm.type == 'text' && docElm.value) || (docOldElm.type == 'textarea' && docOldElm.value)  
		|| (docElm.type == 'select-one' && select_value  != 0) 
            || (docElm.type == 'select-multiple' && select_value  != 0)
			    || (docElm.type == 'radio' && radio_value > -1)
                    || (docElm.type == 'hidden' && docElm.value)) {
    	openStep++;	
    }   
}

	// 
	fill_form[nextStep-1] = fill_form[nextStep-1] + values;
    ////yd_alert(docElm.type + " :: " + fill_form[nextStep-1] + " <= 0) |" + nextStep + "| (" + fill_form[nextStep-1] + "<="+ openStep,'2');
	// based on zhe opeStep value, we can pass the page or not
	// if rthe openStep value is 0 or < fill_form[ARRAY].value we allow to pass the page
	if((fill_form[nextStep-1] <= 0) 
		|| (fill_form[nextStep-1] <= openStep)) {
		moveStep(nextStep);
		return true;
		//document.getElementById("goSubmit").disabled = false;			
		//document.getElementById("goStep").disabled = false;		
	} else {
		// if there are fields to fill up, we open a alert window that some field is missing
		//document.getElementById("goSubmit").disabled = true;			
		//document.getElementById("goStep").disabled = true;
		yd_alert(ER_fillup_nonoption);
		return false;
	}
}



/**
* stop_elements(formname, elementname)  
* Deactivates the elements inside a form
* this obligates the user to wait until the ajax returns the right values
*/
function stop_elements(formname, elementname)  {
	return;
for(var i = 0; i<=document.forms[formname].length-1;i++) {
	if(document.forms[formname].elements[i].name != elementname)
		document.forms[formname].elements[i].disabled = true;
}
}

/**
* js_process_keyword()
* uses the AJAX Returned values to insert the new
* word the user will use onthekeyword manager
*/
function js_process_keyword() {
    
// lade die daten aus dem argument array

var listElement = document.getElementById("keyword_list");
var itemElement = document.getElementById("keyword_item");
var newArray = new Array();
	newArray = arguments[0].split(",");
	//yd_alert(arguments,'2');
	if(newArray) {
    //for(var i = 0; i<= newArray.length-1 ; i = i +2) {
    	newElement = new Option(newArray[0], newArray[1],false,false);
    	listElement.options[listElement.options.length] = newElement;
        
    	newElement = new Option(newArray[0], newArray[1],false,false);        
    	itemElement.options[itemElement.options.length] = newElement;        

    //}
}

    for(var i = 0; i<=document.forms[formname].length-1;i++) {
    	document.forms[formname].elements[i].disabled = false;
    }
    listElement.focus();

}

/**
* currently has no usuablity 
*/
function js_process_keyword_old() {
    // lade die daten aus dem argument array

var listElement = document.getElementById("keyword_list");
var itemElement = document.getElementById("keyword_item");
var current_length = listElement.options.length;
for(i = 0; i<=current_length; i=i+1) {
    if(listElement.options[i].value === 'NULL') {        
        break;
    } else {
	    listElement.options[i] = null;
    }
}

for(i = 0; i<=itemElement.options.length; i=i+1) {
    //yd_alert("i = " + i,'2');
	itemElement.options[i] = null;
}

var newArray = new Array();
var itemArray = new Array();
var arr = new Array();
var arr = arguments[0].split("__AJX__");
	newArray = arr[0].split(",");
    itemArray = arr[1].split(",");        
var e=0;
if(newArray) {
    for(var i = 0; i<= newArray.length-1 ; i = i +2) {
    	//yd_alert(i + "::"+ newArray[i],'2');
    	newElement = new Option(newArray[i+1], newArray[i],false,false);
    	listElement.options[e] = newElement;
    	e++;
    }
    e=0;
    for(var i = 0; i<= itemArray.length-1 ; i = i +2) {
    	//yd_alert(newArray[i],'2');
    	newElement = new Option(itemArray[i+1], itemArray[i],false,false);
    	itemElement.options[e] = newElement;
    	e++;
    }

    for(var i = 0; i<=document.forms[formname].length-1;i++) {
    	document.forms[formname].elements[i].disabled = false;
    }
    listElement.focus();
}
}

/**
* js_process_func()
* splits the return value from the ajax code to insert the 
* city returned by a ZIP code (also the Comunity)
*/
function js_process_func() {
// lade die daten aus dem argument array
//yd_alert(arguments[0],'2');
var docElement = document.getElementById("city_select")
//document.forms[formname].elements[elmName];;
var current_length = docElement.options.length -1;

// set all values to NULL
for(i = current_length; i>0; i=i-1) {
	docElement.options[i] = null;
}
if(document.getElementById("comunity_select") !== null) {
	document.getElementById("comunity_select").options[0] = null;
}

// get the values into the array, solit on ,-sign
var newArray = new Array();
	// 12:49 27/02/2009 neu trennzeichen hinzugefügt
	newArray = arguments[0].split("|");
var e=0;

for(var i = 1; i<= newArray.length-1 ; i = i +1) {
	var elm = newArray[i].split(";")
	newElement = new Option(elm[1], elm[0],false,false);
	docElement.options[e] = newElement;
	//docElement.options[e].onMousemove = function(){hideddrivetip();};
	//docElement.options[e].onmouseover = function(){hideddrivetip();};
	docElement.options[e].selected = true;
	e++;
}
docElement.options[0].selected = true;
changeDivText(docElement.id, docElement.options[0].text,'span_');


//11:28 14/05/2009 new if part

if(document.getElementById("comunity_select") !== null) {
// 12:49 27/02/2009 neu trennzeichen hinzugefügt
ComunityElement = document.getElementById("comunity_select");
var elm = newArray[0].split(";")
newElement = new Option(elm[1], elm[0],false,false);

ComunityElement.options[0] = newElement;
ComunityElement.options[0].selected = true;
notAllowSigns('number', ComunityElement.options[0].value,"comunity_select",error_text[2]);

changeDivText(ComunityElement.id, ComunityElement.options[0].text,'span_');
}
notAllowSigns('number', docElement.options[0].value,"city_select",error_text[2]);
for(var i = 0; i<=document.forms[formname].length-1;i++) {
	document.forms[formname].elements[i].disabled = false;
}

docElement.focus();
}



// LADEN DER ANGEGEBENEN DATEN IN DIE FELDER UM SICH DIE VOR DEM VERSAND ANZUSEHEN
// js_ar_lng = JS Array für Sprachen
function showVorschau() {
	yd_alert(felder.length,'3');

for(sp = 0; sp<= felder.length-1;++sp) {
	var feld_value =''; // ist der gemeinse wert um nict alles neu zu deklarieren, wird erstez bei jedem durchlauf mit dem nötigen wert oder ''
	var docElm = browsercheck.indexOf('IE ') > -1 ? document.forms[formname].elements[felder[sp]] : document.getElementById(felder[sp]);
	var docOldElm = document.forms[formname].elements[felder[sp]];
	if(!docElm) {
		docElm = docOldElm;	
	}
	
	var opt=0;
	yd_alert(felder[sp]  + " :: " + docElm.type,'2');
	select_value =0;
	// handhabe für select_option felder

	if(docElm.type == 'select-one') {
		for(opt=0;opt<docElm.options.length;++opt) {
			if (docElm.options[opt].selected == true) {
				feld_value = docElm.options[opt].text;				
			}
		}
	}	
    
	else if(docElm.type == 'select-multiple') {
		for(opt=0;opt<docElm.options.length;++opt) {
			if (docElm.options[opt].selected == true) {
				feld_value = feld_value + "," + docElm.options[opt].text;
			}
		}
	}    
    
	// handhabe ob das zu prüfende feld ein radio button ist
	else if(docElm.type == 'radio') {
		for(opt=0;opt<docOldElm.length;++opt) {
			//yd_alert(docOldElm[opt].checked,'2');
			if (docOldElm[opt].checked== true) {
				if(felder[sp] == 'work_material') {
					feld_value = docOldElm[opt].value == 0 ? work_material[0] : work_material[1];
				}
				else if(felder[sp] == 'worker_insurance' || felder[sp] == 'condition') {
					feld_value = docOldElm[opt].value == 0 ? NO : YES;
				} 
                else {
                   // add 23:09 30.05.2007 damit der assitent besser läuft in den vorschauseiten
                  feld_value = " ";   // docOldElm[opt].value <= 0 ? 'Nein' : 'Ja'
                }
			} 
		}
	}
    else if(docElm.type == 'checkbox') {
        if (docElm.checked== true) {
            if(docElm.name == "worker_language") {
                for(opt=0;opt<docOldElm.length;++opt) {
                   if (docOldElm[opt].checked== true) {
                        feld_value = feld_value + js_ar_lng[docOldElm[opt].value -1] + " ";
                   }
                }
            } else { 
                feld_value = docElm.value == 1 ? YES : NO;
            }
        }
    }
    
    else if(docElm.type == 'hidden') {
		    feld_value = docElm.value;        
    }
    else if(docElm.type == 'password') {
		    feld_value = '********';        
    }
	else {
        if(docOldElm.type == 'textarea') {
            feld_value = docOldElm.value;
        } else {
		    feld_value = docElm.value;
        }
	}
	if(feld_value == '')
		continue;
	
	yd_alert(felder[sp] + "," + feld_value,'1');
	//yd_alert(docElm.type + "," + docOldElm.type,'2');  
	// change the span value o the current vlaue  
	changeDivText(felder[sp], feld_value);
	//setContent('id',felder[sp],0,feld_value);
	
}
	changeDivImg('reg', '/images/design.0/Bilder/' + lang + '_todobien_' + sitio + '.png');
	// aktiviere den button zum senden der form
	if(document.getElementById("goSubmit")) 
	document.getElementById("goSubmit").disabled = false;
}  


// @param NULL
function fillup(values) {
	//alert("nextStep_" + nextStep);
var FORSTEP ='';
if(nextStep == 1) {
	FORSTEP	= step_1_feld;
} else if(nextStep == 2) {
	FORSTEP	= step_2_feld;
} else if(nextStep == 3) {
	FORSTEP	= step_3_feld;		
} else if(nextStep == 4) {
	FORSTEP	= step_4_feld;
}
////yd_alert(nextStep + "::" +FORSTEP.length,'2');
var openStep =0;
var select_value;
var radio_value = -1;
/**
* FORSTEP gets fill-up with the value from the step_X_feld
* passing to the fields we count5 down the openStep value.
*/
var error = 0;
for(i=0;i<=FORSTEP.length-1;i++) {
    
    //yd_alert(FORSTEP[i],2);
	var docElm = document.getElementById(FORSTEP[i]);
	// IE7 BUG : document.getElementById("description") does not seems to exists
    // in the FF the value gets return right
    // RR is to use the doc.form.elems STUFF
	var docOldElm = document.forms[formname].elements[FORSTEP[i]];
	var opt=0;
	select_value =-1;

	if(!docElm) docElm = docOldElm; // weggenommen wegen BUGGY CODE // continue ; 	
	//yd_alert(FORSTEP[i] + ": " + docElm.type + " ( " + docOldElm.type + " ) : "+ docElm.value + " :: " + select_value + " :: " + radio_value + "(" + openStep + ")");
	// check each value against selected action
	//yd_alert(docElm.name);	
	if(docElm.type == 'select-one') {
		for(opt=0;opt<docElm.options.length;++opt) {
			if (docElm.options[opt].selected == true ) {
				select_value = docElm.options[opt].value;
			}
		}
	}
	// check each value against selected action
    if(docElm.type == 'select-multiple') {
		for(opt=0;opt<docElm.options.length;++opt) {
			if (docElm.options[opt].selected = true) {
				select_value += docElm.options[opt].value;
			}
		}
	}
   
	// handhabe ob das zu prüfende feld ein radio button ist
	if(docElm.type == 'radio') {
		for(opt=0;opt<docOldElm.length;++opt) {
			//yd_alert(docOldElm[opt].checked,'2');
			// wenn radio ausgwählt ist übernimm den Wert
			if (docOldElm[opt].checked== true) {
				radio_value = docOldElm[opt].value;
			}
		}
	}
    
	//yd_alert(radio_value,'2');
	//prüfen der felder ansich
	// wenn die felder ausgefüllt sind, zähl den openStep hoch
	// openStep wird abgeglichen mit dem array value 
	if(docElm.name == 'mail2') {
		if(docElm.value != document.getElementById("mail").value) {
			changeDivText('error_part','Error en Mail');
			error = 99;
		}
	}
	if(docElm.name == 'password_confirm') {
		if(docElm.value != document.getElementById("password").value) {
			changeDivText('error_part','Error en Contraseña');
			error == 1000;
		}
	}
		
	if((docElm.type == 'text' && !docElm.value) || (docOldElm.type == 'textarea' && !docOldElm.value) || (docElm.type == 'password' && !docElm.value)  
		|| (docElm.type == 'select-one' && (select_value  <= 0 || select_value  == "NULL")) 
            || (docElm.type == 'select-multiple' && select_value  <= 0)
			    || (docElm.type == 'radio' && radio_value == -1)
                    || (docElm.type == 'hidden' && !docElm.value)
                    	|| (docElm.name == 'password_confirm' && docElm.value != document.getElementById("password").value)
                    		|| docElm.name == 'mail2' && docElm.value != document.getElementById("mail").value) {
  			//changeDiv('error_part','DIV_open');
			changeDivText('error_part',str_refill);
    yd_alert(FORSTEP[i] + ": " + docElm.type + " ( " + docOldElm.type + " ) : "+ docElm.value + " :: " + select_value + " :: " + radio_value + "(" + openStep + ")",'2');			
			// ändere die hintergrundfarbe zur fehler farbe
			if(docElm.type != 'hidden') {
				
				pos = docElm.style.backgroundImage.indexOf(".png");
				bgImage = docElm.style.backgroundImage.substr(0,pos);
				if(bgImage.indexOf('_er') == -1) {
	  				docElm.style.backgroundImage = bgImage + "_" + sitio + "_er.png)";
	  			}
	
	  				if(docElm.type == 'select-one' || docOldElm.type == 'textarea'){
						if(document.getElementById("div_" + docElm.id).className.indexOf('_er') == -1) {
							document.getElementById("div_" + docElm.id).className = document.getElementById("div_" + docElm.id).className + " " + document.getElementById("div_" + docElm.id).className + "_er";
							if(document.getElementById(docOldElm.id).className) 
								document.getElementById(docOldElm.id).className = document.getElementById(docOldElm.id).className + " " + document.getElementById(docOldElm.id).className + "_er";

						}
					}
			}
  			error++;

    }   

}	
	if(error == 0) {
		changeDiv('error_part','DIV_hidden');
		moveStep(nextStep);
		return true;
	} else {
		// if there are fields to fill up, we open a alert window that some field is missing
		changeDiv('error_part','DIV_open');
		return false;
  		
	}
return false;	
}



// para enviaar al formulario si es uno sin steps, usamos esta funcion, es püreciso que existe el boton goSend, ya que goSubmit() solo finktiona si el fomulario stine steps
function sendSubmit() {
	document.forms[formname].submit();
}

	
