validar_idioma = function (frm){

	if ( document.frm.nullnombre2.value == "" ) { alert("El registro en espaņol no puede estar vaciķ."); return false }

	return true;

}

SMoneda = function (my,newValor, newSimbolo ,cant){

	for ( i=1; i < cant+1; i++ ){

		var divPrecio = objets( "precioDolar" + i );
		var divSimbolo = objets( "simbolo" + i );
		var divValor = objets( "total" + i );

		if ( newSimbolo == "U$S" ) {

			divValor.innerHTML = divPrecio.value;
			divSimbolo.innerHTML = newSimbolo;

			break;

		}

		if ( divPrecio ) {

			var P = divPrecio.value;

			var miFloat = new String (P);
			var newmiFloat = miFloat.replace(/[.]/g,'');

			var newPrecio = newValor * newmiFloat;

			divValor.innerHTML = newPrecio;
			divSimbolo.innerHTML = newSimbolo;

		}

	}

}

formulario = function (t,accion,titulo,dato,nombre){

	if ( document.getElementById('image') ) document.getElementById('image').value = '';
	if ( document.getElementById('pref') ) document.getElementById('pref').value = '';
	if ( document.getElementById('nombre') ) document.getElementById('nombre').value = '';
	if ( document.getElementById('mo') ) document.getElementById('mo').value = '';
	if ( document.getElementById('po') ) document.getElementById('image').value = '';

	document.getElementById('form').style.display = "block";
	document.getElementById('titulo').innerHTML = "<strong>" + titulo + "</strong>";dato
	document.getElementById('id').value = dato;

	if ( document.getElementById('modulo' + dato ) ){

		var ids = document.getElementById('iddemodulo').value;
		var moduloIdiomas = document.getElementById('modulo' + dato ).value;

		var array_ids = ids.split(',');
		var array_moduloIdiomas = moduloIdiomas.split(',');

		for ( i=0; i < array_ids.length; i++ ){

			id_nombre = 'nombre' + array_ids[i];

			document.getElementById( id_nombre ).value = array_moduloIdiomas[i];

		}

	}else {

		if ( document.getElementById('iddemodulo') ){

			var ids = document.getElementById('iddemodulo').value;

			var array_ids = ids.split(',');

			for ( i=0; i < array_ids.length; i++ ){

				id_nombre = 'nombre' + array_ids[i];

				if (document.getElementById( id_nombre )) document.getElementById( id_nombre ).value = '';

			}

		}

	}

	var param = "";

	if ( t != "" ) param = "&t=" + t;

	document.frm.action = "?action=" + accion + param;
}

formulario_idioma = function (t,accion,titulo,dato,nombre){
	document.getElementById('form').style.display = "block";
	document.getElementById('titulo').innerHTML = "<strong>" + titulo + "</strong>";dato
	document.getElementById('id').value = dato;
	document.getElementById('nombre').value = nombre;
	var param = "";

	if ( t != "" ) param = "&t=" + t;

	document.frm.action = "?action=" + accion + param;
}
objets = function ( obj ){
	return document.getElementById(obj)
}

abrirMenu = function (im,obj){
	my = objets(obj);
	if ( my.style.display == "block" ) {
		my.style.display = "none";
		if (im) im.src = URL_BASE + "/templates/img/mas.gif";

	}else {
		my.style.display = "block";
		if (im) im.src = URL_BASE + "/templates/img/men.gif";
	}
}

function cerrarMenu(obj){
	my = objets(obj);
	my.style.display = "none";
}

SPais = function (my,id,writeText){

	var selectTexto = objets('TEXT'+writeText);
	var selectId = objets('ID'+writeText);

	selectTexto.innerHTML = my.innerHTML;
	selectId.value = id;

}
//------------------------------------------------------------
function marcarOfert( obj ){
	if ( obj.className == "HOVER" ) obj.className = "HOVER-ON";
	else obj.className = "HOVER";
}

function SOferta( obj , id ){
	if ( notPrecio( id ) ){
		if ( inOfert( id ) ) marcarOfert( obj )
	}else{
		var precio = objets( "P" + id );
		var newPrecio = prompt( "Ingrese precio" );
		if ( newPrecio ) {
			if ( newPrecio == 0 ) {
				marcarOfert( obj );
				rOfert( "0" , id , "delete" );
			}else {
				rOfert( newPrecio , id , "update" );
			}
		}
	}
	var strOFE = objets( 'OFE' );
	var countOfertas = objets( "oferta" );
	if ( strOFE.value == "" ) {
		countOfertas.innerHTML = "0 Oferta/s";
	}else {
		var arrOFE = inArrays( strOFE.value );
		countOfertas.innerHTML = arrOFE.length + " Oferta/s";
	}
	abrirMenu('','menuOferta');
}

rOfert = function ( precio , id , mod ){
	var strUSS = objets( 'USS' );
	var strOFE = objets( 'OFE' );
	var divPR = objets('P' + id );
	arrUSS = inArrays( strUSS.value );
	arrOFE = inArrays( strOFE.value );

	for ( i=0; i < arrOFE.length; i++ ){
		if ( arrOFE[i] == id ) {
			if ( mod == "delete" ) {
				arrOFE[i] = "null";
				arrUSS[i] = "null";
				listOf = modPrecio( arrOFE );
				list = modPrecio( arrUSS );

				strOFE.value = listOf;
				strUSS.value = list;
				divPR.innerHTML = precio;
			}
			if ( mod == "update" ) {
				arrUSS[i] = precio;
				list = modPrecio( arrUSS );
				strUSS.value = list;
				divPR.innerHTML = precio;
			}
			break;
		}
	}
}

modPrecio = function ( arr ){
	var list = "";
	for ( i=0; i < arr.length; i++ ){
		if ( arr[i] != "null" ) list += arr[i] + ",";
	}
	return list;
}

inArrays = function ( str ){
	var str = str.substr( 0 , str.length -1 );
	arrai = str.split( ',' );
	return arrai;
}

inOfert = function ( idOF , PR ){
	var newPrecio = prompt( "Ingrese precio" );
	if ( newPrecio && newPrecio != 0 ) {
		var USS = objets( 'USS' );
		var OFE = objets( 'OFE' );
		var divUSS = objets( "P" + idOF );
		var nombreOFE = objets( "OF" + idOF );

		USS.value += newPrecio + ",";
		OFE.value += idOF + ",";

		divUSS.innerHTML = newPrecio;

		return true;

	}

}

notPrecio = function ( id ){
	var precio = objets( "P" + id);
	if ( precio.innerHTML == 0 ) return true;

}

/////////////////////////////////////////////////////////////////////////////////

function Borrar( id , action ){

	if (confirm("Confirma que desea borrar el registro?"))

	location.href="?action=" + action + "&id=" + id;

}

function Eliminar( action ){

	if (confirm("Confirma que desea borrar el registro?"))

	location.href = action;

}