﻿$(document).ready(function() {

    // setup the initial UI layout    
    //InitUI();
	

});

function ShowMessage(
    success,
    text) {

    alert(text);
//    title = "Success";
//    if (!success) {
//        title = "There was a problem";
//    }
//    text = "<div class='divHeaderBlue'>" + title + "</div><div class='divGroup'><div class='divInfoWindow'>" + text + "</div></div>";
//    $.colorbox({
//            html: text,
//            transition: 'fade',
//            speed: 500,
//            close: 'Close this message'
//        });
    //    if(success) {
    //        
    //        $.notifyBar({cls:'success',html:"'"+text+"'"});
    //    }   
    //    else
    //    {
    //        $.notifyBar({cls:'error',html:"'"+text+"'"});
    //    }
}


function InitUI() {
    // this layout could be created with NO OPTIONS - but showing some here just as a sample...
    // myLayout = $('body').layout(); -- syntax with No Options

    myLayout = $('body').layout({
            //	enable showOverflow on west-pane so popups will overlap north pane
            west__showOverflowOnHover: false

		//	reference only - these options are NOT required because are already the 'default'
,
            closable: true	// pane can open & close
,
            resizable: true	// when open, pane can be resized 
,
            slidable: true	// when closed, pane can 'slide' open over other panes - closes on mouse-out

		//	some resizing/toggling settings
		// north pane
,
            north__slidable: false	// OVERRIDE the pane-default of 'slidable=true'
,
            north__togglerLength_closed: '100%'	// toggle-button is full-width of resizer-bar
,
            north__spacing_closed: 20		// big resizer-bar when open (zero height)
,
            north__size: 90,
            north__maxSize: 90,
            north__spacing_open: 0

		// south
,
            south__resizable: false	// OVERRIDE the pane-default of 'resizable=true'
,
            south__spacing_open: 1		// no resizer-bar when open (zero height)
,
            south__spacing_closed: 1		// big resizer-bar when open (zero height)
,
            south__size: 0,
            south__minsize: 0

		// west
,
            west__minSize: 0,
            west__maxSize: Math.floor(screen.availWidth / 2)
		//, west__size: Math.floor(screen.availWidth / 2)-5
,
            west__size: 350

		// east
,
            east__minSize: 0,
            east__maxSize: Math.floor(screen.availWidth / 3)/// 1/2 screen width
,
            east__size: 380


		// hide the panes not being used
,
            east__initHidden: true
		/*, east__initHidden: true
		, south__initHidden: true*/,
            onopen_end: loadIframePage // same callback for ALL borderPanes (this refreshes an IFRAME) ***
        });

    // add event to the 'Close' button in the East pane dynamically...
    //myLayout.addCloseBtn('#btnCloseEast', 'east');

    // add event to the 'Toggle South' buttons in Center AND South panes dynamically...
    //myLayout.addToggleBtn('.south-toggler', 'south');

    // add MULTIPLE events to the 'Open All Panes' button in the Center pane dynamically...
    //myLayout.addOpenBtn('#openAllPanes', 'north');
    //myLayout.addOpenBtn('#openAllPanes', 'south');
    //myLayout.addOpenBtn('#openAllPanes', 'west');
    //myLayout.addOpenBtn('#openAllPanes', 'east');

    // allow overflow
    //myLayout.allowOverflow('north');
    myLayout.hide('south');
}

function loadIframePage(pane, $Pane) {

    if (!$Pane) $Pane = $('.ui-layout-' + pane);
    var $Iframe = $Pane.attr('tagName') == 'IFRAME' ? $Pane : $Pane.find('IFRAME:first');
    if (!$Iframe.length) return; // no iframe
    var src = $Iframe.attr('src'), page = $Iframe.attr('longdesc');
    //if (page && src != page) $Iframe.attr('src', page);
    $Iframe.attr('src', src);
}
