/* FUNCTIONS
------------------------------------------------------------------------------*/

/* LINKS (TRANS HOVER)
------------------------------------------------------------------------------*/

$(function(){
	$('.logos a').each(function() {
	    $(this).hover(function() {
	        $(this).stop().animate({ opacity: 1.0 }, 300);
	    },
	   function() {
	       $(this).stop().animate({ opacity: 0.1 }, 300);
	   });
	});
});

/* LINKS (RGS HOVER)
------------------------------------------------------------------------------*/

$(function(){
	$('.rgs a').each(function() {
	    $(this).hover(function() {
	        $(this).stop().animate({ opacity: 0.4 }, 300);
	    },
	   function() {
	       $(this).stop().animate({ opacity: 1.0 }, 300);
	   });
	});
});


/* FLICKERING
------------------------------------------------------------------------------*/

	function flickIt(){
	$zombie = $('#logo');
	$zombie
		.animate({opacity:1}, {duration:200})
		.animate({opacity:0}, {duration:100})
		.animate({opacity:1}, {duration:10})
		.animate({opacity:0}, {duration:10})
		.animate({opacity:1}, {duration:10})
		.animate({opacity:0}, {duration:50})
		.animate({opacity:1}, {duration:100})
		.animate({opacity:0}, {duration:10})
		.animate({opacity:1}, {duration:10})
		.animate({opacity:0}, {duration:50})
		.animate({opacity:1}, {duration:20})
		.animate({opacity:0}, {duration:100})
		.animate({opacity:1}, {duration:10})
		.animate({opacity:0}, {duration:10})
		.animate({opacity:1}, {duration:10})
		.animate({ opacity: 1 },7000, function(){flickIt();});
	}


/* BLANKWIN
/* written by Alen Grakalic, provided by Css Globe (cssglobe.com)
/* http://cssglobe.com/post/1281/open-external-links-in-new-window-automatically/
------------------------------------------------------------------------------*/

this.blankwin = function(){
	var hostname = window.location.hostname;
	hostname = hostname.replace("www.","").toLowerCase();
	var a = document.getElementsByTagName("a");
	this.check = function(obj){
		var href = obj.href.toLowerCase();
		return (href.indexOf("http://")!=-1 && href.indexOf(hostname)==-1) ? true : false;
	};
	this.set = function(obj){
		obj.target = "_blank";
	};
	for (var i=0;i<a.length;i++){
		if(check(a[i])) set(a[i]);
	};
};

// script initiates on page load.

this.addEvent = function(obj,type,fn){
	if(obj.attachEvent){
		obj['e'+type+fn] = fn;
		obj[type+fn] = function(){obj['e'+type+fn](window.event );}
		obj.attachEvent('on'+type, obj[type+fn]);
	} else {
		obj.addEventListener(type,fn,false);
	};
};
addEvent(window,"load",blankwin);
