var $= jQuery.noConflict();

/*
(function($) {
	var imgList = [];
	$.extend({
		preload: function(imgArr, option) {
			var setting = $.extend({
				init: function(loaded, total) {},
				loaded: function(img, loaded, total) {},
				loaded_all: function(loaded, total) {}
			}, option);
			var total = imgArr.length;
			var loaded = 0;
			
			setting.init(0, total);
			for(var i in imgArr) {
				imgList.push($("<img />")
					.attr("src", imgArr[i])
					.load(function() {
						loaded++;
						setting.loaded(this, loaded, total);
						if(loaded == total) {
							setting.loaded_all(loaded, total);
						}
					})
				);
			}
			
		}
	});
})(jQuery);*/

$(document).ready(function(){
	
	$(".drag").draggable({ cursor: "move" });
				
	$(".post iframe, .post object, .post embed").each(function(){
		var largura = $(this).parents('.post').css('width');
		var altura = $(this).parents('.post').css('height');
		
		$(this).attr('width', largura);
		$(this).attr('height', altura);
	});
	
	$('img').removeAttr('title');
	
	// escrevi esta parte pro post de INFO
	$('.maismenos').live('click', function(){
		if ($(this).text() == '+A')
			$(this).text('-A')
		else
			$(this).text('+A')
//					$('.maismenos').toggleClass('maior');
		$(this).parents('.post').toggleClass('maior');
	});
	
	$("a.more-link").click( function() {
		
		var destino= $(this).parents(".post").attr("id")+"_inner";
		$("#"+destino).html("...");
		
		$(this).parents(".post").removeClass("more");
		
		$(this).hide();
		
		$.get($(this).attr("href"), { ajax: '1' },
	
		function(retorno) {
			$("#"+destino).html(retorno);
		});
		
		return false;
	});
	
	$("div.more img").click( function() {
		
		var destino= $(this).parents(".post").attr("id")+"_inner";
		$("#"+destino).html("...");
		
		$(this).parents(".post").removeClass("more");
		
		var post_pai= $(this).parents(".post").attr("id");
		var url= $("#"+post_pai+" a.more-link").attr("href");
		
		$("#"+post_pai+" a.more-link").hide();
		
		$.get(url, { ajax: '1' },
	
		function(retorno) {
			$("#"+destino).html(retorno);
		});
		
		return false;
	});
	
});


//        
//$.fn.media.defaults = { 
//    preferMeta:    1,         // true if markup metadata takes precedence over options object 
//    autoplay:      0,         // normalized cross-player setting 
//    bgColor:       '#ffffff', // background color 
//    params:        {},        // added to object element as param elements; added to embed element as attrs 
//    attrs:         {},        // added to object and embed elements as attrs 
//    flashvars:     {},        // added to flash content as flashvars param/attr 
//    flashVersion:  '7',       // required flash version 
// 
//    flvPlayer:     'http://hifolio.com/_libstatic/mediaplayer/player.swf', 
//    mp3Player:     'http://hifolio.com/_libstatic/mediaplayer/player.swf', 
//};         



/*$.preload([
	template_url+"/images/loading.gif"
]);
*/

$(function() {

	//$("a[href*='mp3']").css('color','red');
	$("a[href*='mp3']").each(function(i) {
		var href = $(this).attr('href');
		
		if (!document.createElement('audio').canPlayType('audio/mpeg;')) {
			var params = {
				swf: template_url+'/js/player.swf',
				width: 230,
				height: 24,
				hasVersion: 9,
				params: {
					allowfullscreen: true,
					AllowScriptAccess: "always"
				},

				flashvars: {
					file: href
					,
					backcolor: "#000000",
					frontcolor: "#ffffff",
					lightcolor: "#ffffff"
				}
			}
			
			var myFlash = $.flash.create(params);
			$(this).after(myFlash)
			$(this).remove();
		}
		else
			$(this).html('<audio controls="controls" src="'+href+'"><source src="'+href+'" type="audio/mp3"></audio>')
	});
	
});

// desabilita o arrastar das imagens quando ela nao é arrastavel
window.onload = function (e) {
	var evt = e || window.event,// define event (cross browser)
		imgs,                   // images collection
		i;                      // used in local loop
	// if preventDefault exists, then define onmousedown event handlers
	if (evt.preventDefault) {
		// collect all images on the page
		imgs = document.getElementsByTagName('img');
		// loop through fetched images
		for (i = 0; i < imgs.length; i++) {
			// and define onmousedown event handler
			imgs[i].onmousedown = disableDragging;
		}
	}
};

// disable image dragging
function disableDragging(e) {
	e.preventDefault();
}			


/*
<script type="text/javascript"> 
var $buoop = {vs:{i:7,f:2,o:10.5,s:3,n:9}} 
$buoop.ol = window.onload; 
window.onload=function(){ 
 if ($buoop.ol) $buoop.ol(); 
 var e = document.createElement("script"); 
 e.setAttribute("type", "text/javascript"); 
 e.setAttribute("src", "http://browser-update.org/update.js"); 
 document.body.appendChild(e); 
} 
</script> 
*/
