function addJS(url){
	var e = document.createElement('script');  
	e.src = url;
	e.type='text/javascript';
	document.getElementsByTagName("head")[0].appendChild(e);
}
function converteData(d){
	var fbData = d;
	var fbData = new Date(fbData * 1000);
	var s = fbData.getDate() + "/" + fbData.getMonth() + "/" + fbData.getFullYear();
	return s;
}

function fb_ultimoPost(){
	FB.api(
		{
		method: 'fql.query', 
		query: 'SELECT message, viewer_id, updated_time, attachment, type, permalink FROM stream WHERE source_id = 100001725439901 limit 3'
		},function(response) {
			var indice = 0;
			var bindObj = '.social-stream';
			
			alert(response[0].message);
			//$(bindObj).html("<a href='" + response[indice].permalink  + "' title='Caos - Facebook' target='_blank'>" + response[indice].message + "<br /><span class='data-post'>" + converteData(response[indice].updated_time) + "</span></a>");
			/*
			if(response[indice].attachment.media != "undefined"){
				if(response[indice].attachment.media[0].type == "photo"){
					$(bindObj).html("<div class='img-social'></div><a href='" + response[indice].permalink  + "' target='_blank' title='Caos - Facebook' >" + response[indice].message + "<br /><span class='data-post'>" + converteData(response[indice].updated_time) + "</span></a>");
					$(".img-social").html("<a href='" + response[indice].permalink  + "' target='_blank'><img src='" + response[indice].attachment.media[0].src + "' border='0' alt='" + response[indice].attachment.media[0].alt + "' title='" + response[indice].attachment.media[0].alt + "' />");
				}
			}	*/		
		}
	)
}


$(document).ready(function(){
	//addJS("http://connect.facebook.net/pt_BR/all.js");
	//fb_ultimoPost();
	if($.fn.facefeeds != undefined){
		$(".social-stream").facefeeds({'id':'100001725439901', 'query':{'limit':'2'}});
	}
    $('#cnt-detalhe-1212').text($('#ComprarObs').text());
    $('#cnt-dicas-1212').text($('#ComprarComposicao').text());
	
	$(".minis ul li a").click(function(){
    $(".video #frame-video").attr("src",$(this).attr("rel"));
    $(".minis ul li a").animate({opacity:1});
    $(this).animate({opacity:0.2});});	
	bgSound();
	$(".loja_link").click(function(){floater('./pre-cadastro.html?TB_iframe=true&height=300&width=400','images/banners/caosclube.png');});
});





function bgSound(){	
	  $("#jquery_jplayer_1").jPlayer({
		ready: function () {
		  $(this).jPlayer("setMedia", {
			mp3: "http://linxb2ccaos.blob.core.windows.net/008-001-prd/geral/linxshop/static/musica/bgsound.mp3",
			m4a: "http://linxb2ccaos.blob.core.windows.net/008-001-prd/geral/linxshop/static/musica/bgsound.m4a"
		  });
		  //$(this).jPlayer("play"); // Autoplay.
		  if($("#jquery_jplayer_1").attr("autoplay") == "false"){$("#jquery_jplayer_1").jPlayer("pause");} // Desable autoplay
		  //$(this).onSoundComplete(function() {$(this).jPlayer("play");}); //repeat	  
		},
		swfPath: "http://linxb2ccaos.blob.core.windows.net/008-001-prd/geral/linxshop/static/js",
		supplied: "mp3,m4a"
	  });
	  $("#jquery_jplayer_1").bind($.jPlayer.event.ended + ".jp-repeat", function(event) { // Using ".jp-repeat" namespace so we can easily remove this event
      	$(this).jPlayer("play"); // Add a repeat behaviour so media replays when it ends. (Loops)
      });
}
function fecharFloater(){$(".floater").fadeOut(600,function(){$(this).remove();});}
function floater(url,img){
 	/*
	$("body").append("<div id='floater' class='floater'><a href='javascript:void(0);' class='link-floater'><img src='"+ img +"' border='0'/></a></div>");
	$(".floater").append("<a href='javascript:void(0);' class='fechar-floater'><img src='images/banners/fechar.png'/></a>");
 	$(".floater").delay(500).fadeIn();
 	$(".fechar-floater").delay(500).animate({top:"-25"},700);
 	$(".fechar-floater").click(function(){fecharFloater();}); 

 	
 	$(".link-floater").click(function(){
 		fecharFloater();
 		tb_show(null, url, null);
 	}); 
 	//setTimeout('fecharFloater()','5000');
	*/
	
	
	tb_show(null,"./floater.html?TB_iframe=true&height=383&width=513",null);
	
	
	
	
	
	
}
function precadastro(){tb_show(null,"./pre-cadastro.html?TB_iframe=true&height=475&width=400",null);}

function fecharFloat(){
	tb_remove();
	//parent.document.getElementById('TB_closeAjaxWindow').style.display = "none";
	
	setTimeout("precadastro()",500);
	
}




