/* For search*/
jQuery(document).ready( function() {
	jQuery("#searchform").submit( function (){
		if(jQuery("#search-text").val() == "" || jQuery("#search-text").val() == "Palabra de búsqueda")
		{
			alert("Completa la palabra de búsqueda");
			jQuery("#search-text").focus();
		}else{
			jQuery("#searchform").attr("action",jQuery("#name").val());
			window.open(jQuery("#name").val()+"?&s="+jQuery("#search-text").val());
		}
	return false;
	});
	
	jQuery("#marq_html").html(" ");
	var html = "";
	jQuery.get(jQuery('#url_template').html()+"/frases.php", function(d) {
				
				//find each 'item' in the file and parse it
				jQuery(d).find('item').each(function() {
					
					//name the current found item this for this particular loop run
					var $item = jQuery(this);
					// grab the post title
					var title = $item.find('title').text();
					// grab the post's URL
					var link = $item.find('link').text();
					// next, the description
					var description = $item.find('description').text();
					//don't forget the pubdate
					var pubDate = $item.find('pubDate').text();
					var content = $item.find('content_encoded').text();
					// now create a var 'html' to store the markup we're using to output the feed to the browser window
					html = content;
					var frase4 = html.replace(/\[INGENET\]/gi,'<img src="'+jQuery('#url_template').html()+'/images/avatar.png" height="20" align="left"/> ');
					frase4 = frase4.replace(/\[TWITTER\]/gi,'<img src="'+jQuery('#url_template').html()+'/images/twitter_icon2.png" height="20" align="left"/> ');
					jQuery('#marq_html').append(jQuery('<marquee  class="marquee2" behavior="scroll" direction="down" scrollamount="2" height="100" width="288" style="padding:5px;">'+frase4+'</marquee>'));
					//put that feed content on the screen!
					 jQuery('.marquee2').marquee('pointer').mouseover(function () {
           					 jQuery(this).trigger('stop');
        				}).mouseout(function () {
           					 jQuery(this).trigger('start');
        				}).mousemove(function (event) {
            					if (jQuery(this).data('drag') == true) {
                					this.scrollLeft = jQuery(this).data('scrollX') + (jQuery(this).data('x') - event.clientX);
            					}
        				}).mousedown(function (event) {
           						 jQuery(this).data('drag', true).data('x', event.clientX).data('scrollX', this.scrollLeft);
        				}).mouseup(function () {
            						jQuery(this).data('drag', false);
        				});
					
				});
			
	});	
	
	 // basic version is: $('div.demo marquee').marquee() - but we're doing some sexy extra
});

