/* -----------------------------------------------------------------

	In this file:
	
	1. Define windows
	
		var myWindow = function(){ 
			new MochaUI.Window({
				id: 'mywindow',
				title: 'My Window',
				loadMethod: 'xhr',
				contentURL: 'pages/lipsum.html',
				width: 340,
				height: 150
			});
		}
	
	2. Build windows on onDomReady
	
		myWindow();
	
	3. Add link events to build future windows
	
		if ($('myWindowLink')){
			$('myWindowLink').addEvent('click', function(e) {
				new Event(e).stop();
				jsonWindows();
			});
		}
		
		Note: If your link is in the top menu, it opens only a single window, and you would
		like a check mark next to it when it's window is open, format the link name as follows:
		
		window.id + LinkCheck, e.g., mywindowLinkCheck
		
		Otherwise it is suggested you just use mywindowLink
	
	Associated HTML for link event above:
	
		<a id="myWindowLink" href="pages/lipsum.html">My Window</a>	

	
	Notes:
		If you need to add link events to links within windows you are creating, do
		it in the onContentLoaded function of the new window.


   ----------------------------------------------------------------- */

initializeWindows = function(){

	MochaUI.chatWindow = function(){
		new MochaUI.Window({
			id: 'chatWindowView',
			title: 'eizesus IM',
			loadMethod: 'iframe',
			contentURL: 'links.html',
			width: 300,
			height: 500,
			minimizable: true,
			maximizable: false,
			closable: false,
			resizable: false,
			x: 990,
			y: 100
		});
	}
	
	MochaUI.chatWindow();
	
	
	MochaUI.aboutWindow = function(){
		new MochaUI.Window({
			id: 'aboutWindowView',
			title: 'Hi! My name is Elad Meidar',
			loadMethod: 'iframe',
			contentURL: 'about.html',
			width: 960,
			height: 350,
			resizeLimit:  {'x': [330, 2500], 'y': [250, 2000]}
		});
	}
	
	if ($('aboutMeLink')){ 
		$('aboutMeLink').addEvent('click', function(e){	
			new Event(e).stop();
			MochaUI.aboutWindow();
		});
	}
	
	MochaUI.terminalWindow = function(){
		new MochaUI.Window({
			id: 'terminalWindowView',
			title: 'Terminal',
			loadMethod: 'iframe',
			contentURL: 'terminal.html',
			width: 960,
			height: 350,
			resizeLimit:  {'x': [330, 2500], 'y': [250, 2000]},
			contentBgColor: '#000'
		});
	}
	
	if ($('terminalLink')){ 
		$('terminalLink').addEvent('click', function(e){	
			new Event(e).stop();
			MochaUI.terminalWindow();
		});
	}
	
	MochaUI.blogWindow = function(){
		new MochaUI.Window({
			id: 'blogWindowView',
			title: 'Emphasized Insanity',
			loadMethod: 'iframe',
			contentURL: 'http://blog.eizesus.com',
			width: 960,
			height: 350,
			resizeLimit:  {'x': [330, 2500], 'y': [250, 2000]},
			contentBgColor: '#000'
		});
	}
	
	if ($('blogLink')){ 
		$('blogLink').addEvent('click', function(e){	
			new Event(e).stop();
			MochaUI.blogWindow();
		});
	}
	
	MochaUI.linkedInWindow = function(){
		new MochaUI.Window({
			id: 'linkedInWindowView',
			title: 'Elad Meidar on Linkedin',
			loadMethod: 'iframe',
			contentURL: 'http://www.linkedin.com/in/eladmeidar',
			width: 960,
			height: 350,
			resizeLimit:  {'x': [330, 2500], 'y': [250, 2000]},
			contentBgColor: '#000'
		});
	}
	
	if ($('linkedInLink')){ 
		$('linkedInLink').addEvent('click', function(e){	
			new Event(e).stop();
			MochaUI.linkedInWindow();
		});
	}
	
	if ($('twitterLink')){ 
		$('twitterLink').addEvent('click', function(e){	
			new Event(e).stop();
			document.location = "http://twitter.com/eladmeidar";
		});
	}
	
	
}
createNewWindow = function(href, name) {

	new MochaUI.Window({
		id: 'blog-' + name,
		title: name + "'s blog",
		loadMethod: 'iframe',
		contentURL: href,
		width: 960,
		height: 450,
		resizeLimit:  {'x': [330, 2500], 'y': [250, 2000]},
		contentBgColor: '#fff'
	});
}
// Initialize MochaUI when the DOM is ready
window.addEvent('domready', function(){
	MochaUI.Desktop = new MochaUI.Desktop();
	MochaUI.Dock = new MochaUI.Dock({
		dockPosition: 'bottom'
	});
	MochaUI.Modal = new MochaUI.Modal();
	
	MochaUI.Desktop.desktop.setStyles({
		'background': '#fff',
		'visibility': 'visible'
	});
	
	initializeWindows();
});

// This is just for the demo. Running it onload gives pngFix time to replace the pngs in IE6.
window.addEvent('load', function(){
	$$('.desktopIcon').addEvent('click', function(){
		MochaUI.notification('Loading...');
	});
});	

// This runs when a person leaves your page.
window.addEvent('unload', function(){
	if (MochaUI) MochaUI.garbageCleanUp();
});