/**
 * Portfolio JavaScript
 * 
 * @author Ollie Maitland
 * @copyright Byng Systems LLP
 *
 * @uses Element.Selectors
 */
  
var CountrySelector = new Class (
{
 	
	data : new Hash ({
		
			'gb' : {	
				'country'	    : 'gb',
				'heading'		: 'Great Britain and N.Ireland',
				'description'   : 'We offer the following cultural exchange programs to the USA:',
				'programsRow1'  : ['Summer Camp','Au Pair','Internship'],
				'programsRow2'  : ['Career Training','Hospitality','Summer Work and Travel'],
				'descriptionSub': 'Please select the flag that represents your country of citizenship to learn more about the programs available to you. If your flag is not represented please contact us at info@smallerearth.com'
			},

			'au' : {	
				'country'	    : 'au',
				'heading'		: 'Australia',
				'description'   : 'We offer the following cultural exchange programs to the USA:',
				'programsRow1'  : ['Summer Camp','Au Pair','Internship','Career Training'],
				'programsRow2'  : ['Hospitality','Winter Work and Travel','12 Months Work Travel'],
				'descriptionSub': 'Please select the flag that represents your country of citizenship to learn more about the programs available to you. If your flag is not represented please contact us at info@smallerearth.com'
			},
			
			'ie' : {	
				'country'	    : 'ie',
				'heading'		: 'Ireland',
				'description'   : 'We offer the following cultural exchange programs to the USA:',
				'programsRow1'  : ['Summer Camp','Au Pair','Internship'],
				'programsRow2'  : ['Career Training','Hospitality','Summer Work and Travel'],
				'descriptionSub': 'Please select the flag that represents your country of citizenship to learn more about the programs available to you. If your flag is not represented please contact us at info@smallerearth.com'
			},

			'nz' : {	
				'country'	    : 'nz',
				'heading'		: 'New Zealand',
				'description'   : 'We offer the following cultural exchange programs to the USA:',
				'programsRow1'  : ['Summer Camp','Au Pair','Internship','Career Training'],
				'programsRow2'  : ['Hospitality','Winter Work and Travel'],
				'descriptionSub': 'Please select the flag that represents your country of citizenship to learn more about the programs available to you. If your flag is not represented please contact us at info@smallerearth.com'
			},

			'de' : {	
				'country'	    : 'de',
				'heading'		: 'Germany',
				'description'   : 'We offer the following cultural exchange programs to the USA:',
				'programsRow1'  : ['Summer Camp','Au Pair','Internship'],
				'programsRow2'  : ['Career Training','Hospitality','Summer Work and Travel'],
				'descriptionSub': 'Please select the flag that represents your country of citizenship to learn more about the programs available to you. If your flag is not represented please contact us at info@smallerearth.com'
			},

			'us' : {	
				'country'	    : 'us',
				'heading'		: 'United States of America',
				'description'   : 'We offer the following cultural exchange programs to the USA:',
				'programsRow1'  : ['Leadership Training Services','Internship','Career Training'],
				'programsRow2'  : ['Hospitality','Summer Work & Travel','Au Pair' ,'Summer Camp'],
				'descriptionSub': 'Please select the flag that represents your country of citizenship to learn more about the programs available to you. If your flag is not represented please contact us at info@smallerearth.com'
			},

			'hu' : {	
				'country'	    : 'hu',
				'heading'		: 'Hungary',
				'description'   : 'We offer the following cultural exchange programs to the USA:',
				'programsRow1'  : ['Summer Camp','Au Pair','Internship'],
				'programsRow2'  : ['Career Training','Hospitality','Summer Work and Travel'],
				'descriptionSub': 'Please select the flag that represents your country of citizenship to learn more about the programs available to you. If your flag is not represented please contact us at info@smallerearth.com'
			},

			'pl' : {	
				'country'	    : 'pl',
				'heading'		: 'Poland',
				'description'   : 'We offer the following cultural exchange programs to the USA:',
				'programsRow1'  : ['Summer Camp','Au Pair','Internship','Career Training'],
				'programsRow2'  : ['Hospitality','Summer Work and Travel'],
				'descriptionSub': 'Please select the flag that represents your country of citizenship to learn more about the programs available to you. If your flag is not represented please contact us at info@smallerearth.com'
			},

			'co' : {	
				'country'	    : 'co',
				'heading'		: 'Colombia',
				'description'   : 'We offer the following cultural exchange programs to the USA:',
				'programsRow1'  : ['Summer Camp','Internship'],
				'programsRow2'  : ['Hospitality','Career Training'],
				'descriptionSub': 'Please select the flag that represents your country of citizenship to learn more about the programs available to you. If your flag is not represented please contact us at info@smallerearth.com'
			},
			
			'ww' : {	
				'country'	    : 'ww',
				'heading'		: 'World Wide',
				'description'   : 'We offer the following cultural exchange programs to the USA:',
				'programsRow1'  : ['Camp','Internship','Career Training'],
				'programsRow2'  : ['Hospitality','Work and Travel'],
				'descriptionSub': 'Please select the flag that represents your country of citizenship to learn more about the programs available to you. If your flag is not represented please contact us at info@smallerearth.com'
			}
		
	}),
	
 	/**
 	 * Initialise the class
 	 * 
 	 */
 	initialize : function () 
 	{	

		var flagContainer = $('country_box');
		var flagSummary   = $('country_summary');
		var flags		  = flagContainer.getElements('ul li a').addEvent('mouseover', this.switchCountry.bind(this));
		
				flagSummary.fade('out');
				flags.addEvents({
								 'mouseenter': function(){
									flagSummary.set('tween', {duration: 300}); 
									flagSummary.fade('in');
								 },
								 'mouseleave': function(){
									flagSummary.set('tween', {duration: 10000}); 
									flagSummary.fade('out');
								 }
				});
	},
		
	switchCountry : function (e)
	{
		var country = e.target.getProperty('id');
		var summary = $('country_summary').empty();	
		var data = null;
		$each(this.data, function(d, key) {
			if (key == country) data = d;
		});
				
		var ulLine1 = new Element('ul').addClass('line1');
		$each(data.programsRow1, function (programsRow1) {
		 	 var li = new Element('li', {'class' : 'program'}).set('text', programsRow1);
				 li.injectInside(this);
		}.bind(ulLine1));

		var ulLine2 = new Element('ul').addClass('line2');
		$each(data.programsRow2, function (programsRow2) {
			 var li = new Element('li', {'class' : 'program'}).set('text', programsRow2);
				 li.injectInside(this);
		}.bind(ulLine2));
		
		var h1	= new Element('h1').set('text', data.heading)
		var p   = new Element('p', {'class' : 'description'}).set('text', data.description);
		var div = new Element('div', {'class' : 'country_hover ' + data.country});
		var p2	= new Element('p', {'class' : 'description'}).set('text', data.descriptionSub)
		
		//Set the Data
		h1.injectInside(div);
		p.injectInside(div);
		ulLine1.injectInside(div);
		ulLine2.injectInside(div);
		p2.injectInside(div);

		div.injectInside(summary);
 	}
});
