/*
* utoplast general v.1.0
*/

var opacity = new Class({    initialize: function(name){        this.name = name;
        // .replace(/#|\./g, ''); // if u dont care 4 id and classes 
        if ( $chk($E(name)) ) {
        	this.element = $E(name);
        	if((name=="#band")||(name=="#band2")){
        		this.style = {'opacity':0.1};
        	}else{
        		this.style = {'opacity':1};
        	}
        	this.readCSS(['opacity']);
			this.element.setOpacity(0);
        }    },    readCSS: function(CSStyles){		$each(document.styleSheets, function(style){			var rules = style.rules || style.cssRules;			$each(rules, function(rule){				if (!rule.selectorText.toLowerCase().test(this.name + '($|,)')) return;
				// test('[\.#^s]?' + // if you dont care 4 id and classes				CSStyles.each(function(style){					if (!rule.style || !rule.style[style]) return;					var ruleStyle = rule.style[style];					this.style[style] = (style.test(/color/i) && ruleStyle.test(/^rgb/)) ? ruleStyle.rgbToHex() : ruleStyle;				}, this);			}, this);		}, this);    },    appear: function(delay, duration){
        // should check if blendin already set
        this.blendin = new Fx.Style(this.element, 'opacity', {duration: duration});
       // if (this.style['opacity'] != 1) {
        	this.blendin.start.delay(delay, this.blendin, this.style['opacity']);
       /* } else {
        	this.blendin.start.delay(delay, this.blendin, 0.1);
        }*/		    }});

function blendout(css) {
	$ES('a.'+css).each(function(el) {
		el.hreforg = el.getProperty('href');
		el.setProperty('href', '#');
		el.addEvent('click', function(){
			var overblend = new Element('div', {			    'styles': {			        'top': '0',			        'left': '0',			        'width': '100%',			        'height': '100%',			        'opacity': '0',
			        'z-index': '50',			        'display': 'block',			        'position': 'absolute'			    },			    'id': 'blendout'			});
			$$('body').adopt(overblend);
			var blendout = new Fx.Style(overblend, 'opacity', {duration:1200});			blendout.start(0, 1);
			(function(){
				window.location.href = el.hreforg
			}).delay(1000);
		});
	});
}


function readCSS(selector, CSStyles){
	var to = CSStyles;	CSStyles.each(function(xx){
		to[xx] = 0;
	});	CSStyles.each(function(xx){
		to[xx] = 1;
	});	$each(document.styleSheets, function(style){		var rules = style.rules || style.cssRules;		$each(rules, function(rule){			if (!rule.selectorText.toLowerCase().test(selector + '($|,)')) return;
			// test('[\.#^s]?' + // if you dont care 4 id and classes			CSStyles.each(function(style){				if (!rule.style || !rule.style[style]) return;				var ruleStyle = rule.style[style];				to[style] = (style.test(/color/i) && ruleStyle.test(/^rgb/)) ? ruleStyle.rgbToHex() : ruleStyle;				
			});		});	});
	return to;}

function listin(selector, delay, duration){
	var liststyle = readCSS(selector, ['opacity']);
	$ES(selector).each(function(el) {
		if( duration == 0 ){
			el.setStyle("visibility", "hidden");
		}else{
			el.setOpacity(0);
		}
	});
	(function(){
		var i = 0;
		$ES(selector).each(function(el) {
			i++;
			if( duration == 0 ){
				(function(){el.setStyle("visibility", "visible")}).delay(i*150);
			}else{
				var elblendIn = new Fx.Style(el, 'opacity', {duration: duration});				(function(){elblendIn.start(0, liststyle['opacity'])}).delay(i*(duration*0.222));
			}
		});
	}).delay(delay);
}

function fixopacity(selector){
	$ES(selector).each(function(el) {
		//el.setOpacity(0.3);//readCSS(el,['opacity'])
	});
}

/*window.addEvent("domready", function(){
	if ( $chk($("text")) ) {
		if ( $chk($("band2")) ) {
			$("band2").setStyle("z-index","5");
		}
	}});*/
/*
window.addEvent("domready", function(){
	if ( $chk($E(".overview")) ) {
		$ES(".overview a").each(function(el) {
			if(el.getPrevious()){
				if(el.getPrevious().hasClass("bg")){
					
					el.myFx = new Fx.Style(el.getPrevious(), 'opacity')
					el.addEvent('mouseenter', function(){
						var actual = el.getPrevious().getStyle("opacity");
						el.myFx.start(actual,0.28);
					});
					
					el.addEvent('mouseleave', function(){
						var actual = el.getPrevious().getStyle("opacity");
						el.myFx.start(actual,0.14);
					});
					
				}
			}
		});
		$ES(".overview ul a").each(function(el) {
			if(el.getParent().getParent().getFirst()){
				if(el.getParent().getParent().getParent().getFirst().hasClass("bg")){
					
				}
			}
		});
		
		
	}});*/











