function formulario_tipo_registro(tipo_registro){
    if(tipo_registro=='persona'){
      $("#persona").show();
      $("#empresa").hide();
    }else{
      $("#empresa").show();
      $("#persona").hide();
    }
}

function validar_registro_cliente(){
	if(getIdValue('rut')=='' ||  getIdValue('dv')=='')
		alert('Ingrese un RUT');
	else if(!validarRut(getIdValue('rut'),getIdValue('dv')))
		return false;
	else if(getIdValue('email')=='')
		alert('Ingrese su Email');
    else if(getIdValue('region')=='')
		alert('Ingrese la Region');
	else if(getIdValue('provincia')=='')
		alert('Ingrese la Provincia');
	else if(getIdValue('comuna')=='')
		alert('Ingrese la Comuna');
	else if(getIdValue('telefono')=='')
		alert('Ingrese el Telefono');
	else if(getIdValue('direccion')=='')
		alert('Ingrese la Direccion');
	else if(getIdValue('password')=='' || getIdValue('re_password')=='' || getIdValue('re_password')!=getIdValue('password') )
		alert('Ingrese su Password y repita en Confirmar  Password');

	else if(getIdValue('tipo_registro')=='persona' && getIdValue('nombre')=='')
   		alert('Ingrese su Nombre');
   	else if(getIdValue('tipo_registro')=='persona' && getIdValue('apellidopaterno')=='')
   		alert('Ingrese su Apellido Paterno');
   	else if(getIdValue('tipo_registro')=='persona' && getIdValue('apellidomaterno')=='')
   		alert('Ingrese su Apellido Materno');

   	else if(getIdValue('tipo_registro')=='empresa' && getIdValue('razon_social')=='')
   		alert('Ingrese la Razon Social');
   	else if(getIdValue('tipo_registro')=='empresa' && getIdValue('giro')=='')
   		alert('Ingrese el Giro');
   	else if(getIdValue('tipo_registro')=='empresa' && getIdValue('contacto')=='')
   		alert('Ingrese la Persona de Contacto');

    else
		enviar_registro_cliente();
}

function enviar_registro_cliente(){
    $('#main_contenido').load('aplicaciones/usuarios/registro_usuarios_accion.php',
    {
    tipo_registro:getIdValue('tipo_registro'),
    rut:getIdValue('rut'),
    dv:getIdValue('dv'),
    email:getIdValue('email'),
    nombre:getIdValue('nombre'),
    apellidopaterno:getIdValue('apellidopaterno'),
    apellidomaterno:getIdValue('apellidomaterno'),
    razon_social:getIdValue('razon_social'),
    giro:getIdValue('giro'),
    contacto:getIdValue('contacto'),
    region:getIdValue('region'),
    provincia:getIdValue('provincia'),
    comuna:getIdValue('comuna'),
    direccion:getIdValue('direccion'),
    telefono:getIdValue('telefono'),
    fax:getIdValue('fax'),
    celular:getIdValue('celular'),
    codigo_postal:getIdValue('codigo_postal'),
    password:getIdValue('password'),
    'intereses[]':getNameValues('intereses[]'),
    re_password:getIdValue('re_password')
    })

}

function enviar_registro_detalle_cliente(){
    $('#main_contenido').load('aplicaciones/usuarios/editar_usuarios_accion.php',
    {
    tipo_registro:getIdValue('tipo_registro'),
    rut:getIdValue('rut'),
    dv:getIdValue('dv'),
    email:getIdValue('email'),
    nombre:getIdValue('nombre'),
    apellidopaterno:getIdValue('apellidopaterno'),
    apellidomaterno:getIdValue('apellidomaterno'),
    razon_social:getIdValue('razon_social'),
    giro:getIdValue('giro'),
    contacto:getIdValue('contacto'),
    region:getIdValue('region'),
    provincia:getIdValue('provincia'),
    comuna:getIdValue('comuna'),
    direccion:getIdValue('direccion'),
    telefono:getIdValue('telefono'),
    fax:getIdValue('fax'),
    celular:getIdValue('celular'),
    codigo_postal:getIdValue('codigo_postal'),
    password:getIdValue('password'),
    'intereses[]':getNameValues('intereses[]'),
    re_password:getIdValue('re_password')
    })

}