function cambiarMesProg(varFecha){
	document.datos.fecha_actual.value=varFecha;
	document.datos.submit();
}
function watchAsset(id_contenido, accion){
	params="accion="+accion+"&id_contenido="+id_contenido;
	$.ajax({
        	beforeSend: function(){},
        	complete: function(){ /*$("#cargando").hide("fast");*/},
		success: function(html){
			switch(html){
				case -1:

				break;
				default:
					$("#watchAsset").html(html);
				break;
			}
                },
        	method: "post",url: "ProcesarAssetWatch.php",data: params, contentType : "application/x-www-form-urlencoded; charset=iso-8859-1"
	}); //close $.ajax(	
}
function cambiarPaisSuscripcion(){
	with (document.datos){
		submit();
	}
}
function guardarRating(varId_cont, varPuntaje, varId_usu){
	params="id_contenido="+varId_cont+"&puntaje="+varPuntaje+"&id_usuario="+varId_usu;
	$.ajax({
       		beforeSend: function(){},
        	complete: function(){ },
		success: function(html){
			/*if(html=="1"){
				$("#rating_"+varId_cont).raty().readOnly(true);
			}*/
                },
       		method: "post",url: "guardarRating.php",data: params, contentType : "application/x-www-form-urlencoded; charset=iso-8859-1"
	}); //close $.ajax(	
}

function votar(varCont){
	params="id_contenido="+varCont+"&id_opcion="+$("#radioEncuesta:checked").val();
	$.ajax({
       		beforeSend: function(){},
        	complete: function(){ },
		success: function(html){
			$("#cont_enc").html(html);
                },
       		method: "post",url: "box_encuesta_resultado.php",data: params, contentType : "application/x-www-form-urlencoded; charset=iso-8859-1"
	}); //close $.ajax(
}

function votarVersus(varCont, varIdOpcion){
	params="id_contenido="+varCont+"&id_opcion="+varIdOpcion;
	$.ajax({
       		beforeSend: function(){},
        	complete: function(){ },
		success: function(html){
			document.location="votacionFinalizada.php";
                },
       		method: "post",url: "box_versus_procesar.php",data: params, contentType : "application/x-www-form-urlencoded; charset=iso-8859-1"
	}); //close $.ajax(
}

function verResultadosEncuesta(varCont){
	params="id_contenido="+varCont;
	$.ajax({
        	beforeSend: function(){},
        	complete: function(){ },
		success: function(html){
			$("#cont_enc").html(html);
                },
        	method: "post",url: "box_encuesta_resultado.php",data: params, contentType : "application/x-www-form-urlencoded; charset=iso-8859-1"
	}); //close $.ajax(	

	$("#cont_enc").html
}

function buscarProgramacionFront(varDia, varMes, varAnio, varAreaId){
	with(document.datos){
		dia.value=varDia;
		mes.value=varMes;
		anio.value=varAnio;
		areaId.value=varAreaId;
		submit();
	}

}
function addFavourite(id_contenido, accion, respuesta){
	params="accion="+accion+"&id_contenido="+id_contenido+"&tipo=1";
	$.ajax({
        	beforeSend: function(){},
        	complete: function(){ },
		success: function(html){
			switch(html){
				case -1:

				break;
				default:
					$("#addFav").html(respuesta);
				break;
			}
                },
        	method: "post",url: "favourite.php",data: params, contentType : "application/x-www-form-urlencoded; charset=iso-8859-1"
	}); //close $.ajax(	
}

function addFavouriteAgenda(id_contenido,evt_id, accion, respuesta){
	params="accion="+accion+"&id_contenido="+id_contenido+"&tipo=2&evt_id="+evt_id;
	$.ajax({
        	beforeSend: function(){},
        	complete: function(){ },
		success: function(html){
			switch(html){
				case -1:

				break;
				default:
					$("#addFav_"+evt_id).html(respuesta);
				break;
			}
                },
        	method: "post",url: "favourite.php",data: params, contentType : "application/x-www-form-urlencoded; charset=iso-8859-1"
	}); //close $.ajax(	
}

function borrarFavorito(varid_usuario,varid_contenido, varfiltro, vartipo, varevt_id){
	with(document.datos){
		accion.value="ELIMINARFAV";
		filtro.value=varfiltro;
		tipo.value=vartipo;
		id_usuario.value=varid_usuario;
		id_contenido.value=varid_contenido;
		evt_id.value=varevt_id;
		action="favourite.php";
		submit();
	}
}

function watchAsset(id_contenido, accion){
	params="accion="+accion+"&id_contenido="+id_contenido;
	$.ajax({
        	beforeSend: function(){},
        	complete: function(){ /*$("#cargando").hide("fast");*/},
		success: function(html){
			switch(html){
				case -1:

				break;
				default:
					$("#watchAsset").html(html);
				break;
			}
                },
        	method: "post",url: "ProcesarAssetWatch.php",data: params, contentType : "application/x-www-form-urlencoded; charset=iso-8859-1"
	}); //close $.ajax(	
}

function quoteMessage(msg_id){
	var textoMsg;
	$("#tempDiv").html($("#contenido_msg_"+msg_id).html());
	$("#tempDiv > *").remove("#quoting");
	textoMsg=$("#tempDiv").html();
	$("#tempDiv").empty();
	textoUsr=$("#user_msg_"+msg_id).html();
	if (editorMsg){
		editorMsg.destroy();
	}
	$("#content").val("<div id=\"quoting\">"+textoUsr+" wrote:"+textoMsg+"</div><p><br></p>");
	editorMsg=CKEDITOR.replace( 'content',
	{
        uiColor : '#9AB8F3',
		language: 'en',
		width: '935',
		height: '200',
		resize_enabled: false, 
		enterMode: 1,
		contentsCss: '../../estilosQuoting.css',
	   toolbar :
			[
				['Source','-','NewPage','Preview'],
				['Cut','Copy','Paste','PasteText','PasteFromWord'],
				['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
				['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],'/',
				['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
				['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
				['Link','Unlink','Anchor'],
				['Image','Flash','Table','HorizontalRule','SpecialChar'],
				'/',
				['Styles','Format','Font','FontSize'],
				['TextColor','BGColor', 'ShowBlocks']
			]
	});
}

function mark(valor, objeto, numero, restar){
	with(document.datos){
		pqo_id.value=valor;
	}
	//ele=document.getElementById(objeto);
	//ele.setAttribute("class", "estrellaFijo");
	hideAllStars();
	
	showStar(numero-1, "star_", restar);
	rated=objeto;
	numeroRated=numero;
	numeroMinimo=parseInt(numero)-parseInt(restar);
}

var rated;
var numeroRated=-1;
var numeroMinimo=-1;

function showStar(valor,nombre, valor_restar){
	for(i=valor;i>valor-valor_restar;i--){
		elemento=document.getElementById(nombre+i);
		elemento.setAttribute("src", "imagenes/icono-ranking-si.gif");
	}
}

function hideStar(valor,nombre, valor_restar){
	for(i=valor;i>valor-valor_restar;i--){
		if(numeroRated==-1){
			elemento=document.getElementById(nombre+i);
			elemento.setAttribute("src", "imagenes/icono-ranking-no.gif");
		} else {
			if(i<numeroMinimo || i>numeroRated-1){
				elemento=document.getElementById(nombre+i);
				elemento.setAttribute("src", "imagenes/icono-ranking-no.gif");
			}
		}

	}
}

function hideAllStars(){
	for(i=0;i>-1;i++){
		if(document.getElementById("star_"+i)){
			elemento=document.getElementById("star_"+i);
			elemento.setAttribute("src", "imagenes/icono-ranking-no.gif");			
		} else {
			break;
		}
	}
}

function goRank(poll_id, pol_ast_id, psu_id){
	if(psu_id=="0"){
		alert("You should choose a subject to Rate");
	} else {
		if(psu_id==""){
			psu_id=document.datos.psu_id.value;
		}
		document.location='doPoll.php?pol_id='+poll_id+'&id_contenido='+pol_ast_id+'&psu_id='+psu_id;
	}	
}

function delRank(poll_id, valorPsu_id){
	with(document.datos){
		if(confirm("Are you sure you want to delete the rated item?")){
			pol_id.value=poll_id;
			varPsu_id.value=valorPsu_id;
			accion.value="BORRAR";
			submit();
		}
	}
}

function getResults(varPsu_id, varPoq_id){
	with(document.datos){
		vpoq_id.value=varPoq_id;
		vpsu_id.value=varPsu_id;
		submit();
	}
}

function submitRank(poll_id){
	with(document.datos){
		if(confirm("If you submit you will not be able to edit or rate another item. Do you want to continue anyway?")){
			pol_id.value=poll_id;
			action="viewPoll.php";
			accion.value="ENVIAR";
			submit();
		}
	}
}



function submitRankQuestion($poll_id ,poq_id, varproxima_preg, tipo){
	switch(tipo){
		case "POLL_OPEN":
			with(document.datos){
				/*if(pqa_answer.value==""){
					alert("You should answer the question.");
				} else {*/
					if(varproxima_preg==-1){
						proxima_preg.value=-2;
					}
					action="doPoll.php";
					accion.value="GUARDAR";
					submit();
				//}
			}
		break;

		case "POLL_ONLYONE":
			if(numeroRated>-1){
				with(document.datos){
					if(varproxima_preg==-1){
						proxima_preg.value=-2;
					}
					action="doPoll.php";
					accion.value="GUARDAR";
					submit();
				}
			} else {
				alert("You should check one option.");
			}
		break;
	}
}

function prevRankQuestion($poll_id ,poq_id, varproxima_preg, tipo){
	switch(tipo){
		case "POLL_OPEN":
			with(document.datos){
				action="doPoll.php";
				proxima_preg.value=varproxima_preg;
				accion.value="";
				submit();
			}
		break;

		case "POLL_ONLYONE":
				with(document.datos){
					proxima_preg.value=varproxima_preg;
					action="doPoll.php";
					accion.value="";
					submit();
				}
		break;
	}
}

function submitRankQuestionFin($poll_id ,poq_id, varproxima_preg, tipo){
	switch(tipo){
		case "POLL_OPEN":
			with(document.datos){
				/*if(pqa_answer.value==""){
					alert("You should answer the question.");
				} else {*/
					if(varproxima_preg==-1){
						proxima_preg.value=-2;
					}
					action="doPoll.php";
					accion.value="GUARDARFIN";
					submit();
				//}
			}
		break;

		case "POLL_ONLYONE":
			if(numeroRated>-1){
				with(document.datos){
					if(varproxima_preg==-1){
						proxima_preg.value=-2;
					}
					action="doPoll.php";
					accion.value="GUARDARFIN";
					submit();
				}
			} else {
				alert("You should check one option.");
			}
		break;
	}
}

		function validarLogin()
		{
			var errores = "";
			var elemFoco = "";
			
			with(document.datos)
			{
				if(username.value == "")
				{
					errores += "- You should fill the username field in order to login\n";
					if(elemFoco == "") elemFoco = "username";
				}

				if(password.value == "")
				{
					errores += "- You should fill the password field in order to login\n";
					if(elemFoco == "") elemFoco = "password";
				}
	
				if(errores == "")
				{
						action="login.php";
						accion.value = "LOGIN";	
						submit();					
				}
				else
				{
					alert(errores);
					SetFocus(eval(elemFoco));
				}
			}
		}
		
		function validarForgot()
		{
			var errores = "";
			var elemFoco = "";
			
			with(document.datos)
			{
				if(email.value == "")
				{
					errores += "- <?= _JS_ERROR_EMAIL?>\n";
					if(elemFoco == "") elemFoco = "email";
				}

				if(errores == "")
				{
						accion.value = "FORGOT";	
						submit();					
				}
				else
				{
					alert(errores);
					SetFocus(eval(elemFoco));
				}
			}
		}

function submitenter(myfield,e, accion)

{

	var keycode;

	if (window.event) keycode = window.event.keyCode;

	else if (e) keycode = e.which;

	else return true;

	

	if (keycode == 13)

	   {
		eval(accion);

	   return false;

	   }

	else

	   return true;

}

function mostrarLayer(capa){
	$("#"+capa).show("fast");
	var target_offset = $("#"+capa).offset();
	var target_top = target_offset.top;
	$('html, body').animate({scrollTop:target_top}, 500);
}

function mostrarLayerWrk(capa){
	$("#"+capa).hide();
	$("#contenidos-desplegables > *").hide();
	$("#titulo-desplegable-flecha img").attr("src", "imagenes/expandible-up.jpg");
	$("#flecha_"+capa).attr("src", "imagenes/expandible-down.jpg");
	$("#"+capa).show("fast");
}

function ocultarLayerWrk(){
	$("#contenidos-desplegables > *").hide();
}

function ocultarLayer(capa){
	$("#"+capa).hide();
}

function enviarJquery(){
     $(document).ready(function(){
     $('.content').load('boo.php'); //by default initally load text from boo.php
         $('#menu a').click(function() { //start function when any link is clicked
                        $(".content").slideUp("slow");
                         var content_show = $(this).attr("title"); //retrieve title of link so we can compare with php file
                            $.ajax({
                            method: "get",url: "boo.php",data: "page="+content_show, contentType : "application/x-www-form-urlencoded; charset=iso-8859-1",
                            beforeSend: function(){$("#loading").show("fast");}, //show loading just when link is clicked
                            complete: function(){ $("#loading").hide("fast");}, //stop showing loading when the process is complete
                            success: function(html){ //so, if data is retrieved, store it in html
                            $(".content").show("slow"); //animation
                            $(".content").html(html); //show the html inside .content div
                     }
                 }); //close $.ajax(
         }); //close click(
     }); //close $(
}


function cargarProvinciaLocalidad(id, lugar, tabla, id_tabla, con, otra_localidad, otra_provincia, id_provincia, id_localidad)
{
	params="id_tabla="+id_tabla+"&tabla="+tabla+"&con="+con+"&valor="+id+"&otra_provincia="+otra_provincia+"&otra_localidad="+otra_localidad+"&id_provincia="+id_provincia+"&id_localidad="+id_localidad;
	$.ajax({
        	beforeSend: function(){
			/*$("#cargando").show("slow");*/
			if(lugar=="provincia"){
				$("#localidad").html("<input type=\"text\" size=\"50\" value=\"\" name=\"otra_localidad\" value=\""+otra_localidad+"\" maxlength=\"255\">");
				params+="&seleccionado="+id_provincia;	
			}
			if(lugar=="localidad"){
				params+="&seleccionado="+id_localidad;
			}
		}, //show loading just when link is clicked
        	complete: function(){ /*$("#cargando").hide("fast");*/}, //stop showing loading when the process is complete
		success: function(html){ //so, if data is retrieved, store it in html
			$("#"+lugar).show("slow"); //animation
			$("#"+lugar).html(html); //show the html inside .content div
                },
        	method: "post",url: "getLocalidad.php",data: params,contentType : "application/x-www-form-urlencoded; charset=iso-8859-1"
	}); //close $.ajax(
}

function cargarAreaInteresCombo(_valor)
{
	params=$("select").serialize();
	params+="&cant_areaId="+$("#cant_areaId").val();
	params+="&areaId_seleccion="+_valor;
	$.ajax({
        	beforeSend: function(){
			/*$("#cargando").show("slow");*/
		
		}, //show loading just when link is clicked
        	complete: function(){ /*$("#cargando").hide("fast");*/}, //stop showing loading when the process is complete
		success: function(html){ //so, if data is retrieved, store it in html
			/*$("#area_elegir").show("slow"); //animation*/
			$("#area_elegir").html(html); //show the html inside .content div
                },
        	method: "post",url: "getArea.php",data: params, contentType : "application/x-www-form-urlencoded; charset=iso-8859-1"
	}); //close $.ajax(
}

function alertComment(){
	alert("Para escribir mensajes, por favor registrate.");
}

function saveComment(_valor)
{
	with(document.datos){
		var errores = "";
		if(texto_comentario.value==""){
			errores+="- Debe completar el comentario";
		}
	}
		if(errores==""){
			params="";	
			params+="id_contenido="+_valor+"&texto_comentario="+escape($("#texto_comentario").val());
			$.ajax({
		        	beforeSend: function(){	
				}, 
		        	complete: function(){
				},
				success: function(html){ 
					//alert("Su comentario fue enviado y esta esperando para ser aprobado. Gracias.");
					loadComments(_valor, '');
		                },
		        	method: "post",url: "insertComment.php",data: params, contentType : "application/x-www-form-urlencoded; charset=iso-8859-1"
			}); //close $.ajax(

		} else {
			alert(errores);
		}
}

function loadComments(_valor, _modo){
	params="";	
	params+="id_contenido="+_valor+"&modo="+_modo;
	$.ajax({
        	beforeSend: function(){	
		}, 
        	complete: function(){
		},
		success: function(html){ 
			$("#contenedor_comments").html(html);
                },
        	method: "post",url: "loadComment.php",data: params, contentType : "application/x-www-form-urlencoded; charset=iso-8859-1"
	}); //close $.ajax(
}

function agregarImagenFunc(){
	with(document.datos){
		var errores = "";
		if(archivo.value==""){
			errores+="- Debe elegir un archivo para subir";
		}
		
		if(errores==""){
			$("#imagenUsuario").html("");
			accion.value="addImagen";
			action="ProcesarImagen.php";
			target="frmImg";
			submit();
		} else {
			alert(errores);
		}
	}
}


function agregarProgramacionFunc(){
	with(document.datos){
		var errores = "";
		if(archivo_programacion.value==""){
			errores+="- Debe elegir un archivo para subir";
		}
		if(tipo_prog_subir.selectedIndex==0){
			errores+="- Debe elegir el tipo de programación";
		}
		
		if(errores==""){
			accion.value="addProgramacion";
			action="ProcesarProgramacion.php";
			target="frmImg";
			submit();
		} else {
			alert(errores);
		}
	}
}

function agregarVideoFunc(){
	with(document.datos){
		var errores = "";
		if(archivo_video.value==""){
			errores+="- Debe elegir un archivo para subir";
		}
		
		if(errores==""){
			$("#imagenUsuario").html("");
			accion.value="addVideo";
			action="ProcesarVideo.php";
			target="frmImg";
			submit();
		} else {
			alert(errores);
		}
	}
}


function agregarAdjuntoFunc(){
	with(document.datos){
		var errores = "";
		if(archivo_agregar.value==""){
			errores+="- You should choose a file for uploading";
		}
		
		if(errores==""){
			accion.value="addAdjunto";
			action="ProcesarAdjunto.php";
			target="frmImg";
			submit();
		} else {
			alert(errores);
		}
	}
}


function insertarAreaInteres(valor)
{
	if(valor!=""){
		params="cant_areaId=1&areaId1="+valor;
	} else {
		params=$("select").serialize();
		params+="&cant_areaId="+$("#cant_areaId").val();
	}
	params+="&"+$(":hidden").serialize();
	$.ajax({
        	beforeSend: function(){

		
		},
        	complete: function(){ /*$("#cargando").hide("fast");*/},
		success: function(html){
			switch(html){
				case "-1":
					alert("Esta categoría ya fue insertada.");
				break;
				default:
					$("#form-areas-interes-seleccionadas").append(html);
				break;
			}
                },
        	method: "post",url: "insertArea.php",data: params, contentType : "application/x-www-form-urlencoded; charset=iso-8859-1"
	}); //close $.ajax(
}

function insertarTag(valor, cant_tags, tag_id, separador)
{
	if(valor!=""){
		var valores=valor.split(separador);
		for(i=0;i<valores.length;i++){
			cant_tags++;
			$("#cant_tags").val(cant_tags);
			vinculo="<div id=\"tag_"+$("#cant_tags").val()+"\"><div id=\"form-item-intermedio\"><span class=\"form-item-nombre\">&nbsp;</span><a href=\"javascript:eliminarTag('tag_"+$("#cant_tags").val()+"')\">borrar</a>&nbsp;</span>"+valores[i];
			if(tag_id!=''){
				vinculo=vinculo+"<input type=\"hidden\" name=\"tag_id_guardar[]\" value=\""+tag_id+"\">";
			} else {
				vinculo=vinculo+"<input type=\"hidden\" name=\"tag_valor_guardar[]\" value=\""+valores[i]+"\">";
			}
			vinculo=vinculo+"</div></div>";
			$("#tag-seleccionado").append(vinculo);
		}
	}
}

function eliminarTag(_id)
{
	$("#"+_id).remove();
}


function insertarLink(valor, cant_links, lnk_id)
{
	if(valor!=""){
		cant_links++;
		$("#cant_links").val(cant_links);
		if(valor.substring(0,7)!="http://"){
			valor="http://"+valor;
		}
			vinculo="<div id=\"link_"+$("#cant_links").val()+"\"><div id=\"form-item-intermedio\"><span class=\"form-item-nombre\">&nbsp;</span><a href=\"javascript:eliminarLink('link_"+$("#cant_links").val()+"')\">borrar</a>&nbsp;<a href=\""+valor+"\" target=\"_blank\">"+valor+"</a>";
			if(lnk_id!=''){
				vinculo=vinculo+"<input type=\"hidden\" name=\"link_id_guardar[]\" value=\""+lnk_id+"\">";
			} else {
				vinculo=vinculo+"<input type=\"hidden\" name=\"link_url_guardar[]\" value=\""+valor+"\">";
			}
			vinculo=vinculo+"</div></div>";
			$("#link-seleccionado").append(vinculo);

	}
}

function eliminarLink(_id)
{
	$("#"+_id).remove();
}

function guardarPrograma(){
	with(document.datos){
		accion.value="GUARDARPROGRAMA";
		submit();
	}
}

function eliminarPrograma(valor){
	$("#prog_"+valor).remove();
}

function insertarPrograma(ast_id, titulo, progId)
{
	progId++;
	$("#progId").val(progId);
	vinculo='<div id="prog_'+progId+'"><a href="javascript:eliminarPrograma('+progId+')" class="letra">borrar</a>&nbsp;<span class="letra">'+titulo+'</span> <input type="text" readonly="readonly" size="20" name="fecha_'+ast_id+'[]" id="prog_fecha_'+progId+'" class="letra">  <input type="button" value="X" onClick="document.getElementById(\'prog_fecha_'+progId+'\').value = \'\';" class="letra"> &nbsp;<select name="tipo_prog_'+ast_id+'[]"><option value="1">Premium</option></select><input type="hidden" name="fechas_guardar[]" value="'+ast_id+'"> <span class="letra">Destacar</span> <input type="checkbox" name="recom_prog_'+ast_id+'[]" value="1"><br></div>';
	$("#programas").append(vinculo);
				jQuery("#prog_fecha_"+progId).dynDateTime({
					showsTime: true,
					timeFormat: "24",
					ifFormat: "%Y-%m-%d | %H:%M",
					align: "TR",
					electric: false,
					singleClick: false
				});
	$("#guardarprogramas").html('<input type="button" value="Guardar Programación" class="letra" onClick="guardarPrograma()">');

}

function insertarImagen(valor, caption, cant_img, lnk_id, carpeta, tamanio, varAccion, vecUse, vecLang)
{
	if(valor!=""){
		cant_img++;
		$("#cant_img").val(cant_img);
		vinculo='<div id="imagen_'+$("#cant_img").val()+'"><div id=\"form-item-intermedio\"><span class=\"form-item-nombre\">&nbsp;</span>';
		vinculo=vinculo+'<table cellspacing=0 cellpadding=0 border=0><tr><td><a href="javascript:eliminarImagenConsulta(\'imagen_'+$("#cant_img").val()+'\', \''+varAccion+'\', \''+carpeta+'\', \''+valor+'\')" class="letra">borrar</a>&nbsp;<img border="1" src="'+carpeta+'/'+valor+'" '+tamanio+' /></td>';
		if(lnk_id!=''){
			vinculo=vinculo+"<input type=\"hidden\" name=\"img_id_guardar[]\" value=\""+lnk_id+"\">";
		} else {
			vinculo=vinculo+"<input type=\"hidden\" name=\"img[]\" value=\""+valor+"\">";
		}
		if(vecUse.length>0){
			vinculo=vinculo+"<td style=\"padding-left:5px;\" class=\"letra\" valign=\"top\">Uso de la imagen<br>"
			if(lnk_id!=''){
				vinculo=vinculo+"<select class=\"letra\" name=\"use_"+lnk_id+"\">";
			} else {
				vinculo=vinculo+"<select class=\"letra\" name=\"use[]\">";
			}
			for(i=0;i<vecUse.length;i++){
				vinculo=vinculo+"<option "+vecUse[i][2]+" value=\""+vecUse[i][0]+"\">"+vecUse[i][1]+"</option>"
			}
			vinculo=vinculo+"</select></td>";
			vinculo=vinculo+"<td class=\"letra\" valign=\"top\" style=\"padding-left:20px;\">";
			vinculo
			if(lnk_id!=''){
				vinculo=vinculo+"<input type=\"hidden\" name=\"img_id_guardar[]\" value=\""+lnk_id+"\">";
				for(i=0;i<vecLang.length;i++){
					vinculo=vinculo+"Caption "+vecLang[i][2]+"<br>";
					vinculo=vinculo+"<input class=\"letra\" type=\"text\" name=\"cap_"+lnk_id+"_"+vecLang[i][0]+"\" maxlength=\"255\" value=\""+vecLang[i][1]+"\"><br>";
				}
			} else {
				for(i=0;i<vecLang.length;i++){
					vinculo=vinculo+"Caption "+vecLang[i][2]+"<br>";
					vinculo=vinculo+"<input class=\"letra\" type=\"text\" name=\"cap_"+vecLang[i][0]+"[]\" id=\"cap\" maxlength=\"255\" value=\"\"><br>";
				}
			}
			vinculo=vinculo+"</td>";
		}
		vinculo=vinculo+"</tr></table><hr></div></div>";
		$("#imagen-seleccionada").append(vinculo);

	}
}

function insertarAdjunto(valor, caption, cant_adj, lnk_id, carpeta, varAccion)
{
	if(valor!=""){
		cant_adj++;
		$("#cant_adj").val(cant_adj);
			vinculo="<div id=\"adjunto_"+$("#cant_adj").val()+"\"><div id=\"form-item-intermedio\"><span class=\"form-item-nombre\">&nbsp;</span><a href=\"javascript:eliminarAdjunto('adjunto_"+$("#cant_adj").val()+"', '"+varAccion+"', '"+carpeta+"', '"+valor+"' )\">remove</a>&nbsp;<a href=\""+carpeta+"/"+valor+"\" target=\"_blank\">"+caption+"</a>";
			if(lnk_id!=''){
				vinculo=vinculo+"<input type=\"hidden\" name=\"adj_id_guardar[]\" value=\""+lnk_id+"\">";
				vinculo=vinculo+"<input type=\"hidden\" name=\"cap_adj_"+lnk_id+"\" value=\""+caption+"\">";
			} else {
				vinculo=vinculo+"<input type=\"hidden\" name=\"adj[]\" value=\""+valor+"\">";
				vinculo=vinculo+"<input type=\"hidden\" name=\"cap_adj[]\" value=\""+caption+"\">";
			}
			vinculo=vinculo+"</div></div>";
			$("#adjunto-seleccionado").append(vinculo);

	}
}

function insertarVideo(valor, caption, cant_vid, lnk_id, carpeta, varAccion)
{
	if(valor!=""){
		cant_vid++;
		$("#cant_vid").val(cant_vid);
			vinculo="<div id=\"video_"+$("#cant_vid").val()+"\"><div id=\"form-item-intermedio\"><span class=\"form-item-nombre\">&nbsp;</span><a href=\"javascript:eliminarVideo('video_"+$("#cant_vid").val()+"', '"+varAccion+"', '"+carpeta+"', '"+valor+"' )\">eliminar</a>&nbsp;<a href=\""+carpeta+"/"+valor+"\" target=\"_blank\">"+caption+"</a>";
			if(lnk_id!=''){
				vinculo=vinculo+"<input type=\"hidden\" name=\"vid_id_guardar[]\" value=\""+lnk_id+"\">";
				vinculo=vinculo+"<input class=\"letra\" type=\"hidden\" name=\"cap_vid_"+lnk_id+"\" value=\""+caption+"\">";
			} else {
				vinculo=vinculo+"<input type=\"hidden\" name=\"vid[]\" value=\""+valor+"\">";
				vinculo=vinculo+"<input class=\"letra\" type=\"hidden\" name=\"cap_vid[]\" value=\""+caption+"\">";
			}
			vinculo=vinculo+"</div></div>";
			$("#video-seleccionado").append(vinculo);

	}
}

function eliminarImagenConsulta(_id, varAccion, carpeta, valor)
{
	if(confirm("¿Está seguro que desea eliminar esta imagen del contenido?")){
	$("#"+_id).remove();
	switch(varAccion){
		case "addImagen":
			/*se acaba de agregar entonces si se eliminar, tambien lo elimino de los temporales*/
			params="accion=borrarImagenTemporal&carpeta="+carpeta+"&img="+valor;
			$.ajax({
		        	beforeSend: function(){
							
				}, //show loading just when link is clicked
		        	complete: function(){ }, 
				success: function(html){ 

		                },
		        	method: "post",url: "ProcesarImagen.php",data: params, contentType : "application/x-www-form-urlencoded; charset=iso-8859-1"
			}); //close $.ajax(
		break;
	}
	}
}

function eliminarAdjunto(_id, varAccion, carpeta, valor)
{
	$("#"+_id).remove();
	switch(varAccion){
		case "addAdjunto":
			/*se acaba de agregar entonces si se eliminar, tambien lo elimino de los temporales*/
			params="accion=borrarAdjuntoTemporal&carpeta="+carpeta+"&img="+valor;
			$.ajax({
		        	beforeSend: function(){
							
				}, //show loading just when link is clicked
		        	complete: function(){ }, 
				success: function(html){ 

		                },
		        	method: "post",url: "ProcesarAdjunto.php",data: params, contentType : "application/x-www-form-urlencoded; charset=iso-8859-1"
			}); //close $.ajax(
		break;
	}
}

function eliminarVideo(_id, varAccion, carpeta, valor)
{
	$("#"+_id).remove();
	switch(varAccion){
		case "addVideo":
			/*se acaba de agregar entonces si se eliminar, tambien lo elimino de los temporales*/
			params="accion=borrarAdjuntoTemporal&carpeta="+carpeta+"&img="+valor;
			$.ajax({
		        	beforeSend: function(){
							
				}, //show loading just when link is clicked
		        	complete: function(){ }, 
				success: function(html){ 

		                },
		        	method: "post",url: "ProcesarVideo.php",data: params, contentType : "application/x-www-form-urlencoded; charset=iso-8859-1"
			}); //close $.ajax(
		break;
	}
}


function eliminarAreaInteres(_id)
{
	$("#"+_id).remove();
}


	function agregarFotoFunc(){
		with(document.datos){
			var errores = "";
			if(archivo.value==""){
				errores+="- Debe elegir un archivo para subir.";
			}
			
			if(errores==""){
				accion.value="addImagen";
				action="ProcesarImagenMember.php";
				target="frmImg";
				submit();
			} else {
				alert(errores);
			}
		}
	}

	function agregarFotoFuncEmpresa(){
		with(document.datos){
			var errores = "";
			if(archivo.value==""){
				errores+="- You should choose a file for uploading";
			}
			
			if(errores==""){
				accion.value="addImagen";
				action="../ProcesarImagenEmpresa.php";
				target="frmImg";
				submit();
			} else {
				alert(errores);
			}
		}
	}

	function agregarFotoFuncEmpresaFront(){
		with(document.datos){
			var errores = "";
			if(archivo.value==""){
				errores+="- You should choose a file for uploading";
			}
			
			if(errores==""){
				accion.value="addImagen";
				action="ProcesarImagenEmpresaFront.php";
				target="frmImg";
				submit();
			} else {
				alert(errores);
			}
		}
	}

function cambiarEstadoAttend(){
	with(document.datos){
		accion.value="CAMBIARATTEND";
		submit();
	}
}

function MM_swapImgRestore() { //v3.0
  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() { //v3.0
  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) { //v4.01
  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 && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  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];}
}

/***********************************************
* Textarea Maxlength script- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

function ismaxlength(obj){
	var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
	if (obj.getAttribute && obj.value.length>mlength)
	obj.value=obj.value.substring(0,mlength)
}

function showAdvanced(capa){
	hideMenu('resulCOM');
	hideMenu('resulNET');
	mi_capa=document.getElementById(capa);
	mi_capa.style.visibility='visible';

	if(capa=="resulCOM"){
		changeBotoneraCOM();
	}
	if(capa=="resulNET"){
		changeBotoneraNET();
	}
}

function hideMenu(capa){
	mi_capa=document.getElementById(capa);
	mi_capa.style.visibility='hidden';
}
	
function sendEmail(id_usuario){
	$("#mensaje-perfil").show();
	$("#error-mensaje-perfil").hide();
}

function enviarMensaje(varId_usuario, errorSubject, errorMensaje)
{
	var errores = "";
	var elemFoco = "";

	with(document.datos)
	{

		if(asunto.value == "")
		{
			errores += "- "+errorSubject+"\n";
			if(elemFoco == "") elemFoco = "asunto";
		}
		if(mensaje.value == "")
		{
			errores += "- "+errorMensaje+"\n";
			if(elemFoco == "") elemFoco = "mensaje";
		}
		if(errores == "")
		{
			params="accion=ENVIAR&mensaje="+escape(mensaje.value)+"&asunto="+asunto.value+"&id_usuario="+varId_usuario;
			$.ajax({
		        	beforeSend: function(){
					//nada
				},
		        	complete: function(){ 
					//nada
				},
				success: function(html){
					$("#mensaje-perfil").hide();
					$("#error-mensaje-perfil").html(html);
					$("#error-mensaje-perfil").show();
		                },
        			method: "post",url: "emailUser.php",data: params, contentType : "application/x-www-form-urlencoded; charset=iso-8859-1"
			}); //close $.ajax(
		}
		else
		{
			alert(errores);
			SetFocus(eval(elemFoco));
		}
	}
}

function buscar()
{
	with(document.datos)
	{
		accion.value="BUSCAR";
		action="advancedSearch.php";
		//pagina.value = 1;
		submit();
	}
}

function buscarInterno()
{
	with(document.datos)
	{
		accion.value="BUSCAR";
		pagina.value = 1;
		submit();
	}
}


function buscarProgramacion()
{
	with(document.datos)
	{	
		pagina.value = 1;
	}

	var params = "";
	var campos="";
	campos=document.getElementsByTagName("input");
	for(i=0; i < campos.length; i++)
	{
		if(campos[i].type == "text" || campos[i].type == "hidden" || campos[i].type == "password")
			params += "&" + campos[i].name + "=" + campos[i].value;
		else if(campos[i].type == "radio" && campos[i].checked)
			params += "&" + campos[i].name + "=" + campos[i].value;
		else if(campos[i].type == "select-one")
			params += "&" + campos[i].name + "=" + campos[i].value;
		else if(campos[i].type == "checkbox"  && campos[i].checked)
			params += "&" + campos[i].name + "=" + campos[i].value;				
	}
	campos=document.getElementsByTagName("select");
	for(i=0; i < campos.length; i++)
	{
		params += "&" + campos[i].name + "=" + campos[i].value;
	}

	$.ajax({
        	beforeSend: function(){},
        	complete: function(){ },
		success: function(html){
			switch(html){
				default:
					$("#resultadosBuscar").html(html);
				break;
			}
                },
        	method: "post",url: "programacion_list_resultados.php",data: params, contentType : "application/x-www-form-urlencoded; charset=iso-8859-1"
	}); //close $.ajax(	


}		

function buscadorHeader()
{
	with(document.datos)
	{
		action="advancedSearch.php";
		accion.value="BUSCAR";
		if (typeof pagina != "undefined") {
			pagina.value="1";
		}
		if(keyword.value=="Search"){
			keyword.value="";
		}
		submit();
	}
}

function verImagen(imagen)
{
	var w = window.open('verImagen.php?imagen=' + imagen, 'WinImagen', 'toolbars=no, scrollbars=yes');
}


function eliminarSeleccionados()
{
	with(document.datos)
	{
		if(confirm("¿Está seguro que desea eliminar los items seleccionados?"))
		{
			accion.value = "ELIMINAR";
			submit();
		}
	}
}

function ir(p)
{
	with(document.datos)
	{
		pagina.value = p;
		submit();
	}
}

function irCOM(p)
{
	with(document.datos)
	{
		paginaCOM.value = p;
		layerActivo.value = "resulCOM";
		submit();
	}
}

function SetRecordFocus(cId)
{
	document.getElementById(cId).style.backgroundColor = "#F5F5F5";
}

function UnSetRecordFocus(cId)
{
	document.getElementById(cId).style.backgroundColor = "white";
}

function ordenar(campo)
{
	with(document.datos)
	{
		if(orden_campo.value != campo)
		{
			orden_campo.value = campo;
			orden_direccion.value = "ASC";
		}
		else
		{
			if(orden_direccion.value == "ASC")
				orden_direccion.value = "DESC";
			else
				orden_direccion.value = "ASC";
		}
		
		submit();
		
	}
}

function Expand(cSectionName)
{
	document.getElementById("tbl" + cSectionName).style.display = "";
	document.getElementById("img" + cSectionName).src = "images/ButtonCollapse.gif";
}

function Collapse(cSectionName)
{
	document.getElementById("tbl" + cSectionName).style.display = "none";
	document.getElementById("img" + cSectionName).src = "images/ButtonExpand.gif";
}

function ExpandCollapse(cSectionName)
{
	if (document.getElementById("tbl" + cSectionName).style.display == "none")
		Expand(cSectionName);
	else
		Collapse(cSectionName);
}

function checkEmail(strEmail)
{
	return (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(strEmail))
}

function SetFocus(elemFoco)
{
	try
	{
		//var oTable = GetParentTable(elemFoco);
		//if(oTable != "") Expand(oTable);
		elemFoco.focus();
	}
	catch(e)
	{
		alert(e.description);
	}
}

