function montaFlash(swf, vars, width, height, id, wmode, cache) {
	noCache = cache || cache == undefined ? "" : "?" + new Date();
	monta_swf = "";
	monta_swf += "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0\" id=\""+ id +"\" width=\""+ width +"\" height=\""+ height +"\" title=\"\">";
	monta_swf += "<param name=\"movie\" value=\""+ swf + noCache +"\" />";
	monta_swf += "<param NAME=FlashVars value=\""+ vars +"\" />";
	monta_swf += "<param name=\"quality\" value=\"high\" />";
	monta_swf += "<param name=\"menu\" value=\"false\" />";
	monta_swf += "<param name=\"wmode\" value=\""+ wmode +"\" />";
	monta_swf += "<embed src=\""+ swf + noCache +"\"  FlashVars=\""+ vars + "\" quality=\"high\" menu=\"false\" wmode=\""+ wmode +"\"  pluginspage=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" id=\""+ id +"\" width=\""+ width +"\" height=\""+ height +"\"></embed>";
	monta_swf += "</object>";
	document.write(monta_swf);
}

function popWin(URL,NAME,WIDTH,HEIGHT,RESIZE,SCROLL) {
   winId = window.open(URL,NAME,'width='+WIDTH+',height='+HEIGHT+',resizable='+RESIZE+',scrollbars='+SCROLL+',menubar=no,toolbar=no,location=no,directories=no,status=no');
	var clientWidth = screen.availWidth;
	var clientHeight = screen.availHeight;
	var xPos = (clientWidth - WIDTH)/2;
	var yPos = (clientHeight - HEIGHT)/2;
	winId.moveTo(xPos,yPos);
}

function CheckMail(str){
	var testresults
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(str)) testresults=false
	else testresults=true
	return (testresults)
}

function openEnq(id) {
	popWin('enquetes.php?id='+id,'enquet'+id,315,500,'no','auto');
}

function ajaxLink(div,pag) {
	$.get(pag,{qazc:'1'}, function(retorno){ $("#"+div).html(retorno); });
}

function changeBox(div,pag,tel) {
	$.get(pag,{tela:tel}, function(retorno){ $("#"+div).html(retorno); });	
}

function abreDiv(dv) {
	$("#"+dv).slideToggle();
}

function cChange(div,clas) {
	var a = div.split(',');
	for(x=0;x<=a.length-1;x++) {
	document.getElementById(a[x]).className = clas;
	}
}

function checkLogin() {
	if($("#logUser").val()=='') {
		alert("Digite seu usuario!");
		$("#logUser").focus();
	} else if($("#logSenha").val()=='') {
		alert("Digite sua senha!");
		$("#logSenha").focus();
	} else {
		$("#loaderLogin").show();
		$.get("_ajaxPeG.php",{tela:'login',act:'login',usuario:$("#logUser").val(),senha:$("#logSenha").val()}, function(retorno){ trataLogin(retorno); });
	}
	return false;
}

function logOut() {
	$("#logOut").html('<img src="img/loader1.gif" width="16" height="16">');
	$.get("_ajaxPeG.php",{tela:'login',act:'logout'}, function(){ $("#boxLogin").load("_boxLogin.php?tela=login"); });
	$("#div_muda").load("_promocoes.php?tela=naologado");
	
	$("#infoLogado").show();
	return false;
}

function trataLogin(i) {
		if(i=='0') {
			alert("Usuário ou senha inválido!");
			$("#logUser,#logSenha").val('');
			$("#div_muda").load("_promocoes.php?tela=naologado");
			
		} else if(i=='1') {
			// ok
			$("#boxLogin").load("_boxLogin.php?tela=login");
			
			$("#div_muda").load("_promocoes.php?tela=logado");
			
			$("#infoLogado").hide();
		}
		$("#loaderLogin").hide();
}

var timeout;

function abreWin(url) {
	$("#overlay").height(document.body.clientHeight);
	$("#overlay").show();
	$("#overlay").fadeTo(0.01, 0.7, function() {
		$("#overlay_content").show();
		$("#overlay_content").width(450);
		$("#overlay_content").height(250);
		$("#overlay_content").load(url);
		upWin();
	});
	
}

function youtube(src) {
	$("#overlay").height(document.body.clientHeight);
	$("#overlay").show();
	$("#overlay").fadeTo(0.01, 0.7, function() {
		$("#overlay_content").show();
		$("#overlay_content").width(425);
		$("#overlay_content").height(344);
		$("#overlay_content").flash({src:src,width:425,height:344},{version:8}).unload(src);
		upWin();
	});

}

function upWin() {
	aVw = document.documentElement.clientWidth/2;
	aVh = document.documentElement.clientHeight/2;
	cWi = $("#overlay_content").width()/2;
	cHe = $("#overlay_content").height()/2;
	$("#overlay_content").css({ top:(aVh-cHe)+document.documentElement.scrollTop, left:(aVw-cWi)+document.documentElement.scrollLeft });
	timeout = setTimeout('upWin()', 200);
}

$(document).keydown(function(event){
	if(event.keyCode==27)fechaVideo();
});

function fechaVideo(){
   $("#overlay").hide('slow', 0, function(){$(this).remove();});
   $("#overlay_content").hide('slow', 0, function(){$(this).remove();});
   $("#overlay_content").unload("#overlay_content");
}


function SetF(id, vv) {
	try { $(id)[0].type; }
	catch(e) {return}
	if(!$(id)[0].type) {
		var type = $("input[@name="+id.replace("#","")+"]")[0].type;
		var o = $("input[@name="+id.replace("#","")+"]");
	} else {
		var type = $(id)[0].type;
		var o = $(id);
	}
	if(typeof vv == "string" || typeof vv == "number"){
		v = []; 
		v.push(vv); 
	}
	else v = vv;
	switch(type) {
		case "radio":
		case "checkbox":
		case "select-multiple":
		case "select-one":
				o.val(v);
				break;
		default:
			o.val(v.join(','));
	}
}

function UnSetF(slist) {
	var l = slist.split(',');
	for(var i=0; i < l.length; i++)	{
		SetF(l[i],'');
	}
}

function check_recover(oque) {
	if($("#fldEmail").val()=='') { 
	   $("#msgErro").html('Preencha seu e-mail');
	   return false;
	} else if(CheckMail($("#fldEmail").val())) {
		$("#msgErro").html('Preencha seu e-mail, corretamente');
		return false;
	} else {
		$("#fldSubmit").val("Enviando...");
		$("#fldSubmit").attr("disabled",true);
		$.get("_ajaxPeG.php",{tela:oque,email:$("#fldEmail").val()}, function(retorna){ $("#fldEmail").val(""); $("#fldSubmit").val("Enviar"); $("#fldSubmit").attr("disabled",false);  if(retorna==1) { $("#msgErro").html('Foi enviado um e-mail contendo seus dados!'); } else { $("#msgErro").html('Este e-mail não foi encontrado, verifique!'); } });
		return false;
	}
}

$(document).ready(function() {
	$.mask.addPlaceholder('~',"[0-1]");
	$.mask.addPlaceholder('^',"[0-3]");
	$.mask.addPlaceholder(',',"[0-2]");
	$.mask.addPlaceholder('.',"[0-6]");
	$("#data,#filtro_data1,#filtro_data2").mask("^9/~9/99");
	$("#hora").mask(",9:.9:.9");
    $("#recado").click(function () {
    
	$("#div_recado").slideToggle("normal");
    });
	
	$("#recad2").click(function () {
    
	$("#div_recado").slideToggle("normal");
    });
	
	$('.tr1').hover(function(){
    	$(this).css("background-color","#fff2ea");
	}, function(){
		$(this).css("background-color","white");
	});
	$('.tr2').hover(function(){
    	$(this).css("background-color","#fff2ea");
	}, function(){
		$(this).css("background-color","#f9f9f9");
	});
	
	$('.lkTop').click(function() {
		$.scrollTo('#inicio', 1500);
		
	});

});

$(document).ready(function() { 
	// bind 'myForm' and provide a simple callback function 
	$('#recado').ajaxForm(function() { 
		alert("Thank you for your comment!"); 
	}); 
}); 

$(function() {
    $(".anyClass").jCarouselLite({
        visible: 6,
		btnNext: ".next",
        btnPrev: ".prev",
		speed: 800, 
		scroll: 6
    });
});

// COLORBOX
//exemplos:
// ABAIXO
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//This hides the inline content if JavaScript is supported.
document.write("<style type='text/css'>.hidden{display:none;}<\/style>");

$(document).ready(function(){
//Examples of Global Changes
$.fn.colorbox.settings.bgOpacity = "0.9";

/*
//Examples of how to assign the ColorBox event to elements.
$("a[rel='jack']").colorbox({transition:"fade"});
$(".colorbox").colorbox({transition:"none", fixedWidth:"75%",fixedHeight:"75%", initialWidth:"75%", initialHeight:"75%"});
*/

$("a[rel='ampliarimgs']").colorbox({transition:"elastic", contentCurrent:"{current} / {total}"});
$("a[title='verobras']").colorbox();
$("a[rel='impressao']").colorbox({fixedWidth:"80%", fixedHeight:"70%", iframe:true});
$("a[rel='textos']").colorbox({fixedWidth:"60%", fixedHeight:"50%", iframe:true});
$("a[rel='vervideo']").colorbox({fixedWidth:"600", fixedHeight:"600", iframe:true});
$("a[rel='vertrailler']").colorbox({fixedWidth:"600", fixedHeight:"600", iframe:true});

$("a[rel='trailer']").colorbox({fixedWidth:"600", fixedHeight:"600", iframe:true});
$("a[rel='clipes']").colorbox({fixedWidth:"600", fixedHeight:"600", iframe:true});
$("a[rel='gols']").colorbox({fixedWidth:"600", fixedHeight:"600", iframe:true});
$("a[rel='globo']").colorbox({fixedWidth:"600", fixedHeight:"600", iframe:true});

$("a[rel='painelnoticias']").colorbox({fixedWidth:"70%", fixedHeight:"70%", iframe:true});
$("a[rel='painelartigos']").colorbox({fixedWidth:"70%", fixedHeight:"70%", iframe:true});
$("a[rel='painelvideos']").colorbox({fixedWidth:"70%", fixedHeight:"70%", iframe:true});

/*
$("#flash").colorbox({href:"../content/flash.html"});
$("a[href='http://google.com']").colorbox({fixedWidth:"80%", fixedHeight:550, iframe:true});
$("#inline").colorbox({fixedWidth:"50%", inline:true, href:"#inline_example"});

//Example of preserving a JavaScript event for inline calls.
$("#click").click(function(){ 
$('#click').css({"background-color":"#f00", "color":"#fff", "cursor":"inherit"}).text("Open this window again and this message will still be here.");
});
*/
});


