var SiteClass = new Class({

	initialize: function(){
	
		hs.lang.cssDirection = lang.cssDirection;
		hs.lang.loadingText = lang.loadingText;
		hs.lang.loadingTitle = lang.loadingTitle;
		hs.lang.focusTitle = lang.focusTitle;
		hs.lang.fullExpandTitle = lang.fullExpandTitle;
		hs.lang.previousText = lang.previousText;
		hs.lang.nextText = lang.nextText; 
		hs.lang.moveText = lang.moveText;
		hs.lang.closeText = lang.closeText; 
		hs.lang.closeTitle = lang.closeTitle; 
		hs.lang.resizeTitle = lang.resizeTitle;
		hs.lang.playText = lang.playText;
		hs.lang.playTitle = lang.playTitle;
		hs.lang.pauseText = lang.pauseText;
		hs.lang.pauseTitle = lang.pauseTitle;
		hs.lang.previousTitle = lang.previousTitle;
		hs.lang.nextTitle = lang.nextTitle;
		hs.lang.moveTitle = lang.moveTitle;
		hs.lang.fullExpandText = lang.fullExpandText;
		hs.lang.number = lang.number;
		hs.lang.restoreTitle = lang.restoreTitle;			
		hs.graphicsDir = 'public/images/highslide/';
		hs.align = 'center';
		hs.transitions = ['expand', 'crossfade'];
		hs.outlineType = 'rounded-white';
		hs.fadeInOut = true;
		hs.dimmingOpacity = 0.75;
		
		hs.addSlideshow({
			//slideshowGroup: 'group1',
			interval: 5000,
			repeat: false,
			useControls: true,
			fixedControls: 'fit',
			overlayOptions: {
				opacity: .75,
				position: 'bottom center',
				hideOnMouseOut: true
			}
		});
				
	}, // initialize

	fadeDuration2: 500,
	delayDuration2: 5000,

	domReady: function() {
		
		$$('a#goback').each(function(a){
			a.addEvent('click', function(){ window.history.go(-1); });
		});
		
		if($('gotop')) {
			$('gotop').addEvent('click', function() {
				var scrollFx = new Fx.Scroll(window, {
					transition: Fx.Transitions.Quad.easeInOut
				});
				scrollFx.toTop();
			});
		}
		//if(typeof sIFR == "function"){
		//	sIFR.replaceElement(named({sSelector:"ul.gallery h2", sFlashSrc:"public/flash/myriadpro.swf", sColor:"#fff2e2", sLinkColor:"#fff2e2", sBgColor:"#FFFFFF", sHoverColor:"#fff2e2", sWmode:"transparent"}));
		//}

		Cufon.replace('.cufon', { hover: true });
		
		$$('div#menu > ul > li > a, div#menu ul ul a, div#bottom-menu ul a').each(function(a){
			var link = window.location.pathname.substr(1);
			if(a.get('href') == link) {
				a.getParent().addClass('active');
			}
			if(a.id == 'menu_03' || a.id == 'menu_04' || a.id == 'menu_05') { 
				a.getParent().addEvent('mouseenter', function(){ this.addClass('hover'); this.getParent().addClass('over'); });	
				a.getParent().addEvent('mouseleave', function(){ this.removeClass('hover'); this.getParent().removeClass('over'); });
			}
		});

		if($('slider')) {
			$$('ul#slider li').each(function(li, i) { li.setStyle('opacity', 0); if(i == 0) li.addClass('active'); });
			new Fx.Tween($('slider').getFirst(), {duration: Site.fadeDuration2}).start('opacity', 0, 1);
			
			if($$('ul#slider li').length > 1) {
				var nextImage = function() {
					var lis = $$('ul#slider li.active');
					var actual = lis[0];
					var next = (actual.getNext()) ? actual.getNext() : actual.getParent().getFirst();
					actual.setStyle('zIndex', 5);
					next.setStyle('zIndex', 10);
					
					new Fx.Tween(next, {
						duration: Site.fadeDuration2, 
						onComplete: function(li){
							li.addClass('active');
							var prev = (li.getPrevious()) ? li.getPrevious() : li.getParent().getLast();
							prev.removeClass('active');
							prev.setStyle('opacity', 0);
						}
					}).start('opacity', 0, 1);
					
				}
				var periodical = nextImage.periodical(Site.fadeDuration2 + Site.delayDuration2);
			}
		}


	}, // domReady
	
	showMail: function(user, domain, country, attr, text) {
		var start = "<a href=\"mailto:" + user + "@" + domain + "." + country + "\"" + attr + ">";
		var end = "</a>";
		if(text) {
			document.write(start + user + '@' + domain + '.' + country + end);
		} else {
			document.write(start + end);
		}
		return false;
	} // showMail
	
});

var Site = new SiteClass();
window.addEvent('domready', function(){ Site.domReady(); });

