/*
	site.js - Site v1.0
	built by AntalMedia
	built on Mootools v1.2 (http://www.mootools.net)
	
	Copyright 2008. All Rights Reserved.
		
*/
var Site = {
	
	init: function() {
		Site.pageSelect();
		Site.padTop();
		//Site.loadGallery();
		if( $('body-index') || $('body-gallery') ) {
			Site.sound();
		}
	},
	pageSelect: function() {
		if($(_params.page['base_name'])) $(_params.page['base_name']).addClass('active');
	},
	getUrl:function(url) {
		window.location.href = url;
	},
	makeBookmark:function(title,url){
		if (window.sidebar) { // firefox
			window.sidebar.addPanel(title, url, _params.self['base_url']);
		} else if(window.opera && window.print) { // opera
			var elem = document.createElement('a');
			elem.setAttribute('href',url);
			elem.setAttribute('title',title);
			elem.setAttribute('rel','sidebar');
			elem.click();
		} else if(document.all) { // ie
			window.external.AddFavorite(url, title);
		}
	},
	flashBg:function() {
		var playerVersion  = swfobject.getFlashPlayerVersion();
		if(playerVersion  >= "9" && !$('body-gallery') && !$('body-references') && (_params['page']['browser'] != 'Microsoft Internet Explorer' && _params['page']['browser_version'] != ' 6.0') ) {
			var flashvars = {};
			//flashvars.traceDebug = true;
			flashvars.base = _params['self']['site_url'];
			flashvars.xmlPath = "/lib/xml/background.xml";
			flashvars.randomize = "false";
			var params = {};
			params.wmode = "transparent";
			params.allownetworking = "all";
			params.scale = "exactfit"
			var attributes = {};
			swfobject.embedSWF("/lib/swf/background_gall.swf?rnd="+Math.random(), "background_holder", "100%", "100%", "9.0.0", false, flashvars, params, attributes);
			if( $('background') ) {$('background').setStyle('background', 'none');}
		} else {
			if( $('background') ) {$('background').setStyle('background', 'url(/lib/images/background/bg_11.jpg) 50% no-repeat');}
		}
		
	},
	sound:function() {
		var playerVersion  = swfobject.getFlashPlayerVersion();
		if(playerVersion  >= "9") {
			var flashvars = {};
			//flashvars.traceDebug = true;
			flashvars.base = _params['self']['site_url'];
			flashvars.audioPath = "/lib/audio/sound.mp3";
			flashvars.vol = "40";
			var params = {};
			params.wmode = "transparent";
			params.allownetworking = "all";
			var attributes = {};
			swfobject.embedSWF("/lib/swf/audio.swf", "sound_bg", "1px", "1px", "9.0.0", false, flashvars, params, attributes);
		}
	},
	padTop:function() {
		Site.setSpacerHeight();
		window.onresize = function() {
			Site.setSpacerHeight();
		}
	},
	setSpacerHeight:function() {
			var scrollSize = window.getScrollSize();
			var windowHeight = window.getHeight();
			var calcHeight = windowHeight-800;
			var readCookie = Cookie.read('spacer_height');
			if ( calcHeight != readCookie ) {
				spacerTween = new Fx.Tween('spacer', {duration: 500, wait: false, onComplete:function(){}});
				spacerTween.start('height', calcHeight);
			}
			var spacerCookie = Cookie.write('spacer_height', calcHeight);
	},
	loadGallery:function() {
		var galleryControls = new Element('div', {id: 'galleryControls'});
		var closeBtn = new Element('div', {'id': 'galleryClose', 'html': '<a href="javascript:Site.endGallery();" id="gallery" name="Close Gallery" title="Close Gallery">Close Gallery</a>'})
		closeBtn.inject(galleryControls);
		galleryControls.inject('container');
		galleryControls.setStyle('opacity', 0);
	},
	startGallery:function() {
		pageTween = new Fx.Tween('page', {duration: 2000, wait: false});
		controlsTween = new Fx.Tween('galleryControls', {duration: 2000, wait: false});
		pageTween.start('opacity', 0.0);
		controlsTween.start('opacity', 1.0);
		$('container').addClass('galleryContainer');
	},
	endGallery:function() {
		pageTween = new Fx.Tween('page', {duration: 2000, wait: false});
		controlsTween = new Fx.Tween('galleryControls', {duration: 2000, wait: false});
		pageTween.start('opacity', 1.0);
		controlsTween.start('opacity', 0.0);
		$('container').removeClass('galleryContainer');
	}
}
window.addEvent('domready', Site.flashBg);
window.addEvent('load', Site.init);