function insertarRegistro(){ 
	document.getElementById('hidMovimiento').value=1;	
	document.getElementById('frmPrincipal').submit();			
}

function editarRegistro(){				
	document.getElementById('hidMovimiento').value=4;
	document.getElementById('frmPrincipal').submit();				  
}

function eliminarRegistro(hidValor){
	vent=confirm('Desea eliminar el registro')
	if(vent){
		document.getElementById('hidValorReg').value=document.getElementById(hidValor).value;
		document.getElementById('hidMovimiento').value=3;
		document.getElementById('frmPrincipal').submit();	
	}	  
}

function eliminarRegistroImg(hidValor){
	vent=confirm("¿Desea Eliminar dicho Registro?")
	if(vent){
		document.getElementById('hidValorReg2').value=document.getElementById(hidValor).value;
		document.getElementById('hidMovimiento').value=5;
		document.getElementById('frmPrincipal').submit();		
	}	  
}

function statuRegistro(hidValor,chk){
	if(document.getElementById(chk).value==2)
		document.getElementById(chk).value=1;
	else
		document.getElementById(chk).value=2;
	document.getElementById('hidMovimiento').value=6;
	document.getElementById('hidChk').value=document.getElementById(chk).value;
	document.getElementById('hidValorReg').value=document.getElementById(hidValor).value;
	document.getElementById('frmPrincipal').submit();		
}

function ver(){			
	document.getElementById('frmPrincipal').submit();
}

function busquedas(){
	document.getElementById('cmbPaginado').selectedIndex='0-1';
	document.getElementById('frmPrincipal').submit();
}

function Mensaje(cMensaje){
	var response=new Array();
	response['css'] ='notice-message';
	response['message'] =cMensaje;
	showResponse(response);
}

function abrirContenido(hidValor,cPagina){			
	document.getElementById('hidValorReg').value=document.getElementById(hidValor).value;			
	document.getElementById('frmPrincipal').action=cPagina;
	document.getElementById('frmPrincipal').submit();
}

///
function votar(cPagina){
	window.open('','frmContenido','width=500, height=510, top=0, left=0,toolbar=no, menubar=no, scrollbars=yes, resizable=yes');
	document.getElementById('frmEncuesta').target="frmContenido";
	document.getElementById('frmEncuesta').action =cPagina;
	document.getElementById('frmEncuesta').submit();
	document.getElementById('frmEncuesta').target="";
	document.getElementById('frmEncuesta').action = "javascript:votar('resultados.php');";
}
/////

function abrirContenidoImp(hidValor,cPagina){		
	window.open('','frmContenido','height=600,width=700,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=no');
	document.getElementById('hidValorReg').value=document.getElementById(hidValor).value;
	document.getElementById('frmPrincipal').target="frmContenido";
	document.getElementById('frmPrincipal').action =cPagina;
	document.getElementById('frmPrincipal').submit();
	document.getElementById('frmPrincipal').target="";
	document.getElementById('frmPrincipal').action ="javascript: eventoSubmit('iNoticiasr.php');"
}

function abrirContenidoImp2(cPagina){		
	window.open('','frmContenido','height=400,width=500,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=no');
	document.getElementById('frmPrincipal').target="frmContenido";
	document.getElementById('frmPrincipal').action =cPagina;
	document.getElementById('frmPrincipal').submit();
	document.getElementById('frmPrincipal').target="";
	document.getElementById('frmPrincipal').action ="nota.php"
}

function abrirContenidoImg(hidValor,cPagina){
	window.open('','frmContenido','width=756, height=410, top=0, left=0,toolbar=no, menubar=no, scrollbars=yes, resizable=yes');
	document.getElementById('hidValorReg').value=hidValor;
	document.getElementById('frm').target="frmContenido";
	document.getElementById('frm').action =cPagina;
	document.getElementById('frm').submit();
	document.getElementById('frm').target="";
	document.getElementById('frm').action = "index.php";
}

function abrirContenidoImg2(hidValor,cPagina){
	window.open('','frmContenido','width=756, height=410, top=0, left=0,toolbar=no, menubar=no, scrollbars=yes, resizable=yes');	
	document.getElementById('hidValorReg').value=document.getElementById(hidValor).value;
	document.getElementById('frmPrincipal').target="frmContenido";
	document.getElementById('frmPrincipal').action =cPagina;
	document.getElementById('frmPrincipal').submit();
	document.getElementById('frmPrincipal').target="";
	document.getElementById('frmPrincipal').action ="javascript: eventoSubmit('iEncuestasr.php');";
}


function abrirResultados(hidValor,cPagina){
	window.open('','frmContenido','width=505, height=460, top=0, left=0,toolbar=no, menubar=no, scrollbars=yes, resizable=yes');
	document.getElementById('hidValorReg').value=hidValor;
	document.getElementById('frm').target="frmContenido";
	document.getElementById('frm').action =cPagina;
	document.getElementById('frm').submit();
	document.getElementById('frm').target="";
	document.getElementById('frm').action = "index.php";
}

function eventoSubmit(cPagina){				
	document.getElementById('frmPrincipal').action =cPagina;
	document.getElementById('frmPrincipal').submit();
	document.getElementById('frmPrincipal').action ="javascript: eventoSubmit('"+cPagina+"');"
}

function textCounter(field, countfield, maxlimit) {		
	//alert("restan: "+ (maxlimit - field.value.length) + " caracteres");	
	document.getElementById(countfield).innerHTML='<label for="title" style="color:green;">restan: '+ (maxlimit - field.value.length) + ' caracteres</label>';
	if(((maxlimit - field.value.length) <= 0)){
		document.getElementById(countfield).innerHTML='<label for="title" style="color:red;">Limite de caracteres sobrepasado</label>';
	}
}

function textCounterInicio(field, countfield, maxlimit) {
	var cObjeto=field;	
	if (cObjeto.length > maxlimit) // if too long...trim it!
		document.getElementById(countfield).innerHTML='<label for="title">hasta ' + maxlimit + ' caracteres</label>';					
	else
		document.getElementById(countfield).innerHTML='';
}

function trim(sString){
	while (sString.substring(0,1) == ' '){
		sString = sString.substring(1, sString.length);
	}
	while (sString.substring(sString.length-1, sString.length) == ' '){
		sString = sString.substring(0,sString.length-1);
	}
	return sString;
}

function validarCamposCorreo(){
	var bValido=true;
	document.getElementById('hidMovimientoEmail').value=1;
	if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById('txtCorreoremitente').value))){
		alert('Correo no valido','Error');
		document.getElementById('txtCorreoremitente').focus();
		bValido=false;
    }
 	if(bValido){
		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById('txtCorreodestinatario').value))){
			alert('Correo no valido','Error');
			document.getElementById('txtCorreodestinatario').focus();
			bValido=false;
		}	
	}
	return bValido;
}

function validarCamposComentario(){
	var bValido=false;
	if(trim(document.getElementById('txtNombre').value)==''){
		window.alert("Introduzca Nombre.");
		document.getElementById('txtNombre').select();
		document.getElementById('txtNombre').focus();
	}else{			
		if(trim(document.getElementById('txtEmail').value)==''){
			window.alert("Introduzca E-mail.");
			document.getElementById('txtEmail').select();
			document.getElementById('txtEmail').focus();
		}else{
			if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById('txtEmail').value))){
				window.alert("E-mail no valido","Error");
				document.getElementById('txtEmail').select();
				document.getElementById('txtEmail').focus();
			}else{
				if(trim(document.getElementById('txtComentario').value)==''){
					window.alert("Introduzca Comentario.");
					document.getElementById('txtComentario').select();
					document.getElementById('txtComentario').focus();
				}else{
					document.getElementById('hidMovimiento').value=1;
					var bValido=true;
				}
			}
		}
	}
	return bValido;
}

function validarCamposForo(){
	var bValido=false;
	if(trim(document.getElementById('txtNombre').value)==''){
		window.alert("Introduzca Nombre.");
		document.getElementById('txtNombre').select();
		document.getElementById('txtNombre').focus();
	}else{			
		if(trim(document.getElementById('txtEmail').value)==''){
			window.alert("Introduzca E-mail.");
			document.getElementById('txtEmail').select();
			document.getElementById('txtEmail').focus();
		}else{
			if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById('txtEmail').value))){
				window.alert("E-mail no valido","Error");
				document.getElementById('txtEmail').select();
				document.getElementById('txtEmail').focus();
			}else{
				if(trim(document.getElementById('txtTitulo').value)==''){
					window.alert("Introduzca Titulo.");
					document.getElementById('txtTitulo').select();
					document.getElementById('txtTitulo').focus();
				}else{
					if(trim(document.getElementById('txtDenuncia').value)==''){
						window.alert("Introduzca Denuncia.");
						document.getElementById('txtDenuncia').select();
						document.getElementById('txtDenuncia').focus();
					}else{
						document.getElementById('hidMovimiento').value=1;
						var bValido=true;
					}
				}
			}
		}
	}
	return bValido;
}


/*function wordCount(cCampo,nPalabraspermitidas,nCaracterespermitidos) {
	var cMsj;
	var nPalabrasrestantes;
	var nCaracteresrestantes;
  // Función que nos va a contar el número de caracteres 
  // y de palabras del area de texto de un formulario

  // Obtenemos el texto del area.
  //textoArea = document.getElementById("area").value;
	textoArea = document.getElementById(cCampo).value;

  // El numero de caracteres es su longitud
  numeroCaracteres = textoArea.length;

  // Eliminamos los caracteres en blanco del inicio y del final.
  // Como no tenemos funciones del tipo trim, rtrim y ltrim usamos
  // expresiones regulares
  // El ^ indica principio de cadena
  inicioBlanco = /^ /
  // El $ indica final de cadena
  finBlanco = / $/
  // El global (g) es para obtener todas las posibles combinaciones
  variosBlancos = /[ ]+/g 

  textoArea = textoArea.replace(inicioBlanco,"");
  textoArea = textoArea.replace(finBlanco,"");
  textoArea = textoArea.replace(variosBlancos," ");

  // Creamos un array con las diferentes palabras. Teniendo en 
  // cuenta que la separación entre palabras es el espacio en blanco.
  textoAreaDividido = textoArea.split(" ");
  numeroPalabras = textoAreaDividido.length;

	nPalabrasrestantes=(nPalabraspermitidas-numeroPalabras);
	nCaracteresrestantes=(nCaracterespermitidos-numeroCaracteres);

  // Mostramos los datos.
  // Tendremos en cuenta si hay que escribir en plural o en singular.
  //tC = (numeroCaracteres==1)?" carácter":" caracteres";
  //tP = (numeroPalabras==1)?" palabra":" palabras";
	tC = (numeroCaracteres==1)?" carácter":" caracteres";
	tP = (numeroPalabras==1)?" palabra":" palabras";
	if(nCaracteresrestantes <= 0 || nPalabrasrestantes <= 0){
		cMsj='¡Rebaso los limites!';
	}else{
		cMsj='Restan '+nCaracteresrestantes + tC +"\n o " + nPalabrasrestantes + tP;
	}
	 
  //alert (numeroCaracteres + tC +"\n" + numeroPalabras + tP);
	document.getElementById("msjTitlelimitado").innerHTML='<label for="title" style="color:green;">'+ cMsj +'</label>';
}
*/


