﻿$(document).ready(function(){
	
	//troca a largura do layout
	$("#ctrLayout img").click(function(){
		$("#ctrLayout img").css("opacity","100");
		if ($(this).attr("title") == "ajustar") {
			$(this).css("opacity","0.4");
			if(jQuery.browser.msie) {
				$("body").css("width","95%");
				$("body").css("margin","-46%");
			} else {
				$("html").animate({width: "95%"}, 5000 );						
			}
		} else {
			if(jQuery.browser.msie) {
				$("body").css("width","960px");
			} else {
				$("html").animate({width: "960px"}, 5000 );
			}
			$(this).css("opacity","0.4");
		}
	});
	//troca a largura do layout
	
	
	
	//inicio: menu
	cfg = {remote:false};
	$("#menuArea").mwMenu();
	//fim: menu

	
	
	
	
	//inicio: mwGlobalSearch
	wTmp = $("#dsBusca").val();
	$("#btBusca").click(function() {
		if ($("#dsBusca").val() != wTmp) {
			//alert("buscar: "+$("#dsBusca").val());
			$("#findForm").submit();
		} else {
			$("#dsBusca").focus();
		}
	});
	$("#btBusca").focus(function() {
		$(this).text("");
	});
	
	//atribui comportamento ao campo de busca
	//ao mouse sair, se o valor igual vazio, preenche com "Palavra-Chave"
	//ao receber o foco, apaga valor do campo se valor igual "Palavra-Chave"
	$("#dsBusca").focus(function() {
		if($(this).val() == wTmp){
			$(this).val("");
		}	
	}).blur(function() {
		if($(this).val() == ""){
			$(this).val(wTmp);
		}	
	});
	//fim: mwGlobalSearch
	
	
	if ($("#EditPopup").html() != null) {
		$('#EditPopup').draggable({
			containment: 'html',
			opacity: 0.80,
			drag:function(event,ui){
				//apenas para referência futura caso precise...
				//http://www.mikesdotnetting.com/Article.aspx?ArticleID=100
				//$("#x").val(ui.position.left);
				//$("#y").val(ui.position.top);
				//$("#x2").val(ui.absolutePosition.left);
				//$("#y2").val(ui.absolutePosition.top);
			}
		});
	}
	
	if ($("#googleMaps").html() != null) {
		$("#googleMaps").googleMap(null, null, 5, {
			controls: ["GLargeMapControl", "GMapTypeControl"],
			markers: $(".geo")
		});
	}
	
	$(".brandArea p:first, #smallColLeft p:first, #smallCol p:contains('')").each(function(){
		if($(this).html() == "") {
			$(this).remove();
		}
	});
	
	
	
	if ($("#containerTabs").html() != null) {
		$('#containerTabs > ul').tabs();
	}
	
});


// NOME : Popups sendlink sendmail
function openWindow(url,name,width,height,toolbar,directories,status,menubar,scrollbars,resizable) {
    var leftPos = (screen.width-width)/2;
    var topPos = (screen.height-height)/2;
	win = open(url,name,"width="+width+",height="+height+",toolbar="+toolbar+",directories="+directories+",status="+status+",menubar="+menubar+",scrollbars="+scrollbars+",resizable="+resizable+",left="+leftPos+",top="+topPos);
}



function popupflash(varFile,varWidth,varHeight){
  	var ww=varWidth;
	var hh=varHeight;
  	var wWW=varWidth+35;
	var wHH=varHeight+115;
	var flashname=varFile;

    var leftPos = (screen.width-wWW)/2;
    var topPos = (screen.height-wHH)/2;

	var flashText='';
	flashText=flashText+'<OBJECT id="login" codeBase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" ';
	flashText=flashText+'height='+hh+' width='+ww+' align=middle classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000">';
	flashText=flashText+'<PARAM NAME="Movie" VALUE="'+flashname+'">';
	flashText=flashText+'<PARAM NAME="Src" VALUE="'+flashname+'">';
	flashText=flashText+'<PARAM NAME="WMode" VALUE="Transparent">';
	flashText=flashText+'<PARAM NAME="Play" VALUE="-1">';
	flashText=flashText+'<PARAM NAME="Loop" VALUE="-1">';
	flashText=flashText+'<PARAM NAME="Quality" VALUE="High">';
	flashText=flashText+'<PARAM NAME="SAlign" VALUE="">';
	flashText=flashText+'<PARAM NAME="Menu" VALUE="-1">';
	flashText=flashText+'<PARAM NAME="AllowScriptAccess" VALUE="always">';
	flashText=flashText+'<PARAM NAME="Scale" VALUE="ShowAll">';
	flashText=flashText+'<PARAM NAME="DeviceFont" VALUE="0">';
	flashText=flashText+'<PARAM NAME="EmbedMovie" VALUE="0">';
	flashText=flashText+'<PARAM NAME="BGColor" VALUE="FFFFFF">';
	flashText=flashText+'<PARAM NAME="SeamlessTabbing" VALUE="1">';
	flashText=flashText+'<PARAM NAME="Profile" VALUE="0">';
	flashText=flashText+'<PARAM NAME="ProfilePort" VALUE="0">';
	flashText=flashText+'<embed src="'+flashname+'" quality="high" bgcolor="#ffffff" width="'+ww+'" height="'+hh+'" name="flash" ';
	flashText=flashText+'align="middle" type="application/x-shockwave-flash" ';
	flashText=flashText+'pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	flashText=flashText+'</OBJECT>';

  	flashwdw = window.open("","flash","width="+wWW+",height="+wHH+",status=0,resizable=0,toolbar=0,top="+topPos+",left="+leftPos+",scrollbars=1");
  	flashwdw.document.write('<html><head><title>Compiere</title><link href="/lib/2004_interna.css" rel="stylesheet" type="text/css"></head>');
	flashwdw.document.write('<body leftmargin=0 rightmargin=0  topmargin=0 bottommargin=0 marginwidth=0 marginheight=0>');
	flashwdw.document.write('<a href="Javascript:window.close();"><img style="float:right;" border=0 src="/templates/megawork/img/head_pop_produtos2.gif"></a>');
	flashwdw.document.write('<img src="/templates/megawork/img/head_pop_produtos.gif">');
	flashwdw.document.write('<div style="width:100%;border-top:1px solid #454545;"></div>');
	flashwdw.document.write('<div align="center">'+flashText+'</div>');
  	flashwdw.document.write('</body>');
  	flashwdw.document.write('</html>');
    flashwdw.document.focus();
    flashwdw.document.close();
   // If we are on NetScape, we can bring the window to the front
  	if (navigator.appName.substring(0,8) == "Netscape") flashwdw.focus();
}



  // NOME : ampliar_foto
  // Descrição : Página para imagem de produtos ampliada
  // Parametros FileName    -> Nome da foto sem o caminho, sem a extensão e sem o sufixo G, 
  //                           que define qual o tamanho da foto a ser exibida
  // Parametros ProductName -> Nome do produto

function Thumb(image,titulo,w,h) {
    var hh=h , ww=w
    var leftPos = (screen.width - ww) / 2;
    var topPos = (screen.height - hh) / 2;
    photoWin = window.open( "", "photo","width=" + ww +",height=" + hh +",status=0,scrollbars=1,resizable=0,screenX=20,screenY=40,left=20,top=40");
    photoWin.document.write('<html><head><title>'+titulo+'</title></head>');
    photoWin.document.write('<link rel="stylesheet" href="/LIB/site.css" type="text/css">');
    photoWin.document.write('<BODY BGCOLOR=#ffffff>');
    photoWin.document.write('<table width=330 height=280><tr><td height=240 valign=middle>');
    photoWin.document.write('<center><img src="' + image + '"></center>');
    photoWin.document.write('</td></tr><tr><td valign=bottom height=10>');
    photoWin.document.write('<div align="right"><br><br><a style="font: bold 11px Verdana,Arial" href="Javascript:window.close();"><b>fechar</b></a></div>');
    photoWin.document.write('</td></tr></table>');
    photoWin.document.write('</body></html>');
    photoWin.document.focus();
    photoWin.document.close();
   // If we are on NetScape, we can bring the window to the front
  	if (navigator.appName.substring(0,8) == "Netscape") photoWin.focus();
}