var Main = new Class({
	
	flashDir: 'public/swf/',
	
	initialize: function(){
	}, // initialize
	
	onDomReady: function() {
		this.insertFlash();
		this.replaceFont();
		this.insertGmap();
		this.activateJumpinBtns4();
	}, // onDomReady

	insertFlash: function(){
		elements = $$('div.flash');
		if (elements.length > 0) {
	    	elements.each(function(obj){
            	var size = obj.getSize();
            	if (size.x==document.body.clientWidth) size.x='100%';
            	if (size.x==document.body.clientHeight) size.y='100%';
            	var id = obj.get('id');
            	var bgColor =  obj.getStyle('background-color');
            	var SwiffObj = new Swiff(main.flashDir + id + '.swf', { id: "flash" + $random(1,99),container: id, width: size.x, height: size.y, 
					 params: {wmode: 'transparent', bgcolor: ((bgColor!='transparent')?'#':'') + bgColor},
					 vars: {  }
					 });
            	obj.setStyle('background-image', 'none');
	    	});
		}
	}, // insertFlash
	
	replaceFont: function(){
		Cufon.replace('.myriad600', { fontFamily: 'MyriadRegular' });
		Cufon.replace('.myriad300', { fontFamily: 'MyriadLight' });
	}, // replaceFont
	
	insertGmap: function(){
		if ($('gmap')) {
		  	var point = new google.maps.LatLng(51.74865,-8.736735); 
		  	var options = {
		  			zoom: 9,
		  			center: point,
		  			mapTypeId: google.maps.MapTypeId.ROADMAP,
		  			mapTypeControl: false
		  	};
		  	var map = new google.maps.Map($('gmap'), options);
		  	
		  	var points =
		  		[
				new google.maps.LatLng(51.830686,-8.32489),
				new google.maps.LatLng(51.713416,-8.497925),
				new google.maps.LatLng(51.638476,-8.552856),
				new google.maps.LatLng(51.662334,-8.756104),
				new google.maps.LatLng(51.6129,-8.8797),
				new google.maps.LatLng(51.723626,-9.187317),
				new google.maps.LatLng(51.795027,-9.118652),
				new google.maps.LatLng(51.869708,-8.904419),
				new google.maps.LatLng(51.827291,-8.665466),
				new google.maps.LatLng(51.845959,-8.547363),
				new google.maps.LatLng(51.827291,-8.459473),
				new google.maps.LatLng(51.847656,-8.393555),
				new google.maps.LatLng(51.828988,-8.32489) 
		  		];
		  	
	  		var polygon = new google.maps.Polygon({
	  				paths: points,
	  				strokeWeight: 0,
	  				fillColor: '#ced655',
	  				fillOpacity: 0.5
	  		});
		  	polygon.setMap(map);
		  	
		  	var points2 =
		  		[
				new google.maps.LatLng(51.835778,-8.286438),
				new google.maps.LatLng(51.738935,-8.415527),
				new google.maps.LatLng(51.609489,-8.536377),
				new google.maps.LatLng(51.640181,-8.747864),
				new google.maps.LatLng(51.595842,-8.901672),
				new google.maps.LatLng(51.725327,-9.236755),
				new google.maps.LatLng(51.808615,-9.151611),
				new google.maps.LatLng(51.890054,-8.887939),
				new google.maps.LatLng(51.849353,-8.695679),
				new google.maps.LatLng(51.862924,-8.530884),
				new google.maps.LatLng(51.842566,-8.432007),
				new google.maps.LatLng(51.859532,-8.352356),
				new google.maps.LatLng(51.830686,-8.289185)
		  		];
		  	
	  		var polygon2 = new google.maps.Polygon({
	  				paths: points2,
	  				strokeWeight: 0,
	  				fillColor: '#f1fa63',
	  				fillOpacity: 0.35
	  		});
		  	polygon2.setMap(map);
		}
	}, // insertGmap
	
	activateJumpinBtns4: function() {
		$$('.btns4 a span').each(function(obj){
			var running = false;
			var fx2 = new Fx.Morph(obj, {duration: 100, link: 'chain', onChainComplete:function() { running = false; } });
			var fx1 = new Fx.Morph(obj, {duration: 200, link: 'chain', onComplete:function() {
					fx2.start({'margin-top':'-7px'}).start({'margin-top':'0px'}).start({'margin-top':'-6px'}).start({'margin-top':'0px'});
				}
			});

			obj.addEvent('mouseenter',function() {
				if(!running) {
					fx1.start({'margin-top':'-10px'}).start({'margin-top':'0px'});
					running = true;
				}
			});

			obj.addEvent('mouseleave',function() { this.setStyle('margin-top', '0'); });
		});
	},
	
	showMail: function(user, domain, contry, attr) {
		if (!attr) var attr='';
		var start = "<a href=\"mailto:" + user + "@" + domain + "." + contry + "\"" + attr + ">";
		var end = "</a>";
		document.write(start + user + "@" + domain + "." + contry + end);
		return false;
	} // showMail
	
});

var main = new Main();
window.addEvent('domready', function(){ main.onDomReady(); });

