﻿
var ARGUS = {
	popup: function(sHref, nMode){
		var winPopup = [];
	
		switch(nMode){
			case 1: // RTE
				winPopup[nMode] = window.open(sHref, 'winPopup' + nMode, 'dependant=yes, toolbar=no, status=no, menubar=no, scrollbars=yes, movable=yes, resizable=yes, width=600, height=500');
				break;
			default:
				winPopup[nMode] = window.open(sHref, 'winPopup' + nMode, '');
				break;
		}
	},
	
	checkEmail: function(sEmail){
		var reFilter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
		if (reFilter.test(sEmail)){
			return true;
		}else{
			return false;
		}
	},
	
	centerWindow: function(oWindow){
		var nY = new Number((window.screen.availHeight - oWindow.document.body.offsetHeight) / 2 - 200);
		var nX = new Number((window.screen.availWidth - oWindow.document.body.offsetWidth) / 2);
		oWindow.moveTo(nX, nY);
	},
	
	fitWindow: function(oContainer){
		window.resizeTo(oContainer.offsetWidth + 20, oContainer.offsetHeight + 85);
	},
	
	centerElement: function(oElement){
		oElement = $(oElement);
		oElement.setStyle('top', ($(document.body).getSize().y / 2) - (oElement.getSize().y / 2));
		oElement.setStyle('left', ($(document.body).getSize().x / 2) - (oElement.getSize().x / 2));
	},
	
	setDefaultText: function(oElement, sText, bMode){
		if(bMode){
			if(oElement.value == sText) oElement.value = '';
		}else if(oElement.value.length < 1) oElement.value = sText;
	},
	
	addToFavorites: function(sTitle, sUrl){
		if (window.sidebar) // firefox
			window.sidebar.addPanel(sTitle, sUrl, "");
		else if(window.opera && window.print){ // opera
			var elem = document.createElement('a');
			elem.setAttribute('href', sUrl);
			elem.setAttribute('title', sTitle);
			elem.setAttribute('rel', 'sidebar');
			elem.click();
		} else if(document.all)// ie
			window.external.AddFavorite(sUrl, sTitle);
	},
	
	popupImage: function(oRef, bBlink){
		oRef = $(oRef);
		if(bBlink){
			var oImg = new Element('img').setStyles({
				position: 'absolute',
				width: 500,
				opacity: '0',
				'cursor': 'pointer',
				'border': 'solid 1px #999',
				zIndex: '10'
			}).injectInside(document.body);
			
			var oBlink = new Fx.Morph(oImg, {duration: 500, transition: 'expo:out'});
			
			oImg.src = oRef.src.replace('&width=90', '&width=500').replace('&width=165', '&width=500');
			oImg.addEvents({
				'load': function(){
					ARGUS.centerElement(oImg);
					oBlink.start({
						left: [oRef.getPosition().x, oImg.getPosition().x],
						top: [oRef.getPosition().y, oImg.getPosition().y],
						width: [oRef.getSize().x, oImg.getSize().x],
						height: [oRef.getSize().y, oImg.getSize().y],
						'opacity': [0, 1]
					});
				},
				'click': function(){
					ARGUS.centerElement(oImg);
					oBlink = new Fx.Morph(oImg, {duration: 500, transition: 'expo:in'})
					oBlink.start({
						left: [oImg.getPosition().x, oRef.getPosition().x],
						top: [oImg.getPosition().y, oRef.getPosition().y],
						width: [oImg.getSize().x, oRef.getSize().x],
						height: [oImg.getSize().y, oRef.getSize().y],
						'opacity': [1, 0]
					}).chain(function(){
						oImg.dispose();
					});
				}
			});
		}else{
			
		}
	},
	
	querystring: document.location.search.substring(1).parseQueryString()

}

Element.extend({
	clearValue: function(){
		switch(this.getTag()){
			case 'select':
				$each(this.options, function(option){
					if (option.selected) option.selected = false;
				});
			case 'input':
				if (this.checked || ['hidden','submit','button'].contains(this.type)) {
					if (['checkbox', 'radio'].contains(this.type)) this.checked = false;
					break;
				}
			case 'textarea': this.value = '';
		}
		return false;
	},
 
	clearFormElements: function(){
		this.getFormElements().each(function(el){ el.clearValue() });
	}
 
});

window.addEvent('load', function(){
	if(Browser.Engine.trident){// && Browser.Engine.version == 4){
		var oIeAlert = new Element('div').setProperty('align', 'center').setStyle('margin', '10px').inject($('main-body'), 'top');
		new Element('div').setStyles({
			background: '#FFF',
			border: 'solid 1px #F00',
			color: '#900',
			padding: '10px',
			textAlign: 'left',
			width: '400px'
		}).set('html', '<strong>DEAR MISGUIDED USER</strong>, you\'re using Internet Explorer which is inferior in almost every way to most of the alternatives. For that reason your experience in this website may be diminished. Please consider using one of these wonderful and FREE browsers <a href="http://www.getfirefox.com/" target="_blank" style="COLOR: #000; FONT-WEIGHT: bold;">Firefox</a>, <a href="http://www.google.com/chrome" target="_blank" style="COLOR: #000; FONT-WEIGHT: bold;">Google Chrome</a> or <a href="http://www.apple.com/safari/download/" target="_blank" style="COLOR: #000; FONT-WEIGHT: bold;">Apple Safari</a>. You can thank me later.').inject(oIeAlert);
	}

	if($('guestbookList')){
		var oGuestbook = new Hermes('guestbookList', {
			height: 50,
			width: 270,
			displayItems: 1,
			speed: 1000,
			pause: 5000
		});
	}

});

window.addEvent('load', function(){
	$$('.button', '.button-pause', '.button-play', '.button-previous', '.button-next', '.music-albums .off').set('morph', {duration: 400, transition: 'expo:out', wait: false});
	$$('.button', '.button-pause', '.button-play', '.button-previous', '.button-next').addEvents({
		'mouseenter': function(e){
			e.stop();
			this.morph({backgroundColor: ['#234767', '#70A0CD']});
		},
		'mouseleave': function(e){
			e.stop();
			this.morph({backgroundColor: ['#70A0CD', '#234767']});
		}
	});
	
	$$('.music-albums .off').addEvents({
		'mouseenter': function(e){
			e.stop();
			this.morph({backgroundColor: ['#101114', '#222'], borderColor: ['#101114', '#CCC']});
		},
		'mouseleave': function(e){
			e.stop();
			this.morph({backgroundColor: ['#222', '#101114'], borderColor: ['#CCC', '#101114']});
		}
	});
});

window.addEvent('resize', function(){

});



