  function validateField(fieldName){
	if (document.getElementById(fieldName).value == ''){
		//document.getElementById(fieldName + '-error').style.display = 'block';
                //$("#" + fieldName + '-error').slideDown(800);
                $("#" + fieldName + '-error').fadeIn(800);
		return false;
	}else{
		return true;
	}
}

function validateCheck(fieldName){
	if (document.getElementById(fieldName).checked == 0){
		//document.getElementById(fieldName + '-error').style.display = 'block';
                //$("#" + fieldName + '-error').slideDown(800);
                $("#" + fieldName + '-error').fadeIn(800);
		return false;
	}else{
		return true;
	}
}

function prepareValidate(stringFields){
	var fields = stringFields.split(',');
	for (field in fields){
		document.getElementById(fields[field] + '-error').style.display = 'none';
	}
}

function oNumero(numero)
{
	//Propiedades
	this.valor = numero || 0
	this.dec = -1;
	//M�todos
	this.formato = numFormat;
	this.ponValor = ponValor;
	//Definici�n de los m�todos
	function ponValor(cad)
	{
		if (cad =='-' || cad=='+') return
		if (cad.length ==0) return
		if (cad.indexOf('.') >=0)
		this.valor = parseFloat(cad);
		else
		this.valor = parseInt(cad);
	}
	function numFormat(dec, miles)
	{
		var num = this.valor, signo=3, expr;
		var cad = ""+this.valor;
		var ceros = "", pos, pdec, i;
		for (i=0; i < dec; i++)
		ceros += '0';
		pos = cad.indexOf('.')
		if (pos < 0)
		cad = cad+"."+ceros;
		else
		{
			pdec = cad.length - pos -1;
			if (pdec <= dec)
			{
				for (i=0; i< (dec-pdec); i++)
				cad += '0';
			}
			else
			{
				num = num*Math.pow(10, dec);
				num = Math.round(num);
				num = num/Math.pow(10, dec);
				cad = new String(num);
			}
		}
		pos = cad.indexOf('.')
		if (pos < 0) pos = cad.lentgh
		if (cad.substr(0,1)=='-' || cad.substr(0,1) == '+')
		signo = 4;
		if (miles && pos > signo)
		do{
			expr = /([+-]?\d)(\d{3}[\.\,]\d*)/
			cad.match(expr)
			cad=cad.replace(expr, RegExp.$1+','+RegExp.$2)
		}
		while (cad.indexOf(',') > signo)
		if (dec<0) cad = cad.replace(/\./,'')
		return cad;
	}
}//Fin del objeto oNumero:


// Determina si es un valor numerico o no
function isNumeric(sText){
	var ValidChars = "0123456789.";
	var IsNumber=true;
	var Char;
	for (i = 0; i < sText.length && IsNumber == true; i++){
		Char = sText.charAt(i);
		if (ValidChars.indexOf(Char) == -1){
			IsNumber = false;
		}
	}
	return IsNumber;
}
// Colocar nobre al archivo de imagenes de esta forma:
// icon-font-more-on.png
// icon-font-more-off.png
function setHover(img){

	strUrl = img.src
	arrUrl = strUrl.split('/');
	imgDir = arrUrl[arrUrl.length-2];
	fileName = arrUrl[arrUrl.length-1];
	arrFileName = fileName.split('.');
	fileName = arrFileName[arrFileName.length-2];
	fileExt = arrFileName[arrFileName.length-1];

	fileName = fileName.split('-off');

	img.src = imgDir + "/" + fileName[0] + "-on." + fileExt;
}

// Colocar nobre al archivo de imagenes de esta forma:
// icon-font-more-on.png
// icon-font-more-off.png
function setOut(img){
	strUrl = img.src
	arrUrl = strUrl.split('/');
	imgDir = arrUrl[arrUrl.length-2];
	fileName = arrUrl[arrUrl.length-1];
	arrFileName = fileName.split('.');
	fileName = arrFileName[arrFileName.length-2];
	fileExt = arrFileName[arrFileName.length-1];
	fileName = fileName.split('-off');
	fileName = fileName[0].split('-on');
	img.src = imgDir + "/" + fileName[0] + "-off." + fileExt;
}


// Colocar nobre al archivo de imagenes de esta forma:
// icon-font-more-on.png
// icon-font-more-off.png
function setHoverUrl(img, imgDir){

	strUrl = img.src
	arrUrl = strUrl.split('/');
	//imgDir = arrUrl[arrUrl.length-2];
	fileName = arrUrl[arrUrl.length-1];
	arrFileName = fileName.split('.');
	fileName = arrFileName[arrFileName.length-2];
	fileExt = arrFileName[arrFileName.length-1];

	fileName = fileName.split('-off');

	img.src = imgDir + "/" + fileName[0] + "-on." + fileExt;
}

// Colocar nobre al archivo de imagenes de esta forma:
// icon-font-more-on.png
// icon-font-more-off.png
function setOutUrl(img, imgDir){
	strUrl = img.src
	arrUrl = strUrl.split('/');
	//imgDir = arrUrl[arrUrl.length-2];
	fileName = arrUrl[arrUrl.length-1];
	arrFileName = fileName.split('.');
	fileName = arrFileName[arrFileName.length-2];
	fileExt = arrFileName[arrFileName.length-1];
	fileName = fileName.split('-off');
	fileName = fileName[0].split('-on');
	img.src = imgDir + "/" + fileName[0] + "-off." + fileExt;
}


function trim(cadena)
{
	for(i=0; i<cadena.length; )
	{
		if(cadena.charAt(i)==" ")
		cadena = cadena.substring(i+1, cadena.length);
		else
		break;
	}
	for(i = cadena.length-1; i>=0; i = cadena.length-1)
	{
		if(cadena.charAt(i)==" ")
		cadena = cadena.substring(0,i);
		else
		break;
	}
	return cadena;
}

function getCookie(name){
	var cname = name + "=";
	var dc = document.cookie;
	if (dc.length > 0) {
		begin = dc.indexOf(cname);
		if (begin != -1) {
			begin += cname.length;
			end = dc.indexOf(";", begin);
			if (end == -1) end = dc.length;
			return unescape(dc.substring(begin, end));
		}
	}
	return null;
}

function setCookie(name, value, expires, path, domain, secure) {
	document.cookie = name + "=" + escape(value) +
	((expires == null) ? "" : "; expires=" + expires.toString()) +
	((path == null) ? "" : "; path=" + path) +
	((domain == null) ? "" : "; domain=" + domain) +
	((secure == null) ? "" : "; secure");
}

function delCookie(name,path,domain) {
	if (getCookie(name)) {
		document.cookie = name + "=" +
		((path == null) ? "" : "; path=" + path) +
		((domain == null) ? "" : "; domain=" + domain) +
		"; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}

function pullCookie(id){
	var classifields = getCookie('classifields');
	if(classifields == null){
		classifields = 'null_null_null_null';
	}
	var arrClass = classifields.split('_');
	class_1 = arrClass[0];
	class_2 = arrClass[1];
	class_3 = arrClass[2];
	class_4 = arrClass[3];

	if ((id != class_1) && (id != class_2) && (id != class_3) && (id != class_4)){
		// Mueve la cola
		class_4 = class_3;
		class_3 = class_2;
		class_2 = class_1;
		class_1 = id;
		// Borra las viejas
		delCookie('classifields', '/');
		classifields = class_1 + '_' + class_2 + '_' + class_3 + '_' + class_4;
		// Fecha de expiracion
		var expDays = 30;
		var exp = new Date();
		exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
		// Guarda los nuevos
		setCookie('classifields', classifields, exp, '/');
	}
}


/**
* JavaScript code to detect available availability of a
* particular font in a browser using JavaScript and CSS.
*
* Author : Lalit Patel
* Website: http://www.lalit.org/lab/jsoncookies
* License: Creative Commons Attribution-ShareAlike 2.5
*          http://creativecommons.org/licenses/by-sa/2.5/
* Version: 0.15
*          changed comparision font to serif from sans-serif,
*          as in FF3.0 font of child element didn't fallback
*          to parent element if the font is missing.
* Updated: 09 July 2009 10:52pm
*
*/

/**
* Actual function that does all the work. Returns an array with all the info.
* This test will fail for the font set as the default serif font.
*
* Usage: d = new Detector();
*        d.test('font_name');
*/
var Detector = function(){
	var h = document.getElementsByTagName("BODY")[0];
	var d = document.createElement("DIV");
	var s = document.createElement("SPAN");
	d.appendChild(s);
	d.style.fontFamily = "sans";			//font for the parent element DIV.
	s.style.fontFamily = "sans";			//serif font used as a comparator.
	s.style.fontSize   = "72px";			//we test using 72px font size, we may use any size. I guess larger the better.
	s.innerHTML        = "mmmmmmmmmmlil";		//we use m or w because these two characters take up the maximum width. And we use a L so that the same matching fonts can get separated
	h.appendChild(d);
	var defaultWidth   = s.offsetWidth;		//now we have the defaultWidth
	var defaultHeight  = s.offsetHeight;	//and the defaultHeight, we compare other fonts with these.
	h.removeChild(d);
	/* test
	* params:
	* font - name of the font you wish to detect
	* return:
	* f[0] - Input font name.
	* f[1] - Computed width.
	* f[2] - Computed height.
	* f[3] - Detected? (true/false).
	*/
	function debug(font) {
		h.appendChild(d);
		var f = [];
		f[0] = s.style.fontFamily = font;	// Name of the font
		f[1] = s.offsetWidth;				// Width
		f[2] = s.offsetHeight;				// Height
		h.removeChild(d);
		font = font.toLowerCase();
		if (font == "serif") {
			f[3] = true;	// to set arial and sans-serif true
		} else {
			f[3] = (f[1] != defaultWidth || f[2] != defaultHeight);	// Detected?
		}
		return f;
	}
	function test(font){
		f = debug(font);
		return f[3];
	}
	this.detailedTest = debug;
	this.test = test;
}

function switchColor(id, color){
	document.getElementById(id).style.color = color;
}

/*
Browser name: BrowserDetect.browser
Browser version: BrowserDetect.version
OS name: BrowserDetect.OS
*/
var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
			versionSearch: "Version"
		},
		{
			prop: window.opera,
			identity: "Opera",
			versionSearch: "Version"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			   string: navigator.userAgent,
			   subString: "iPhone",
			   identity: "iPhone/iPod"
	    },
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();

