// JavaScript Document
//
function getLastTwitt(target){
    target.html("Cargando datos de Twitter...");
	var username='FuerzaMonarca'; 
	var format='json'; 
	var url='http://api.twitter.com/1/statuses/user_timeline/'+username+'.'+format+'?callback=?'; 
	$.getJSON(url,function(tweet){ 
		target.html("<table width='290' height='40'><tr><td width='290' height='40' valign='middle' align='center'>" + parseTweet(tweet[0].text) + "</td></tr></table>");
	});
}

function parseTweet(text) {
    var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
    var link=text.replace(exp,"<a href='$1' target='_blank' class='hashtag-txt'>$1</a>"); 
	return link.replace(/(^|\s)#(\w+)/g, "$1#<a href='http://search.twitter.com/search?q=%23$2' target='_blank' class='hashtag-txt'>$2</a>")
}

function getBackground(idFoto){
	$.post("setBackground.aspx", { id: idFoto },
   	function(data) {
     	alert("Data Loaded: " + data);
   	});	

}









var droplinemenu={


animateduration: {over: 0, out: 0},

buildmenu:function(menuid){
	jQuery(document).ready(function($){
		var $mainmenu=$("#"+menuid+">ul")
		var $headers=$mainmenu.find("ul").parent()
		$headers.each(function(i){
			var $curobj=$(this)
			var $subul=$(this).find('ul:eq(0)')
			this._dimensions={h:$curobj.find('a:eq(0)').outerHeight()}
			this.istopheader=$curobj.parents("ul").length==1? true : false
			if (!this.istopheader)
				$subul.css({left:0, top:this._dimensions.h})
			var $innerheader=$curobj.children('a').eq(0)
			$innerheader=($innerheader.children().eq(0).is('span'))? $innerheader.children().eq(0) : $innerheader //if header contains inner SPAN, use that
			
			$curobj.hover(
				function(e){
					
					
					var $targetul=$(this).children("ul:eq(0)")
					if ($targetul.queue().length<=1) //if 1 or less queued animations
						if (this.istopheader)
							$targetul.css({left: $mainmenu.position().left, top: $mainmenu.position().top+this._dimensions.h})
						if (document.all && !window.XMLHttpRequest) //detect IE6 or less, fix issue with overflow
							$mainmenu.find('ul').css({overflow: (this.istopheader)? 'hidden' : 'visible'})
						$targetul.dequeue().slideDown(droplinemenu.animateduration.over)
						
						switch($(this).attr('id')){
							case 'uno':
								$targetul.css({left:'+=0px' });
								break;
							case 'dos':
								$targetul.css({left:'+=0px' });
								break;
							case 'tres':
								$targetul.css({left:'+=0px' });
								break;
							case 'cuatro':
								$targetul.css({left:'+=240px' });
								break;
							case 'cinco':
								$targetul.css({left:'+=370px' });
								break;
							case 'seis':
								$targetul.css({left:'+=460px' });
								break;
						}
				},
				function(e){
					var $targetul=$(this).children("ul:eq(0)")
					$targetul.dequeue().slideUp(droplinemenu.animateduration.out)
					
				}
			) //end hover
		}) //end $headers.each()
		$mainmenu.find("ul").css({display:'none', visibility:'visible', width:$mainmenu.width()})
	}) //end document.ready
}
}
