function useable_dimensions(content_height) 
{
	if( typeof( window.innerWidth ) == 'number' ) { //Non-IE
	
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { //IE 6+ in 'standards compliant mode'
	
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { //IE 4 compatible
	
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	
	}	
		
	var left_over = (myHeight - content_height);
	var half_over = (left_over / 2);
	
	var top_height = (half_over - 2); //an extra 2 for the border
	var bot_height = (half_over - 2);
	
	sizeObj = {};
	sizeObj.height = myHeight;
	sizeObj.width = myWidth;
	sizeObj.top = top_height;
	sizeObj.bot = bot_height;
	sizeObj.remaining = left_over;
	sizeObj.hremaining = half_over;
	
	return sizeObj;
	
}

function show_center_div()
{
	
	YUI().use('node', 'anim', function (Y) {
							 
		Y.one('#centerDiv').setStyle('display', 'block');
		
	});
	
}

//static pages
function populate_page(page_id) 
{
		
	if (page_id == 694) {
		
		var content_height = 450;
		var img_id = 5;
		var tHeight = 75;
		
	} else if(page_id == 1010) {
		
		var content_height = 400;
		var img_id = 3;
		var tHeight = 125;
		
	} else if(page_id == 1012) {
		
		var content_height = 350;
		var img_id = 4;
		var tHeight = 200;
		
	} else {
		
		var content_height = 400;
		var img_id = 2;
		var tHeight = 150;
		
	}
	
	var UD = useable_dimensions(content_height);	
	
	var bot_height = UD.remaining - tHeight
	var top_height = tHeight;
	
	
	YUI().use('node', 'anim', 'io', function (Y) {	
	
		var centerDiv = Y.one('#centerDiv');
		centerDiv.setStyle('display', 'none');
		centerDiv.setStyle('overflow', 'hidden');
		centerDiv.setStyle('height', content_height + "px");
		centerDiv.setStyle('backgroundImage', 'none');
		
		var animF = new Y.Anim();
		animF.set('node', '#footer');
		animF.set('to', {height : bot_height});
		animF.set('duration', 1);
		animF.set('easing', Y.Easing.easeOut);
		
		
		var animH = new Y.Anim();
		animH.set('node', '#headerDiv');
		animH.set('duration', 1);
		animH.set('to', {height:top_height});
		animH.set('easing', Y.Easing.easeOut);
		
		animF.run();
		animH.run();
		
		function make_page(id, o, args) {
			
			var centerDiv = Y.one('#centerDiv');

			centerDiv.set('innerHTML', "<div id=\"flash_content\"><div id=\"html_content\">" + o.responseText + "</div></div>");
			centerDiv.setStyle('overflow', 'auto');
			centerDiv.setStyle('height', content_height + "px");
			centerDiv.setStyle('backgroundImage', "url('images/mail_back_" + img_id + ".jpg')");
			centerDiv.setStyle('display', 'block');
			
		}
		
		function show_page_loader() {
			
			var centerDiv = Y.one('#centerDiv');

			centerDiv.set('innerHTML', "<div id=\"flash_content\"><div id=\"html_content\">Loading Content...</div></div>");
			
			
		}
		
		animF.on('end', function() {
								 
			var uri = 'required/ajax_servers/pbmm.php?page_id=' + page_id;
			Y.on('io:start',	show_page_loader, this);
			Y.on('io:complete', make_page, this);
			Y.io(uri);  
		
		});
	
	});
}

//gallery menu
function load_accordion() 
{
	
	YUI().use('node', 'anim', function (Y) {	
	
		var content_height = 280;	
		
		var centerDiv = Y.one('#centerDiv');
		centerDiv.setStyle('display', 'none');
		centerDiv.setStyle('overflow', 'hidden');
		centerDiv.setStyle('height', content_height + "px");
		centerDiv.setStyle('backgroundImage', 'none');

		var UD = useable_dimensions(content_height);	
		
		var bot_height = UD.remaining - 304; //an extra 2 for the border
		var top_height = 300;
		
		var animF = new Y.Anim();
		animF.set('node', '#footer');
		animF.set('to', {height : bot_height});
		animF.set('duration', 1);
		animF.set('easing', Y.Easing.easeOut);
		
		
		var animH = new Y.Anim();
		animH.set('node', '#headerDiv');
		animH.set('duration', 1);
		animH.set('to', {height:top_height});
		animH.set('easing', Y.Easing.easeOut);
		
		animF.on('end', embed_gallery_menu);	
		animF.run();
		animH.run();
		
	});

}	

function embed_gallery_menu() 
{
				
	var flashvars = {};
	flashvars.settingsXML = "required/swf/accordion_fx_settings.xml";
	
	var params = {};
	params.scale = "noscale";
	params.salign = "tl";
	params.wmode = "transparent";
	
	var attributes = {};
	
	swfobject.embedSWF("./required/swf/accordion.swf", "flash_content", "900", "280", "9.0.0", false, flashvars, params, attributes, show_center_div);				

}

//portfolio
function load_slide_show() 
{ 
	
	YUI().use('node', 'anim', function (Y) {	
	
		var content_height = 350;	
		
		var centerDiv = Y.one('#centerDiv');
		centerDiv.setStyle('display', 'none');
		centerDiv.setStyle('overflow', 'hidden');
		centerDiv.setStyle('height', content_height + "px");
		centerDiv.setStyle('backgroundImage', 'none');
		
		var UD = useable_dimensions(content_height);	
		
		var bot_height = UD.remaining - 204; //an extra 2 for the border
		var top_height = 200;
		
		var animF = new Y.Anim();
		animF.set('node', '#footer');
		animF.set('to', {height: bot_height });
		animF.set('easing', Y.Easing.easeOut);
		animF.set('duration', 1);
			
		var animH = new Y.Anim();
		animH.set('node', '#headerDiv');
		animH.set('to', {height: top_height });
		animH.set('easing', Y.Easing.easeOut);
		animH.set('duration', 1);
			
		animF.on('end', embed_portfolio);
		animF.run();
		animH.run();
		
	});
				
}

function embed_portfolio()
{
	
	var flashvars = {};
	flashvars.settingsXML = "./required/swf/slide_show_settings.xml";
	
	var params = {};
	params.scale = "noscale";
	params.salign = "tl";
	params.wmode = "transparent";
	
	var attributes = {};
	
	swfobject.embedSWF("./required/swf/banner.swf", "flash_content", "900", "350", "9.0.0", false, flashvars, params, attributes, show_center_div);				
	
}

//main galleries
function load_main_gallery(pid)
{ 
	
	YUI().use('node', 'anim', function (Y) {	
	
		var content_height = 475;
		
		var centerDiv = Y.one('#centerDiv');
		centerDiv.setStyle('display', 'none');
		centerDiv.setStyle('backgroundImage', 'none');
		centerDiv.setStyle('overflow', 'hidden');
		centerDiv.setStyle('height', content_height + "px");
			
		var UD = useable_dimensions(content_height);	
		
		var bot_height = UD.remaining - 79; //an extra 4 for the border
		var top_height = 75;
		
		var animF = new Y.Anim();
		animF.set('node', '#footer');
		animF.set('to', {height : bot_height});
		animF.set('duration', 1);
		animF.set('easing', Y.Easing.easeOut);
		
		
		var animH = new Y.Anim();
		animH.set('node', '#headerDiv');
		animH.set('duration', 1);
		animH.set('to', {height:top_height});
		animH.set('easing', Y.Easing.easeOut);
		
		animF.run();
		animH.run();
		
		animF.on('end', function() {
								 								 
			var flashvars = {};
			flashvars.file_to_load = "./required/swf/flash_gallery_data.php?page_id=" + pid;
			//flashvars.file_to_load = "./pbmm.js";
							
			var params = {};
			//params.wmode = "transparent";
			
			var attributes = {};
				
			//swfurl, id, width, height, version, 
			swfobject.embedSWF("./required/swf/flash_gallery.swf", "flash_content", "900", "475", "6","./required/swf/expressInstall.swf", flashvars, params, attributes, show_center_div);
								 
								 
		});
		
	});

}

function load_album()
{

	YUI().use('node', 'anim', function (Y) {	
	
		var content_height = 600;
		
		var centerDiv = Y.one('#centerDiv');
		centerDiv.setStyle('display', 'none');
		centerDiv.setStyle('backgroundImage', 'none');
		centerDiv.setStyle('overflow', 'hidden');
		centerDiv.setStyle('height', content_height + "px");
	
		var UD = useable_dimensions(content_height);	
	
		var a_height = UD.height;
		var left_over = (a_height - content_height);
	
		var bot_height = left_over - 75;
		var top_height = 75;
		
		var animF = new Y.Anim();
		animF.set('node', '#footer');
		animF.set('to', {height : bot_height});
		animF.set('duration', 1);
		animF.set('easing', Y.Easing.easeOut);
		
		
		var animH = new Y.Anim();
		animH.set('node', '#headerDiv');
		animH.set('duration', 1);
		animH.set('to', {height:top_height});
		animH.set('easing', Y.Easing.easeOut);
		
		animF.run();
		animH.run();
		animF.on('end', function() {
							
			var flashvars = {};
			
			var params = {};
			params.wmode = "transparent";
			
			var attributes = {};
						
			swfobject.embedSWF("./required/swf/gallery.swf", "flash_content", "900", "600", "9.0.0", false, flashvars, params, attributes, show_center_div);				
	
		});
		
	});
	
}

//send mail
function send_mail() 
{
	
	YUI().use('node', 'io-base', function (Y) {	
								
		var form_name = Y.one('#name').get('value');
		var form_phone = Y.one('#phone').get('value');
		var form_email = Y.one('#email').get('value');
		var form_date = Y.one('#date').get('value');
		var form_location = Y.one('#location').get('value');
		var form_information = Y.one('#information').get('value');	
		
		function show_loader() {
			
			var centerDiv = Y.one('#centerDiv');
			centerDiv.set('innerHTML', "<div id=\"flash_content\"><div id=\"html_content\">Loading...</div></div>");
			
		}
		
		function make_page(id, o, args) {
		
			var centerDiv = Y.one('#centerDiv');
			centerDiv.set('innerHTML', "<div id=\"flash_content\"><div id=\"html_content\">" + o.responseText + "</div></div>");
		
		}
		
							 
		var uri = 'required/ajax_servers/pbmm.php?page_id=694&name=' + form_name + '&phone=' + form_phone + '&email=' + form_email + '&date=' +  form_date + '&location=' + form_location + '&information=' + form_information;
			
		Y.on('io:complete', make_page, this);
		Y.on('io:start', show_loader);
		Y.io(uri);
		
	});
	
}


//on load
YUI().use('node', 'anim', function (Y) {
									
	function outputStatus(e) 
	{
	
		if (e.success == true) {
			
			//var centerDiv = Y.one('#centerDiv');
			//var flash_content = Y.one('#flash_content');
			
			//centerDiv.setStyle('display', 'block');
			//centerDiv.setStyle('height', '350px');
			//flash_content.setStyle('height', '350px');
		
		} else {
			
			alert("Could NOt Embed Flash " + e.success);
			
		}
	
	}

	function load_music()
	{
		
		var flashvars = {};
		flashvars.xmlUrl = "required/swf/mp3player.xml";
	
		var params = {};
		params.scale = "noscale";
		params.menu = "true";
		params.wmode = "transparent";
		
		var attributes = {};
		
		swfobject.embedSWF("mp3player.swf", "mp3player_div", "300", "160", "9", false, flashvars, params, attributes);
		
	}
	
	var content_height = 5;

	var UD = useable_dimensions(content_height);

	var AnFooter = new Y.Anim();
	AnFooter.set('node', '#footer');
	AnFooter.set('to', {height:UD.bot});
	AnFooter.set('easing', Y.Easing.easeOut);
	AnFooter.set('duration', 2);
	
	var AnHeader = new Y.Anim();
	AnHeader.set('node', '#headerDiv');
	AnHeader.set('to',	{height: UD.top});
	AnHeader.set('easing', Y.Easing.easeOut);
	AnHeader.set('duration', 2);
		
	
	var AnLogoFade = new Y.Anim();
	AnLogoFade.set('node', '#logo');
	AnLogoFade.set('to',	{opacity: 100});
	AnLogoFade.set('easing', Y.Easing.easeOut);
	AnLogoFade.set('duration', 500);
	
	var AnCopy = new Y.Anim();
	AnCopy.set('node', '#footer_text');
	AnCopy.set('to',	{opacity: 100});
	AnCopy.set('easing', Y.Easing.easeOut);
	AnCopy.set('duration', 500);
		
	var AnMenuFade = new Y.Anim();
	AnMenuFade.set('node', '#listmenu');
	AnMenuFade.set('to',	{opacity:100});
	AnMenuFade.set('easing', Y.Easing.easeOut);
	AnMenuFade.set('duration', 500);
	
	var AnLogoMove = new Y.Anim();
	AnLogoMove.set('node', '#logo');
	AnLogoMove.set('to',	{bottom: -10});
	AnLogoMove.set('easing', Y.Easing.easeIn);
	AnLogoMove.set('duration', 2);
	
	var AnMenuMove = new Y.Anim();
	AnMenuMove.set('node', '#listmenu');
	AnMenuMove.set('to',	{bottom:25});
	AnMenuMove.set('easing', Y.Easing.easeIn);
	AnMenuMove.set('duration', 2);
	
	AnLogoMove.on('end', menu_stuff);
	AnLogoMove.on('end', load_music);
	AnMenuMove.on('end', load_slide_show);
	AnFooter.on('end', ani_logo);
	
	AnFooter.run();
	AnHeader.run();
	
	function ani_logo() {
		
		AnLogoFade.run();
		AnLogoMove.run();
		AnCopy.run();
		
		//turn on the mp3_cont div
		var mp3_cont = Y.one('#mp3_cont');
		mp3_cont.setStyle('display', 'block');

	}
	
	function menu_stuff() {
		
		AnMenuFade.run();
		AnMenuMove.run();
		
	}
	
});
