/*
 * JavaScript file to www.felipeacosta.com
 * Copyright Felipe Avila da Costa
 */

/*
addEvent function from http://www.quirksmode.org/blog/archives/2005/10/_and_the_winner_1.html
*/
function addEvent(obj, type, fn) {
	if (obj.addEventListener)
		obj.addEventListener(type, fn, false);
	else 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]);
	}
}

/* Bookmark Button */

function CreateBookmarkLink()
{
	if (isIE)
	{
		window.external.AddFavorite("./", "Felipe Avila da Costa");
	}
	else if (window.sidebar)// Mozilla Firefox Bookmark
	{ 
		window.sidebar.addPanel("Felipe Avila da Costa", "./","");
	}
}

/**** Next Function from http://www.456bereastreet.com/archive/200610/opening_new_windows_with_javascript_version_12/ *****/

/*
JSTarget function by Roger Johansson, www.456bereastreet.com
*/
var JSTarget = {
	init: function(att,val,warning) {
		if (document.getElementById && document.createElement && document.appendChild) {
			var strAtt = ((typeof att == 'undefined') || (att == null)) ? 'class' : att;
			var strVal = ((typeof val == 'undefined') || (val == null)) ? 'non-html' : val;
			var strWarning = ((typeof warning == 'undefined') || (warning == null)) ? ' (opens in a new window)' : warning;
			var oWarning;
			var arrLinks = document.getElementsByTagName('a');
			var oLink;
			var oRegExp = new RegExp("(^|\\s)" + strVal + "(\\s|$)");
			for (var i = 0; i < arrLinks.length; i++) {
				oLink = arrLinks[i];
				if ((strAtt == 'class') && (oRegExp.test(oLink.className)) || (oRegExp.test(oLink.getAttribute(strAtt)))) {
					oWarning = document.createElement("em");
					oWarning.appendChild(document.createTextNode(strWarning));
					oLink.appendChild(oWarning);
					oLink.onclick = JSTarget.openWin;
				}
			}
			oWarning = null;
		}
	},
	openWin: function(e) {
		var event = (!e) ? window.event : e;
		if (event.shiftKey || event.altKey || event.ctrlKey || event.metaKey) return true;
		else {
		    var oWin = window.open(this.getAttribute('href'), '_blank');
			if (oWin) {
				if (oWin.focus) oWin.focus();
				return false;
			}
			oWin = null;
			return true;
		}
	}
};

function welcome()
{
	new Effect.Appear('topheadertext');
	new Effect.Appear('bottomheadertext');
	setTimeout("new Effect.Appear('felipe')",3500);	
	
	setTimeout("new Effect.Appear('aboutme')",830);
	setTimeout("new Effect.Appear('curriculumvitae')",1160);
	setTimeout("new Effect.Appear('projects')",1500);
	setTimeout("new Effect.Appear('publications')",1830);
	setTimeout("new Effect.Appear('traveling')",2160);
	setTimeout("new Effect.Appear('interests')",2500);
	//setTimeout("new Effect.Appear('tools')",3160);
	setTimeout("new Effect.Appear('contactme')",2830);	

}

addEvent(window, 'load', function(){JSTarget.init("rel","external","");});
addEvent(window, 'load', function(){welcome();});



