//CSValiViewpublicaranuncio.js

//Clase CSValiViewpublicaranuncio

function CSValiViewpublicaranuncio(form,title,label_entrada,label_presupuesto,label_flim,label_empresa,label_sector,label_direccion,label_cp,
								   label_poblacion,label_provincia,label_pais,label_web,label_email,label_telefono,label_fax) {

    this.form = form;
    this.title = title;

    this.entrada = new CSAlfanum(entrada.GetText(),label_entrada,1);	
    this.presupuesto = new CSAlfanum(form.presupuesto.value,label_presupuesto,0);	
	this.flim = new CSFecha(form.flim.value,label_flim,1);	
	this.empresa = new CSAlfanum(form.empresa.value,label_empresa,1);
    this.sector = new CSCombo(form.idsector,label_sector);
	this.direccion = new CSAlfanum(form.direccion.value,label_direccion,1);		
	this.cp = new CSCP(form.cp.value,label_cp,1);			
    this.poblacion = new CSAlfanum(form.poblacion.value,label_poblacion,1);
    this.provincia = new CSCombo(form.provincia,label_provincia);
    this.pais = new CSCombo(form.idpais,label_pais);
    this.web = new CSAlfanum(form.web.value,label_web,0);	
	this.email = new CSAlfanum(form.email.value,label_email,1);	
	this.telefono = new CSTelefax(form.telefono.value,label_telefono,1);
	this.fax = new CSTelefax(form.fax.value,label_fax,0);

    this.msg_error = new Array();
	
	this.validar = CSValiViewpublicaranuncio_validar;
	this.show_bugs = CSValiViewpublicaranuncio_show_bugs;
	this.submit_query = CSValiViewpublicaranuncio_submit_query;
}


function CSValiViewpublicaranuncio_validar() {

    if (!this.entrada.validarEntradaTexto(TEXTO_PROYECTO_ENTRADA_SIZE)) { this.msg_error[this.msg_error.length] = this.entrada.msg_error(); }			
    if (!this.presupuesto.validarDecimal()) { this.msg_error[this.msg_error.length] = this.presupuesto.msg_error(); }		
    if (!this.flim.validar()) { this.msg_error[this.msg_error.length] = this.flim.msg_error(); }		
    if (!this.empresa.validar()) { this.msg_error[this.msg_error.length] = this.empresa.msg_error(); }
    if (!this.sector.validar()) { this.msg_error[this.msg_error.length] = this.sector.msg_error(); }
    if (!this.direccion.validar()) { this.msg_error[this.msg_error.length] = this.direccion.msg_error(); }
    if (!this.cp.validar()) { this.msg_error[this.msg_error.length] = this.cp.msg_error(); }		
    if (!this.poblacion.validar()) { this.msg_error[this.msg_error.length] = this.poblacion.msg_error(); }
    if (!this.provincia.validar()) { this.msg_error[this.msg_error.length] = this.provincia.msg_error(); }	
    if (!this.pais.validar()) { this.msg_error[this.msg_error.length] = this.pais.msg_error(); }
    if (!this.web.validar()) { this.msg_error[this.msg_error.length] = this.web.msg_error(); }			
    if (!this.email.validar()) { this.msg_error[this.msg_error.length] = this.email.msg_error(); }
	if (!this.telefono.validar()) { this.msg_error[this.msg_error.length] = this.telefono.msg_error(); }
	if (!this.fax.validar()) { this.msg_error[this.msg_error.length] = this.fax.msg_error(); }

    return (this.msg_error.length == 0);
}
	
function CSValiViewpublicaranuncio_show_bugs() {
     show_bugs(this.title,this.msg_error);
}

function CSValiViewpublicaranuncio_submit_query() {
    this.form.entrada.value=entrada.GetHTML();
    this.form.submit();
}


function CSValiViewpublicaranuncio_eval(form,title,label_entrada,label_presupuesto,label_flim,label_empresa,label_sector,label_direccion,label_cp,
								   label_poblacion,label_provincia,label_pais,label_web,label_email,label_telefono,label_fax) {
  var obj1=new CSValiViewpublicaranuncio(form,title,label_entrada,label_presupuesto,label_flim,label_empresa,label_sector,label_direccion,label_cp,
								   label_poblacion,label_provincia,label_pais,label_web,label_email,label_telefono,label_fax);

  if (obj1.validar()) {
	  obj1.submit_query()
  } else {
	 obj1.show_bugs();
  }
}

