/*var file_pth = "/special/www.expo2010canada.gc.ca/";*/



var file_pth="/";



/**

 *	Calls all initialization methods.

**/

$(document).ready(function()

{
    Gallery.Init();
	
	//select all the a tag with name equal to modal
	$('a[name=modal]').click(function(e) {
		//Cancel the link behavior
		e.preventDefault();
		
		//Get the A tag
		var id = $(this).attr('href');
	
		//Get the screen height and width
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();
	
		//Set heigth and width to mask to fill up the whole screen
		$('#mask').css({'width':maskWidth,'height':maskHeight});
		
		//transition effect		
		$('#mask').fadeIn(1000);	
		$('#mask').fadeTo("slow",0.8);	
	
		//Get the window height and width
		/*var winH = $(window).height();
		var winW = $(window).width();*/
              
		//Set the popup window to center
		/*$(id).css('top',  winH/2-$(id).height()/2);
		$(id).css('left', winW/2-$(id).width()/2);*/
		$(id).css('top',  $(id).height());
		$(id).css('left', 265);
		//transition effect
		$(id).fadeIn(2000); 
	
	});
	
	//if close button is clicked
	$('.window .close').click(function (e) {
		//Cancel the link behavior
		e.preventDefault();
		
		$('#mask').hide();
		$('.window').hide();
	});		
	
	//if mask is clicked
	$('#mask').click(function () {
		$(this).hide();
		$('.window').hide();
	});			
																																																																																																																																									
																																																																																																																																									
	/*$(".addthis_org_cn").addthis();*/
	

	/*MediaCenter.Init();	

	Activities.Init();

    Calend.Init();*/

});





/**

 *	Handles functionality for the media centre page.

**/

/*var MediaCenter = {

	

	Animating : false,

	Photo_Preview_URL : file_pth+'rotation/getphotopreview.cfm?get=#get#&curNum=#curNum#&lang=#lang#',

	Animation_Speed : 400,

	Margin_Left: "104px",

	

	Init: function()

	{

		$("#photo-previews li.arrow.next a").click(MediaCenter.Handle_Next_Click);

		$("#photo-previews li.arrow.previous a").click(MediaCenter.Handle_Prev_Click);

	},

	

	Handle_Next_Click : function()

	{

		if( !MediaCenter.Animating ) {

			var Item_URL = MediaCenter.GetUrl("next");	// get the next item's ajax URL

			$.get(Item_URL, MediaCenter.Handle_Next_Callback);

		}

		return false;

	},

	

	Handle_Prev_Click : function()

	{

		if( !MediaCenter.Animating ) {

			var Item_URL = MediaCenter.GetUrl("prev");	// get the prev item's ajax URL

			$.get(Item_URL, MediaCenter.Handle_Prev_Callback);

		}

		return false;

	},

	

	Handle_Next_Callback:function(data)

	{

		// add this content to the list

		$("#photo-previews li.photo:last").after(data);

		

		// scroll the list to the left

		MediaCenter.Animating = true;

		$("#photo-previews li.photo-holder ul").animate({ marginLeft: "-=" + MediaCenter.Margin_Left }, MediaCenter.Animation_Speed, "swing", MediaCenter.Remove_First );

	},

	

	Handle_Prev_Callback: function(data)

	{

		// add this content to the list

		$("#photo-previews li.photo-holder ul").animate({ marginLeft: "-=104px"	}, 0 );

		

		$("#photo-previews li.photo:first").before(data);

		

		// scroll the list to the right

		MediaCenter.Animating = true;

		$("#photo-previews li.photo-holder ul").animate({ marginLeft: "+=104px"	}, MediaCenter.Animation_Speed, "swing", MediaCenter.Remove_Last );

	},

	

	Remove_First: function() {

		$("#photo-previews li.photo:first").remove();

		$("#photo-previews li.photo-holder ul").animate({ marginLeft: "+=104px"	}, 0 );

		MediaCenter.Animating = false;

	},

	

	Remove_Last:function() {

		$("#photo-previews li.photo:last").remove();

		MediaCenter.Animating = false;

	},

	

	GetCurrentNum : function()

	{

		return $("#photo-previews li.photo:last").attr("id").split("photo-").join('');

	},

	

	GetLang : function()

	{

		return $("meta[name$='language']").attr("content");

	},

	

	GetUrl : function(get)

	{

		var curNum = MediaCenter.GetCurrentNum();

		var lang = MediaCenter.GetLang();

		return MediaCenter.Photo_Preview_URL.split("#get#").join(get).split("#curNum#").join(curNum).split("#lang#").join(lang);

	}

	

}	//	MediaCenter

	

*/



/**

 *	Handles functionality for the Various gallery pages.

**/

var Gallery = {

	

	Init:function()

	{

		$('#gallery-photos li a').click(Gallery.HandleThumbClick);

		$('#gallery-photos li a:first').click();

	},

	

	HandleThumbClick : function()

	{

		//	Get the values

		var title = $(this).children('img').attr('title');

		var alt = $(this).children('img').attr('alt');		

		var src = $(this).attr('href');

		var hires = $(this).next().attr('href');

		

		//	Set the values

		Gallery.GetMainImage().attr('src', src);

		Gallery.GetMainImage().attr('alt', alt);

		Gallery.GetMainImage().attr('title', alt);

		/*Gallery.GetMainCaption().text(title);*/
		Gallery.GetMainCaption().text(alt);
		

		if (hires == '' || !hires) {

			Gallery.GetHighResLink().css("display", "none");

		}

		else {

			Gallery.GetHighResLink().attr('href', hires);

			Gallery.GetHighResLink().css("display", "inline");

		}

		

		return false;

	},

	

	GetMainImageContainer : function()

	{

		return $('#gallery-photo-large');

	},

	

	GetMainImage : function()

	{

		var container = Gallery.GetMainImageContainer();

		

		//	Create the image if it doesn't exist.

		if($(container).children('img').length == 0)

		{

			$(container).prepend('<img />');

		}

		

		return container.children('img');

	},

	

	

	GetMainCaption : function()

	{

		return Gallery.GetMainImageContainer().children('p.caption');

	},

	

	GetHighResLink : function()

	{

		return Gallery.GetMainImageContainer().children('p.download_link').children('a');

	}

	

	

}	//	Gallery





/**

 *	Activities page

**/

/*var Activities = 

{

	Init : function()

	{

		Activities.GetList().addClass("activities-js");

		Activities.HideDetails();

		Activities.ActivateLinks();

		

		Activities.GetList().find('li>img').each(function(i){

			$(this).attr('rel','dialog-' + i);

			$(this).next('div.details').attr('id','dialog-' + i);

		});

		Activities.GetList().find('li div.details').each(function() {

			var Dialog_Title = $(this).find('h4').text();

			$(this).dialog({ autoOpen: false, width: 400, title: Dialog_Title });

		});

	},

	

	GetList : function()

	{

		return $('ol#activities');

	},

	

	HideDetails : function()

	{

		$('div.details').dialog('close');

	},

	

	ActivateLinks : function()

	{

		Activities.GetList().find('li>img').click(function(){

			Activities.HideDetails();

			var Target_ID = $(this).attr('rel');

			

			

			// figure out the left and right position of the body area

			var Body_Object = $('div.colLayout>div.center');

			Body_Left = Body_Object.offset().left;

			Body_Right = Body_Left + Body_Object.width();

			Body_Middle = ((Body_Right - Body_Left) / 2) + Body_Left;

			

			// get the current clicked image's position

			var Location = $(this).offset();

			var Width = $(this).width();

			var Height = $(this).height();

			

			// dialog width

			var Dialog_Width = $('#' + Target_ID).dialog('option', 'width');

			

			if (Location.left > Body_Middle) {

				Location.left = (Location.left + Width) - Dialog_Width;

			}

			

			/*alert('Location top: ' + Location.top);

			alert('Scroll top: ' + $('html').scrollTop() );*/

							

			/*$('#' + Target_ID).dialog('option', 'position', [Location.left, (Location.top + Height + 5 - $('html').scrollTop())]);

			

			

			$('#' + Target_ID).dialog('open');

		});

	}

	

}*/	//	Activities



/**

 *	Calendar page

**/

/*var Calend = 

{

	Init : function()

	{

		Calend.GetList().addClass("calend-js");

		Calend.HideDetails();

		Calend.ActivateLinks();

		

		Calend.GetList().find('li>img').each(function(i){

			$(this).attr('rel','dialog-' + i);

			$(this).next('div.details').attr('id','dialog-' + i);

		});

		Calend.GetList().find('li div.details').each(function() {

			var Dialog_Title = $(this).find('h4').text();

			$(this).dialog({ autoOpen: false, width: 400, title: Dialog_Title });

		});

	},

	

	GetList : function()

	{

		return $('ol#calend');

	},

	

	HideDetails : function()

	{

		$('div.details').dialog('close');

	},

	

	ActivateLinks : function()

	{

		Calend.GetList().find('li>img').click(function(){

			Calend.HideDetails();

			var Target_ID = $(this).attr('rel');

			

			

			// figure out the left and right position of the body area

			var Body_Object = $('div.colLayout>div.center');

			Body_Left = Body_Object.offset().left;

			Body_Right = Body_Left + Body_Object.width();

			Body_Middle = ((Body_Right - Body_Left) / 2) + Body_Left;

			

			// get the current clicked image's position

			var Location = $(this).offset();

			var Width = $(this).width();

			var Height = $(this).height();

			

			// dialog width

			var Dialog_Width = $('#' + Target_ID).dialog('option', 'width');

			

			if (Location.left > Body_Middle) {

				Location.left = (Location.left + Width) - Dialog_Width;

			}

			

			/*alert('Location top: ' + Location.top);

			alert('Scroll top: ' + $('html').scrollTop() );*/

							

			/*$('#' + Target_ID).dialog('option', 'position', [Location.left, (Location.top + Height + 5 - $('html').scrollTop())]);

			

			

			$('#' + Target_ID).dialog('open');

		});

	}

	

}*/	//	Calendar












