/***
*	A huge thanks to Dean Parkinson for the help with this widget
*/
/************************************************************************************************************
@fileoverview
Slide out menu
Copyright (C) 2007  Dean Parkinson

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

Alf Magne Kalleland, 2007
Owner of DHTMLgoodies.com


************************************************************************************************************/	
var MENUDIV_ID = "dhtmlgoodies_menu";
var SUBMENU_CLASS = 'dhtmlgoodies_subMenu';
var menuItems;
var slideSpeed_out = 10;	// Steps to move sub menu at a time ( higher = faster)
var slideSpeed_in = 10;
var delayMenuClose = 150;	// Microseconds from mouseout to close of menu
var slideTimeout_out = 25;	// Microseconds between slide steps ( lower = faster)
var slideTimeout_in = 10;	// Microseconds between slide steps ( lower = faster)
var xOffsetSubMenu = 0; 	// Offset x-position of sub menu items - use negative value if you want the sub menu to overlap main menu

	var readSizeFromCookie = false;	// Determines if size and position of windows should be set/retreved by use of cookie
	var windowMinSize = [80,30];	// Mininum width and height of windows.
	
	var moveCounter = -1;	
	var startEventPos = new Array();
	var startPosWindow = new Array();
	var startWindowSize = new Array();
	var initResizeCounter = -1;	
	var activeWindow = false;
	var activeWindowContent = false;	
	var windowSizeArray = new Array();
	var windowPositionArray = new Array();
	var currentZIndex = 10000;
	var windowStateArray = new Array();	// Minimized or maximized
	var activeWindowIframe = false;
	var divCounter = 0;
	var zIndexSet = false;
	
	var MSIEWIN = (navigator.userAgent.indexOf('MSIE')>=0 && navigator.userAgent.indexOf('Win')>=0 && navigator.userAgent.toLowerCase().indexOf('opera')<0)?true:false;
	var opera = navigator.userAgent.toLowerCase().indexOf('opera')>=0?true:false;
	
	var ajaxObjects = new Array();

/* Don't change anything below here */

var indeces = new Array();
indeces[0] = 0;
var isMSIE = navigator.userAgent.indexOf('MSIE')>=0?true:false;
var browserVersion = parseInt(navigator.userAgent.replace(/.*?MSIE ([0-9]+?)[^0-9].*/g,'$1'));
if(!browserVersion)browserVersion=1;

function mouseOn(obj) {
	var mi = findNode(getSearchIdFromObj(obj));
	if (mi) mi.mouseOn();
}

function mouseOff(obj) {
	var mi = findNode(getSearchIdFromObj(obj));
	if (mi) mi.mouseOff();
}

function getSearchIdFromObj(obj) {
	// pull the postfix off the A link or LI tag id and return the menu item ID
	var objId = obj.id;
	var idx = objId.indexOf('_');
	if (idx>=0) {
		return "MenuItem" + objId.substring(idx);
	}
	return null;
}

function slideChildMenu(aId) {
	var mi = findNode(aId);
	if (mi) mi.slideChildMenu();
}

function findNode(searchId) {
	var result;
	for (var no=0;no<menuItems.length;no++) {
		result = menuItems[no].findNode(searchId);
		if (result) return result;
	}
	return null;
}

function getNextIndex(lvl) {
	var result = 0;
	if (indeces.length<=lvl) {
		indeces[lvl] = 1;
	} else {
		result = indeces[lvl];
		indeces[lvl]++;
	}
	return result;
}

function MenuItem(divref, ulref, liref, lvlnum, parentref) {
	this.parent = parentref;
	this.div = divref;
	this.ul = ulref;
	this.width = this.ul.offsetWidth;
	// this.left = div.style.left.replace(/[^0-9]/g,'');
	this.li = liref;
	this.alink = this.li.getElementsByTagName('A')[0];
	this.lvl = lvlnum;
	this.idx = getNextIndex(this.lvl);
	this.children;
	this.subUL = this.li.getElementsByTagName('UL')[0];
	this.children;
	this.isMouseOnMe = false;
	// note: if !isOpen && !isClosed then I am animating a slide
	this.isChildMenuOpen = false;
	this.isChildMenuClosed = true;

	// Constructor
	// if a node does not have an A tag but it's children do then we need
	// null out this node's alink field...
	if (this.alink) {
		if (this.alink.parentNode!=this.li) this.alink = null;
	}
	if (this.subUL) {
		this.children = new Array();
		var subLI = this.subUL.getElementsByTagName('LI')[0];
		while(subLI) {
			if(subLI.tagName && subLI.tagName.toLowerCase()=='li') {
				this.children[this.children.length] = new MenuItem(null, this.subUL, subLI, this.lvl + 1, this);
			}
			subLI = subLI.nextSibling;
		}
	}

	this.getPostfix = function() {
		return '_' + this.idx + '_' + this.lvl;
	}
	
	this.getId = function() {
		return "MenuItem" + this.getPostfix();
	}

	this.hasChildren = function() {
		return (this.children!=null);
	}

	this.getTopPos = function() {
		var origDisp = this.div.style.display;
		this.div.style.display = "";
		var obj = this.li;
		var result = obj.offsetTop;
		while((obj = obj.offsetParent) != null) result += obj.offsetTop;
		this.div.style.display = origDisp;
		return result;
	}

	this.getLeftPos = function() {
		var origDisp = this.div.style.display;
		this.div.style.display = "";
		var obj = this.li;
		var result = obj.offsetLeft;
		while((obj = obj.offsetParent) != null) result += obj.offsetLeft;
		this.div.style.display = origDisp;
		return result;
	}

	this.renderNode = function() {
		// set node properties
		this.li.id = "menuItemLI" + this.getPostfix();
		this.ul.style.position = "relative";
		if (this.alink) {
			this.alink.id = "menuItemA" + this.getPostfix();
			this.alink.onmouseover = function() {mouseOn(this);};
			this.alink.onmouseout = function() {mouseOff(this);};
		} else {
			this.li.onmouseover = function() {mouseOn(this);};
			this.li.onmouseout = function() {mouseOff(this);};
		}

		// set sub-menu nodes
		if (this.hasChildren()) {
			var mi = this.children[0];
			var subdiv = document.createElement('DIV');
			subdiv.className=SUBMENU_CLASS;
			document.body.appendChild(subdiv);
			subdiv.id = "menuItemDIV" + mi.getPostfix();
			this.subUL.id = "menuItemUL" + mi.getPostfix();
			subdiv.appendChild(this.subUL);
			subdiv.style.left = this.getLeftPos() + this.width + xOffsetSubMenu + 'px';
			subdiv.style.top = this.getTopPos() + 'px';
			subdiv.style.visibility = "hidden";
			subdiv.style.display = "none";
			subdiv.style.zindex = "1000";
			for (var no=0;no<this.children.length;no++) {
				var mi = this.children[no];
				mi.div = subdiv;
				mi.renderNode();
			}
		}
		return this.li;
	}

	this.findNode = function(searchId) {
		var result;
		if (this.getId() == searchId) {
			result = this;
		} else {
			if (this.hasChildren()) {
				for (var no=0;no<this.children.length;no++) {
					var mi = this.children[no];
					result = mi.findNode(searchId);
					if (result!=null) break;
				}
			}
		}
		return result;
	}

	this.mouseOn = function() {
		this.isMouseOnMe = true;
		if (this.hasChildren() && this.isChildMenuClosed) {
			this.initiateChildMenuOpen();
		}
	}

	this.mouseOff = function() {
		this.isMouseOnMe = false;
		if (this.hasChildren() && !this.isChildMenuClosed) {
			this.initiateChildMenuClose();
		} else if (this.parent) {
			this.parent.mouseOff();
		}
	}

	this.isMouseOnChild = function() {
		if (this.isMouseOnMe) return true;
		if (this.hasChildren()) {
			for (var no=0;no<this.children.length;no++) {
				if (this.children[no].isMouseOnChild()) return true;
			}
		}
		return false;
	}

	this.initiateChildMenuOpen = function() {
		this.isChildMenuClosed = false;
		var childDiv = this.children[0].div;
		childDiv.style.width = "0px";
		childDiv.style.visibility = "visible";
		childDiv.style.display = "";
		this.slideChildMenu();
	}

	this.initiateChildMenuClose = function() {
		this.isChildMenuOpen = false;
		// we have to wait to close the menu
		// allow the mouse to navigate over the child menu
		setTimeout("slideChildMenu('" + this.getId() + "')", delayMenuClose);
	}

	this.slideChildMenu = function() {
		var divref = this.children[0].div;
		var ulref = this.children[0].ul;
		var maxwidth = this.children[0].width;
		var nextWidth;
		if (this.isMouseOnMe  || this.isMouseOnChild()) {
			nextWidth = divref.offsetWidth + slideSpeed_out;
			if (nextWidth >= maxwidth) {
				this.finishOpeningChild(divref, ulref, maxwidth);
			} else {
				ulref.style.left = nextWidth - maxwidth + "px";
				divref.style.width = nextWidth + "px";
				setTimeout("slideChildMenu('" + this.getId() + "')", slideTimeout_out);
			}
		} else {
			nextWidth = divref.offsetWidth - slideSpeed_in;
			if (nextWidth <= 0) {
				this.finishClosingChild(divref, ulref, maxwidth);
			} else {
				ulref.style.left = nextWidth - maxwidth + "px";
				divref.style.width = nextWidth + "px";
				setTimeout("slideChildMenu('" + this.getId() + "')", slideTimeout_out);
			}
		}
	}

	this.finishOpeningChild = function(divref, ulref, maxwidth) {
		this.isChildMenuOpen = true;
		this.isChildMenuClosed = false;
		ulref.style.left = "0px";
		divref.style.width = maxwidth + "px";
	}

	this.finishClosingChild = function(divref, ulref, maxwidth) {
		this.isChildMenuOpen = false;
		this.isChildMenuClosed = true;
		divref.style.visibility = "hidden";
		divref.style.display = "none";
		divref.style.width = maxwidth + "px";
		if (this.parent) this.parent.mouseOff();
	}

}

function collectMenuNodes(menuObj) {
     if (!menuObj) return null;

     var results = new Array();
     var menuUL = menuObj.getElementsByTagName('UL')[0];
     var menuLI = menuUL.getElementsByTagName('LI')[0];
     while(menuLI) {
        if(menuLI.tagName && menuLI.tagName.toLowerCase()=='li') {
              results[results.length] = new MenuItem(menuObj, menuUL, menuLI, 0, null);
        }
        menuLI = menuLI.nextSibling;
     }
     return results;
}

function initMenu() {
	var mainDiv = document.getElementById(MENUDIV_ID);
	menuItems = collectMenuNodes(mainDiv);
	if (menuItems) {
		for (var no=0;no<menuItems.length;no++) {
			var mi = menuItems[no];
			mi.renderNode();
		}
		mainDiv.style.visibility = 'visible';
	}
	// window.onresize = resetPosition;
}

	function Get_Cookie(name) { 
	   var start = document.cookie.indexOf(name+"="); 
	   var len = start+name.length+1; 
	   if ((!start) && (name != document.cookie.substring(0,name.length))) return null; 
	   if (start == -1) return null; 
	   var end = document.cookie.indexOf(";",len); 
	   if (end == -1) end = document.cookie.length; 
	   return unescape(document.cookie.substring(len,end)); 
	} 
	// This function has been slightly modified
	function Set_Cookie(name,value,expires,path,domain,secure) { 
		expires = expires * 60*60*24*1000;
		var today = new Date();
		var expires_date = new Date( today.getTime() + (expires) );
	    var cookieString = name + "=" +escape(value) + 
	       ( (expires) ? ";expires=" + expires_date.toGMTString() : "") + 
	       ( (path) ? ";path=" + path : "") + 
	       ( (domain) ? ";domain=" + domain : "") + 
	       ( (secure) ? ";secure" : ""); 
	    document.cookie = cookieString; 
	} 
			
	function cancelEvent()
	{
		return (moveCounter==-1 && initResizeCounter==-1)?true:false;
	}
	function initMove(e)
	{		
		if(document.all)e = event;
		moveCounter = 0;
		switchElement(false,this);
		startEventPos = [e.clientX,e.clientY];
		startPosWindow = [activeWindow.offsetLeft,activeWindow.offsetTop];
		startMove();
		if(!MSIEWIN)return false;
	
	}
	
	function startMove()
	{
		if(moveCounter>=0 && moveCounter<=10){
			moveCounter++;
			setTimeout('startMove()',5);
		}
	}
	
	function stopMove(e)
	{
		if(document.all)e = event;
		moveCounter=-1;
		initResizeCounter=-1;
		if(!activeWindow || !activeWindowContent)return;
		var state = '0';
		if(windowStateArray[activeWindow.id.replace(/[^0-9]/g,'')])state = '1';
		
		Set_Cookie(activeWindow.id + '_attr',activeWindow.style.left.replace('px','') + ',' + activeWindow.style.top.replace('px','') + ',' + activeWindow.style.width.replace('px','') + ',' + activeWindowContent.style.height.replace('px','') + ',' + activeWindow.style.zIndex + ',' + state,50);
	}
	
	function moveWindow(e)
	{
		
		if(document.all)e = event;
		if(moveCounter>=10){
			activeWindow.style.left = startPosWindow[0] + e.clientX - startEventPos[0]  + 'px';
			activeWindow.style.top = startPosWindow[1] + e.clientY - startEventPos[1]  + 'px';
			
		}	
		
		if(initResizeCounter>=10){
			var newWidth = Math.max(windowMinSize[0],startWindowSize[0] + e.clientX - startEventPos[0]);
			var newHeight = Math.max(windowMinSize[1],startWindowSize[1] + e.clientY - startEventPos[1]);
			activeWindow.style.width =  newWidth + 'px';
			activeWindowContent.style.height = newHeight  + 'px';		
			
			if(MSIEWIN && activeWindowIframe){
				activeWindowIframe.style.width = (newWidth) + 'px';	
				activeWindowIframe.style.height = (newHeight+20) + 'px';	
			}
				
			
		}
		if(!document.all)return false;
	}
	
	
	function initResizeWindow(e)
	{
		if(document.all)e = event;
		initResizeCounter = 0;
		switchElement(false,document.getElementById('dhtml_goodies_id' + this.id.replace(/[^\d]/g,'')));

		startWindowSize = [activeWindowContent.offsetWidth,activeWindowContent.offsetHeight];
		startEventPos = [e.clientX,e.clientY];
		
		if(MSIEWIN)activeWindowIframe = activeWindow.getElementsByTagName('IFRAME')[0];
		startResizeWindow();
		return false;
			
	}
	
	function startResizeWindow()
	{
		if(initResizeCounter>=0 && initResizeCounter<=10){
			initResizeCounter++;
			setTimeout('startResizeWindow()',5);
		}
	}
	
	function switchElement(e,inputElement)
	{
		if(!inputElement)inputElement = this;
		var numericId = inputElement.id.replace(/[^0-9]/g,'');
		var state = '0';
		if(windowStateArray[numericId])state = '1';
			
		if(activeWindow && activeWindowContent){
			Set_Cookie(activeWindow.id + '_attr',activeWindow.style.left.replace('px','') + ',' + activeWindow.style.top.replace('px','') + ',' + activeWindow.style.width.replace('px','') + ',' + activeWindowContent.style.height.replace('px','') + ',' + activeWindow.style.zIndex + ',' + state,50);
	
		}
		currentZIndex = currentZIndex/1 + 1;
		activeWindow = document.getElementById('dhtml_goodies_id' + numericId);	
		activeWindow.style.zIndex = currentZIndex;
		activeWindowContent = document.getElementById('windowContent' + numericId);

		Set_Cookie(activeWindow.id + '_attr',activeWindow.style.left.replace('px','') + ',' + activeWindow.style.top.replace('px','') + ',' + activeWindow.style.width.replace('px','') + ',' + activeWindowContent.style.height.replace('px','') + ',' + activeWindow.style.zIndex + ',' + state,50);
	}
	
	function hideWindow()
	{
		switchElement(false,document.getElementById('dhtml_goodies_id' + this.id.replace(/[^\d]/g,'')));	
		activeWindow.style.display='none';
	}
	
	function minimizeWindow(e,inputObj)
	{
		if(!inputObj)inputObj = this;
		var numericID = inputObj.id.replace(/[^0-9]/g,'');
		switchElement(false,document.getElementById('dhtml_goodies_id' + numericID));
		var state;	
		if(inputObj.src.indexOf('minimize')>=0){
			activeWindowContent.style.display='none';
			document.getElementById('resizeImage'+numericID).style.display='none';
			inputObj.src = inputObj.src.replace('minimize','maximize');	
			windowStateArray[numericID] = false;
			state = '0';		
		}else{			
			activeWindowContent.style.display='block';
			document.getElementById('resizeImage'+numericID).style.display='';
			inputObj.src = inputObj.src.replace('maximize','minimize');
			windowStateArray[numericID] = true;
			state = '1';
		}
		
		Set_Cookie(activeWindow.id + '_attr',activeWindow.style.left.replace('px','') + ',' + activeWindow.style.top.replace('px','') + ',' + activeWindow.style.width.replace('px','') + ',' + activeWindowContent.style.height.replace('px','') + ',' + activeWindow.style.zIndex + ',' + state,50);

	}
	
	function initWindows(e,divObj)
	{
		
		
		var divs = document.getElementsByTagName('DIV');
		
		if(divObj){
			var tmpDivs = divObj.getElementsByTagName('DIV');
			var divs = new Array();
			divs[divs.length] = divObj;
			
			for(var no=0;no<tmpDivs.length;no++){
				divs[divs.length] = tmpDivs[no];
			}
		}
		
		for(var no=0;no<divs.length;no++){
			
			if(divs[no].className=='dhtmlgoodies_window'){	
		
				if(MSIEWIN){
					var iframe = document.createElement('IFRAME');
					iframe.style.border='0px';
					iframe.frameborder=0;
					iframe.style.position = 'absolute';
					iframe.style.backgroundColor = '#FFFFFF';
					iframe.style.top = '0px';
					iframe.style.left = '0px';
					iframe.style.zIndex = 100;
				
					
					var subDiv = divs[no].getElementsByTagName('DIV')[0];
					divs[no].insertBefore(iframe,subDiv);
					
				}					
				if(divObj){
					divs[no].style.zIndex = currentZIndex;
					currentZIndex = currentZIndex /1 + 1;
				}
				
				divCounter = divCounter + 1;	
				if(divCounter==1)activeWindow = divs[no];		
				divs[no].id = 'dhtml_goodies_id' + divCounter;	
				divs[no].onmousedown = switchElement;
				if(readSizeFromCookie)var cookiePos = Get_Cookie(divs[no].id + '_attr') + '';	else cookiePos = '';
				if(divObj)cookiePos='';
				var cookieValues = new Array();
				
					
				if(cookiePos.indexOf(',')>0){
					cookieValues = cookiePos.split(',');
					if(!windowPositionArray[divCounter])windowPositionArray[divCounter] = new Array();
					windowPositionArray[divCounter][0] = Math.max(0,cookieValues[0]);
					windowPositionArray[divCounter][1] = Math.max(0,cookieValues[1]);
				}

				if(cookieValues.length==5 && !zIndexSet){
					divs[no].style.zIndex = cookieValues[4];
					if(cookieValues[4]/1 > currentZIndex)currentZIndex = cookieValues[4]/1;					
				}
				if(windowPositionArray[divCounter]){
					divs[no].style.left = windowPositionArray[divCounter][0] + 'px';	
					divs[no].style.top = windowPositionArray[divCounter][1] + 'px';	
				}
				
				var subImages = divs[no].getElementsByTagName('IMG');
				for(var no2=0;no2<subImages.length;no2++){
					if(subImages[no2].className=='resizeImage'){
						subImages[no2].style.cursor = 'nw-resize';
						subImages[no2].onmousedown = initResizeWindow;
						subImages[no2].id = 'resizeImage' + divCounter;
						break;
					}	
					if(subImages[no2].className=='closeButton'){
						subImages[no2].id = 'closeImage' + divCounter;
						subImages[no2].onclick = hideWindow;	
					}	
					if(subImages[no2].className=='minimizeButton'){
						subImages[no2].id = 'minimizeImage' + divCounter;
						subImages[no2].onclick = minimizeWindow;	
						if(cookieValues.length==6 && cookieValues[5]=='0'){							
							setTimeout('minimizeWindow(false,document.getElementById("minimizeImage' + divCounter + '"))',10);
						}
						if(cookieValues.length==6 && cookieValues[5]=='1'){							
							windowStateArray[divCounter] = 1;
						}
						
						
					}
				}			
			}	
			if(divs[no].className=='dhtmlgoodies_windowMiddle' || divs[no].className=='dhtmlgoodies_window_bottom'){
				divs[no].style.zIndex = 1000;
				
			}
			if(divs[no].className=='dhtmlgoodies_window_top'){
				divs[no].onmousedown = initMove;
				divs[no].id = 'top_bar'+divCounter;
				divs[no].style.zIndex = 1000;
	
			}

			if(divs[no].className=='dhtmlgoodies_windowContent'){
				divs[no].id = 'windowContent'+divCounter;
				divs[no].style.zIndex = 1000;
				if(cookieValues && cookieValues.length>3){
					if(!windowSizeArray[divCounter])windowSizeArray[divCounter] = new Array();
					windowSizeArray[divCounter][0] = cookieValues[2];
					windowSizeArray[divCounter][1] = cookieValues[3];
				}	
				if(cookieValues && cookieValues.length==5){
					activeWindowContent = document.getElementById('windowContent' + divCounter);	
				}		
				if(windowSizeArray[divCounter]){
					divs[no].style.height = windowSizeArray[divCounter][1] + 'px';
					divs[no].parentNode.parentNode.style.width = windowSizeArray[divCounter][0] + 'px';
					
					if(MSIEWIN){
						iframe.style.width = (windowSizeArray[divCounter][0]) + 'px';
						iframe.style.height = (windowSizeArray[divCounter][1]+20) + 'px';
					}
				}
			}

			
		}	
		
		if(!divObj){
			document.documentElement.onmouseup = stopMove;	
			document.documentElement.onmousemove = moveWindow;
			document.documentElement.ondragstart = cancelEvent;
			document.documentElement.onselectstart = cancelEvent;
		}
		
		return divCounter;
	}

	function createNewWindow(width,height,left,top)
	{
		var div = document.createElement('DIV');
		div.className='dhtmlgoodies_window';
		document.body.appendChild(div);
				
					
		var topDiv = document.createElement('DIV');
		topDiv.className='dhtmlgoodies_window_top';
		div.appendChild(topDiv);
		
		var img = document.createElement('IMG');
		img.src = 'images/cons_usu_header_borde.jpg';
		img.className='topCenterImage';
		topDiv.appendChild(img);
		
		var buttonDiv = document.createElement('DIV');
		buttonDiv.className='top_buttons';
		topDiv.appendChild(buttonDiv);
		
		var img = document.createElement('IMG');
		img.src = 'images/minimize.gif';
		img.className='minimizeButton';
		buttonDiv.appendChild(img);	
		
		var img = document.createElement('IMG');
		img.src = 'images/close.gif';
		img.className='closeButton';
		buttonDiv.appendChild(img);		
		
		var middleDiv = document.createElement('DIV');
		middleDiv.className='dhtmlgoodies_windowMiddle';
		div.appendChild(middleDiv);
		
		var contentDiv = document.createElement('DIV');
		contentDiv.className='dhtmlgoodies_windowContent';
		middleDiv.appendChild(contentDiv);
		
		var bottomDiv = document.createElement('DIV');
		bottomDiv.className='dhtmlgoodies_window_bottom';
		div.appendChild(bottomDiv);
		
		var img = document.createElement('IMG');
		img.src = 'images/bottom_right.gif';
		img.className='resizeImage';
		bottomDiv.appendChild(img);		

		windowSizeArray[windowSizeArray.length] = [width,height];
		windowPositionArray[windowPositionArray.length] = [left,top];


		div.style.width =  width + 'px';
		contentDiv.style.height = height  + 'px';		
		div.style.left =  left + 'px';
		div.style.top = top  + 'px';	
			
		return initWindows(false,div);
		
		
		 	
	}
	
	function showAjaxContent(ajaxIndex,windowId)
	{
		document.getElementById('windowContent' + windowId).innerHTML = ajaxObjects[ajaxIndex].response;			
		
		
	}
	
	function addContentFromUrl(url,windowId)
	{
		var ajaxIndex = ajaxObjects.length;
		ajaxObjects[ajaxIndex] = new sack();
		ajaxObjects[ajaxIndex].requestFile = url;	// Specifying which file to get
		ajaxObjects[ajaxIndex].onCompletion = function(){ showAjaxContent(ajaxIndex,windowId); };	// Specify function that will be executed after file has been found
		ajaxObjects[ajaxIndex].runAJAX();		// Execute AJAX function			
		
		
	}
	
	/* This function illustrates how you can create a new custom window dynamically */

	
	/* This function illustrates how you can create a new custom window dynamically */
	
	function customFunctionCreateWindow(urlToExternalFile,width,height,left,top)
	{		

		var divId = createNewWindow(width,height,left,top);
		document.getElementById('windowContent' + divId).innerHTML = 'Cargando informacion, un momento por favor.....';
		if(urlToExternalFile)addContentFromUrl(urlToExternalFile,divId);	// Add content from external file
		


			
	}

window.onload  = initMenu;
window.onfocus = initWindows;
