<!--

function g(id) {return document.getElementById(id);}

function inputType(evt,tipo) {
	var charCode = (evt.which) ? evt.which : event.keyCode
	if (tipo==1) {		
	
	 if (charCode > 31 && (charCode < 48 || charCode > 57)){
	 return false;
		} 
	}
	
	if (tipo==2) {
	if (charCode > 32 && (charCode < 65 || charCode > 122)){
	   return false;
		} 
	}
 return true;
}

function cleancontents() 
{
	var x = document.forms[0];
	
	for (i=0;i<x.length;i++) 
	{
		if(x[i].type!='button')
		{
			x[i].value = ''	
		}
	}
	x.reset();
}


function validarform(lang,form) 
{

	var question1 = new Array("Deseja enviar os dados abaixo?","Desea enviar las informaciones abajo","The following information will be submitted, confirm?")
	var question2 = new Array("Por favor preencher o campo solicitado com dados validos","Por favor completar los datos solicitados","Please fill out the form with valid information")
	var question3 = new Array("Enviar formulario?","Enviar formulario?","The form will be submitted")
	var txtfrm_value = '';
	var confirma = question1[lang] + String.fromCharCode(10) + String.fromCharCode(10);
	var labels = document.getElementsByTagName('label');
	var divs = document.getElementsByTagName('div');
	var forname = form.name
	var formcontent= ""; 
	//$('#txtfrm_txt').val(''); //clear the hidden field with data that is submitted
	//$('hidden').val(''); //clear the hidden field with data that is submitted
	//$('input:hidden[name=txtfrm_txt]').val(); // get the value from a set of radio buttons
	g('txtfrm_txt').value ="";

	for(x=0,j=0,t=0;x<form.length;x++)
	{

		if(form[x].tagName=='FIELDSET'){
			txtfrm_value += '\n' + form[x].getAttribute('name') + '\n';
		}
		
		if((form[x].tagName=='INPUT'&&form[x].type=='text')||form[x].tagName=='TEXTAREA'||form[x].tagName=='SELECT'||form[x].type=='radio'||form[x].type=='checkbox'){
			vlreq = form[x].getAttribute('req');
			if(vlreq == 'yes' && (
								  (form[x].tagName=='INPUT' && (form[x].value=='' || form[x].value.length < 3)) 
								  || (form[x].tagName=='SELECT' && form[x].value=='' && vlreq=='yes')
								  || (form[x].tagName=='TEXTAREA'&&form[x].value=='')
								  ))
			{
				
				alert(question2[lang]);
				form[x].focus();
				j++;
				return false;
				break;
			}
			

			if(g('lbl'+form[x].id))
			{
				xyz = g('lbl'+form[x].id);
				formcontent += g(xyz.id).innerHTML  + '\n';		
				//txtfrm_value += $('#' + xyz).val() + ': ' + $('#' + form[x].id).val()  + '\n';		
				//txtfrm_value += $("'"+xyz+"'").value + ': ' + form[x].value + '\n';			
				if(document.all)
				{
					//txtfrm_value += xyz.innerText + ': ' + form[x].value + '\n';		
					txtfrm_value += g(xyz.id).innerText + ': ' + form[x].value + '\n';		
				} else {
					//txtfrm_value += xyz.textContent + ': ' + form[x].value +'\n';		
					txtfrm_value += g(xyz.id).innerHTML + ': ' + form[x].value +'\n';
				}
			}
		}
	}

	if (forname.indexOf('noconfirm')>0) {
		msgconfirm = question3[lang];
	} else {
		//msgconfirm = confirma + txtfrm_value.replace(/&/g,String.fromCharCode(10))
		msgconfirm = confirma + txtfrm_value.replace(/\n/g,String.fromCharCode(10))
	}

	if (j==0){
	//alert(formcontent);
		if(confirm(msgconfirm)){
			txtfrm_value = ConvertCRtoBR(txtfrm_value);
			g('txtfrm_txt').value = txtfrm_value;
			form.submit() ;
		} 
	}
}

function ConvertCRtoBR(thetext)
{
	//var therows=0;
	var output = thetext ;
	//output = output == '' ? '&nbsp;' : output;

	if (output.indexOf("\n") != -1)
	{
		var br = "<br />";
		var newtext = output.split("\n");
		output = "";
		for(var i=0; i<newtext.length; i++)
		{
			// if (i>= (newtext.length-1)) br = ""; // don't add last BR
			output+= newtext[i] +br;
		}
	}
	return output;
} 

function getBirthday() {
	frmdia = g('day');
	frmmes = g('month');
	frmano = g('year');
	frm1 = g('birthday');
	frm1.value = frmdia.value + '/' + frmmes.value + '/' + frmano.value;
}

function changevalue(valor) {
	g('payment').value = valor
}


function addvalues() {
	g('formato').value = '';
	var abcd = document.getElementsByName('formatoanuncio');
	for(i=0;i<abcd.length;i++){
		if(abcd[i].checked){
				g('formato').value = g('formato').value + abcd[i].value + ' - ';
		}
	}

	}

function changevl(elm,lang) {
	var errmsg = new Array("Digite corretamente o speed dial","Digite corretamente o speed dial","Please fill in the required fields");
	idel = elm.substring(3,elm.length);
	countrycode = g('countrycode'+idel).value;
	citycode = g('citycode'+idel).value;
	telephone = g('tel'+idel).value;
	speeddial = g('discrapida' + idel);
	speeddial.value = countrycode + '-' + citycode + '-' + telephone;
	if (((countrycode==''|| citycode=='') && telephone.length > 0) || (countrycode!=''|| citycode!='') && telephone.length==0){
		alert(errmsg[lang]);
	}
}

function setValue(vl1,vl2){
	arrsplit = vl1.split(',');
	vl = ''
	for (i in arrsplit) {
		vl += g(arrsplit[i]).value + '/';
		}
	g(vl2).value = vl.substring(0,vl.length-1);
}


function showInput(src,inpt,idx){
	dvinpt = g('dv'+inpt);
	lbl = dvinpt.getElementsByTagName('label')
	inpt = g(inpt);
	if(src.selectedIndex==idx){
		dvinpt.style.display='block';
		lbl.id = 'lbl'+inpt;
		inpt.value = '';
	} else {
		dvinpt.style.display='none';
	}
}



function showInputCancel(){
	dvother1 = g('dvother');
	dvtripdate1 = g('dvtripdate');
	cancela = g('cancelreason');

	lblreason = dvother1.getElementsByTagName('label')[0];
	lbldata = dvtripdate1.getElementsByTagName('label')[0];

	if(cancela.selectedIndex==10){
		dvother1.style.display='block';
		dvtripdate1.style.display='none';
		lblreason.id='lbl'+lblreason.htmlFor;
		lbldata.id='';
		g(lblreason.htmlFor).value='';
		g(lblreason.htmlFor).req='yes';
		g(lbldata.htmlFor).req='no';
	} else if(cancela.selectedIndex==1||cancela.selectedIndex==2){
		dvother1.style.display='none';
		dvtripdate1.style.display='block';
		lblreason.id='';
		lbldata.id='lbl'+lbldata.htmlFor;
		g(lbldata.htmlFor).value='';
		g(lblreason.htmlFor).req='no';
		g(lbldata.htmlFor).req='yes';
	} else {
		dvtripdate1.style.display='none';
		dvother1.style.display='none';
		g(lblreason.htmlFor).req='no';
		g(lbldata.htmlFor).req='no';
		lblreason.id='';
		lbldata.id='';
	}
}
      //-->

