function addToFavorite(){
	if (window.sidebar) { // Mozilla Firefox Bookmark  
		window.sidebar.addPanel('The UnCoolHunter', 'http://www.uncoolhunter.com.ar',"");  
	} else if( window.external ) { // IE Favorite  
		window.external.AddFavorite( 'http://www.uncoolhunter.com.ar', 'The UnCoolHunter');  
	} else if(window.opera) { // Opera 7+  
		return false; // do nothing - the rel="sidebar" should do the trick  
	} else { // for Safari, Konq etc - browsers who do not support bookmarking scripts (that i could find anyway)  
		alert('You need to press Command/Cmd + D to bookmark our site.'); 
		//alert('Unfortunately, this browser does not support the requested action,' + ' please bookmark this page manually.');  
	}  
}

suscripcionNewsletter = function(language_id, textSuccess){
	show_loading('button');
	$.ajax({
		type: 'POST',
		url: '/user/content/frontend/ajax/suscripcion_newsletter.php',
		data: 'email='+$('#email').attr('value')+'&language_id='+language_id,
		success: function () { suscriptionNewsletterSuccess(textSuccess); /*$('#email_suscription_success').show();*/ },
		error: function(XMLHttpRequest, textStatus, errorThrown) { alert('Verifique su email');}
	});
	$("#loading_span").remove();
	$("#button").show();
}

$('#email').focus(function () { 
	$(this).attr('value', '');
});

suscriptionNewsletterSuccess = function(textSuccess) {
	$("#success").empty();
	$("#success").append('<div>'+textSuccess+'</div>');
	$("#success").overlay({ 
	    // custom top position 
	    top: 203, 
	    // some expose tweaks suitable for facebox-looking dialogs 
	    expose: { 
	        // you might also consider a "transparent" color for the mask 
	        color: '#fff', 
	        // load mask a little faster 
	        loadSpeed: 200, 
	        // highly transparent 
	        opacity: 0.5 
	    }, 
	 
	    // we want to use the programming API 
	    api: true 
	// load it immediately after the construction 
	}).load();
	setTimeout('$("#success").overlay().close();',1500);
}

$(document).ready(function(){
	
});


function fArchivoClick(id){
	$('.submenu').hide();
	$(this).attr('class', 'active');
	$('#'+id).show();
}

fArchivoUncools = function(monthYear, mes, anio, language_id){
	//var monthYear=$(this);
	$.ajax({
		type: 'POST',
		url: '/user/content/frontend/ajax/archivo.php',
		data: 'mes='+mes+'&anio='+anio+'&language_id='+language_id,
		success: function (xml) { fArchivoUncoolsXml(xml, monthYear, mes, anio); },
		error: function(XMLHttpRequest, textStatus, errorThrown) { alert('fArchivoUncools - Error');}
	});
}

fArchivoUncoolsXml = function(xml, obj, mes, anio){
	var uncools='<ul class="submenu" style="display:none;">';
	$(xml).find('elem').each(function(){ //start each... creating option in select
		uncools += '<li><a href="/home_ecf.php?uncool_id='+$(this).find('id').text()+'">'+$(this).find('fecha').text()+' &bull; '+$(this).find('titulo').text()+'</a></li>';
	});
	uncools += '</ul>';
	$('.submenu').remove();
	$('.month a').attr('class', '');
	obj.after(uncools);
	obj.attr('class', 'active');
	$('.submenu').show();
}


//INGRESAR VOTO
ingresarVoto = function(campo, textSuccess){
	var votacion_respuesta_id=$('input[@name='+campo+']:checked').val();
	if (votacion_respuesta_id==undefined) {
		alert('Seleccione su respuesta');
	} else {
		show_loading('votar');
		$.ajax({
			type: 'POST',
			url: '/user/content/frontend/ajax/votacion.php',
			data: 'votacion_respuesta_id='+votacion_respuesta_id,
			success: function () { votacionSuccess(campo, textSuccess); },
			error: function(XMLHttpRequest, textStatus, errorThrown) { alert('Verifique su email');}
		});
		$("#loading_span").remove();
		$("#votar").show();
	}
	
}


votacionSuccess = function(campo, textSuccess) {
	$('.resultado').remove();
	$("#success").empty();
	$("#success").append('<div>'+textSuccess+'</div>');//<div class="close">X</div>
	
	$("#success").overlay({ 
	    // custom top position 
	    top: 203, 
	    // some expose tweaks suitable for facebox-looking dialogs 
	    expose: { 
	        // you might also consider a "transparent" color for the mask 
	        color: '#fff', 
	        // load mask a little faster 
	        loadSpeed: 200, 
	        // highly transparent 
	        opacity: 0.5 
	    }, 
	    closeOnClick: true,
	    onBeforeLoad: function() {$('embed').hide();},
	    onClose: function() {$('embed').show();},
	    // we want to use the programming API 
	    api: true 
	// load it immediately after the construction 
	}).load();
	setTimeout('$("#success").overlay().close();',1500);

}

//VER RESULTADOS DE LA VOTACION
verResultados = function(votacion_id, language_id, ver_resultados, ocultar_resultados){
	if ($('#resultados').val()==ocultar_resultados) {
		$('#resultados').val(ver_resultados);
		$('.resultado').remove();
	} else {
		if (votacion_id==undefined) {
			alert('Error');
		} else {
			$.ajax({
				type: 'POST',
				url: '/user/content/frontend/ajax/votacion_resultados.php',
				data: 'votacion_id='+votacion_id+'&language_id='+language_id,
				success: function (xml) { votacionResultadoSuccess(xml, ocultar_resultados); },
				error: function(XMLHttpRequest, textStatus, errorThrown) { alert('Error - verResultados');}
			});
		}
	}
}


votacionResultadoSuccess = function(xml, ocultar_resultados) {
	var resultadosText = '';
	$('.resultado').remove();
	$(xml).find('elem').each(function(){ //start each... creating option in select
		resultadosText = '<div class="resultado">';
		resultadosText += '<div class="porcentaje">'+$(this).find('cant_votaciones_porcentaje').text()+'%</div>';
		resultadosText += '<div class="barra"><div style="width: '+$(this).find('cant_votaciones_porcentaje').text()+'%;"></div></div>';
		resultadosText += '</div>';
		$('#votacion_respuesta_'+$(this).find('votacion_respuesta_id').text()).append(resultadosText);
	});
	$('#resultados').val(ocultar_resultados);
}


//PUNTAJE
incrementarPuntaje = function(obj, uncool_id){
	
	if (uncool_id==undefined) {
		alert('Error');
	} else {
		show_loading('puntaje_href_'+uncool_id);		
		$.ajax({
			type: 'POST',
			url: '/user/content/frontend/ajax/incrementar_puntaje_uncool.php',
			data: 'uncool_id='+uncool_id,
			success: function (puntaje) { incrementarPuntajeSuccess(obj, uncool_id, puntaje); },
			error: function(XMLHttpRequest, textStatus, errorThrown) { alert('Error - verResultados');}
		});
		$("#loading_span").remove();
		$("#puntaje_href_"+uncool_id).show();
	}
}


incrementarPuntajeSuccess = function(obj, uncool_id, puntaje) {
	obj.attr('class', 'puntaje_off');
	obj.attr('onclick', '');
	$('#puntaje_nro_'+uncool_id).empty();
	$('#puntaje_nro_'+uncool_id).append(puntaje);
}

//comentarios
ingresarComentario = function(uncool_id, language_id, textSuccess, diceLang){
	var website=$('#comentario_website_'+uncool_id).val();
	var email=$('#comentario_email_'+uncool_id).val();
	var nombre=$('#comentario_nombre_'+uncool_id).val();
	var comentario=$('#comentario_texto_'+uncool_id).val();
	
	if (uncool_id==undefined || email==undefined || nombre==undefined || comentario==undefined) {
		alert('Complete todos los datos');
	} else {
		show_loading('button2_'+uncool_id);
		$.ajax({
			type: 'POST',
			url: '/user/content/frontend/ajax/comentario_insertar.php',
			data: 'uncool_id='+uncool_id+'&website='+website+'&email='+email+'&nombre='+nombre+'&comentario='+comentario+'&language_id='+language_id,
			success: function (xml) { ingresarComentarioSuccess(uncool_id, textSuccess, nombre, diceLang, comentario, xml); },
			error: function(XMLHttpRequest, textStatus, errorThrown) { alert('Verifique los datos ingresados.');}
		});
		$("#loading_span").remove();
		$("#button2_"+uncool_id).show();
	}
}

insertarComentario = function(uncool_id, nombre, diceLang, comentario, fecha_comentario, cant_comentarios) {
	var div='<div class="comentario" ><p class="autor">'+nombre+' '+diceLang+': </p><p>'+comentario+'</p><p class="fecha">'+fecha_comentario+'</p></div>';
	$("#listado_comentarios_"+uncool_id).prepend(div);
	$(".size_comments_"+uncool_id).html(cant_comentarios);
}
ingresarComentarioSuccess = function(uncool_id, textSuccess, nombre, diceLang, comentario, xml) {
	
	$("#success").empty();
	$("#success").append('<div>'+textSuccess+'</div>');
	
	$("#success").overlay({ 
	    // custom top position 
	    top: 203, 
	    // some expose tweaks suitable for facebox-looking dialogs 
	    expose: { 
	        // you might also consider a "transparent" color for the mask 
	        color: '#fff', 
	        // load mask a little faster 
	        loadSpeed: 200, 
	        // highly transparent 
	        opacity: 0.5 
	    }, 
	 
	    // we want to use the programming API 
	    api: true 
	// load it immediately after the construction 
	}).load();
	
	$('#comentario_website_'+uncool_id).val('');
	$('#comentario_email_'+uncool_id).val('');
	$('#comentario_nombre_'+uncool_id).val('');
	$('#comentario_texto_'+uncool_id).val('');
	
	var fecha_comentario=$(xml).find('fecha_comentario').text();
	var cant_comentarios=$(xml).find('cant_comentarios').text();
	insertarComentario(uncool_id, nombre, diceLang, comentario, fecha_comentario, cant_comentarios);
	
	setTimeout('$("#success").overlay().close();',1500);
	
}

//COMENTARIOS NOTICIAS
ingresarComentarioNoticia = function(noticia_id, language_id, textSuccess){
	var website=$('#comentario_website_'+noticia_id).val();
	var email=$('#comentario_email_'+noticia_id).val();
	var nombre=$('#comentario_nombre_'+noticia_id).val();
	var comentario=$('#comentario_texto_'+noticia_id).val();
	
	if (uncool_id==undefined || email==undefined || nombre==undefined || comentario==undefined) {
		alert('Complete todos los datos');
	} else {
		$.ajax({
			type: 'POST',
			url: '/user/content/frontend/ajax/comentario_noticia_insertar.php',
			data: 'uncool_id='+uncool_id+'&website='+website+'&email='+email+'&nombre='+nombre+'&comentario='+comentario+'&language_id='+language_id,
			success: function (xml) { ingresarComentarioNoticiaSuccess(noticia_id, textSuccess, nombre, diceLang, comentario, xml); },
			error: function(XMLHttpRequest, textStatus, errorThrown) { alert('Verifique los datos ingresados.');}
		});
	}
}

insertarComentarioNoticia = function(noticia_id, nombre, diceLang, comentario, fecha_comentario, cant_comentarios) {
	var div='<div class="comentario" ><p class="autor">'+nombre+' '+diceLang+': </p><p>'+comentario+'</p><p class="fecha">'+fecha_comentario+'</p></div>';
	$("#listado_comentarios_"+noticia_id).prepend(div);
	$(".size_comments_"+noticia_id).html(cant_comentarios);
}

ingresarComentarioNoticiaSuccess = function(noticia_id, textSuccess, nombre, diceLang, comentario, xml) {
	$("#success").empty();
	$("#success").append('<div>'+textSuccess+'</div>');
	
	$("#success").overlay({ 
	    // custom top position 
	    top: 203, 
	    // some expose tweaks suitable for facebox-looking dialogs 
	    expose: { 
	        // you might also consider a "transparent" color for the mask 
	        color: '#fff', 
	        // load mask a little faster 
	        loadSpeed: 200, 
	        // highly transparent 
	        opacity: 0.5 
	    }, 
	 
	    // we want to use the programming API 
	    api: true 
	// load it immediately after the construction 
	}).load();
	
	$('#comentario_website_'+noticia_id).val('');
	$('#comentario_email_'+noticia_id).val('');
	$('#comentario_nombre_'+noticia_id).val('');
	$('#comentario_texto_'+noticia_id).val('');
	
	var fecha_comentario=$(xml).find('fecha_comentario').text();
	var cant_comentarios=$(xml).find('cant_comentarios').text();
	insertarComentarioNoticia(noticia_id, nombre, diceLang, comentario, fecha_comentario, cant_comentarios);
	
	setTimeout('$("#success").overlay().close();',1500);

}

//Click en ver mas tags
verMasTags = function(ver, ocultar) {
	$('#tags_ver_mas').slideToggle();
	
	if ($('#tag_ver_mas_link').html()==ver) {
		$('#tag_ver_mas_link').html(ocultar);
	} else {
		$('#tag_ver_mas_link').html(ver);
	}
}



show_loading = function(id) {
	$("#"+id).hide();
	$("#"+id).after('<span style="vertical-align:top; " id="loading_span" class="loading"><img align="center" src="/user/content/frontend/img/loading.gif" align="absmiddle"></span>');
}
