function loadDoc( url ) {
	ShowModalWindow(true);
	
	if ( !$("iframe#iframe-doc").length>0 ) {
		if (/iPhone|iPod|iPad/.test(navigator.userAgent)) {
		  $( "#box-frame" ).append('<div class="pane ui-layout-center" id="box-iframe"><iframe id="iframe-doc" src=""></iframe></div>');	
		  $('#box-tree-int').css({overflow: 'auto', '-webkit-overflow-scrolling': 'touch'});
		} else {
		  $( "#box-frame" ).append('<iframe id="iframe-doc" src="" class="pane ui-layout-center"></iframe>');
		}
	}
	
    $('iframe#iframe-doc').attr('src', url);
	
    $('iframe#iframe-doc').ready(function() 
    {
		var innerLayout;
		
		var layoutSettings_Inner = {
			fxName: "none",
			spacing_open: 0,
			spacing_closed: 0,
			togglerLength_open: 0,
			togglerLength_closed: 0,
			name: "innerLayout",
			defaults: {contentSelector: ".content"},
			north: {
				size: 30,
				spacing_open: 2,
				spacing_closed: 2,
				togglerLength_open: 0,
				togglerLength_closed: 0,
				resizable: false,
				slidable: false
			}
		};
		innerLayout = $('#box-frame').layout( layoutSettings_Inner );
	});
	
    $('iframe#iframe-doc').load(function() 
    {
		$("iframe#iframe-doc").css( "background-image", "none" );
		if (/iPhone|iPod|iPad/.test(navigator.userAgent)) {
			$('#box-iframe').css({	height: "4000px", overflow: 'auto', '-webkit-overflow-scrolling': 'touch' });
			$('#iframe-doc').css({	height: "4000px", overflow: 'auto', '-webkit-overflow-scrolling': 'touch' });
		};
		ShowModalWindow(false);		
		
	});
};

$(document).ready(function()
{


	var outerLayout;
	var topLayout;	
	
	var layoutSettings_Outer = {
		fxName: "none",
		spacing_open: 4,
		spacing_closed: 0,
		togglerLength_open: 0,
		togglerLength_closed: 0,
		maskIframesOnResize: false,
		name: "outerLayout",
		defaults: { contentSelector: ".content"	},
		north: {
			size: (getIsMenuWide() ? 70 : 40),
			spacing_open: 0,
			spacing_closed: 0,
			togglerLength_open: 0,
			togglerLength_closed: -1,
			resizable: false,
			slidable: false
		},
		west: {
			size: oLSize,
			minSize: 150,
			spacing_closed: 20,
			slidable: false,
			onclose: function(){ 
				$( "#btn-tree-open" ).show(); 
				$.ajax({
						url: "layoutcookies.php?page=admin&west_hide=1" ,
						success: function(response) { 
							var r = response; r = null; 
					}
				});
			},
			onopen: function(){ 
				$( "#btn-tree-open" ).hide(); 
				$.ajax({
						url: "layoutcookies.php?page=admin&west_hide=0" ,
						success: function(response) { 
							var r = response; r = null;
					}
				});
			},
			onresize: function(){
				outerLayout = $("#main").layout( layoutSettings_Outer );
				$.ajax({
						url: "layoutcookies.php?page=admin&west=" + outerLayout.state.west.size ,
						success: function(response) { 
							var r = response; r = null; 
					}
				});
				
			 }
		},

		center: {
			onresize: "innerLayout.resizeAll"
		}
	};
		
	var layoutSettings_Top = {
		fxName: "none",
		spacing_open: 0,
		spacing_closed: 0,
		togglerLength_open: 0,
		togglerLength_closed: 0,
		maskIframesOnResize: false,
		name: "topLayout",
		defaults: {
		},
		north: {
			size: 74,
			spacing_open: 2,
			spacing_closed: 2,
			togglerLength_open: 0,
			togglerLength_closed: 0,
			resizable: false,
			slidable: false,
			onclose: function(){
				$( "#btn-toggle-header" ).addClass( "closed" );
				$( "#btn-toggle-header" ).blur();
				$.ajax({
					url: "hideheader.php?hheader=1" ,
					success: function(response) {
					}
				});

			},
			onopen: function(){
				$( "#btn-toggle-header" ).removeClass( "closed" );
				$( "#btn-toggle-header" ).blur();
				$.ajax({
					url: "hideheader.php?hheader=0" ,
					success: function(response) {
					}
				});
			}
		}
	};

	topLayout = $('#container').layout( layoutSettings_Top );
	$("#btn-toggle-header").show();
	topLayout.addToggleBtn("#btn-toggle-header", "north");
	outerLayout = $("#main").layout( layoutSettings_Outer );
	outerLayout.options.stateManagement.autoSave = true;
	if( $("#box-tree > header").length ) outerLayout.addCloseBtn("#box-tree > header", "west");
	if( $("#btn-tree-open").length ) outerLayout.addOpenBtn("#btn-tree-open", "west");

	$('#box-menu').height('80px'); 
	$('#box-tree').offset({top:156}); 	
	$('#main div.ui-layout-resizer').offset({top:156}); 	
	$('#box-frame').offset({top:156}); 
	if (wstHide && wstHide == 1 ) {
		outerLayout.close("west");
	}
});


