/** KumbiaForms - PHP Rapid Development Framework *****************************
*
* Copyright (C) 2005-2007 Andrés Felipe Gutiérrez (andresfelipe at vagoogle.net)
*
* This framework is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This framework is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this framework; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*
* Este framework es software libre; puedes redistribuirlo y/o modificarlo
* bajo los terminos de la licencia pública general GNU tal y como fue publicada
* por la Fundación del Software Libre; desde la versión 2.1 o cualquier
* versión superior.
*
* Este framework es distribuido con la esperanza de ser util pero SIN NINGUN
* TIPO DE GARANTIA; sin dejar atrás su LADO MERCANTIL o PARA FAVORECER ALGUN
* FIN EN PARTICULAR. Lee la licencia publica general para más detalles.
*
* Debes recibir una copia de la Licencia Pública General GNU junto con este
* framework, si no es asi, escribe a Fundación del Software Libre Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*****************************************************************************/


function saveMasterData(action){

	var obj;
	if(document.getElementById("errStatus").value>0){
		if(!confirm("El Formulario tiene errores\nDesea Continuar?")) {
			return;
		}
	}
	
	//reportType
	obj = document.createElement("INPUT");
	obj.type = "hidden";
	obj.name = "reportType"	
	if(document.fl.reportType) {
		obj.value = document.getElementById("reportType").value;
	}
	document.saveDataForm.appendChild(obj)

	for(i=0;i<=Fields.length-1;i++){
		if(document.getElementById("flid_"+Fields[i])){			
			obj = document.createElement("INPUT");
			obj.type = "hidden"
		}
		if(document.getElementById("flid_"+Fields[i]+"_up")){	
			if(document.getElementById("flid_"+Fields[i]+"_up").value){
				obj = document.getElementById("flid_"+Fields[i]+"_up")
				obj.style.display = "none"
			}
		} 
		obj.name = "fl_"+Fields[i]
		if(document.getElementById("flid_"+Fields[i]).type=='checkbox'){
			obj.value = document.getElementById("flid_"+Fields[i]).checked
		} else {
			if(document.getElementById("flid_"+Fields[i]+"_up")){
				if(!document.getElementById("flid_"+Fields[i]+"_up").value){
					obj.value = document.getElementById("flid_"+Fields[i]).value
				} 
			} else {
				obj.value = document.getElementById("flid_"+Fields[i]).value
			}
		}
		document.saveDataForm.appendChild(obj)		
	}

	//Controller-Action
	document.saveDataForm.action = $Kumbia.path+document.fl.aaction.value+"/"+action
	document.saveDataForm.submit();

}

function enableForm(){
	var i;
	for(i=0;i<=Fields.length-1;i++){
		document.getElementById("flid_"+Fields[i]).disabled = false		
	}

	for(i=0;i<=DateFields.length-1;i++){
		document.getElementById("xfl_"+DateFields[i]+'_Month_ID').disabled = false
		document.getElementById("xfl_"+DateFields[i]+'_Day_ID').disabled = false
		document.getElementById("xfl_"+DateFields[i]+'_Year_ID').disabled = false
	}

	for(i=0;i<=timeFields.length-1;i++){
		document.getElementById("time"+timeFields[i]+"_hour").disabled = false
		document.getElementById("time"+timeFields[i]+"_minutes").disabled = false
	}

	for(i=0;i<=imageFields.length-1;i++){
		document.getElementById("flid_"+imageFields[i]+"_up").disabled = false
	}

	for(i=0;i<=emailFields.length-1;i++){
		document.getElementById(emailFields[i]+'_email1').disabled = false
		document.getElementById(emailFields[i]+'_email2').disabled = false
	}

	if(document.getElementById('aceptar')) document.getElementById('aceptar').disabled = false
	if(document.getElementById('cancelar')) document.getElementById('cancelar').disabled = false
}

function disableForm(){
	var i;
	for(i=0;i<=Fields.length-1;i++){
		document.getElementById("flid_"+Fields[i]).disabled = true
		if(document.getElementById("actAction").lang!='Modificar'){
			if(document.getElementById("flid_"+Fields[i]).tagName=="SELECT"){
				document.getElementById("flid_"+Fields[i]).selectedIndex = 0
				if(document.getElementById(Fields[i]+"_helper")){
					cancel_helper(Fields[i])					
				}
			}
		}
	}

	for(i=0;i<=timeFields.length-1;i++){
		document.getElementById("time"+timeFields[i]+"_hour").disabled = true
		document.getElementById("time"+timeFields[i]+"_minutes").disabled = true
	}

	for(i=0;i<=imageFields.length-1;i++){
		document.getElementById("flid_"+imageFields[i]+"_up").disabled = true
	}

	for(i=0;i<=DateFields.length-1;i++){
		document.getElementById("xfl_"+DateFields[i]+'_Month_ID').disabled = true
		document.getElementById("xfl_"+DateFields[i]+'_Day_ID').disabled = true
		document.getElementById("xfl_"+DateFields[i]+'_Year_ID').disabled  = true
	}

	for(i=0;i<=emailFields.length-1;i++){
		document.getElementById(emailFields[i]+'_email1').disabled = true
		document.getElementById(emailFields[i]+'_email2').disabled = true
	}

	if(document.getElementById("aceptar")) document.getElementById("aceptar").disabled = true
	if(document.getElementById("cancelar")) document.getElementById("cancelar").disabled = true
	if(document.getElementById("adiciona")) document.getElementById("adiciona").disabled = false
	if(document.getElementById("consulta")) document.getElementById("consulta").disabled = false
	if(document.getElementById("modifica")) document.getElementById("modifica").disabled = true
	if(document.getElementById("visualiza")) document.getElementById("visualiza").disabled = false
	if(document.getElementById("borra")) document.getElementById("borra").disabled = true
	if(document.getElementById("reporte")) document.getElementById("reporte").disabled = false
	if(document.getElementById("anterior")) document.getElementById("anterior").disabled = false;
	if(document.getElementById("primero")) document.getElementById("primero").disabled = false;
	if(document.getElementById("siguiente")) document.getElementById("siguiente").disabled = false;
	if(document.getElementById("ultimo")) document.getElementById("ultimo").disabled = false;
	if(document.getElementById("actAction").lang=='Modificar'||document.getElementById("actAction").lang=='Borrar') {
		if(document.getElementById("modifica"))document.getElementById("modifica").disabled = false
		if(document.getElementById("borra")) document.getElementById("borra").disabled = false
	}
}

function enableInsert(obj, x){
	var i;
	enableForm();

	if(obj.value){
		obj.disabled = true;
		document.getElementById("actAction").lang = obj.lang
	} else document.getElementById("actAction").lang = obj

	if(x!=1){
		for(i=0;i<=AddFields.length-1;i++){
			if(document.getElementById("flid_"+AddFields[i]).tagName=="SELECT"){
				document.getElementById("flid_"+AddFields[i]).selectedIndex = 0
			}
			if(document.getElementById("flid_"+AddFields[i]).tagName=="TEXTAREA"){
				document.getElementById("flid_"+AddFields[i]).innerText = ""
			}
			if(document.getElementById("flid_"+AddFields[i]).tagName=="INPUT"){
				if(document.getElementById("flid_"+AddFields[i]).type!="hidden"){
					if(document.getElementById("flid_"+AddFields[i]).type=="checkbox"){
						document.getElementById("flid_"+AddFields[i]).checked = false
					} else {
						document.getElementById("flid_"+AddFields[i]).value = ""
					}
				}
			}
		}
	}

	for(i=0;i<=AutoValuesFields.length-1;i++){
		document.getElementById("flid_"+AutoValuesFields[i]).value = AutoValuesFFields[i];
	}

	for(i=0;i<=AutoFields.length-1;i++){
		document.getElementById("flid_"+AutoFields[i]).readOnly = true
	}

	for(i=0;i<=queryOnlyFields.length-1;i++){
		if(document.getElementById("flid_"+queryOnlyFields[i]).tagName!="SELECT")
		document.getElementById("flid_"+queryOnlyFields[i]).readOnly = true
		else
		document.getElementById("flid_"+queryOnlyFields[i]).disabled = true
	}

	for(i=0;i<=queryOnlyDateFields.length-1;i++){
		document.getElementById("xfl_"+queryOnlyDateFields[i]+'_Month_ID').disabled = true
		document.getElementById("xfl_"+queryOnlyDateFields[i]+'_Day_ID').disabled = true
		document.getElementById("xfl_"+queryOnlyDateFields[i]+'_Year_ID').readOnly = true
	}

	if(document.getElementById("consulta")) document.getElementById("consulta").disabled = true
	if(document.getElementById("reporte")) document.getElementById("reporte").disabled = true
	if(document.getElementById("visualiza")) document.getElementById("visualiza").disabled = true
}


function enableUpdate(obj){

	//enableForm();
	if(document.getElementById("anterior")) document.getElementById("anterior").disabled = true;
	if(document.getElementById("primero")) document.getElementById("primero").disabled = true;
	if(document.getElementById("siguiente")) document.getElementById("siguiente").disabled = true;
	if(document.getElementById("ultimo")) document.getElementById("ultimo").disabled = true;

	obj.disabled = true;
	document.getElementById("actAction").lang = obj.lang

	for(var i=0;i<=UFields.length-1;i++){
		document.getElementById("flid_"+UFields[i]).disabled = false
	}

	for(var i=0;i<=queryOnlyFields.length-1;i++){
		if(document.getElementById("flid_"+queryOnlyFields[i]).tagName!="SELECT")
		document.getElementById("flid_"+queryOnlyFields[i]).readOnly = true
		else
		document.getElementById("flid_"+queryOnlyFields[i]).disabled = true
	}

	for(var i=0;i<=DateFields.length-1;i++){
		document.getElementById("xfl_"+DateFields[i]+'_Month_ID').disabled = false
		document.getElementById("xfl_"+DateFields[i]+'_Day_ID').disabled = false
		document.getElementById("xfl_"+DateFields[i]+'_Year_ID').disabled = false
	}

	for(var i=0;i<=queryOnlyDateFields.length-1;i++){
		document.getElementById("xfl_"+queryOnlyDateFields[i]+'_Month_ID').disabled = true
		document.getElementById("xfl_"+queryOnlyDateFields[i]+'_Day_ID').disabled = true
		document.getElementById("xfl_"+queryOnlyDateFields[i]+'_Year_ID').readOnly = true
	}
	
	for(i=0;i<=imageFields.length-1;i++){
		document.getElementById("flid_"+imageFields[i]+"_up").disabled = false
	}

	for(var i=0;i<=emailFields.length-1;i++){
		document.getElementById(emailFields[i]+'_email1').disabled = false
		document.getElementById(emailFields[i]+'_email2').disabled = false
	}

	if(document.getElementById("borra")) document.getElementById("borra").disabled = true

	document.getElementById("aceptar").disabled = false
	document.getElementById("cancelar").disabled = false
}

function enableQuery(obj){
	var i;
	enableForm();
	obj.disabled = true;

	for(i=0;i<=AutoFields.length-1;i++){
		document.getElementById("flid_"+AutoFields[i]).readOnly = false
	}

	for(i=0;i<=queryOnlyFields.length-1;i++){
		document.getElementById("flid_"+queryOnlyFields[i]).readOnly = false
	}

	for(i=0;i<=queryOnlyDateFields.length-1;i++){
		document.getElementById("xfl_"+queryOnlyDateFields[i]+'_Month_ID').disabled = false
		document.getElementById("xfl_"+queryOnlyDateFields[i]+'_Day_ID').disabled = false
		document.getElementById("xfl_"+queryOnlyDateFields[i]+'_Year_ID').readOnly = false
	}

	for(i=0;i<=emailFields.length-1;i++){
		document.getElementById(emailFields[i]+'_email1').value = ""
		document.getElementById(emailFields[i]+'_email2').value = ""
		document.getElementById(emailFields[i]+'_email1').disabled = false
		document.getElementById(emailFields[i]+'_email2').disabled = false
	}

	document.getElementById("actAction").lang = obj.lang
	for(i=0;i<=Fields.length-1;i++){
		if(document.getElementById("flid_"+Fields[i]).tagName=="SELECT"){
			document.getElementById("flid_"+Fields[i]).selectedIndex = 0
		}
		if(document.getElementById("flid_"+Fields[i]).tagName=="TEXTAREA"){
			document.getElementById("flid_"+Fields[i]).innerText = ""
		}
		if(document.getElementById("flid_"+Fields[i]).tagName=="INPUT"){
			if(document.getElementById("flid_"+Fields[i]).type!="hidden"){
				if(document.getElementById("flid_"+Fields[i]).type=="checkbox"){
					document.getElementById("flid_"+Fields[i]).checked = false
				} else {
					document.getElementById("flid_"+Fields[i]).value = ""
				}
			}
		}
	}
	if(document.getElementById("adiciona")) document.getElementById("adiciona").disabled = true
	if(document.getElementById("reporte")) document.getElementById("reporte").disabled = true
	if(document.getElementById("visualiza")) document.getElementById("visualiza").disabled = true
}

function FormAccept(){
	var iErr = 0
	var i
	var s = 0

	if(document.getElementById("actAction").lang=='Adicionar'){
		for(i=0;i<=NotNullFields.length-1;i++){
			if(document.getElementById("flid_"+NotNullFields[i]).tagName=="INPUT"||
			document.getElementById("flid_"+NotNullFields[i]).tagName=="TEXTAREA"){
				if(document.getElementById("flid_"+NotNullFields[i]).type!="hidden"){
					if(!document.getElementById("flid_"+NotNullFields[i]).value) {
						if(typeof Effect != undefined){
							effectObj = document.getElementById("flid_"+NotNullFields[i])
							new Effect.ScrollTo("flid_"+NotNullFields[i], {duration:0.5, afterFinish:highlightObj})
						} else {
							alert('Este campo es Obligatorio');
							document.getElementById("flid_"+NotNullFields[i]).select()
							document.getElementById("flid_"+NotNullFields[i]).focus()
						}
						return;
					} else {
						if(document.getElementById("flid_"+NotNullFields[i]).value=='00/00/0000'){
							alert('Este campo es Obligatorio');
							document.getElementById("flid_"+NotNullFields[i]).select()
							document.getElementById("flid_"+NotNullFields[i]).focus()
							return;
						}
					}
				}
			}
		}
		for(i=0;i<=Fields.length-1;i++){
			if(document.getElementById("flid_"+Fields[i]).tagName=="SELECT"){
				if(document.getElementById("flid_"+Fields[i]).options[document.getElementById("flid_"+Fields[i]).selectedIndex].value=='@'){
					if(!document.getElementById("flid_"+Fields[i]).disabled){
						if(!$("flid_"+Fields[i]+"_up")){						
							if(typeof Effect != undefined){
								if(!s){
									effectObj = document.getElementById("flid_"+Fields[i])
									new Effect.ScrollTo("flid_"+Fields[i], {duration:0.5, afterFinish:iErrorObj})
									s = 1
								} else {
									new Effect.Highlight("flid_"+Fields[i], {startcolor:"#FF0000"})
								}
							} else {
								document.getElementById("flid_"+Fields[i]).className = "iError"
							}
							iErr = 1
						}
					} else {
						if(!$("flid_"+Fields[i]+"_up").value){
							if(typeof Effect != undefined){
								if(!s){
									effectObj = document.getElementById("flid_"+Fields[i])
									new Effect.ScrollTo("flid_"+Fields[i], {duration:0.5, afterFinish:iErrorObj})
									s = 1
								} else {
									new Effect.Highlight("flid_"+Fields[i], {startcolor:"#FF0000"})
								}
							} else {
								document.getElementById("flid_"+Fields[i]).className = "iError"
							}
							iErr = 1	
						}
					}
				} else document.getElementById("flid_"+Fields[i]).className = "iNormal"
			}
		}
		document.getElementById("errStatus").value = iErr
		if(iErr) return;
		for(i=0;i<=Fields.length-1;i++){
			if(document.getElementById("flid_"+Fields[i]).tagName=="SELECT"){
				document.getElementById("flid_"+Fields[i]).disabled = true
			}
		}
		saveMasterData('insert')
	}

	if(document.getElementById("actAction").lang=='Consultar'){
		saveMasterData('query')
	}

	if(document.getElementById("actAction").lang=='Reporte'){
		saveMasterData('report')
	}

	if(document.getElementById("actAction").lang=='Modificar'){
		for(i=0;i<=NotNullFields.length-1;i++){
			if(document.getElementById("flid_"+NotNullFields[i]).tagName=="INPUT"||
			document.getElementById("flid_"+NotNullFields[i]).tagName=="TEXTAREA")
			if(document.getElementById("flid_"+NotNullFields[i]).type!="hidden"){
				if(!document.getElementById("flid_"+NotNullFields[i]).value) {
					alert('Este campo es Obligatorio');
					if(typeof Effect != undefined){
						effectObj = document.getElementById("flid_"+NotNullFields[i])
						new Effect.ScrollTo("flid_"+NotNullFields[i], {duration:0.5, afterFinish:highlightObj})
					} else {
						alert('Este campo es Obligatorio');
						document.getElementById("flid_"+NotNullFields[i]).select()
						document.getElementById("flid_"+NotNullFields[i]).focus()
					}
					return;
				} else {
					if(document.getElementById("flid_"+NotNullFields[i]).value=='0000-00-00'){
						if(typeof Effect != undefined){
							effectObj = document.getElementById("flid_"+NotNullFields[i])
							new Effect.ScrollTo("flid_"+NotNullFields[i], {duration:0.5, afterFinish:highlightObj})
						} else {
							alert('Este campo es Obligatorio');
							document.getElementById("flid_"+NotNullFields[i]).select()
							document.getElementById("flid_"+NotNullFields[i]).focus()
						}
					}
				}
			}
		}
		for(i=0;i<=Fields.length-1;i++){
			if(document.getElementById("flid_"+Fields[i]).tagName=="SELECT"){
				if(document.getElementById("flid_"+Fields[i]).options[document.getElementById("flid_"+Fields[i]).selectedIndex].value=='@'){
					if(typeof Effect != undefined){
						if(!s){
							effectObj = document.getElementById("flid_"+Fields[i])
							new Effect.ScrollTo("flid_"+Fields[i], {duration:0.5, afterFinish:iErrorObj})
							s = 1
						} else {
							new Effect.Highlight("flid_"+Fields[i], {startcolor:"#FF0000"})
						}
					} else {
						document.getElementById("flid_"+Fields[i]).className = "iError"
					}
					iErr = 1
				} else {
					document.getElementById("flid_"+Fields[i]).className = "iNormal"
				}
			}
		}
		document.getElementById("errStatus").value = iErr
		if(iErr) return;
		saveMasterData('update')
	}
	disableForm();
}

function cancelForm(){
	var i;
	if(document.getElementById('actAction').value!='Modificar'&&document.getElementById('actAction').value!='Borrar') {
		for(i=0;i<=Fields.length-1;i++){
			if(document.getElementById("flid_"+Fields[i]).tagName=="SELECT")
			document.getElementById("flid_"+Fields[i]).selectedIndex = 0
			if(document.getElementById("flid_"+Fields[i]).tagName=="INPUT"){
				if(document.getElementById("flid_"+Fields[i]).type!="hidden"){
					document.getElementById("flid_"+Fields[i]).value = document.getElementById("flid_"+Fields[i]).defaultValue
				}
			}
			document.getElementById("flid_"+Fields[i]).className = "iNormal";

		}
	}
	for(i=0;i<=emailFields.length-1;i++){
		document.getElementById(emailFields[i]+'_email1').value = document.getElementById(emailFields[i]+'_email1').defaultValue
		document.getElementById(emailFields[i]+'_email2').value = document.getElementById(emailFields[i]+'_email2').defaultValue
	}

	disableForm();
	if(typeof Effect != undefined){
		new Effect.Fade("reportTypeTd")
	}
	
}

function enableDelete(){
	if(confirm("Esta seguro que desea borrar el registro?")) saveMasterData('delete')
}

function enableReport(obj){
	var i;
	enableForm();
	obj.disabled = true;
	
	if(typeof Effect != undefined){
		new Effect.Appear("reportTypeTd")
	}

	for(i=0;i<=AutoFields.length-1;i++){
		document.getElementById("flid_"+AutoFields[i]).readOnly = false
	}

	for(i=0;i<=queryOnlyFields.length-1;i++){
		document.getElementById("flid_"+queryOnlyFields[i]).readOnly = false
	}

	for(i=0;i<=queryOnlyDateFields.length-1;i++){
		document.getElementById("xfl_"+queryOnlyDateFields[i]+'_Month_ID').disabled = false
		document.getElementById("xfl_"+queryOnlyDateFields[i]+'_Day_ID').disabled = false
		document.getElementById("xfl_"+queryOnlyDateFields[i]+'_Year_ID').readOnly = false
	}

	document.getElementById("actAction").lang = obj.lang
	for(i=0;i<=Fields.length-1;i++){
		if(document.getElementById("flid_"+Fields[i]).tagName=="SELECT")
		document.getElementById("flid_"+Fields[i]).selectedIndex = 0
		if(document.getElementById("flid_"+Fields[i]).tagName=="TEXTAREA")
		document.getElementById("flid_"+Fields[i]).innerText = ""
		if(document.getElementById("flid_"+Fields[i]).tagName=="INPUT")
		if(document.getElementById("flid_"+Fields[i]).type!="hidden")
		if(document.getElementById("flid_"+Fields[i]).type=="checkbox")
		document.getElementById("flid_"+Fields[i]).checked = false
		else
		document.getElementById("flid_"+Fields[i]).value = ""
	}
	if(document.getElementById("adiciona")){
		document.getElementById("adiciona").disabled = true
	}
	if(document.getElementById("consulta")){
		document.getElementById("consulta").disabled = true
	}
	if(document.getElementById("visualiza")){
		document.getElementById("visualiza").disabled = true
	}
}

function show_upload_image(component){
	if($('a_'+component).innerHTML=='Subir Imagen'){
		$('flid_'+component).hide()
		$('flid_'+component+'_up').show()
		$('a_'+component).innerHTML = 'Cancelar'
	} else {
		$('flid_'+component).show()
		$('flid_'+component+'_up').hide()
		$('a_'+component).innerHTML = 'Subir Imagen'
	}
	
}

function show_helper(helper){
	if(!$("flid_"+helper).disabled){
		$(helper+"_helper").value = ""
		$(helper+"_helper").show()
		$("helper_new_"+helper).hide()
		$("helper_save_"+helper).show()
		$("helper_cancel_"+helper).show()
		$("flid_"+helper).hide()
		$("flid_"+helper).selectedIndex = 0
		$(helper+"_helper").focus()
	}
}

function cancel_helper(helper){
	$(helper+"_helper").value = ""
	$(helper+"_helper").hide()
	$("helper_new_"+helper).show()
	$("helper_save_"+helper).hide()
	$("helper_cancel_"+helper).hide()
	$("flid_"+helper).show()
}

function save_helper(helper){
	new AJAX.execute( 
	{
		action: document.fl.aaction.value+"/_save_helper/0",
		parameters: "name="+helper+"&valor="+$(helper+"_helper").value,
		callbacks: {
			before: function() {
				$(helper+"_spinner").show()
			},
			complete: function() {
				$(helper+"_spinner").hide()				
				new Ajax.Request($Kumbia.path+document.fl.aaction.value+"/_get_detail/0/&name="+helper+"&valor="+$(helper+"_helper").value, 
				{
					asynchronous: false,
					onSuccess: function(resp){						
						xml = resp.responseXML
						items = xml.getElementsByTagName("row");						
						while($('flid_'+helper).lastChild){
							$('flid_'+helper).removeChild($('flid_'+helper).lastChild)
						}
						option = document.createElement("OPTION");
						option.value = '@'
						if(document.all){
							option.innerText = 'Seleccione...'
						} else {
							option.text = 'Seleccione...'
						}
						$('flid_'+helper).appendChild(option)
						for(i=0;i<=items.length-1;i++){
							option = document.createElement("OPTION");
							option.value = items[i].getAttribute('value')
							if(document.all){
								option.innerText = items[i].getAttribute('text')
							} else {
								option.text = items[i].getAttribute('text')
							}
							$('flid_'+helper).appendChild(option)
							if(items[i].getAttribute('selected')=="1"){
								 $('flid_'+helper).selectedIndex = i+1
							}							
						}						
					}
				}
				)				
				cancel_helper(helper);				
			}
		}
	}
	)
}
