/*
// Funcion para seleccionar elementos por ID ( getElementById )
function $() {
	var elements = new Array();
	for (var i = 0; i < arguments.length; i++) {
		var element = arguments[i];
		if (typeof element == 'string')
			element = document.getElementById(element);
		if (arguments.length == 1)
			return element;
		elements.push(element);
	}
	return elements;
}

//Version para un solo elemento
function mostrar_bloque(el) {
	new Effect.toggle($(el),'blind');
}
//Version multi-elemento
function mostrar_bloque() {
  for (var i=0, el; el = $(arguments[i]); i++) {
	new Effect.toggle(el,'blind');
  }
}
*/
/*
// *** TRACARA
function removeMessage() {

	if ($('message') == null) {
		return false;
	}

	var oP = $('message').getElementsByTagName("p")[0];
	if (oP) {
		oP.parentNode.removeChild(oP);
	}

}

function replaceMessage(msgID,lang) {

	if ($('message') == null) {
		return false;
	}

	var oElement = $('message');
	var oNewP = document.createElement("p");
	var msg = '';
	var msgA = new Array();

	switch (lang) {
		case 'es': codeLang = 0; break;
		case 'ct': codeLang = 1; break;
		case 'en': codeLang = 2; break;
		case 'fr': codeLang = 3; break;
		default: codeLang = 0; break;
	}


	switch (msgID) {
		case 'error':
			msgA[0] = 'Existen campos incorrectos o vacios. Revise el formulario';
			msgA[1] = 'Camps buits o incorrectes. Revisi el formulari';
			msgA[2] = 'Invalid or empty required fields';
			msgA[3] = 'Champs required inadmissibles ou vides';
			clase = 'warning';
		break;
		case 'process':
			msgA[0] = 'Procesando formulario. Esta operacion puede tardar unos minutos.';
			msgA[1] = 'Processant dades. Tingui paciencia';
			msgA[2] = 'Sending form. Wait a moment, please';
			msgA[3] = 'Envoi de la forme. Attendre un moment, svp';
			clase = 'success';
		break;
		case 'select':
			msgA[0] = 'No hay ningun elemento seleccionado';
			msgA[1] = 'No hi ha cap element seleccionat';
			msgA[2] = 'Please, select at least one element';
			msgA[3] = 'Svp, choisir au moins un oloment';
			clase = 'warning';
		break;
		case 'cancel':
			msgA[0] = 'Operacion cancelada';
			msgA[1] = 'Operacio cancelada';
			msgA[2] = 'Stop process';
			msgA[3] = 'Arreter le processus';
			clase = 'warning';
		break;
		default:
			msgA[0] = 'Rellene los campos requeridos del formulario';
			msgA[1] = 'Ompli tots els camps requerits';
			msgA[2] = 'Fill required fields';
			msgA[3] = 'Remplir champs required';
			clase = 'success';
		break;

	}

	// Mensaje en el idioma
	msg = msgA[codeLang];

	// For Firefox
	oElement.setAttribute('class',clase);
	// For IE 7.0
	oElement.setAttribute('className',clase);

	// Añadimos elemento
	oElement.appendChild(oNewP);

	var oText = document.createTextNode(msg);
	oNewP.appendChild(oText);


}

function checkField(sId) {
	var oField = document.$(sId);
	var bHaveErrors = false;

	if ( oField.type == 'text' || oField.type == 'textarea' ) {
		bHaveErrors = (haveWhites(oField.value) || oField.value.length < 2) ? true : false;
	}
	if (oField.type == 'select-one') {
		var indice = oField.selectedIndex;
		var valor = oField.options[indice].value;
		if (valor == '0') {
			bHaveErrors = true;
		}
		else {
			bHaveErrors = false;
		}
	}

	if (bHaveErrors) {
		oField.style.border = '1px solid #f00';
	} else {
		oField.style.border = '1px solid #7f9db9';
	}
	return;
}

function nospam(user,domain) {
	locationstring = "mailto:" + user + "@" + domain;
	window.location = locationstring;
}




function clear_number(unformatNum) {
	var numero	= unformatNum;
	if (numero != "") { //solo suma si hay algo en el campo.
		//numero = numero.split(".").join("");
		numero = numero.split(",").join(".");
		numero = parseFloat(numero);
	}
	return numero;
}

function format_number(unformatNum) {
	var g	= '';
	var enteros;
	var decimales;
	partes = String(unformatNum).split(".");
	// Separamos enteros de decimales
	enteros		= partes[0];
	decimales	= partes[1];

	// Preparamos los decimales para mostrar
	decimales = (decimales != null) ? String(decimales).substring(0,2) : '00';
	if (decimales.length < 2) {
		decimales += '0';
	}

	// Preparamos los enteros
	cifras		= enteros.length;
	primerPunto = cifras%9;
	primerPunto = (primerPunto == 0) ? 9: primerPunto;

	// Colocamos los puntos a los miles
	anterior = 0;
	for (ff = primerPunto; ff <= cifras; ff+=3) {
		g += enteros.substring(anterior,ff) + ".";
		anterior = ff;
	}

	formatedNum = Math.round(g.substring(0,g.length-1)) + "." + Math.round(decimales);

	return formatedNum;

}

function set_price_tax() {
	var precio  = 0;
	var precioNeto	= clear_number($('price').value);

	//var impuesto = $('price_tax').value;

	var selectedIndexTax = $('price_tax').selectedIndex;
	var impuesto		 = $('price_tax').options[selectedIndexTax].value;

	precioNeto = precioNeto*1
	if (impuesto > 0) {
		precio = precioNeto + ((precioNeto * impuesto) / 100);
	} else {
		precio = precioNeto;
	}

	precio = format_number(precio);
	document.getElementById("price_pvp").value = precio;
}

*/


// Para una mejor validacion, usando javascript podemos abrir ventanas externas
// mediante el atributo rel="external" dentro de un <a>
function fix_external_links() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i = 0; i < anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("rel") && anchor.getAttribute("rel") == "external") {
			anchor.target = "_blank";
		}
	}
}

/*
function validarSiNumero(numero){
	if (!/^([0-9])*$/.test(numero)) {
		alert("El valor " + numero + " no es un número");
	}
}
*/

