FivecomUtil = {


	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: FivecomUtil.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) {

			//$('#frameLoading').show();
			$.ajax( {
			  url: Url,
			  type: "GET",
			  cache: true,
			  async: false,
			  success: function(html){
				$(frameName).html(html);
			  }
			});
			//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('');
			
			FivecomUtil.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);
			}
			FivecomUtil.setSizeContent();
		},

	closeFunctionBottom:
	
		function() {
			this.splitFrameH(false);
			FivecomUtil.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;
		},


	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);

		}
};