function trim(myString) {
	return myString.replace(/^\s+/g, '').replace(/\s+$/g, '')
}

/* FUNCIONES DISPARADAS EN EL ONLOAD DE TODO EL SITIO */
/** *********************** */
var _Combobox = null;
var _ComboboxPuestos = null;
$(document).ready(function() {
	// REEMPLAZO DE TIPOGRAFIA
		Cufon.replace('.cufon');
		// REEMPLAZO COMBOBOX

		var _animationType = "slide";
		/*
		 * _Combobox = $('.combobox') .combobox( { comboboxContainerClass :
		 * "comboboxContainer", comboboxValueContentContainerClass :
		 * "comboboxValueContainer", comboboxValueContentClass :
		 * "comboboxValueContent", comboboxDropDownClass :
		 * "comboboxDropDownContainer", comboboxDropDownButtonClass :
		 * "comboboxDropDownButton", comboboxDropDownItemClass : "comboboxItem",
		 * comboboxDropDownItemHoverClass : "comboboxItemHover",
		 * comboboxDropDownGroupItemHeaderClass : "comboboxGroupItemHeader",
		 * comboboxDropDownGroupItemContainerClass :
		 * "comboboxGroupItemContainer"
		 *  }, { animationType : _animationType, width : 254 });
		 * 
		 * _ComboboxPuestos = $('#slt_puestos_tf') .combobox( {
		 * comboboxContainerClass : "comboboxContainer",
		 * comboboxValueContentContainerClass : "comboboxValueContainer",
		 * comboboxValueContentClass : "comboboxValueContent",
		 * comboboxDropDownClass : "comboboxDropDownContainer",
		 * comboboxDropDownButtonClass : "comboboxDropDownButton",
		 * comboboxDropDownItemClass : "comboboxItem",
		 * comboboxDropDownItemHoverClass : "comboboxItemHover",
		 * comboboxDropDownGroupItemHeaderClass : "comboboxGroupItemHeader",
		 * comboboxDropDownGroupItemContainerClass :
		 * "comboboxGroupItemContainer"
		 *  }, { animationType : _animationType, width : 254 });
		 */

		// Asigno funcion para md_estadisticas
		$('.btn_md_estadisticas').bind('click', function() {
			md_estadisticas();
		});

		$('.md_solapas li a').bind('click', function() {

			var slp = $(this).attr('href');

			$('.md_solapas li a').removeClass('selected')

			$(this).addClass('selected');

			$('.panel .tab').css('display', 'none');

			$(slp).css('display', 'block');

		});

		/* FUNCIONALIDAD FAQ */

		/*
		 * var flag_ffaq = 0; $('.item_faq').bind('click', function(){
		 * 
		 * var hijo = $(this).find("p");
		 * 
		 * if ( flag_ffaq == 0) { hijo.fadeIn();
		 * 
		 * flag_ffaq = 1; } else if (flag_ffaq == 1) { hijo.fadeOut();
		 * 
		 * flag_ffaq = 0; } })
		 */

	});// FIN ONLOAD

/** ****FUNCIONES********** */
/** *********************** */
/* FUNCION PARA EMULAR SUBMIT */
function submitform(id) {
	$(id).submit();
}
/* FUNCION PARA OCULTAR ELEMENTOS */
function ocultar(id) {
	alert(id);
	if (id == '.md_flash_alerta') {
		SetCookie('md_flash_alerta', '1', '10');
	}

	if (id == '.md_layer_msj') {
		SetCookie('md_layer_msj', '1', '10');
	}

	$(id).fadeOut();
}

/* FUNCION PARA SETEAR UNA COOKIE */

function SetCookie(cookieName, cookieValue, nDays) {	
	var today = new Date();
	var expire = new Date();
	if (nDays == null || nDays == 0)
		nDays = 1;
	expire.setTime(today.getTime() + 3600000 * 24 * nDays);
	document.cookie = cookieName + "=" + escape(cookieValue) + ";expires="
			+ expire.toGMTString();
}

/* FUNCION PARA ENMASCARAR BORDES DE ELEMENTOS EJ->SELECT MULTIPLE BORDER */
function setClip(id) {
	var element = document.getElementById(id);
	if (element != null) {
		var height = element.clientHeight - 3;
		var width = element.clientWidth - 3;
		element.style.position = "absolute";
		element.style.clip = "rect(" + 3 + "px " + width + "px " + height
				+ "px " + 3 + "px)";
	}

}

/* FUNCION PARA OCULTAR-MOSTRAR ELEMENTOS */
var flag_ocultar_mostrar = 0;

function ocultar_mostrar(id) {
	if (flag_ocultar_mostrar == 0) {
		$(id).fadeIn();

		flag_ocultar_mostrar = 1;

	} else if (flag_ocultar_mostrar == 1) {
		$(id).fadeOut();

		flag_ocultar_mostrar = 0;

	}
}

/* FUNCION MD ESTADISTICAS */
var flag_md_st = 0;
function md_estadisticas() {
	var md_st = $(".md_estadisticas");
	md_st.fadeIn();
	md_st.draggable( {
		axis : 'y',
		containment : '#content'
	});
	document.location.href = "#arqueros";
	$('.md_estadisticas .btn_close').bind('click', function() {
		md_st.fadeOut();
	});
	if (flag_md_st == 0) {
		$('.md_estadisticas .accordion').accordion();
	}
	flag_md_st = 1;
}
/*-----*/

/* FUNCION SWITCH PARA TESTEO */
var flag_switchTest = 1;
function switchTest(id1, id2) {

	if (flag_switchTest == 0) {
		$(id2).hide();
		$(id1).show();

		flag_switchTest = 1;

	} else if (flag_switchTest == 1) {
		$(id1).hide();
		$(id2).show();

		flag_switchTest = 0;

	}

}

