function verVideoPrincipal(intId){
	div = document.getElementById("divVideoPrincipal");
	div.innerHTML = '<img src="images/ajax.gif">';
	ajaxHTML("GET", "ajaxVideoPrincipal.php?id=" + intId, div);
}
/*
function verPaginaVideosPrincipal(intPagina, intId, intTipo){
	div = document.getElementById("divGaleriaVideosFicha");
	div.innerHTML = '<img src="images/ajax.gif">';
	ajaxHTML("GET", "ajaxVideosPrincipal.php?pagina=" + intPagina + "&id=" + intId + "&tipo=" + intTipo, div);
}
*/

function verVideoFicha(intId,idioma){
	div = document.getElementById("divVideoFicha");
	div.innerHTML = '<img src="images/ajax.gif">';
	ajaxHTML("GET", "ajaxTabVideoFicha.php?id=" + intId+ "&l="+idioma, div);
}

function verPaginaVideosFicha(intPagina, intId, intTipo,idioma ){
	div = document.getElementById("divGaleriaVideosFicha");
	div.innerHTML = '<img src="images/ajax.gif">';
	ajaxHTML("GET", "ajaxTabVideos.php?pagina=" + intPagina + "&id=" + intId + "&tipo=" + intTipo+"&l="+idioma, div);
}

function verPaginaArchivosFicha(intPagina, intId, intTipo){
	div = document.getElementById("divArchivosFicha");
	div.innerHTML = '<img src="images/ajax.gif">';
	ajaxHTML("GET", "ajaxTabArchivos.php?pagina=" + intPagina + "&id=" + intId + "&tipo=" + intTipo, div);
}

function borrarFicha(intId, intTipo){
	if(confirm("¿Estás seguro de querer eliminar todos los datos?")){
		div = document.getElementById("divBorrarFicha_" + intId + "_" + intTipo);
		div.innerHTML = 'Borrando...';
		simple_ajax("ajaxBorrarFicha.php", "POST","id=" + intId + "&tipo=" + intTipo);
	}
}


function cambiaPagina(intPagina){
	var frm = document.Form;
	frm.hidPagina.value = intPagina;
	//frm.hidOrdenLB.value = "";
	//frm.hidCampoOrdenLB.value = "";
	frm.submit();

}

function InsertarComentario(intIdDestino, intTipo){
	var strValues = "dest="+intIdDestino+"&tipo="+intTipo+"&txtComentario="+document.getElementById("txtComentario").value;
	var div = document.getElementById("divComentarios")
	var strFunction = "actualizarTotal()"
	ajaxHTML("POST", "ajaxComentar.php", div, strValues, strFunction);
}
function InsertarComentario2(intIdDestino, intTipo){
	var strValues = "dest="+intIdDestino+"&tipo="+intTipo+"&txtComentario="+document.getElementById("txtComentario").value+"&txtUsuario="+document.getElementById("txtUsuario").value+"&txtEmail="+document.getElementById("txtEmail").value+"&txtPassword1="+document.getElementById("txtPassword1").value;
	var div = document.getElementById("divComentarios")
	var strFunction = "actualizarTotal()"
	ajaxHTML("POST", "ajaxComentar2.php", div, strValues, strFunction);
}


function mostrarInvitar(){
	if(document.getElementById("divInvitar").style.display == "none") {
		document.getElementById("divInvitar").style.display = "block";
	} else {
		document.getElementById("divInvitar").style.display = "none";
	}
}

function enviarInvitacion(intId, intTipo){
	var frm = document.FormInvitacion;
		var strError = '';
		var objCheck = new check("FormInvitacion");
		
		objCheck.checkEmail("txtEmail", "Email", 1, 255, false);
		objCheck.checkString("txtMensaje", "Mensaje", 1, 255, true);
		
		strError = objCheck.toString();
		if(strError == "") {
			
			var strValues = "id="+intId+"&tipo="+intTipo+"&email="+frm.txtEmail.value+"&txtMensaje="+frm.txtMensaje.value;
			document.getElementById("spanInvitacion").innerHTML = "<img src='images/ajax.gif'>"
			simple_ajax("ajaxEnviarInvitacion.php", "POST", strValues);
		} else {
			alert(strError);
		}
	
	
}

function ordenLB(sField) {
		var frm = document.Form;
		if(frm.hidCampoOrdenLB.value==sField) {
			if(frm.hidOrdenLB.value=="ASC") {
				frm.hidOrdenLB.value = "DESC";
			} else {
				frm.hidOrdenLB.value = "ASC";
			}
		} else {
			frm.hidOrdenLB.value = "ASC";
			frm.hidCampoOrdenLB.value = sField;
		} 
		//frm.hidPagina.value = "";
		frm.submit();
	}
	
function ordenLBDESC(sField) {
		var frm = document.Form;
		if(frm.hidCampoOrdenLB.value==sField) {
			if(frm.hidOrdenLB.value=="ASC") {
				frm.hidOrdenLB.value = "DESC";
			} else {
				frm.hidOrdenLB.value = "ASC";
			}
		} else {
			frm.hidOrdenLB.value = "DESC";
			frm.hidCampoOrdenLB.value = sField;
		} 
		//frm.hidPagina.value = "";
		frm.submit();
	}


function borrarFoto(intIdFoto, tipo, id) {
	if(confirm("¿Estás seguro de querer eliminar esta foto?")){
		div = document.getElementById("divBorrarFoto_" + intIdFoto);
		div.innerHTML = '<img src="images/uploading.gif"> borrando...';
		simple_ajax("ajaxBorrarFoto.php", "POST","foto=" + intIdFoto + "&tipo=" + tipo + "&id=" + id);
	}
}

function borrarVideo(intIdVideo, tipo, id) {
	if(confirm("¿Estás seguro de querer eliminar este video?")){
		div = document.getElementById("divBorrarVideo_" + intIdVideo);
		div.innerHTML = '<img src="images/uploading.gif"> borrando...';
		simple_ajax("ajaxBorrarVideo.php", "POST","video=" + intIdVideo + "&tipo=" + tipo + "&id=" + id);
	}
}

function borrarArchivo(intIdArchivo, tipo, id) {
	if(confirm("¿Estás seguro de querer eliminar este archivo?")){
		div = document.getElementById("divBorrarArchivo_" + intIdArchivo);
		div.innerHTML = '<img src="images/uploading.gif"> borrando...';
		simple_ajax("ajaxBorrarArchivo.php", "POST","archivo=" + intIdArchivo + "&tipo=" + tipo + "&id=" + id);
	}
}

function enviarInapropiado(intIdUsuario, intId, intTipo){
	var frm = document.Form;
	var strError = '';
	var objCheck = new check("Form");
	objCheck.checkString("txtMensajeInapropiado", "mensaje", 1, 500, false);
	
	strError = objCheck.toString();
	if(strError == "") {

		div = document.getElementById("divInapropiado");
		var strMensaje = frm.txtMensajeInapropiado.value;
		div.innerHTML = '<img src="images/ajax.gif"> Enviando mensaje...';

		ajaxHTML("POST", "ajaxInapropiado.php", div, "usuario=" + intIdUsuario + "&id=" + intId + "&tipo=" + intTipo + "&mensaje=" + strMensaje);
	} else {
		alert(strError);
	}
}
function borrarFotos(){
		if(document.getElementById("divBorrarFotos").style.display == "none") {
			document.getElementById("divBorrarFotos").style.display ="block";
		} else {
			document.getElementById("divBorrarFotos").style.display ="none";
		}
}
function verInapropiado() {
	document.getElementById("divInapropiado").style.display ="block";
}

function ocultarInapropiado(){
	document.getElementById("divInapropiado").style.display ="none";
}

function cambiarSolapa() {
			if(document.getElementById("Fotos").src.indexOf("fotos_.png") > 0) {
				MM_swapImage('Fotos','','images/player/videos_.png',1)
				document.getElementById("divPlayerVideo").style.display = "block";
				document.getElementById("divPlayerFotos").style.display = "none";
			} else {
				MM_swapImage('Fotos','','images/player/fotos_.png',1)
				document.getElementById("divPlayerVideo").style.display = "none";
				document.getElementById("divPlayerFotos").style.display = "block";
			}	
		}

function mostrarVideo() {
	if(document.getElementById("divVideo").style.display == "none") {
		document.getElementById("divVideo").style.display ="block";
		document.getElementById("divSubirVideo").style.display ="none";
		document.getElementById("divSubirVideoEnlace").style.display ="none";
	} else {
    	document.getElementById("divVideo").style.display ="none";
	}	
}

function mostrarFoto() {
	if(document.getElementById("divImagen").style.display == "none" || document.getElementById("hidProducto").value == "1") {
		document.getElementById("divImagen").style.display ="block";
		document.getElementById("hidProducto").value = "0";
		document.getElementById("txtUploader").innerHTML = "Pulsa el bot&oacute;n para subir todas tus fotos.<br />Puedes seleccionar hasta 50 fotos cada vez<br />";
	} else {
    	document.getElementById("divImagen").style.display ="none";
	}	
}

function mostrarProducto() {
	if(document.getElementById("divImagen").style.display == "none" || document.getElementById("hidProducto").value == "0") {
		document.getElementById("divImagen").style.display ="block";
		document.getElementById("hidProducto").value = "1";
		document.getElementById("txtUploader").innerHTML = "Pulsa el bot&oacute;n para subir las fotos de tus productos<br />Puedes seleccionar hasta 30 fotos cada vez. Al terminar podr&aacute;s a&ntilde;adirle m&aacute;s datos como el t&iacute;tulo y la descripci&oacute;n<br />"; 
	} else {
    	document.getElementById("divImagen").style.display ="none";
		
	}	
}



function subirImagen() {
	var frm = document.Form;
	
	if(frm.txtFoto.value != "") {
		arrExt = frm.txtFoto.value.split(".");
		if(arrExt[arrExt.length-1].toLowerCase() != "jpg" && arrExt[arrExt.length-1].toLowerCase() != "jpeg" && arrExt[arrExt.length-1].toLowerCase() != "png" && arrExt[arrExt.length-1].toLowerCase() != "gif") {	
			alert('Por favor, seleccione un archivo JPG, PNG o GIF');
			return;
		}
		frm.hidEnviarFoto.value="1";
		frm.hidEnviar.value="1";
		document.getElementById("lbl1").innerHTML = '<img src="images/uploading.gif">subiendo archivo, un momento por favor...';
		frm.submit();
		
	} else {
		alert('Por favor, seleccione un archivo JPG, PNG o GIF');
	}
	
}


function mostrarArchivo() {
	if(document.getElementById("divArchivo").style.display == "none") {
		document.getElementById("divArchivo").style.display ="block";
	} else {
    	document.getElementById("divArchivo").style.display ="none";
	}	
}

function subirArchivo() {
	var frm = document.Form;
	
	if(frm.txtArchivo.value != "") {
		arrExt = frm.txtArchivo.value.split(".");
		if(arrExt[arrExt.length-1].toLowerCase() != "jpg" && arrExt[arrExt.length-1].toLowerCase() != "jpeg" && arrExt[arrExt.length-1].toLowerCase() != "doc" && arrExt[arrExt.length-1].toLowerCase() != "docx" && arrExt[arrExt.length-1].toLowerCase() != "xls" && arrExt[arrExt.length-1].toLowerCase() != "xlsx" && arrExt[arrExt.length-1].toLowerCase() != "pdf" && arrExt[arrExt.length-1].toLowerCase() != "odt" && arrExt[arrExt.length-1].toLowerCase() != "txt") {	
			alert('Por favor, seleccione un archivo JPG, PDF, ODT, DOC, XLS o TXT');
			return;
		}
		frm.hidEnviarArchivo.value="1";
		document.getElementById("lblArchivo").innerHTML = '<img src="images/uploading.gif">subiendo archivo, un momento por favor...';
		frm.submit();
		
	} else {
		alert('Por favor, seleccione un archivo válido');
	}
	
}

function subirVideoEnlace() {
	var frm = document.Form;
	var strError = '';
	var objCheck = new check("Form");
	//objCheck.checkString("txtTituloVideo", "título del video", 1, 100, false);	
	if(frm.txtVideoEnlace.value == "") {
		alert('Inserte la URL del video');
		return;	
	}	
		
	if(frm.txtVideoEnlaceTipo.value != 3) {	
	
		
		if((frm.txtVideoEnlace.value.indexOf("http://www.mallorcatube.com/view_video.php?viewkey=") == 0 && frm.txtVideoEnlaceTipo.value == 1) || (frm.txtVideoEnlace.value.indexOf("http://www.balearestube.com/videos/") == 0  && frm.txtVideoEnlaceTipo.value == 2) || (frm.txtVideoEnlace.value.indexOf("v=") > 0 && frm.txtVideoEnlaceTipo.value == 1)) {
			
			
			if((frm.txtVideoEnlace.value.indexOf("http://www.mallorcatube.com/view_video.php?viewkey=") == 0 && frm.txtVideoEnlace.value.slice(51).length != 20 && frm.txtVideoEnlace.value.indexOf("http://www.balearestube.com/videos/") != 0) || (frm.txtVideoEnlace.value.indexOf("http://www.balearestube.com/videos/") == 0 && frm.txtVideoEnlace.value.slice(35).length <= 0 && frm.txtVideoEnlace.value.indexOf("http://www.mallorcatube.com/view_video.php?viewkey=") != 0)) {
				alert('La URL del video es inválida');
				return;	
			}
			
		} else {
			
			alert('La URL del video es inválida');
			return;	
		}

	}

	strError = objCheck.toString();
	if(strError == "") {
		
		frm.hidEnviarVideoEnlace.value="1";	
		document.getElementById("lblVideo").innerHTML = '<img src="images/uploading.gif"> un momento por favor...';
		frm.submit();
		
	} else {
		alert(strError);
		
	}

}


function subirVideo__() {
	var frm = document.Form;
	var strError = '';
	var objCheck = new check("Form");
	objCheck.checkString("txtTitulovideo", "título del video", 1, 60, false);

	strError = objCheck.toString();
	if(strError == "") {
		//chequear si la imagen es JPG o JPEG
		if(frm.filImagenVideo.value != "") {
			arrExt = frm.filImagenVideo.value.split(".");
			if(arrExt[arrExt.length-1].toLowerCase() != "jpg" && arrExt[arrExt.length-1].toLowerCase() != "jpeg") {	
				alert('Por favor, seleccione un archivo de video');
				return;
			}
		}
		
		
		//chequear si el archivo esta lleno, y es flv.
		if(frm.filVideo.value == "") {
			alert('Por favor, seleccione un archivo FLV');
			return;
		}
		arrExt = frm.filVideo.value.split(".");
		if(arrExt[arrExt.length-1].toLowerCase() != "flv") {
			alert('El archivo debe ser de formato FLV');
			return;
		} else {
			frm.hidEnviarVideo.value="1";	
			document.getElementById("lbl3").innerHTML = '<img src="images/uploading.gif">subiendo archivo, un momento por favor...';
			frm.submit();
		}
		
	} else {
		alert(strError);
		
	}

}

function verVideo(intIdVideo, intId, tipo, borrar) {
	div = document.getElementById("divPlayerVideo");
	div.height="250";
	div.innerHTML = '<img src="images/ajax.gif">';
	
	ajaxHTML("GET", "ajaxVerVideo.php?borrar="+borrar+"&tipo="+tipo+"&id="+intId+"&video=" + intIdVideo, div);
}



function subirVideo_() {
	var frm = document.Form;
	var strError = '';
	var objCheck = new check("Form");
	objCheck.checkString("txtTituloVideo", "título del video", 1, 100, false);	
	if(frm.txtCodigoVideo.value == "") {
			alert('Inserte el código embebido del video por favor.');
			return;	
		}	
		
		if(frm.txtCodigoVideo.value.toUpperCase().indexOf("SCRIPT") > 0) {
			alert('El campo código embebido es inválido');
			return;	
		}	
		if(frm.txtCodigoVideo.value.toUpperCase().indexOf("EMBED") == 0) {
			alert('El campo código embebido es inválido');
			return;	
		}	

	strError = objCheck.toString();
	if(strError == "") {
		
		frm.hidEnviarVideo.value="1";	
		document.getElementById("lbl3").innerHTML = '<img src="images/uploading.gif">un momento por favor...';
		frm.submit();
		
	} else {
		alert(strError);
		
	}

}

function mostrarMp3() {
	if(document.getElementById("divMp3").style.display == "none") {
		document.getElementById("divMp3").style.display ="block";
	} else {
    	document.getElementById("divMp3").style.display ="none";
	}	
}

function subirMp3() {


var frm = document.Form;
var strError = '';
var objCheck = new check("Form");
objCheck.checkString("txtTitulomp3", "título del mp3", 1, 60, false);

strError = objCheck.toString();
if(strError == "") {
	//chequear si el archivo esta lleno, y es mp3.
	if(frm.filMp3.value == "") {
		alert('Por favor, seleccione un archivo MP3');
		return;
	}
	arrExt = frm.filMp3.value.split(".");
	if(arrExt[arrExt.length-1].toLowerCase() != "mp3") {
		alert('El archivo debe ser de formato MP3');
		return;
	} else {
		frm.hidEnviarMp3.value="1";	
		document.getElementById("lbl2").innerHTML = '<img src="images/uploading.gif">subiendo archivo, un momento por favor...';
		frm.submit();
	}
	
} else {
	alert(strError);
	
}


}

/*
function BuscarTag(strTag, intOpc) {
	switch(intOpc) {
		case 2: 
				document.forms[1].action = "listado_grupos.php";
				document.forms[1].hidBuscadorTag.value = strTag;
				document.forms[1].submit();				
				break;
		case 1: 
				document.forms[1].action = "listado_usuarios.php";
				document.forms[1].hidBuscadorTag.value = strTag;
				document.forms[1].submit();				
				break;		
		case 0: 
				document.forms[1].action = "listado_general.php";
				document.forms[1].hidBuscadorTag.value = strTag;
				document.forms[1].submit();				
				break;
		case 3: 
				document.forms[1].action = "listado_eventos.php";
				document.forms[1].hidBuscadorTag.value = strTag;
				document.forms[1].submit();				
				break;				
	} 
}
*/
function BuscarTag(strTag) {
		var frm = document.FormTag;
		with(frm) {
		method = "get";
		}
 		var strError = '';
		var objCheck = new check("FormTag");
		frm.hidTag.value = strTag;
		objCheck.checkString("hidTag", "buscador de tags", 1, 1000, false);
		
		strError = objCheck.toString();
		if(strError == "") {
			frm.submit();
		} else {
			alert(strError);
			
		}
}

function BuscadorGeneral() {
		var frm = document.FormBuscador;
		var strError = '';
		var objCheck = new check("FormBuscador");
		LimpiarCampo(frm.txtBuscadorG, 'Introduce aqui tu búsqueda');
		objCheck.checkString("txtBuscadorG", "buscador general", 3, 1000, false);
		
		strError = objCheck.toString();
		if(strError == "") {
			frm.submit();
		} else {
			alert(strError);
			
		}
}

function BuscadorGrupos() {
	var frm = document.Form;
		var strError = '';
		var objCheck = new check("Form");
		
		objCheck.checkString("txtBuscadorGrupo", "tags", 3, 1000, false);
		
		strError = objCheck.toString();
		if(strError == "") {
			frm.action="listado_grupos.php";
			frm.submit();
		} else {
			alert(strError);
		}
}

function BuscadorUsuarios() {
	var frm = document.Form;
		var strError = '';
		var objCheck = new check("Form");
		
		objCheck.checkString("txtBuscadorUsuario", "tags", 3, 1000, false);
		
		strError = objCheck.toString();
		if(strError == "") {
			frm.action="listado_usuarios.php";
			frm.submit();
		} else {
			alert(strError);
		}
}

function verImagen(intOpc) {
	if(intOpc == 1) {
		document.getElementById("divImagen1").style.display = "none";
		document.getElementById("divImagen2").style.display = "block";
	} else {
		document.getElementById("divImagen2").style.display = "none";
		document.getElementById("divImagen1").style.display = "block";
	}	
}

function verPass(intOpc) {
	if(intOpc == 1) {
		document.getElementById("divPass1").style.display = "none";
		document.getElementById("divPass2").style.display = "block";
	} else {
		document.getElementById("divPass2").style.display = "none";
		document.getElementById("divPass1").style.display = "block";
	}	
}

function actualizarImagen(){
	div = document.getElementById("divImg");
	div.innerHTML = '<img src="images/ajax.gif">';
	ajaxHTML("GET", "ajaxCaptcha.php", div);
}

function LimpiarCampo(objText, strValue){
	if(objText.value == strValue) {
		objText.value = "";
	}
}

function emptyObjCmb(obj){
		for (i=0; i < obj.length; i++) {
	 		obj.options[i] = null;
	 	}
	 	obj.options.length = 0;
}

function mostrarResponderMensajePrivado(intIdMensaje) {
	if(document.getElementById("divMensajePrivado_"+intIdMensaje).style.display == "block"){
		document.getElementById("divMensajePrivado_"+intIdMensaje).style.display = "none";
	} else {
		document.getElementById("divMensajePrivado_"+intIdMensaje).style.display = "block";
		document.getElementById("txtComentario").focus();
	};
	
}


function responderMensajePrivado(intIdEmisor, intTipoEmisor, intIdReceptor, intTipoReceptor, intIdCadena, intPagina){
	var frm = document.FormMensajePrivado;
		var strError = '';
		var objCheck = new check("FormMensajePrivado");
		
		
		
		objCheck.checkString("txtMensaje_"+intIdCadena, "mensaje privado", 1, 5000, true);
		
		strError = objCheck.toString();
		if(strError == "") {
			
			var strValues = "pagina="+intPagina+"&emisor="+intIdEmisor+"&tipo_emisor="+intTipoEmisor+"&receptor="+intIdReceptor+"&tipo_receptor="+intTipoReceptor+"&txtMensaje="+document.getElementById("txtMensaje_"+intIdCadena).value+"&id_cadena="+intIdCadena;
			document.getElementById("divMensajePrivado_"+intIdCadena).innerHTML = "<img src='images/ajax.gif'>"
			//simple_ajax("ajaxEnviarMensajePrivado.php", "POST", strValues);
			
			var div = document.getElementById("divConversaciones")
			var strFunction = "actualizarTotal()"
			ajaxHTML("POST", "ajaxConversacion.php", div, strValues, strFunction);
			
		} else {
			alert(strError);
		}
	
	
}

function verMensajePagina(intPagina, intId, intTipo){
	var strValues = "pagina=" + intPagina + "&receptor=" + intId + "&tipo_receptor=" + intTipo;
	div = document.getElementById("divConversaciones");
	div.innerHTML = '<img src="images/ajax.gif">';
	ajaxHTML("POST", "ajaxConversacion.php", div,strValues);
}


function comentar() {
	if(document.getElementById("divComentario").style.display == "block"){
		document.getElementById("divComentario").style.display = "none";
	} else {
		document.getElementById("divComentario").style.display = "block";
		document.getElementById("txtComentario").focus();
	};
	
}



function publicarComentario(intIdDestino, intTipo) {
		var frm = document.FormComentario;
		var strError = '';
		var objCheck = new check("FormComentario");
		
		/* Limpio los campos */
		LimpiarCampo(frm.txtComentario, 'Escribe aquí tu comentario...');
		
		objCheck.checkString("txtComentario", "comentario", 5, 10000, false);

			
		strError = objCheck.toString();
		
		if (strError == "") {
			document.getElementById("divComentario").style.display = "none";
			document.getElementById("divComentarios").innerHTML = "<img src='images/ajax.gif'>";
			document.getElementById("txtComentario").value = strReplace(document.getElementById("txtComentario").value, "&", "[amp]");
			InsertarComentario(intIdDestino, intTipo);
			document.getElementById("txtComentario").value = "Escribe aquí tu comentario...";
		} else {
			alert(strError);
		}
}

function publicarComentario2(intIdDestino, intTipo) {
		var frm = document.FormComentario;
		var strError = '';
		var objCheck = new check("FormComentario");
		
		/* Limpio los campos */
		LimpiarCampo(frm.txtComentario, 'Escribe aquí tu comentario...');
		
		objCheck.checkString("txtComentario", "comentario", 5, 10000, false);
objCheck.checkString("txtUsuario", "Usuario", 3, 10000, false);
objCheck.checkString("txtPassword1", "Password", 3, 10000, false);
objCheck.checkString("txtEmail", "Email", 5, 10000, false);

			
		strError = objCheck.toString();
		
		if (strError == "") {
			document.getElementById("divComentario").style.display = "none";
			document.getElementById("divComentarios").innerHTML = "<img src='images/ajax.gif'>";
			document.getElementById("txtComentario").value = strReplace(document.getElementById("txtComentario").value, "&", "[amp]");
			InsertarComentario2(intIdDestino, intTipo);
			//document.getElementById("txtComentario").value = "Escribe aquí tu comentario...";
		} else {
			alert(strError);
		}
}

function verComentarioPagina(intPagina, intId, intTipo){
	div = document.getElementById("divComentarios");
	div.innerHTML = '<img src="images/ajax.gif">';
	ajaxHTML("GET", "ajaxComentar.php?pagina=" + intPagina + "&id=" + intId + "&tipo=" + intTipo, div);
}


function login(frm){
	frm.action="login.php";
	frm.submit();
}

function verPagina(strPagina) {
	document.Form.action = strPagina;
	document.Form.submit();
}


function volver (){
 history.back()	
}


/**
 * @author Alexander Farkas
 * v. 1.02
 */
(function($1) {
	$1.extend($1.fx.step,{
	    backgroundPosition: function(fx) {
            if (fx.state === 0 && typeof fx.end == 'string') {
                var start = $1.curCSS(fx.elem,'backgroundPosition');
                start = toArray(start);
                fx.start = [start[0],start[2]];
                var end = toArray(fx.end);
                fx.end = [end[0],end[2]];
                fx.unit = [end[1],end[3]];
			}
            var nowPosX = [];
            nowPosX[0] = ((fx.end[0] - fx.start[0]) * fx.pos) + fx.start[0] + fx.unit[0];
            nowPosX[1] = ((fx.end[1] - fx.start[1]) * fx.pos) + fx.start[1] + fx.unit[1];
            fx.elem.style.backgroundPosition = nowPosX[0]+' '+nowPosX[1];

           function toArray(strg){
               strg = strg.replace(/left|top/g,'0px');
               strg = strg.replace(/right|bottom/g,'100%');
               strg = strg.replace(/([0-9\.]+)(\s|\)|$)/g,"$1px$2");
               var res = strg.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);
               return [parseFloat(res[1],10),res[2],parseFloat(res[3],10),res[4]];
           }
        }
	});
})(jQuery);
//check_.js
function check(strForm) {
	//Properties
	this.strForm = strForm;
	this.arrErrors = new Array();

	//Methods
	this.getInput = check_getInput;
	this.getNextPosition = check_getNextPosition;
	this.checkError = check_checkError;
	this.checkFixedError = check_checkFixedError;
	this.isDate = check_isDate;

	this.checkString = check_string;
	this.checkFixedString = check_fixedString;
	this.checkNumber = check_number;
	this.checkNumberPos = check_numberPos;
	this.checkFloat = check_float;
	this.checkDate = check_date;
	this.checkEmail = check_email;
	this.checkCombo = check_combo;
	this.compareDates = check_compareDates;
	this.toString = check_toString;
}

function check_getInput (strInput) {
	return eval("document." + this.strForm + "." + strInput);
}

function check_getNextPosition () {
	return this.arrErrors.length;
}

function check_checkError (objInput, strNameShow, strRegExp, intMinLen, intMaxLen, blnOptional, strErrorMessage) {
	var intPosition = this.getNextPosition();
	var objRegExp = new RegExp(strRegExp);
var strin=objInput.value;
//strin=(strin.replace(/\´/g, "´"));
    strin=(strin.replace(/\'/g, "´"));
	
//	strin=(strin.replace(/\''/g, "´"));
    objInput.value=(strin.replace(/\"/g, "´"));
	
	if (!objInput.value.length) {
		if (!blnOptional){
			this.arrErrors[intPosition] = "El campo " + strNameShow + " no puede estar vacío";
			return false;
		}else
			return true;
	}else{
		if ((!objRegExp.test(objInput.value))) {
			this.arrErrors[intPosition] = "El campo " + strNameShow + (strErrorMessage ? strErrorMessage : " contiene caracteres inválidos" );
			return false;
		}else if (objInput.value.length < intMinLen) {
				this.arrErrors[intPosition] = "El campo " + strNameShow + " debe tener más de " + intMinLen + " caracteres";
				return false;
			}else if (objInput.value.length > intMaxLen) {
					this.arrErrors[intPosition] = "El campo " + strNameShow + " no debe tener más de " + intMaxLen + " caracteres";
					return false;
				}
				else
					return true;
	}
}

function check_checkFixedError (objInput, strNameShow, strRegExp, intLen, blnOptional, strErrorMessage) {
	var intPosition = this.getNextPosition();
	var objRegExp = new RegExp(strRegExp);
	
	if (!objInput.value.length) {
		if (!blnOptional){
			this.arrErrors[intPosition] = "El campo " + strNameShow + " no puede estar vacío";
			return false;
		}else
			return true;
	}else{
		if ((!objRegExp.test(objInput.value))) {
			this.arrErrors[intPosition] = "El campo " + strNameShow + (strErrorMessage ? strErrorMessage : " contiene caracteres inválidos" );
			return false;
		}else if (objInput.value.length != intLen) {
				this.arrErrors[intPosition] = "El campo " + strNameShow + " debe tener " + intLen + " caracteres";
				return false;
			} else
				return true;
	}
}

function check_isDate(datFecha) {
	var arrFecha = datFecha.split("/");
	var datFechaValida = new Date(arrFecha[2], arrFecha[1] - 1, arrFecha[0]);

	if ((arrFecha[0] == datFechaValida.getDate()) && 
		(arrFecha[1] == (datFechaValida.getMonth() + 1)) && 
		(arrFecha[2] == datFechaValida.getFullYear()))
		return true;
	else
		return false;
}

function check_string (strInput, strNameShow, intMinLen, intMaxLen, blnOptional) {
	var objInput = this.getInput(strInput);
	var strRegExp = "^[^<>]+$";

	return this.checkError(objInput, strNameShow, strRegExp, intMinLen, intMaxLen, blnOptional, false);
}

function check_fixedString (strInput, strNameShow, intLen, blnOptional) {
	var objInput = this.getInput(strInput);
	var strRegExp = "^[^<>]+$";

	return this.checkFixedError(objInput, strNameShow, strRegExp, intLen, blnOptional, false);
}

function check_number (strInput, strNameShow, intMinLen, intMaxLen, blnOptional) {
	var objInput = this.getInput(strInput);
	var strRegExp = "^[0-9]+$";

	return this.checkError(objInput, strNameShow, strRegExp, intMinLen, intMaxLen, blnOptional, false);
}

function check_numberPos (strInput, strNameShow, intMinLen, intMaxLen, blnOptional) {
	var objInput = this.getInput(strInput);
	var strRegExp = "^[0-9]+$";
	
	if (this.checkError(objInput, strNameShow, strRegExp, intMinLen, intMaxLen, blnOptional, "El campo " + strNameShow + " debe ser positivo")) {
		if (objInput.value > 0)
			return true;
		else {
			this.arrErrors[this.getNextPosition()] = "El campo " + strNameShow + " debe ser positivo";
			return false;
		}
	} else
		return false;
}

function check_float (strInput, strNameShow, intMinLen, intMaxLen, blnOptional) {
	var objInput = this.getInput(strInput);
	var strRegExp = "^[0-9]+(\\,[0-9]+)?$";

	return this.checkError(objInput, strNameShow, strRegExp, intMinLen, intMaxLen, blnOptional, false);
}

function check_date (strInput, strNameShow, blnOptional) {
	var objInput = this.getInput(strInput);
	var strRegExp = "^[0-9]{1,2}\/[0-9]{1,2}\/[0-9]{4}";
	var intPosition;
	
	if ((objInput.value.length == 0) && (blnOptional)) return true;
	if (this.checkError(objInput, strNameShow, strRegExp, 8, 10, blnOptional, " no contiene una fecha válida"))
		if (!this.isDate(objInput.value)) {
			var intPosition = this.getNextPosition();
			this.arrErrors[intPosition] = "El campo " + strNameShow + " no contiene una fecha válida";
			return false;
		} else
			return true;
}

function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}
 
function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}
function check_email (strInput, strNameShow, intMinLen, intMaxLen, blnOptional) {
strInput=trim(strInput)
//str.replace(new RegExp("[" + chars + "]+$", "g"), "");
//chars = chars || "\\s";


	var objInput = this.getInput(strInput);
	var strRegExp = "^\\w+([\\.-]?\\w+)*@\\w+([\\.-]?\\w+)*(\\.\\s\\w{2,3})+$";
//return true;
//	return this.checkError(objInput, strNameShow, strRegExp, intMinLen, intMaxLen, blnOptional, false);
}

function check_combo (strInput, strNameShow, blnOptional) {
	var objInput = this.getInput(strInput);
	
	if (blnOptional) {
		return true;
	}
	else {
		if (objInput.selectedIndex > 0) {
			return true;
		}
		else {
			var intPosition = this.getNextPosition();
			this.arrErrors[intPosition] = "No has seleccionado ninguna opción para el campo " + strNameShow;

			return false;
		}
	}
}

function check_compareDates(strInput1, strInput2, strUnidad) {
	if ((!this.isDate(strInput1)) || (!this.isDate(strInput2)))
		return null;
	
//	Si son fechas válidas, las paso a arrays para compararlas.
	var arrFecha1 = strInput1.split("/");
	var datFechaValida1 = new Date(arrFecha1[2], arrFecha1[1] - 1, arrFecha1[0]);
	var arrFecha2 = strInput2.split("/");
	var datFechaValida2 = new Date(arrFecha2[2], arrFecha2[1] - 1, arrFecha2[0]);
	var intAjuste;
	
	switch (strUnidad) {
//		El resultado te lo devuelve en años
		case "a":
		case "A":
			intAjuste = 86400000 * 365;
			break;
//		El resultado te lo devuelve en horas
		case "h":
		case "H":
			intAjuste = 86400000 / 24;
			break;
//		El resultado te lo devuelve por default en días
		case "d":
		case "D":
		default:
			intAjuste = 86400000;
			break;
	}
	
	return ((datFechaValida1 - datFechaValida2) / intAjuste);
}

function check_toString () {
	var strErrors = "";
	var i;
	
	for (i = 0; i < this.arrErrors.length; i++) {
		strErrors = strErrors + this.arrErrors[i] + "\n";
	}
	
	return strErrors;
}
/**** AJAX ****/

function ajax(){
	var args=ajax.arguments;
	var action=args[0],method=args[1],form=args[2],plus=args[3];

	if(window.ActiveXObject){
		var req = new ActiveXObject("Microsoft.XMLHTTP");
	}else if(window.XMLHttpRequest){
		var req = new XMLHttpRequest();
	}

	req.onreadystatechange = function (){
		if(req.readyState == 4){
			eval(req.responseText);
		}
	}

	var form_data='';
	for(i=0;i<form.length;i++){
		if(form[i].type=="checkbox"){
			if(form[i].checked==true) {
				form_data+=form[i].name+'='+form[i].value+'&';
			}
		} else if(form[i].type=="radio"){
			if(form[i].checked==true) {
				form_data+=form[i].name+'='+form[i].value+'&';
			}
		} else if( form[i].type=="file" ) {
			continue;
		} else {
			form_data+=form[i].name+'='+form[i].value+'&';
		}
	}
	form_data+='form_name='+form.name+plus;
	
	if(method=='POST'){
		req.open('POST', action, true);
		var content_type = 'application/x-www-form-urlencoded';
//		var content_type = 'multipart/form-data'; AJAX no banca este tipo de codificacion
		if(args[4])
			content_type = args[4];
		req.setRequestHeader('Content-Type', content_type);

		req.send(form_data);
	}else if(method=='GET'){
		if(action.indexOf('?')==-1){
			action+='?'+form_data;
		} else {
			action+='&'+form_data
		}

		req.open('GET', action, true);
		req.send(null);
	}
}

function simple_ajax(){
	var args=simple_ajax.arguments;
	var action=args[0],method=args[1],values=args[2];
	
	if(window.ActiveXObject){
		var req = new ActiveXObject("Microsoft.XMLHTTP");
	}else if(window.XMLHttpRequest){
		var req = new XMLHttpRequest();
	}

	req.onreadystatechange = function (){
		if(req.readyState == 4){
			eval(req.responseText);
		}
	}
	
	if( method=='POST' ){
		/*req.open('POST', action, true);
		req.send(values);*/
		req.open('POST', action, true);
		var content_type = 'application/x-www-form-urlencoded';
		req.setRequestHeader('Content-Type', content_type);
		req.send(values);
	}else{
		req.open('GET', action+'?'+values, true);
		req.send(null);
	}
}

function ajaxHTML(sMetodo, sUrl, div, values, strFunction){
	strHTML = "";
	if(window.ActiveXObject){
		var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}else if(window.XMLHttpRequest){
		var xmlhttp = new XMLHttpRequest();
	}
	xmlhttp.open(sMetodo,sUrl);
	var content_type = 'application/x-www-form-urlencoded';
	xmlhttp.setRequestHeader('Content-Type', content_type);
	
	
	xmlhttp.onreadystatechange = function (){
			if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
			
			div.innerHTML = xmlhttp.responseText;
		
			if(strFunction) {
				eval(strFunction);
			}
		}
	}
	xmlhttp.send(values);
	
	
}

/**** BASICS ****/


/* BasicMM */
function MM_swapImgRestore(){
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages(){
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d){
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage(){
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_showHideLayers() {
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}


/*** FUNCIONES GENERALES *****/

	function strReplace(str, str1, str2) {
		while(str.indexOf(str1) > 0) {
			str = str.replace(str1, str2);
		}
		return str;
	}
	function AgregarCeros(Str){
  	
  	arrValores = Str.split("/");
  	for(i=0;i < arrValores.length; i++){
    	if(parseInt(arrValores[i]) < 10 && arrValores[i].length == 1){
      	arrValores[i] = "0" + arrValores[i];
      }
    }
  	
  	strNuevaFecha = arrValores[0] + "/" + arrValores[1] + "/" + arrValores[2];
  	
  	return strNuevaFecha;
  }
	
	function fechaMayorQue(strFecha1, strFecha2){ 
	
	var arrFecha1 = strFecha1.split('/');
	var sDia0 = arrFecha1[0];
	var sMes0 = arrFecha1[1]; 
	var sAno0 = arrFecha1[2];
	//alert(sMes0+ sAno0);
	var arrFecha2 = strFecha2.split('/');
	var sDia1 = arrFecha2[0];
	var sMes1 = arrFecha2[1]; 
	var sAno1 = arrFecha2[2];
    var bRes = false; 
  /* strFecha1 = AgregarCeros(strFecha1);
   strFecha2 = AgregarCeros(strFecha2)
	    var sDia0 = strFecha1.substr(0, 2); 
	    var sDia1 = strFecha2.substr(0, 2); 
	    var sMes0 = strFecha1.substr(3, 2); 
	    var sMes1 = strFecha2.substr(3, 2); 
	    var sDia0 = strFecha1.substr(3, 2); 
	    var sDia1 = strFecha2.substr(3, 2); 
	    var sMes0 = strFecha1.substr(0, 2); 
	    var sMes1 = strFecha2.substr(0, 2); 
	    
    var sAno0 = strFecha1.substr(6, 4); 
    var sAno1 = strFecha2.substr(6, 4); */
    if (parseInt(sAno0) > parseInt(sAno1)){
    bRes = true; 
    
    } else { 
     
     if (parseInt(sAno0) == parseInt(sAno1)){ 
      
      if (parseInt(sMes0) > parseInt(sMes1)){
      	 bRes = true; 
      } else { 
       if (parseInt(sMes0) == parseInt(sMes1)) 
        if (parseInt(sDia0) > parseInt(sDia1)){ bRes = true; }
      } 
     } 
    } 
    return(bRes); 
   } 
	
	function Chr(CharCode)
{
	return String.fromCharCode(CharCode);
}
	
	function strReplace(str, strBusqueda, strReemplazo) {
		while(str != str.replace(strBusqueda, strReemplazo)) {
			str = str.replace(strBusqueda, strReemplazo);
		}
		return str;
	}
	
	function mostrarDiv(strDiv) {
		document.getElementById(strDiv).style.position="relative";
		document.getElementById(strDiv).style.width="";
		document.getElementById(strDiv).style.height="";
		document.getElementById(strDiv).style.top=0;
		document.getElementById(strDiv).style.left="";
		MM_showHideLayers(strDiv,'','show');
	}

	function ocultarDiv(strDiv) {
		document.getElementById(strDiv).style.position="absolute";
		document.getElementById(strDiv).style.width="";
		document.getElementById(strDiv).style.height="";
		document.getElementById(strDiv).style.top="";
		document.getElementById(strDiv).style.left=0;
		MM_showHideLayers(strDiv,'','hidden');
	}
	
	function verLink(strLink){
		return !window.open(strLink);
	}
	
	function PermitirSoloEnteros(evt)	{                               
		var key = document.all  ?  evt.keyCode: evt.which;              
		return (key < 13 || (key >= 48 && key <= 57) ) ;        	

	}

/* funcion trim que la uso en el resto de las funciones */
	function trim(inputString) {
   
   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " ") { 
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") { 
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
   while (retValue.indexOf("  ") != -1) { 
      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
   }
   return retValue; 
	} 
	
	
	function CapturarEnter(e, strFuncion){
		if(document.all){
       intTecla=event.keyCode;
    } else {
       intTecla=e.which; 
    }
 	  if(intTecla==13){
        eval(strFuncion);
  	}
	
  }
	
	function roundNumber(numero, intDecimales) {
	var rlength = intDecimales; 
	if (numero > 8191 && numero < 10485) {
		numero = numero-5000;
		var newnumber = Math.round(numero*Math.pow(10,rlength))/Math.pow(10,rlength);
	} else {
		var newnumber = Math.round(numero*Math.pow(10,rlength))/Math.pow(10,rlength);
	}
	return newnumber;
  }
  
	function InChar(strSearch, charSearchFor)
	{
		for (i=0; i < Len(strSearch); i++)
		{
		    if (charSearchFor == Mid(strSearch, i, 1))
		    {
				return i;
		    }
		}
		return -1;
	}

	function InStr(strSearch, strSearchFor)
	{
		for (i=0; i < Len(strSearch); i++)
		{
		    if (strSearchFor == Mid(strSearch, i, Len(strSearchFor)))
		    {
					return i;
		    }
		}
		return -1;
	}

  function Len(str) {  
  	return String(str).length;  
  }

	function Mid(str, start, len) {
	  if (start < 0 || len < 0) return "";
	
	  var iEnd, iLen = String(str).length;
	  if (start + len > iLen)
	          iEnd = iLen;
	  else
	          iEnd = start + len;
	
	  return String(str).substring(start,iEnd);
	}

	function Left(str, n){
		if (n <= 0)
		    return "";
		else if (n > String(str).length)
		    return str;
		else
		    return String(str).substring(0,n);
	}

	function Right(str, n){
	    if (n <= 0)
	       return "";
	    else if (n > String(str).length)
	       return str;
	    else {
	       var iLen = String(str).length;
	       return String(str).substring(iLen, iLen - n);
	    }
	}

function getContenido (contenido) {
	var abreTag = "";
	var contenidoLimpio = "";
	
	contenido = replaceSubstring(contenido, "<HR>", "-----");
	contenido = replaceSubstring(contenido, "&nbsp;", "");
	contenido = replaceSubstring(contenido, "</P>", "{BR}{BR}");
	contenido = replaceSubstring(contenido, "<BR>", "{BR}");
	
	for (i = 0; i < contenido.length; i++) {
		if ((contenido.substring(i, i + 1) == "<") && (abreTag == "")) {
			abreTag = "<";
		}
		if (abreTag == "") {
			contenidoLimpio = contenidoLimpio + contenido.substring(i, i + 1);
		}
		
		if ((contenido.substring(i, i + 1) == ">") && (abreTag != "")) {
			abreTag = "";
		}
	}
	contenidoLimpio = replaceSubstring(contenidoLimpio, "{BR}", "<BR>");
	return contenidoLimpio;
}

function replaceSubstring(inputString, fromString, toString) {
	var temp = inputString;
	if (fromString == "") {
	  return inputString;
	}
	if (toString.indexOf(fromString) == -1) { 
	  while (temp.indexOf(fromString) != -1) {
	     var toTheLeft = temp.substring(0, temp.indexOf(fromString));
	     var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
	     temp = toTheLeft + toString + toTheRight;
	  }
	} else { 
	  var midStrings = new Array("~", "`", "_", "^", "#");
	  var midStringLen = 1;
	  var midString = "";
	
	  while (midString == "") {
	     for (var i=0; i < midStrings.length; i++) {
	        var tempMidString = "";
	        for (var j=0; j < midStringLen; j++) { tempMidString += midStrings[i]; }
	        if (fromString.indexOf(tempMidString) == -1) {
	           midString = tempMidString;
	           i = midStrings.length + 1;
	        }
	     }
	  }
	  while (temp.indexOf(fromString) != -1) {
	     var toTheLeft = temp.substring(0, temp.indexOf(fromString));
	     var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
	     temp = toTheLeft + midString + toTheRight;
	  }
	  while (temp.indexOf(midString) != -1) {
	     var toTheLeft = temp.substring(0, temp.indexOf(midString));
	     var toTheRight = temp.substring(temp.indexOf(midString)+midString.length, temp.length);
	     temp = toTheLeft + toString + toTheRight;
	  }
	}
	return temp;
}

function emptyObjCmb(obj){
		for (i=0; i < obj.length; i++) {
	 		obj.options[i] = null;
	 	}
	 	obj.options.length = 0;
	}
	
Array.prototype.inArray = function (value)
// Returns true if the passed value is found in the
// array.  Returns false if it is not.
{
    var i;
    for (i=0; i < this.length; i++) {
        // Matches identical (===), not just similar (==).
        if (this[i] === value) {
            return true;
        }
    }
    return false;
};
	

//yetti
/*
Yetii - Yet (E)Another Tab Interface Implementation
version 1.6
http://www.kminek.pl/lab/yetii/
Copyright (c) Grzegorz Wojcik
Code licensed under the BSD License:
http://www.kminek.pl/bsdlicense.txt
*/

function Yetii() {

	this.defaults = {
		
		id: null,
		active: 1,
		interval: null,
		wait: null,
		persist: null,
		tabclass: 'tab',
		activeclass: 'active',
		callback: null,
		leavecallback: null
	
	};
	
	this.activebackup = null;
	
	for (var n in arguments[0]) { this.defaults[n]=arguments[0][n]; };	
	
	this.getTabs = function() {
        	
        var retnode = [];
        var elem = document.getElementById(this.defaults.id).getElementsByTagName('*');
		
		var regexp = new RegExp("(^|\\s)" + this.defaults.tabclass.replace(/\-/g, "\\-") + "(\\s|$)");
	
        for (var i = 0; i < elem.length; i++) {
			if (regexp.test(elem[i].className)) retnode.push(elem[i]);
        }
    
        return retnode;
    
    };
	
	this.links = document.getElementById(this.defaults.id + '-nav').getElementsByTagName('a');
	this.listitems = document.getElementById(this.defaults.id + '-nav').getElementsByTagName('li');
	
	this.show = function(number) {
        
        for (var i = 0; i < this.tabs.length; i++) {
			
			this.tabs[i].style.display = ((i+1)==number) ? 'block' : 'none';
				
			if ((i+1)==number) {
				this.addClass(this.links[i], this.defaults.activeclass);
				this.addClass(this.listitems[i], this.defaults.activeclass + 'li');
			} else {
				this.removeClass(this.links[i], this.defaults.activeclass);
				this.removeClass(this.listitems[i], this.defaults.activeclass + 'li');
			}
		
		}
		
		
		if (this.defaults.leavecallback && (number != this.activebackup)) this.defaults.leavecallback(this.defaults.active);
		
		this.activebackup = number;
		
		
		this.defaults.active = number;
		
		if (this.defaults.callback) this.defaults.callback(number);
		
    
    };
	
	this.rotate = function(interval) {
    
        this.show(this.defaults.active);
        this.defaults.active++;
    
        if (this.defaults.active > this.tabs.length) this.defaults.active = 1;
    
	
        var self = this;
		
		if (this.defaults.wait) clearTimeout(this.timer2);
		 
        this.timer1 = setTimeout(function(){self.rotate(interval);}, interval*1000);
    
    };
	
	this.next = function() {

        var _target = (this.defaults.active + 1 > this.tabs.length) ? 1 : this.defaults.active + 1;
        this.show(_target);
        this.defaults.active = _target;

    };
	
	this.previous = function() {

        var _target = ((this.defaults.active - 1) == 0) ? this.tabs.length : this.defaults.active - 1;
        this.show(_target);
        this.defaults.active = _target; 

    };
	
	this.previous = function() {
		
		this.defaults.active--;
    	if(!this.defaults.active) this.defaults.active = this.tabs.length;
		this.show(this.defaults.active);
	
	};
	
	this.gup = function(name) {
		name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
		var regexS = "[\\?&]"+name+"=([^&#]*)";
		var regex = new RegExp( regexS );
		var results = regex.exec( window.location.href );
		if (results == null) return null;
		else return results[1];
	};
	
	this.parseurl = function(tabinterfaceid) {
		
		var result = this.gup(tabinterfaceid);
		
		if (result==null) return null;
		if (parseInt(result)) return parseInt(result); 
		if (document.getElementById(result)) {	
			for (var i=0;i<this.tabs.length;i++) {
				if (this.tabs[i].id == result) return (i+1);
			}
		}
		
		return null;
		
	};

	this.createCookie = function(name,value,days) {
		if (days) {
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		}
		else var expires = "";
		document.cookie = name+"="+value+expires+"; path=/";
	};
	
	this.readCookie = function(name) {
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
	};
	
	this.contains = function(el, item, from) {
		return el.indexOf(item, from) != -1;
	};
	
	this.hasClass = function(el, className){
		return this.contains(el.className, className, ' ');
	};
	
	this.addClass = function(el, className){
		if (!this.hasClass(el, className)) el.className = (el.className + ' ' + className).replace(/\s{2,}/g, ' ').replace(/^\s+|\s+$/g, '');
	};
	
	this.removeClass = function(el, className){
		el.className = el.className.replace(new RegExp('(^|\\s)' + className + '(?:\\s|$)'), '$1');
		el.className.replace(/\s{2,}/g, ' ').replace(/^\s+|\s+$/g, '');
	};


	this.tabs = this.getTabs();
	this.defaults.active = (this.parseurl(this.defaults.id)) ? this.parseurl(this.defaults.id) : this.defaults.active;
	if (this.defaults.persist && this.readCookie(this.defaults.id)) this.defaults.active = this.readCookie(this.defaults.id);  
	this.activebackup = this.defaults.active;
	this.show(this.defaults.active);
	
	var self = this;
	for (var i = 0; i < this.links.length; i++) {
	this.links[i].customindex = i+1;
	this.links[i].onclick = function(){ 
		
		if (self.timer1) clearTimeout(self.timer1);
		if (self.timer2) clearTimeout(self.timer2); 
		
		self.show(this.customindex);
		if (self.defaults.persist) self.createCookie(self.defaults.id, this.customindex, 0);
		
		if (self.defaults.wait) self.timer2 = setTimeout(function(){self.rotate(self.defaults.interval);}, self.defaults.wait*1000);
		
		return false;
	};
    }
	
	if (this.defaults.interval) this.rotate(this.defaults.interval);
	
};

/* AJAX Star Rating : v1.0.3 : 2008/05/06 */
/* http://www.nofunc.com/AJAX_Star_Rating/ */

function $(v,o) { return((typeof(o)=='object'?o:document).getElementById(v)); }
function $S(o) { return((typeof(o)=='object'?o:$(o)).style); }
function agent(v) { return(Math.max(navigator.userAgent.toLowerCase().indexOf(v),0)); }
function abPos(o) { var o=(typeof(o)=='object'?o:$(o)), z={X:0,Y:0}; while(o!=null) { z.X+=o.offsetLeft; z.Y+=o.offsetTop; o=o.offsetParent; }; return(z); }
function XY(e,v) { var o=agent('msie')?{'X':event.clientX+document.documentElement.scrollLeft,'Y':event.clientY+document.documentElement.scrollTop}:{'X':e.pageX,'Y':e.pageY}; return(v?o[v]:o); }

function votar(intVoto, intId, strTipo, intIdUsuario){
	div = document.getElementById("star");
	div.innerHTML = '<img src="images/ajax.gif">';
	ajaxHTML("GET", "ajaxValoracion.php?voto=" + intVoto + "&id=" + intId + "&tipo=" + strTipo + "&id_usuario=" + intIdUsuario, div);
}


star={};

star.mouse=function(e,o) { if(star.stop || isNaN(star.stop)) { star.stop=0;

    document.onmousemove=function(e) { var n=star.num;
    
        var p=abPos($('star'+n)), x=XY(e), oX=x.X-p.X, oY=x.Y-p.Y; star.num=o.id.substr(4);

        if(oX<1 || oX>84 || oY<0 || oY>19) { star.stop=1; star.revert(); }
        
        else {

            $S('starCur'+n).width=oX+'px';
            $S('starUser'+n).color='#111';
            $('starUser'+n).innerHTML=Math.round(oX/84*100)/10;
        }
    };
} };

star.update=function(e, o, id, tipo, id_usuario) { var n=star.num, v=parseFloat($('starUser'+n).innerHTML);

    n=o.id.substr(4); $('starCur'+n).title=v;

    req=new XMLHttpRequest(); req.open('GET','ajaxValoracion.php?voto='+(v/100),false); req.send(null);   
	votar(v, id, tipo, id_usuario);


};

star.revert=function() { var n=star.num, v=parseFloat($('starCur'+n).title);

    $S('starCur'+n).width=Math.round(v*84/100)/10 +'px';
    $('starUser'+n).innerHTML=(v>0?Math.round(v/10):'');
    $('starUser'+n).style.color='#888';
    
    document.onmousemove='';
	//votar(v,1,1);
};



star.num=0;



//// fotos



function verMas(intPagina, intId, strTipo){
	div = document.getElementById("divBorrarFotos");
	div.innerHTML = '<img src="images/ajax.gif">';
	ajaxHTML("GET", "ajaxFotos.php?pagina=" + intPagina + "&id=" + intId + "&tipo=" + strTipo, div);
}
function verMasProductos(intPagina, intId, strTipo){
	div = document.getElementById("divBorrarFotosProductos");
	div.innerHTML = '<img src="images/ajax.gif">';
	ajaxHTML("GET", "ajaxFotosProductos.php?pagina=" + intPagina + "&id=" + intId + "&tipo=" + strTipo, div);
}

function verGaleriaPagina(intPagina, intId, intTipo){
	div = document.getElementById("divGaleria");
	div.innerHTML = '<img src="images/ajax.gif">';
	ajaxHTML("GET", "ajaxTabGaleria.php?pagina=" + intPagina + "&id=" + intId + "&tipo=" + intTipo, div);
}
function verGaleriaPaginaProductos(intPagina, intId, intTipo){
	div = document.getElementById("divGaleriaProductos");
	div.innerHTML = '<img src="images/ajax.gif">';
	ajaxHTML("GET", "ajaxTabGaleriaProductos.php?pagina=" + intPagina + "&id=" + intId + "&tipo=" + intTipo, div);
}

function verGaleriaUsuariosPagina(intPagina, intId, intTipo){
	div = document.getElementById("divGaleriaUsuarios");
	div.innerHTML = '<img src="images/ajax.gif">';
	ajaxHTML("GET", "ajaxTabGaleriaUsuarios.php?pagina=" + intPagina + "&id=" + intId + "&tipo=" + intTipo, div);
}
