// JavaScript Document
function addEvent(obj, evType, fn){ 
 if (obj.addEventListener){ 
   obj.addEventListener(evType, fn, false); 
   return true; 
 } else if (obj.attachEvent){ 
   var r = obj.attachEvent("on"+evType, fn); 
   return r; 
 } else { 
   return false; 
 } 
}
function spamSave( element ) {
	element = $( element == undefined ? 'body' : element );
	var arA = element.getElementsByTagName('A');
	for (var i=0;i<arA.length; i++ ) {
		if (arA[i].href.substr(0,7) == 'mailto:') {
			arA[i].href = arA[i].href.replace("--AT--","@");
			arA[i].innerHTML = arA[i].innerHTML.replace("--AT--","@");
		}
	}
}
function sizeContent() {
	arDimensions = getWindowsDimensions();
	// portfolio
	$('portfolio').style.height = arDimensions[1] + 'px';
	$('portfolio_content').style.height = arDimensions[1] -66 + 'px'; //-42 -62
	portfolio.resize();
}
function getWindowsDimensions() {
	var myWidth = 0, myHeight = 0;
	if	( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    	//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	return [myWidth,myHeight];
}
function addPortfolio() {
	portfolio = new Portfolio();	
	portfolio.enter();
}
function closePortfolio() {
	portfolio.leave();
}
function togglePortfolio() {
	//portfolio = new Portfolio();	
	portfolio.toggle();
	sizeContent();
	// flexCroll uses onresize event, not onresize function
	// so first resize needs fixing
	$('portfolio_content').scrollUpdate();
}
var portfolio;