Util = {
	
		excluiLista:

		function(cod) {
			

			if (confirm("Deseja realmente excluir sua lista de presentes?")){ 
				//Util.loadHtml('#minhasCompras','?go=listadepresentes/deleta_lista.php&cod='+cod);
				document.location.href = "?go=listadepresentes/&action=D";
			}else
				return false;

		},

	splitFrameV:

		function (enable) {



			if (enable == false) {

				$("#frameCenterLeft").hide();

				$("#frameCenter").css("margin", "0 5px 0 5px");

			}

			else {

				$("#frameCenterLeft").show();

				$("#frameCenter").css("margin", "0 5px 0 210px");

			}

		},



	splitFrameH:

		function (enable) {



			if (enable == false) {

				$("#frameCenterRightTop").attr("style", "");

				$("#frameCenterRightBottom").attr("style", "");

				$(".hsplitbar").remove();

				$("#frameCenterRightTop").css("height", "100%");

				$("#frameCenterRightTop").css("background-image", "url(/imagens/linha.gif)"); 

				$("#frameCenterRightTop").css("background-position", "bottom");

				$("#frameCenterRightTop").css("background-repeat", "repeat-x");

				$("#frameCenterRightBottom").hide();

			}

			else {

				$("#frameCenterRightTop").css("height", "50%");

				$("#frameCenterRightTop").css("background-image", ""); 

				$("#frameCenterRightTop").css("background-position", "");

				$("#frameCenterRightTop").css("background-repeat", "");

				$("#frameCenterRightBottom").show();

			

				$(".hsplitbar").remove();

				$("#frameCenterRight").splitter({

					type: "h",

					accessKey: "_"

				});

				

				$(window).bind("resize", "this.setSizeContent()");

				

			}

		},



	openMsgBox:

		function(url) {

			$("#MsgBox").html('');

			this.loadHtml("#MsgBox", url);

			$("#MsgBox").show();

			$("#MsgBox").bgiframe();

		},



	closeMsgBox:

		function() {

			$("#MsgBox").html('');

			$("#MsgBox").hide();

		},



	submitFormMsgBox:



		function(msg, typeMsgBox, idForm, action, div) {

			this.loadHtml("#MsgBox", "/includes/pages/msgbox.php?msg[]=" + msg);

			$("#MsgBox .contentMsgBoxBottom").hide();

			if (typeMsgBox == 1) {

				$("#MsgBox #contentMsgBoxBottomYes").show();

				$("#hrefButtomYes").attr("href", "javascript: Util.submitForm('" + idForm + "', " + "'" + action + "', '" + div + "');");

				$("#MsgBox #contentMsgBoxBottomNo").show();

			}

			else {

				$("#MsgBox #contentMsgBoxBottomOk").show();

			}



			$("#MsgBox").show();

			$("#MsgBox").bgiframe();

			//this.submitForm(idForm, action, div);

		},



	submitForm:

		function(div, form) {
			
			
			$.ajax( {
			  url: $(form).attr("action"),
			  type: $(form).attr("method"),
			  data: $(form).serialize(),
			  cache: false,
			  async: false,
			  success: function(html){
				  $(div).html('');
				  $(div).html(html);
				  
			  },
			  error: function(html) {
				  $(div).html('');
				  $(div).html(html);
			  }
			});

	
		},



	loadHtml:



		function(frameName, Url) {

			//$(frameName).html('Carregando...');
			
			$('#loading').show();

			$.ajax( {

			  url: Url,

			  type: "GET",

			  cache: true,

			  async: false,

			  success: function(html){

				$(frameName).html(html);
				$('#loading').hide();

			  }

			});

			//setTimeout('$(\'#frameLoading\').hide();', 100);

		},



	openModule:



		function(id, moduleUrl, topUrl, bottomUrl) {

			if (moduleUrl != "")

				this.splitFrameV(true);

			else

				this.splitFrameV(false);

				

			$('#frameTop .ativo').removeClass();

			$('#frameTop #' + id).addClass('ativo');

			if (moduleUrl != "") {

				this.loadHtml('#frameCenterLeftContent', moduleUrl);

			}

			this.openFunction(topUrl, bottomUrl);

		},



	openSubModule:

	

		function(id, description, image, treeViewUrl, topUrl, bottomUrl) {

			$('#frameCenterLeftBoxModuloTreeview').hide();

			$('#frameCenterLeftBoxModuloList').show();

			$('#frameCenterLeftBoxModuloToolBar').show();

			if (treeViewUrl != "") {

				$('#frameCenterLeftBoxModuloToolBar li').show();

				$('#frameCenterLeftBoxModuloToolBar #' + id).hide();

				$('#frameCenterLeftBoxModuloList').hide();

				$('#frameCenterLeftBoxModuloTreeview').show();

				this.loadHtml('#frameCenterLeftBoxModuloTreeviewBox', treeViewUrl);

			}

			else

				$('#frameCenterLeftBoxModuloToolBar').hide();



			$('#frameCenterLeftBox .ativo').removeClass();

			$('#frameCenterLeftBox .cabecalho').html('<img src="' + image + '" alt="' + description + '" width="26" height="26" align="absmiddle" /> ' + description);

			$('#frameCenterLeftBoxModuloToolBar #' + id).addClass('ativo');

			$('#frameCenterLeftBoxModuloList #' + id).addClass('ativo');



			this.openFunction(topUrl, bottomUrl);

		},



	openFunction:

	

		function(topUrl, bottomUrl) {

			if (bottomUrl != "")

				this.splitFrameH(true);

			else

				this.splitFrameH(false);



			if (topUrl != "")

				this.loadHtml('#frameCenterRightTopContent', topUrl);

			else

				$('#frameCenterRightTopContent').html('');



			if (bottomUrl != "") {

				this.loadHtml('#frameCenterRightBottomContent', bottomUrl);

			}

			else

				$('#frameCenterRightBottomContent').html('');

			

			Util.setSizeContent();

		},



	openFunctionBottom:

	

		function(bottomUrl) {

			if (($("#frameCenterRightBottom").css("display") == "none") && (bottomUrl != "")){

				if (bottomUrl != "")

					this.splitFrameH(true);

				else

					this.splitFrameH(false);

			}



			if (bottomUrl != "") {

				this.loadHtml('#frameCenterRightBottomContent', bottomUrl);

			}

			Util.setSizeContent();

		},



	closeFunctionBottom:

	

		function() {

			this.splitFrameH(false);

			Util.setSizeContent();

		},



	getBrowser:

		function() {

			if( typeof( window.innerWidth ) == 'number' )

				return 0; //Firefox

			else

				return 1; //IE

		},



	getSize:

		function() {

			var myWidth = 0, myHeight = 0;

			if( typeof( window.innerWidth ) == 'number' ) {

				//Non-IE

				myWidth = window.innerWidth;

				myHeight = window.innerHeight;

			} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {

				//IE 6+ in 'standards compliant mode'

				myWidth = document.documentElement.clientWidth;

				myHeight = document.documentElement.clientHeight;

			} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {

				//IE 4 compatible

				myWidth = document.body.clientWidth;

				myHeight = document.body.clientHeight;

			}

			_myWidth = myWidth;

			_myHeight = myHeight;

		},





	initEditor:

		function (cd_sisma, field, width, height) {



			//$(document).ready ( function() {

			Ext.onReady( function() {

					if (typeof height == "undefined")

						height = 350;



					if (typeof width == "undefined")

						width = 250;



					if ((typeof cd_sisma == "undefined") || (typeof field == "undefined"))

						return;

		

					//Ext.onReady( function() {  

										  

						Ext.form.HtmlEditorFivecom = Ext.extend(Ext.form.HtmlEditor, {



							//essa funcao foi necessaria refaze-la (herdar), pois o on fivemidia estava com bug.

							//foi trocado as chamadas dos medodos execCmd para relayCmd

							insertAtCursor : function(text){

								if(!this.activated){

									return;

								}

								if(Ext.isIE){

									this.win.focus();

									var r = this.doc.selection.createRange();

									if(r){

										r.collapse(false);

										r.pasteHTML(text);

										(function(){

											this.syncValue();

											this.deferFocus();

										}).defer(10, this);



									}

								}else if(Ext.isGecko || Ext.isOpera){

									this.win.focus();

									this.relayCmd('InsertHTML', text);

									this.deferFocus();

								}else if(Ext.isSafari){

									this.relayCmd('InsertText', text);

									this.deferFocus();

								}

							},

																

							createToolbar : function(editor) {

								Ext.form.HtmlEditorFivecom.superclass.createToolbar.call(this, editor);

								

								this.tb.add(

									'-',

									{

										itemId : 'insertMidia',

										cls : 'x-btn-icon x-edit-'+'insertMidia',

										enableToggle:false !== false,

										scope: editor,

										handler:function() { Util.openFivemidia(cd_sisma, field) }||editor.relayBtnCmd,

										clickEvent:'mousedown',

										tooltip: this.tipsEnabled ? editor.buttonTips[id] || undefined : undefined,

										tabIndex:-1,

										icon: 'editar.gif',

										tooltip: 'inserir Midias (editar.gif)'

									}

								);

							}

							

						});

						

						Ext.reg('htmleditorfivecom', Ext.form.HtmlEditorFivecom);

		

						var ed = new Ext.form.HtmlEditorFivecom({

							height: height,

							width: width,

							//autoWidth : true,

							id:"htmledit_" + field,

							enableFormat:true,

							enableAlignments:true,

							enableFont:true,

							enableFontSize:true,

							enableLinks:true,

							enableLists:false,

							enableSourceEdit:true,

							applyTo: field,

							layout: "fit",

							listeners: { 

								'sync':function(htmlEditor, e) { 

									//alert('sync');

								},

								'push':function(htmlEditor, e) { 

									//alert('push');

								}								

							}

						});

						

		

					//}); 



			});

			

		},





	setSizeContent:

		function() {

			

			var lLngOffSetTitulo = 0;

			var lLngOffSetToolbar = 0;

			var lLngFrameCenterRightTop = 0;



			lLngOffSetTitulo = $("#frameCenterRightTopContent .functionTitle").size();

			lLngOffSetTitulo = lLngOffSetTitulo * 25;



			lLngOffSetToolbar = $("#frameCenterRightTopContent .ToolBar").size();

			lLngOffSetToolbar = lLngOffSetToolbar * 25;

			

			//Variavel do Tamanho do FrameCenterRightTop

			lLngFrameCenterRightTop = parseInt($("#frameCenterRightTop").height().replace("px"));

			

			$("#frameCenterRightTopContent .functionBox").css("height", lLngFrameCenterRightTop - lLngOffSetTitulo - lLngOffSetToolbar - 0);

			$("#frameCenterRightTopContent #gridBox").css("height", lLngFrameCenterRightTop - lLngOffSetTitulo - lLngOffSetToolbar - 0);



			lLngOffSetTitulo = $("#frameCenterRightBottomContent .functionTitle").size();

			lLngOffSetTitulo = lLngOffSetTitulo * 25;



			lLngOffSetToolbar = $("#frameCenterRightBottomContent .ToolBar").size();

			lLngOffSetToolbar = lLngOffSetToolbar * 25;

			

			//Variavel do Tamanho do FrameCenterRightTop

			lLngFrameCenterRightBottom = parseInt($("#frameCenterRightBottom").height().replace("px"));

			

			$("#frameCenterRightBottomContent .functionBox").css("height", lLngFrameCenterRightBottom - lLngOffSetTitulo - lLngOffSetToolbar - 3);

			$("#frameCenterRightBottomContent #gridBox").css("height", lLngFrameCenterRightBottom - lLngOffSetTitulo - lLngOffSetToolbar - 3);





			this.getSize();

			

			var qtList = $("#frameCenterLeftBoxModuloToolBar li").size() - 1;

			if ((qtList%6) != 0)

				qtList = parseInt(qtList/6) + 1;

			else

				qtList = parseInt(qtList/6);

				

			

			$("#frameCenterLeftBoxModuloTreeviewBox").height(_myHeight - 85 - 35 - (qtList*32) - 28 - 2);

			$("#frameCenterLeftBoxModuloTreeviewBox").width(200 - 3);



		}

};


function openDialog(cod, lnk, id){

		Util.loadHtml('#resposta', lnk+cod);

		var maskHeight = $(document).height();
		var maskWidth = $(window).width();
	
		$('#mask').css({'width':maskWidth,'height':maskHeight});
 
		$('#mask').fadeIn(1000);	
		$('#mask').fadeTo("slow",0.8);	
	
		//Get the window height and width
		var winH = $(window).height();
		var winW = $(window).width();
              
		$(id).css('top',  winH/2-$(id).height()/2);
		$(id).css('left', winW/2-$(id).width()/2);
	
		$(id).fadeIn(2000); 
	

} 
 
$(document).ready(function() {	
 
	$('a[name=mordal]').click();
	
	$('.window .close').click(function (e) {
		e.preventDefault();
		
		$('#mask').hide();
		$('.window').hide();
	});		
	
	$('#mask').click(function () {
		$(this).hide();
		$('.window').hide();
	});			
	
});

function popup(Url, Titulo, Width, Height, Scrollbar) 

{

    window.open(Url, Titulo, 'width='+Width+', height='+Height+', scrollbars='+Scrollbar+', status=no, resizable, toolbar=no, menubar=no, top='+((screen.availHeight/2)-(Height/2))+', left='+((screen.availWidth/2)-(Width/2)))

}