(function($){$.fn.tipsy=function(options){options=$.extend({},$.fn.tipsy.defaults,options);return this.each(function(){var opts=$.fn.tipsy.elementOptions(this,options);$(this).hover(function(){$.data(this,'cancel.tipsy',true);var tip=$.data(this,'active.tipsy');if(!tip){tip=$('<div class="tipsy"><div class="tipsy-inner"/></div>');tip.css({position:'absolute',zIndex:100000});$.data(this,'active.tipsy',tip);}if($(this).attr('xtitle')||typeof($(this).attr('original-title'))!='string'){$(this).attr('original-title',$(this).attr('xtitle')||'').removeAttr('title');}var title;if(typeof opts.title=='string'){title=$(this).attr(opts.title=='title'?'original-title':opts.xtitle);}else if(typeof opts.title=='function'){title=opts.title.call(this);}tip.find('.tipsy-inner')[opts.html?'html':'text'](title||opts.fallback);var pos=$.extend({},$(this).offset(),{width:this.offsetWidth,height:this.offsetHeight});tip.get(0).className='tipsy';tip.remove().css({top:0,left:0,visibility:'hidden',display:'block'}).appendTo(document.body);var actualWidth=tip[0].offsetWidth,actualHeight=tip[0].offsetHeight;var gravity=(typeof opts.gravity=='function')?opts.gravity.call(this):opts.gravity;switch(gravity.charAt(0)){case'n':tip.css({top:pos.top+pos.height,left:pos.left+pos.width/2-actualWidth/2}).addClass('tipsy-north');break;case's':tip.css({top:pos.top-actualHeight,left:pos.left+pos.width/2-actualWidth/2}).addClass('tipsy-south');break;case'e':tip.css({top:pos.top+pos.height/2-actualHeight/2,left:pos.left-actualWidth}).addClass('tipsy-east');break;case'w':tip.css({top:pos.top+pos.height/2-actualHeight/2,left:pos.left+pos.width}).addClass('tipsy-west');break;}if(opts.fade){tip.css({opacity:0,display:'block',visibility:'visible'}).animate({opacity:1});}else{tip.css({visibility:'visible'});}},function(){$.data(this,'cancel.tipsy',false);var self=this;setTimeout(function(){if($.data(this,'cancel.tipsy'))return;var tip=$.data(self,'active.tipsy');if(opts.fade){tip.stop().fadeOut(function(){$(this).remove();});}else{tip.remove();}},100);});});};$.fn.tipsy.elementOptions=function(ele,options){return $.metadata?$.extend({},options,$(ele).metadata()):options;};$.fn.tipsy.defaults={fade:false,fallback:'',gravity:'n',html:false,title:'title'};$.fn.tipsy.autoNS=function(){return $(this).offset().top>($(document).scrollTop()+$(window).height()/2)?'s':'n';};$.fn.tipsy.autoWE=function(){return $(this).offset().left>($(document).scrollLeft()+$(window).width()/2)?'e':'w';};})(jQuery);

$(function(){
	var retardo;
	var retardo2
	
	$(".salir").bind("click" ,function(ev) {	
		$.get("includes/logout.php", function(data){
					if (data){
						location.href = location.href;
					}
			});
	});
	
	function New(frame){
				 var name_text = '<a id="boxy" href="'+frame+'" rel="prettyPhoto[iframe]" class="hide"></a>';
				
				$('.MainMessage').html(name_text);
				$("#btn-del").click( function(){ Del(obj); }); $(".MainMessage:first a[rel^='prettyPhoto']").prettyPhoto({animation_speed:'normal',theme:'facebook',slideshow:3000, autoplay_slideshow: false, hideflash: true, social_tools:"", gallery_markup:"", iframe_markup:'<iframe src ="{path}" width="{width}" height="{height}" frameborder="no" scrolling="no"></iframe>'});
				$('#boxy').click();
	}

	
	function Edit(frame){

				var name_text = '<a id="boxy" href="'+frame+'" rel="prettyPhoto[iframe]" class="hide"></a>';
				
				$('.MainMessage').html(name_text);
				$(".MainMessage:first a[rel^='prettyPhoto']").prettyPhoto({animation_speed:'normal',theme:'facebook',slideshow:3000, autoplay_slideshow: false, hideflash: true, social_tools:"", gallery_markup:"", iframe_markup:'<iframe src ="{path}" width="{width}" height="{height}" frameborder="no" scrolling="no"></iframe>'});
				$('#boxy').click();
	}
	
	function edition(root, child, fnew, fedit){
		var top;
		var left;
		top = 10;
		left = 10;
		$(root).hover(function(){$(child).html('<div id="box-editor" style="position: absolute; background:#FFF; z-index: 100000; padding:4px;"><div id="btn-new" class="btn">Nuevo</div> <div class="hspacer3"></div> <div id="btn-edit" class="btn">Editar</div></div>').show(10); $("#box-editor").css("top", top); $("#box-editor").css("left", left); $("#btn-new").click( function(){ New(fnew); }); $("#btn-edit").click( function(){ Edit(fedit); }); },function(){$(child).html("").hide(10);});
	}
	
	function edition2(root, child, fnew, fedit, fa){
		var top;
		var left;
		top = 10;
		left = 10;
		$(root).hover(function(){$(child).html('<div id="box-editor" style="position: absolute; background:#FFF; z-index: 100000; padding:4px;"><div id="btn-new" class="btn">Nuevo</div> <div class="hspacer3"></div> <div id="btn-edit" class="btn">Editar</div><div id="btn-archivo" class="btn">Archivo</div></div>').show(10); $("#box-editor").css("top", top); $("#box-editor").css("left", left); $("#btn-new").click( function(){ New(fnew); }); $("#btn-edit").click( function(){ Edit(fedit); }); $("#btn-archivo").click( function(){ Edit(fa); }); },function(){$(child).html("").hide(10);});
	}
	
	$.get('includes/command.php',{uType:true},function(data){
			if (data){
				edition(".rotator1", "#content-edit-banner1", 'admin/alta_home_1.php?iframe=true&amp;width=575&amp;height=403', 'admin/lista_home_b1.php?iframe=true&amp;width=732&amp;height=300');
				edition(".rot1", "#content-edit-banner2", 'admin/alta_home_2.php?iframe=true&amp;width=575&amp;height=397', 'admin/lista_home_b2.php?iframe=true&amp;width=600&amp;height=300');
				edition(".gallery", "#conten-edit-carbobanner", 'admin/alta_bcarbono.php?iframe=true&amp;width=575&amp;height=423', 'admin/lista_bcarbono.php?iframe=true&amp;width=732&amp;height=300');
				edition(".galleryx", "#content-edit-aerth1", 'admin/alta_earth1.php?iframe=true&amp;width=575&amp;height=423', 'admin/lista_earth1.php?iframe=true&amp;width=732&amp;height=300');
				edition(".gallery-rxx", "#content-edit-aerth2", 'admin/alta_earth2.php?iframe=true&amp;width=575&amp;height=423', 'admin/lista_earth2.php?iframe=true&amp;width=732&amp;height=300');
				edition2(".gallery-r", "#content-edit-aporta", 'admin/aporta.php?iframe=true&amp;width=742&amp;height=282', 'admin/lista_aporta.php?iframe=true&amp;width=732&amp;height=300', 'admin/carga_archivo.php?iframe=true&amp;width=575&amp;height=403');
			}
	});
		
});

function opened(arg){
		//alert($('#d'+arg).height());
		if ($('#d'+arg).hasClass('hide')){
			$('#'+arg).css('color', '#54C247');
			$('#'+arg).css('font-weight', 'bold');
			$('#d'+arg).removeClass('hide');
			//setHeight($('#d'+arg).top, $('#d'+arg).height(), arg, 'datas1');
		}else{
			$('#'+arg).css('color', '#000');
			$('#'+arg).css('font-weight', 'normal');
			$('#d'+arg).addClass('hide');
			//setHeight($('#d'+arg).height(), $('#d'+arg).top, arg, 'datas1');
		}

	}
	
$(function () {
	$.get('calendar.php',{uType:true},function(data){
			if (data != ''){
				putcall(data);
			}
	})
});

function putcall(data){
		$('#calendar').html(data);
				$('.date_has_event').each(function () {
				// options
				var distance = 10;
				var time = 250;
				var hideDelay = 500;
		
				var hideDelayTimer = null;
		
				// tracker
				var beingShown = false;
				var shown = false;
		
				var trigger = $(this);
				var popup = $('.events ul', this).css('opacity', 0);
		
				// set the mouseover and mouseout on both element
				$([trigger.get(0), popup.get(0)]).mouseover(function () {
					// stops the hide event if we move from the trigger to the popup element
					if (hideDelayTimer) clearTimeout(hideDelayTimer);
		
					// don't trigger the animation again if we're being shown, or already visible
					if (beingShown || shown) {
						return;
					} else {
						beingShown = true;
		
						// reset position of popup box
						popup.css({
							bottom: 20,
							left: -76,
							display: 'block' // brings the popup back in to view
						})
		
						// (we're using chaining on the popup) now animate it's opacity and position
						.animate({
							bottom: '+=' + distance + 'px',
							opacity: 1
						}, time, 'swing', function() {
							// once the animation is complete, set the tracker variables
							beingShown = false;
							shown = true;
						});
					}
				}).mouseout(function () {
					// reset the timer if we get fired again - avoids double animations
					if (hideDelayTimer) clearTimeout(hideDelayTimer);
		
					// store the timer so that it can be cleared in the mouseover if required
					hideDelayTimer = setTimeout(function () {
						hideDelayTimer = null;
						popup.animate({
							bottom: '-=' + distance + 'px',
							opacity: 0
						}, time, 'swing', function () {
							// once the animate is complete, set the tracker variables
							shown = false;
							// hide the popup entirely after the effect (opacity alone doesn't do the job)
							popup.css('display', 'none');
						});
					}, hideDelay);
				});
			});	
	}

function ant(m, y){
	$.get('calendar.php',{m:m, y:y},function(data){
			if (data != ''){
				putcall(data);
			}
	})
}

function sig(m, y){
	$.get('calendar.php',{m:m, y:y},function(data){
			if (data != ''){
				putcall(data);
			}
	})
}
