var yyy;
	function abrirLink(url,event){
		var div=jQuery("#link_compartir");
		div.fadeIn('slow');
		div.html("<div style=\"background:url(images/triangulo.gif) right bottom no-repeat; heigth:20px; width:280px\">&nbsp;</div><div style=\"background:#C21638;height:100px;width:290px;\"><div class=\"amarilloE\" style=\"padding:10px;float:left;width:220px\"><a href=\"javascript:void(0)\" onclick=\"copy_clip('http://www.pac.cr/"+url+"')\">Copia</a> y pega el link para compartir el art&iacute;culo</div><div id=\"x\" style=\"float:right;width:20px;margin-top:5px;margin-right:5px;\"><img src=\"http://pac.cr/images/x.gif\" onclick=\"cerrarbyid('link_compartir')\" onmouseover=\"this.style.cursor='pointer'\" height=\"13\" width=\"13\"></div><div style=\"padding:10px\"><input id=\"parasel\" style=\"margin-top:10px;border:none;width:100%;background:#FFF;\" value=\"http://www.pac.cr/"+url+"\" onclick=\"this.focus();this.select==true ? this.select=false : this.select=true\" onblur=\"this.select=false\"></input></div></div>");
		div.css("top",event.clientY+5);
		div.css("left",event.clientX-280);
		div.css("height","100px");
		div.css("width","290px");
		jQuery("#parasel").focus();
		jQuery("#parasel").select();
	}
	
	function cerrarbyid(link) {
		jQuery('#'+link).fadeOut('slow',function() {jQuery('#'+link).html('')});
	}
	
	var bbb=function closeThis() {		
		jQuery("#link_compartir").fadeOut('slow',function() {jQuery("#link_compartir").html("")});
	}
	
	function hacer() {
		yyy=setTimeout(bbb,1000);
	}

function copy_clip(content) {

   
}


	function mostrarEvento(id,event){
		jQuery("#contenidoCal").html("Cargando...");
	jQuery("#mousePositions").css("display",'block');
	jQuery("#mousePositions").css("left",  event.clientX+'px');
	jQuery("#mousePositions").css("top", event.clientY+'px');
jQuery.ajax({
			 	url: "evento.php?id="+id,
				async: true,
				dataType: "html",
				success: function(datos){				
					/*jQuery("#scrollbar").css("display","none");*/
					jQuery("#contenidoCal").html(datos);
				},
				type: "GET"
		});
	}
	
	function getAgenda(url) {
		var url2 = url.replace('@','?');
		url2 = url2.substring(1,url2.length);
		jQuery("#crt").html("<img src=\"http://otton.cr/ajax-loader.gif\">");
		jQuery.ajax({
			 	url: url2,
				async: true,//revisar
				dataType: "html",
				success: function(datos){
					jQuery("#crt").html(datos);
					jQuery("#scrollbar_peq").css("visibility","hidden");
				},
				type: "GET"
		});
	}
	
	jQuery(document).ready(function(){
		intervalo = setInterval(cambiarNoti,4000);		
		jQuery('#noticias .notis a').bind("mouseenter",function(){clearInterval(intervalo)});
		jQuery('#noticias .notis a').bind("mouseleave",function(){intervalo=setInterval(cambiarNoti,3000)});
	});
	
	
	
	function cambiarNoti() {
		div = jQuery('#noticias .notis a:visible');
		if (div.next().html()) {
			div.fadeOut('slow',function(){div.next().fadeIn('slow')});
		}
		else {
			div.fadeOut('slow',function(){jQuery('#noticias .notis a:first-child').fadeIn('slow')});
		}		
	}
	
	function cerrar_com() {
		jQuery("#oscuridad").fadeOut('slow');
		jQuery("#fb_comentarios").css("display","none");
		jQuery("#laX").css("display","none");
		jQuery("#comentar").html('');
	}

	function showComments(url) {
	jQuery("#oscuridad").fadeIn("slow");
	jQuery("#fb_comentarios").css("display","block");
	jQuery("#laX").css("display","block");
	//jQuery('<iframe src="frame_comentario.php?id=15"></iframe>').insertAfter("#fb_comentarios");
	//jQuery("#comentar").load(url);
	jQuery.ajax({
			 	url: url,
				async: true,
				dataType: "html",
				success: function(datos){				
					//jQuery("#scrollbar").css("visibility","hidden");
					jQuery("#comentar").html(datos);
				},
				type: "GET"
		});
}

	function funcion_de_enviar(form,divBf,divAf) {
		
            // definimos las opciones del plugin AJAX FORM
            var opciones= {
                               beforeSubmit: mostrarLoader, //funcion que se ejecuta antes de enviar el form
                               success: mostrarRespuesta //funcion que se ejecuta una vez enviado el formulario
							   
            };
             //asignamos el plugin ajaxForm al formulario myForm y le pasamos las opciones
            jQuery('#'+form).ajaxForm(opciones) ; 
            
             //lugar donde defino las funciones que utilizo dentro de "opciones"
             function mostrarLoader(){
                      jQuery("#"+divBf).fadeIn("slow");
             };
             function mostrarRespuesta (){
                          jQuery("#"+divBf).fadeOut("slow");
						  jQuery('#'+form).css("display", "none");
						  jQuery("#"+divAf).css("display", "block");
						  
             };
			
   
        }
		
	function makeScrollbar(content,scrollbar,handle,horizontal,ignoreMouse){
	var steps = (horizontal?(content.getScrollSize().x - content.getSize().x):(content.getScrollSize().y - content.getSize().y))
	var slider = new Slider(scrollbar, handle, {	
		steps: steps,
		mode: (horizontal?'horizontal':'vertical'),
		onChange: function(step){
			// Scrolls the content element in x or y direction.
			var x = (horizontal?step:0);
			var y = (horizontal?0:step);
			content.scrollTo(x,y);
		}
	}).set(0);
	if( !(ignoreMouse) ){
		// Scroll the content element when the mousewheel is used within the 
		// content or the scrollbar element.
		$$(content, scrollbar).addEvent('mousewheel', function(e){	
			e = new Event(e).stop();
			var step = slider.step - e.wheel * 30;	
			slider.set(step);					
		});
	}
	// Stops the handle dragging process when the mouse leaves the document body.
	$(document.body).addEvent('mouseleave',function(){slider.drag.stop()});
}

function makeScrollbar(content,scrollbar,handle,horizontal,ignoreMouse){
				var steps = (horizontal?(content.getScrollSize().x - content.getSize().x):(content.getScrollSize().y - content.getSize().y))
				var slider = new Slider(scrollbar, handle, {	
					steps: steps,
					mode: (horizontal?'horizontal':'vertical'),
					onChange: function(step){
						// Scrolls the content element in x or y direction.
						var x = (horizontal?step:0);
						var y = (horizontal?0:step);
						content.scrollTo(x,y);
					}
				}).set(0);
				if( !(ignoreMouse) ){
					// Scroll the content element when the mousewheel is used within the 
					// content or the scrollbar element.
					$$(content, scrollbar).addEvent('mousewheel', function(e){	
						e = new Event(e).stop();
						var step = slider.step - e.wheel * 30;	
						slider.set(step);					
					});
				}
				// Stops the handle dragging process when the mouse leaves the document body.
				$(document.body).addEvent('mouseleave',function(){slider.drag.stop()});
			}
						
			window.addEvent('domready', function(){				
				
			});
			
//-------------------AJAX--------------------------

//pedido de ajax con jquery, si se da carga el contenido y lo hace en columnas
function getDataServer(url){
		if (url.indexOf("agenda")==0) {
					jQuery("#target").css("position","absolute");
					jQuery("#target").css("width","700px");			
		}
		else {
			jQuery("#target").css("position","");
			jQuery("#target").css("width","1000px");
			jQuery("#target").css("display","block");
		}
		
	if ((url.indexOf("prensa_items")==-1) && (url.indexOf('info.php')==-1 && (url.indexOf('propuesta_items')==-1) && url.indexOf('pagina.php?guide=true')==-1)) {
	url = url.replace("@","?");
	jQuery("#PagH1 a").removeClass('rojoE');
	jQuery('#m-'+url.split('=')[1]).addClass('rojoE');
		//if (url.indexOf("prensa_items")==-1) {
     	jQuery.ajax({
			 	url: url,
				async: true,
				dataType: "html",
				success: function(datos){				
				if ((url.indexOf("noticias")==-1)&&(url.indexOf("prensa_items")==-1)&&(url.indexOf("agenda")==-1)&&(url.indexOf("contacto")==-1)&&(url.indexOf("unete")==-1)&&(url.indexOf("propuesta")==-1)&&(url.indexOf("videos")==-1) && (url.indexOf("descargas")==-1) && (url.indexOf("sala_prensa")==-1) && (url.indexOf("campanha")==-1)&& (url.indexOf("pagina.php")==-1) && (url.indexOf("blog")==-1)&&(url.indexOf("vida")) && (url.indexOf('fraccion_legislativa')==-1) && (url.indexOf("provincias")==-1)) {
					jQuery("#target").css("width","1000px");
					jQuery("#carga").html(datos);
					jQuery(function(){
					jQuery("#carga").columnize({
						target: "#target",
						width:325,
						height:390
					});				
				});
				makeScrollbar( $('content'), $('scrollbar'), $('handle'), true );
				jQuery("#scrollbar").css("visibility","visible");
				} else {
					jQuery("#target").html("");					
					jQuery("#scrollbar").css("visibility","hidden");
					jQuery("#target").css("width","1000px");
					//document.getElementById("target").style.background='#FF3388';
					jQuery("#target").html(datos);
					makeScrollbar( $('content'), $('scrollbar'), $('handle'), true );
				}
				},
				type: "GET"
		});
	}
	else {
		
		if (url.indexOf('si=1')==1) {
		jQuery.ajax({
			 	url: "noticias.php",
				async: true,
				dataType: "html",
				success: function(datos){				
					jQuery("#scrollbar").css("visibility","hidden");
					jQuery("#target").html(datos);
				},
				type: "GET"
		});
		
		}		
		else {			
			pet_prensa(url,2);
		}
		
		
		
	}
}

function getInfo(url,si) {
var url2 = url.replace('@','?');
url2 = url2.substring(1,url2.length);
jQuery("#crt").html("<img src=\"http://otton.cr/ajax-loader.gif\">");
	jQuery.ajax({
			 	url: url2,
				async: true,
				dataType: "html",
				success: function(datos){				
					jQuery("#relleno").html(datos);					
					jQuery(function(){
					if (datos.length!=7){
		jQuery("#relleno").columnize({				
			target: "#crt",
			width:300,
			height:390
		});
		jQuery("#scrollbar_peq").css("visibility","visible");
		makeScrollbar( $('content2'), $('scrollbar_peq'), $('handle2'), true );
		}
		else {
			jQuery("#crt").html("");
			jQuery("#scrollbar_peq").remove();
		}	 
});					
				},
				type: "GET"
		});
		
}

var tiempo;

function eliminarC() {
	tiempo=setTimeout(function(){jQuery('#cantones').remove();},1000);
}


function getCanton(url,si) {
	var url2 = url.replace('@','?');
url2 = url2.substring(1,url2.length);
jQuery("#cargar_not").html("<img src=\"http://otton.cr/ajax-loader.gif\">");
	jQuery.ajax({
			 	url: url2,
				async: true,
				dataType: "html",
				success: function(datos){
					jQuery("#cargar_not").html(datos);
					jQuery('#cantones').remove();
			
				},
				type: "GET"
		});
}

function getCantones(url,left,top) {
var url2 = url.replace('@','?');
url2 = url2.substring(1,url2.length);
if( jQuery('#cantones').attr('id') == 'cantones' )
	jQuery('#cantones').remove();
var nuevoDiv=jQuery(document.createElement('div')).attr('id','cantones').css({'left':'450px','top':'110px','background':'#FFF','border':'1px solid #E2183F','border-left':'2px solid #E2183F','display':'none'});
jQuery('body').append(nuevoDiv);
nuevoDiv.bind('mouseout',eliminarC);
nuevoDiv.bind('mouseover',function(){clearTimeout(tiempo);});
nuevoDiv.bind('onblur',function(){jQuery('#cantones').remove()});
jQuery('#crt').html('');
jQuery('#scrollbar_peq').css('visibility','hidden');
	jQuery.ajax({
			 	url: url2,
				async: true,
				dataType: "html",
				success: function(datos){				
					jQuery("#cantones").html(datos);
					jQuery("#cantones").fadeIn('slow');
				},
				type: "GET"
		});		
}

function getNotis(url,left,top) {
var url2 = url.replace('@','?');
url2 = url2.substring(1,url2.length);
if( jQuery('#cantones').attr('id') == 'cantones' )
	jQuery('#cantones').remove();
var nuevoDiv=jQuery(document.createElement('div')).attr('id','cantones').css({'left':'600px','top':'110px','background':'#FFF','border':'1px solid #E2183F','border-left':'2px solid #E2183F','display':'none'});
jQuery('body').append(nuevoDiv);
nuevoDiv.bind('mouseout',eliminarC);
nuevoDiv.bind('mouseover',function(){clearTimeout(tiempo);});
nuevoDiv.bind('onblur',function(){jQuery('#cantones').remove()});
//jQuery('#scrollbar_peq').css('visibility','hidden');
	jQuery.ajax({
			 	url: url2,
				async: true,
				dataType: "html",
				success: function(datos){				
					jQuery("#cantones").html(datos);
					jQuery("#cantones").fadeIn('slow');
				},
				type: "GET"
		});		
}


function peticion(url){
	if ((url.indexOf("prensa_items")==-1) && (url.indexOf("info.php")==-1) && url.indexOf("propuesta_items.php")==-1) {
	jQuery("#target").html("<div id=\"ajax_load\"><img src=\"http://otton.cr/ajax-loader.gif\"></div>");
	}
	getDataServer(url);
	var cadenaTexto = url;
	var fragmentoTexto = cadenaTexto.split('=');
	jQuery(document).attr('title', fragmentoTexto[1]+' | Acción Ciudadana | Si Querés Podés');
}

function pet_prensa(url,si) {
	var url2 = url.replace('@','?');
	url2 = url2.substring(1,url2.length);
	jQuery("#crt").html("");
	jQuery("#scrollbar_peq").css("visibility","hidden");
	
	jQuery("#cargar_not").html("<img src=\"http://otton.cr/ajax-loader.gif\">");
	jQuery.ajax({
			 	url: url2,
				async: true,//revisar
				dataType: "html",
				success: function(datos){
						if (datos.length!=97){
						jQuery("#content2").css("width","300px");
						jQuery("#scrollbar_peq").css("width","300px");
						jQuery("#cargar_not").html(datos);
						jQuery("#crt").html("");
						}
						else {
							getPro(url2,2);	
						}
				},
				type: "GET"
		});	
	/*}
	if (si==1){
		jQuery.historyLoad(url2.replace("?","@"));
	}*/
}

function pet_descarga(url,si) {
	var url2 = url.replace('@','?');
	url2 = url2.substring(1,url2.length);
	jQuery("#cargar_descarga").html("");
	jQuery("#item").html("");
	jQuery("#cargar_not").html("<img src=\"http://otton.cr/ajax-loader.gif\">");
	jQuery.ajax({
			 	url: url2,
				async: true,//revisar
				dataType: "html",
				success: function(datos){
					jQuery("#cargar_not").html(datos);
				},
				type: "GET"
		});	
	/*}
	if (si==1){
		jQuery.historyLoad(url2.replace("?","@"));
	}*/
}

function itemDescarga(url,si) {
	var url2 = url.replace('@','?');
	url2 = url2.substring(1,url2.length);
	jQuery("#item").html("cargando...");
	jQuery.ajax({
			 	url: url2,
				async: true,//revisar
				dataType: "html",
				success: function(datos){										
					jQuery("#item").html(datos);				

				},
				type: "GET"
		});
}

function getDescargas(url,si){
	var url2 = url.replace('@','?');
	url2 = url2.substring(1,url2.length);
	jQuery("#item").html("");
	jQuery("#cargar_descarga").html("cargando...");
	jQuery.ajax({
			 	url: url2,
				async: true,//revisar
				dataType: "html",
				success: function(datos){										
					jQuery("#cargar_descarga").html(datos);				

				},
				type: "GET"
		});	
	
}

function getPro(url,si) {
	var url2 = url.replace('@','?');
	if (si==1) {
	url2 = url2.substring(1,url2.length);
	jQuery("#crt").html("cargando...");
	jQuery.ajax({
			 	url: url2,
				async: true,//revisar
				dataType: "html",
				success: function(datos){
					jQuery("#relleno").html(datos);
					jQuery("#relleno").columnize({				
			target: "#crt",
			width:400,
			height:390
		});
					jQuery("#scrollbar_med").css("visibility","visible");
					jQuery("#scrollbar_med").css("width","400px");
					makeScrollbar( $('content3'), $('scrollbar_med'), $('handle3'), true );

				},
				type: "GET"
		});
	} else {
	url2 = url2.replace("prensa_items","propuesta_items"); 
	jQuery.ajax({
			 	url: url2,
				async: true,//revisar
				dataType: "html",
				success: function(datos){					
					jQuery("#content2").css("width","400px");
					jQuery("#relleno").html(datos);
					jQuery("#relleno").columnize({				
			target: "#crt",
			width:400,
			height:390
		});
					jQuery("#scrollbar_peq").css("visibility","visible");
					jQuery("#scrollbar_peq").css("width","400px");
					makeScrollbar( $('content2'), $('scrollbar_peq'), $('handle2'), true );
					jQuery("#cargar_not").html("");

				},
				type: "GET"
		});
	}
	
}

function avanzar(url) {
	jQuery("#target").html("<div id=\"ajax_load\"><img src=\"http://otton.cr/ajax-loader.gif\"></div>");
	jQuery.ajax({
			 	url: url,
				async: true,//revisar
				dataType: "html",
				success: function(datos){										
					jQuery("#target").html(datos);
					//makeScrollbar( $('DosColumnasLibres'), $('scrollbar_med'), $('handle3'), true );

				},
				type: "GET"
		});	
}

function pageload(hash) {
		 // hash doesn't contain the first # character.
		if(hash) {
			// restore ajax loaded state
			//if (hash.indexOf("prensa_items")==-1)
			if (hash!='')			
			peticion(hash);					
		} else {
			jQuery('#target').html('');
			jQuery('#carga').html('');
			jQuery('#scrollbar').css("visibility","hidden");
			// start page
			//peticion(hash);//default de la primera pagina
		}
	}
	
	jQuery(document).ready(function(){	
		// Initialize history plugin.
		// The callback is called at once by present location.hash. 
		jQuery.historyInit(pageload, "2010.php");		
		var hash ="";
		// set onlick event for buttons
		jQuery("a[rel='history']").click(function(){			
		hash = this.href.replace('?','@').split("/")[3];//cambio el ? por @ porque no pasa ?
		jQuery("#PagH, a").removeClass("rojoE");
		jQuery("#"+this.id).addClass("rojoE");
		jQuery("#noticias").remove();
		hash=hash.substring(1,hash.length);
		//var hash = this.href;
			//hash = hash.replace(/^.*#/, '');
			// moves to a new page. 
			// pageload is called at once. 
			// hash don't contain "#", "?"
			
			jQuery.historyLoad(hash);
			return false;
		});
	});


function getVideos (url,si) {
	//var url2 = url.replace('@','?');
	jQuery("#DosColumnasLibres").html("");
	jQuery("#cargar_video").html("<img src=\"http://otton.cr/ajax-loader.gif\">");
	jQuery.ajax({
			 	url: url,
				async: true,//revisar
				dataType: "html",
				success: function(datos){					
					jQuery("#DosColumnasLibres").html("");
					jQuery("#cargar_video").html(datos);
					//makeScrollbar( $('DosColumnasLibres'), $('scrollbar_med'), $('handle3'), true );
				},
				type: "GET"
		});	
}

function getVid (url,si) {
	var url2 = url.replace('@','?');
	jQuery("#DosColumnasLibres").html("<img src=\"http://otton.cr/ajax-loader.gif\">");
	jQuery.ajax({
			 	url: url2,
				async: true,//revisar
				dataType: "html",
				success: function(datos){									
					jQuery("#DosColumnasLibres").html(datos);
					jQuery("#target").css("position","absolute");				
					//makeScrollbar( $('DosColumnasLibres'), $('scrollbar_med'), $('handle3'), true );

				},
				type: "GET"
		});	
}

//funcion para hacer la vara en columnas

/*
$('#timeline')
  .bind('mousedown', function(e) {
    // aquí vendrá nuestro código
  });
  
  $(document)
  .data('timeline', {
    element: this,
    scroll: this.scrollLeft,
    x : e.clientX
  });*/
var a= function func (){
	var mousePositions = document.getElementById('mousePositions');
	mousePositions.style.top = y+'px';
}

function position(x,y){
	/*mousePositions.innerHTML = 'X coords: '+x+', Y coords: '+y;*/
	jQuery("#mousePositions").html("");
	jQuery("#mousePositions").css("display",'block');
	jQuery("#mousePositions").css("left",  x+'px');
	jQuery("#mousePositions").css("top", y+'px');
}
var aaa;
function cerrar(id){
	 aaa = setTimeout(cer, 700);
}

var cer = function cerrar2(id){

var div = document.getElementById('mousePositions');
div.style.display = 'none';
}

function cerrar3(){
var mousePositions = document.getElementById('mousePositions');
mousePositions.style.display = 'none';
}


function cerrar4(){
var mousePositions = document.getElementById('formulario');
mousePositions.style.display = 'none';
}

function cargarEventos(event,fecha){
	jQuery("#contenidoCal").html("Cargando...");
	jQuery("#mousePositions").css("display",'block');
	jQuery("#mousePositions").css("left",  event.clientX+'px');
	jQuery("#mousePositions").css("top", event.clientY+'px');
jQuery.ajax({
			 	url: "consultas_agenda.php?fecha="+fecha,
				async: true,
				dataType: "html",
				success: function(datos){				
					/*jQuery("#scrollbar").css("display","none");*/
					jQuery("#contenidoCal").html(datos);
				},
				type: "GET"
		});
		}
		
function cargarFormulario(event, pagina){
	jQuery("#formulario").html("Cargando Formulario...");
	jQuery("#formulario").css("display",'block');
	jQuery("#formulario").css("left",  event.clientX+'px');
	jQuery("#formulario").css("top", event.clientY+'px');
jQuery.ajax({
			 	url: pagina,
				async: true,
				dataType: "html",
				success: function(datos){				
					/*jQuery("#scrollbar").css("display","none");*/
					jQuery("#formulario").html(datos);
				},
				type: "GET"
		});
		}
		
function valor(campo){
//alert('ghkljdklñ');
window.document.getElementById(campo).value = '';
}

function valor2(campo){
//alert('ghkljdklñ');
window.document.getElementById(campo).value = 'E-mail';
}
