// JavaScript Document


/**
*	Function to initialise all flash objects on the page
*/
function initialiseFlash()
{
	// This is the flash music player setup
	var flashvars = {CONFIGURL: "php/flash_playersettings.php", ID: "1"}; 
	var params = {}; 
	var attributes = {}; 
 	swfobject.embedSWF("coo_player01.swf", "player", "186", "335", "9.0.0",
						"expressInstall.swf", flashvars, params, attributes); 
	
	// This is the flash slide show set up
	var flashvars2 = {CONFIGURL:  "php/flash_slideshowxml.php",
					  PHOTO_PATH: "php/flash_getphoto.php"}; 
	var params2 = {}; 
	var attributes2 = {}; 
 	swfobject.embedSWF("coo_slideshow.swf", "slideshow", "500", "352", "9.0.0",
						"expressInstall.swf", flashvars2, params2, attributes2); 
						
}


/**
*	Navbar graphics event handlers
*/
function handleMouseOver(event)
{
	event.target.src = "images/" + event.target.name + "_f2.jpg";
}

function handleMouseOut(event)
{
	event.target.src = "images/" + event.target.name + ".jpg";
}

function handleMouseOverFooter(event)
{
	event.target.src = "images/" + event.target.name + "_f2.gif";
}

function handleMouseOutFooter(event)
{
	event.target.src = "images/" + event.target.name + ".gif";
}



/*
* Code courtsey of http://www.quirksmode.org/contact.html
* @param obj - the target object
* @return an array of two elements [0] letf, [1] top
*/
function findPos(obj) 
{
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}
	return [curleft,curtop];
}


/*
*	handle the mouse over event
*/
function handleMouseOverPB(event)
{
	if( state == "normal" && (event.target.id=="B1" || event.target.id=="B2" || event.target.id=="B3"))
	{
		var left =  photoBlog[event.target.id][0] + jQuery(event.target).width() / 2;
		var leftTarget = photoBlog[event.target.id][0];
		var top = photoBlog[event.target.id][1];
		
		state = "expanding";
				
		if(event.target.id == 'B3')
		{
			leftTarget = leftTarget - (exwidth - 101);
		}
		else if(event.target.id == 'B2')
		{
			leftTarget = leftTarget - (exwidth / 4);
		}

		jQuery("#photoblogEx").css('visibility','visible').css('left', left).css('top',top).css('opacity','0');
		jQuery("#photoblogEx").html(jQuery(event.target).html());
		jQuery("#photoblogEx").animate(
							{
								left: leftTarget,
								width: jQuery(this).width() * xscale,	
								height: jQuery(this).height() * yscale,	
								opacity: 100
							},
							200);					
	}
}


// While the mouse is over the extended area
function handleMouseOverPBEx(event)
{
	state = "expanded";
}

function handleMouseOutPBEx(event)
{
	state = "normal";
	jQuery("#photoblogEx").css('visibility','hidden');					
	jQuery("#photoblogEx").css(
					{
						width: '0px',
						height: '0px'
					});	
}

function handleMouseOutPB(event)
{
	if( state == "expanded")
	{
		state = "normal";
		jQuery("#photoblogEx").css('visibility','hidden');	
		jQuery("#photoblogEx").css(
						{
							width: '0px',
							height: '0px'
						});	
	}
}
	
// Mail functions
function handleMailPost(event)
{
	var parms = "?";
	parms += "email=" + escape(jQuery("#email").val());// +"&";
	jQuery("#dialog").dialog("close");
	jQuery.post('php/ajax_mailinglist.php'+parms, '', function(data){alert(data);});
	jQuery("#email").val("");
}

