// JavaScript Document
$(document).ready(function(){
	//$(".lCol").height($(".Content").height());
	$(".Links a.aBubble").hover(
		function(){
			$_obj = "#" + $(this).attr("path");
			$($_obj).fadeIn("normal");
		},function(){
			$($_obj).fadeOut("normal");
		}
	);
/* Busca Global */
	$(".BuscaGlobal li#btnBusca.Close img.bgOpen").click(function(){
		$(".BuscaGlobal").animate({
			width:267,
			height:310
		},500);
		$(".BuscaGlobal li#btnBusca").removeClass("Close");
		$(".BuscaGlobal li#btnBusca").addClass("Open");
	})
	$(".BuscaGlobal li#btnBusca.Close img.bgClose").click(function(){
		$(".BuscaGlobal").animate({
			width:177,
			height:33
		},500);
		$(".BuscaGlobal li#btnBusca").removeClass("Open");
		$(".BuscaGlobal li#btnBusca").addClass("Close");
	})
	
	//Corrigindo Enderecos web das lojas
	if($("#EndSite").is("a")){
		var EndSite = $("#EndSite").attr("href");

		if(EndSite.slice(0,4) != "http") {
			$("#EndSite").attr({href:"http://" + EndSite});
		}
	}
});

function CreateFloatWindow(){
	var HTMLIndique = '<div class="AlphaBG"></div>';
	HTMLIndique = HTMLIndique + '<div class="Trailler Indique">';
	HTMLIndique = HTMLIndique + '<img src="client/images/txt_fechar.gif" onclick="RemoveFloatWindow();" alt="Fechar" class="btnFechar" />';
	HTMLIndique = HTMLIndique + '<h1><img src="client/images/tit_indique_amigo.gif" alt="Indique para um amigo" /></h1>';
	HTMLIndique = HTMLIndique + '<iframe id="iframe_float" src="index.php?actionName=Indique.exibirPagina" frameborder="0" allowtransparency="yes" name="iframe_float" style="width:385px; height:250px;" scrolling="no" />';
	HTMLIndique = HTMLIndique + '</div>';
	
	$("body").append(HTMLIndique);
	
	setTimeout(function(){$(".AlphaBG").height($("body").height());}, 500);
	//alert(HTMLIndique);
	
}

function CreateFloatWindowBlog(objId){
	var HTMLIndique = '<div class="AlphaBG"></div>';
	HTMLIndique = HTMLIndique + '<div class="Trailler Indique RDBlog">';
	HTMLIndique = HTMLIndique + '<img src="client/images/txt_fechar.gif" onclick="RemoveFloatWindow();" alt="Fechar" class="btnFechar" />';
	HTMLIndique = HTMLIndique + '<h1><img src="client/images/tit_indique_amigo.gif" alt="Indique para um amigo" /></h1>';
	HTMLIndique = HTMLIndique + '<iframe id="iframe_float" src="index.php?actionName=Indique.exibirPagina&Session=RDBlog&objId=' + objId + '" frameborder="0" allowtransparency="yes" name="iframe_float" style="width:385px; height:350px;" scrolling="no" />';
	HTMLIndique = HTMLIndique + '</div>';
	
	$("body").append(HTMLIndique);
	
	setTimeout(function(){$(".AlphaBG").height($("body").height());}, 500);
	//alert(HTMLIndique);
	
}

function CreateFWModa(){
	var HTMLModa = '<div class="AlphaBG"></div>';
	HTMLModa = HTMLModa + '<div class="Trailler Indique">';
	HTMLModa = HTMLModa + '<img src="client/images/txt_fechar.gif" onclick="RemoveFloatWindow();" alt="Fechar" class="btnFechar" />';
	HTMLModa = HTMLModa + '<h1><img src="client/images/tit_fale_pinha.gif" alt="Fale com a Pinha" /></h1>';
	HTMLModa = HTMLModa + '<iframe id="iframe_float" src="index.php?actionName=Index.modaContato" frameborder="0" allowtransparency="yes" name="iframe_float" style="width:385px; height:250px;" scrolling="no" />';
	HTMLModa = HTMLModa + '</div>';
	
	$("body").append(HTMLModa);
	
	setTimeout(function(){$(".AlphaBG").height($("body").height());}, 500);
	//alert(HTMLIndique);
	
}

function RemoveFloatWindow(){
	//document.getElementById('divFloat').style.display = 'none';
	$(".AlphaBG, .Indique").remove();
}

function OpenTrailler(id_cinema_filme) {
	//var HTMLTrailler = loadContentAjax( "index.php?actionName=SlideShow.exibirTrailler&id_cinema_filme=" +id_cinema_filme );
	var HTMLTrailler = LoadContent( "index.php?actionName=SlideShow.exibirTrailler&id_cinema_filme=" +id_cinema_filme, "body" );
	$("body").append(HTMLTrailler);

	$(".AlphaBG").height($("body").height());
}

function CloseTrailler() {
	$(".AlphaBG, .Trailler").remove();
}

function OpenGallery(id_cinema_filme) {
	/*alert(LoadContent("templates/gallery.php", "body"));
	var HTMLGallery = LoadContent("templates/gallery.php", "body");
	$("body").append(HTMLGallery); */
	//loadContentAjax("index.php?actionName=SlideShow.exibirPagina&id_cinema_filme=" + id_cinema_filme);
	
	var HTMLGallery = LoadContent("index.php?actionName=SlideShow.exibirPagina&id_cinema_filme=" + id_cinema_filme, "body");
	$("body").append(HTMLGallery);
	
	setTimeout(function(){$(".AlphaBG").height($("body").height());}, 500);
}

function CloseGallery() {
	$(".AlphaBG, .SlideShow").remove();
}

function loadContentAjax(url) {
	ajaxLoader.setUrl(url);
	ajaxLoader.loadFile();
}

function LoadContent(Url, Obj) {
	$.ajax({
		url: Url,
		cache: false,
		success: function(html){
			AjaxResult = html;
			$(Obj).append(html);
		},
		error: function(){
			alert("erro na requisicao");
		}
	});
	
}

function WriteFlash(path, width, height, opacity) {
  document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' width='"+width+"' height='"+height+"'>");
  document.write("<param name='movie' value='"+path+"'>");
  document.write("<param name='quality' value='high'>");
  if(opacity == "yes"){
    document.write("<param name='wmode' value='transparent'>");
  }else{
    document.write("<param name='BGCOLOR' value='#ffffff'>");
  }
  document.write("<embed src='"+path+"' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash'"); 
  if(opacity == "yes"){
    document.write(" wmode='transparent'");
  }else{
    document.write(" bgcolor='#ffffff' ");
  }
  document.write("width='"+width+"' height='"+height+"'></embed>");
  document.write("</object>");
}

function URLencode(sStr) {
	return 	escape(sStr).
			replace(/\+/g, '%2B').
			replace(/\"/g,'%22').
			replace(/\'/g, '%27').
			replace(/\//g,'%2F');
}

function NWOpen(nome, width, height, url) {
	window.open(url, nome, '"status , scrollbars=1, height=' + height + ', width='+ width + '"');
}

function OpenMap(uni) {
	var HTMLMap = '<div class="AlphaBG"></div>';
	HTMLMap = HTMLMap + '<div class="Trailler Uni'+ uni +'">';
	HTMLMap = HTMLMap + '<img src="client/images/txt_fechar.gif" onclick="CloseTrailler()" alt="Fechar" class="btnFechar" />';
	HTMLMap = HTMLMap + '<h1><img src="client/images/txt_tit_' + uni + '.gif" alt="" /></h1>';
	HTMLMap = HTMLMap + '<img src="client/images/mapa_' + uni + '_g.jpg" alt="" />';
	HTMLMap = HTMLMap + '</div>';
	
	$('body').append(HTMLMap);
}

function OpenStaticGallery() {
	var HTMLGallery = LoadContent("gallery.php" , "body");
	$("body").append(HTMLGallery);
	
	setTimeout(function(){$(".AlphaBG").height($("body").height());}, 500);
}

function ZerarCampo(obj, txt) {
	if ($(obj).val() == txt) $(obj).val("");
}