/**
 * @author marcondes
 */
$(window).resize(function() {
	$('div#triquiback').css("width", $(document).width()-80);
	$('div#triquiback').css("height", $(document).height()-80);
	$('div#triquiback').css("width", $(document).width()-80);
	$('div#triquiback').css("height", $(document).height()-100);
	$('div#triquiback').css('background', 'url("media/home'+img+'.jpg")');
	$('div#triquiback').css('background-repeat','no-repeat');
	$('div#triquiback').css('background-attachment','fixed');
	$('div#triquiback').css('background-position','center');

	if (ua.mozilla) {
		//$('#imgFundo1').css("width",$(window).width()-2);
		var por = ($(window).width()*100)/1200;
		//alert(por-100);
		var alt = (789-((por-100)/100))-2;
		//alert(alt);
		//$('#imgFundo1').css("height",alt);
		//$('#imgFundo2').css("width",$(window).width()-2);
		//$('#imgFundo2').css("height",alt);
		$('#menu').css("width",$(window).width());
		$('#menu').css("margin-top",$(window).height()-50);
	} else if (ua.webkit) {
		//$('#imgFundo1').css("width",$(window).width());
		var por = ($(window).width()*100)/1200;
		//alert(por-100);
		var alt = (789-((por-100)/100))-2;
		//alert(alt);
		//$('#imgFundo1').css("height",alt);
		//$('#imgFundo2').css("width",$(window).width());
		//$('#imgFundo2').css("height",alt);
		$('#menu').css("width",$(window).width()+15);
		$('#menu').css("margin-top",$(window).height()-50);
	}else{
		//$('#imgFundo1').css("width",$(window).width());
		var por = ($(window).width()*100)/1200;
		//alert(por-100);
		var alt = (789-((por-100)/100))-2;
		//alert(alt);
		//$('#imgFundo1').css("height",alt);
		//$('#imgFundo2').css("width",$(window).width());
		//$('#imgFundo2').css("height",alt);
		$('#menu').css("width",$(window).width()+15);
		$('#menu').css("margin-top",$(window).height()-50);
	}
});

function getProdutos(produto) {
	$('div#produtos2').html('');
	$.get('produtos/' + produto.value + '/' + produto.value + '.php', function(data) {
		$("div#produtos2").html(data);
	});
}

function limparTela() {
	$('div#modal').css('visibility', 'hidden');
	$('div#pagina').removeClass();
	$("div#pagina").html('');
}

function criadivjanela2(id, title, container, pagina) {
	var div = document.createElement('div');
	div.id = id;
	div.title = title;
	var container = document.getElementById(container);
	container.innerHTML = '';
	container.appendChild(div);

	$('#' + id).dialog( {
		autoOpen : false,
		width : 900,
		height : 700,
		modal : true,
		draggable : false,
		resizable : false,
		position : 'top',
		closeOnEscape : true,
		buttons : {
			"Fechar" : function() {
				$(this).dialog("close");
				$(this).remove();
			}
		}
	});
	$('#' + id).dialog('open');
	$(document).ready(function() {
		$("#" + id).load(pagina + ".php");
	});
}

function criadivjanela(id, title, container, pagina) {
	var div = document.createElement('div');
	div.id = id;
	div.title = title;
	var container = document.getElementById(container);
	container.innerHTML = '';
	container.appendChild(div);

	$('#' + id).dialog( {
		autoOpen : false,
		width : 800,
		height : 600,
		modal : true,
		draggable : false,
		resizable : false,
		position : 'top',
		closeOnEscape : true,
		buttons : {
			"Fechar" : function() {
				$(this).dialog("close");
				$(this).remove();
			}
		}
	});
	$('#' + id).dialog('open');
	$(document).ready(function() {
		$("#" + id).load(pagina + ".php");
	});
}

function getPagina(pagina, classFundo) {
	// limparTela();
	// $('div#modal').css('visibility', 'visible');
	$('div#home').css('visibility', 'hidden');
	$('div#menu').css('visibility', 'hidden');
        $('div#player').css('visibility', 'hidden');
	$("div#pagina").html('Aguarde...');
	$.get(pagina + '.php', function(data) {
		$("div#pagina").html(data);
		$('div#pagina').css('visibility', 'visible');
		getProdutos(document.getElementById('produtoSelecionado'));
	});
}

function mostraFotos() {
	$('div#content').css('visibility', 'visible');
}

function FecharProdutos() {
	$("div#pagina").html('Aguarde...');
	$('div#home').css('visibility', 'visible');
	$('div#menu').css('visibility', 'visible');
	$('div#player').css('visibility', 'visible');
	$('div#pagina').css('visibility', 'hidden');

}
function limparTela() {
	$('div#modal').css('visibility', 'hidden');
	$('div#pagina').removeClass();
	$("div#pagina").fadeOut();
	$("div#pagina").html('');
}

