/* 
*  everybody should love and participate with open source
*  donate & contribute to open source projects to support them 
*
*/

var options = 
{
	assetURL: '/files/',
	loadingImage: 'loading-light.gif',
	onOpen : function(){ fn_openclose(); }, 
	onClose : function(){ fn_openclose(true); },
	overlayOpacity: 0.0,
	overlayColor: '#000',
	initialHeight: 480,
	initialWidth: 740,
	displayNav: false,
	resizeDuration: 0,
	fadeDuration: 0.35
};

function OpenWindow(mypage, myname, w, h, scroll)
{
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

/* many thanks to Wizzud for the tip! */
function fn_openclose(close)
{ 
	var pm = close ? ['-=','+='] : ['+=','-='];
	
	$.each(// id, top, left, ('open' values...) 
	{ 
		keychain: 	[-10, 100],
		notebook: 	[15, 125],
		culture: 	[-50, 0],
		work:    	[75, 0],
		approach: 	[0, -100], 
		awards: 	[230, 0],
		clients: 	[0, -250], 
		sharpener: 	[400, 675], 
		eraser: 	[-540, 120],
		shells: 	[-65, -550] 
	},
	
	function(n, a)
	{ 
		var b = {}; 
		$.each(a, function(i,v) { if(v) { b[['top','left'][i]] = v > 0 ? pm[0] + v : pm[1] + (-1 * v); } }); 
		$('#' + n).animate(b, 'slow'); 
	}); 
}

jQuery.preloadImages = function()
{
	for (var i = 0; i<arguments.length; i++)
	{
		jQuery("<img>").attr("src", arguments[i]);
	}
}

function place_desktop()
{
	var h = $(window).height();
	
	if (h > 745)
	{
		x = parseInt((h - 745) / 2);
		$('#desktop').css('top', x);
	}
}

function place_splash()
{
	var h = $(window).height();
	
	if (h > 500)
	{
		x = parseInt((h - 500) / 2);
		$('#splash').css('top', x);
	}
}

function position_img()
{
	var w = $(window).width();
	var h = $(window).height();
	var x = parseInt((w * 600) / 800);
	
	if (x > h)
	{
		var y = parseInt((x - h) / 2);
		$('#showme').css('top', -y);
	}
	else
	{
		var y = parseInt((h - x) / 2);
		$('#showme').css('top', y);
	}
}