window.onresize = sizeContent;
window.onload = fixPNG;

function sizeContent() {
	var viewportheight;
	var size;
	
	if (typeof window.innerWidth != 'undefined') {
		viewportheight = window.innerHeight
	}
	
	else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) {
		viewportheight = document.documentElement.clientHeight
	}
	else {
		viewportheight = document.getElementsByTagName('body')[0].clientHeight
	}
	size = viewportheight - extraheight - 137 - 224 - 20;
	if(!googlemap) {
		document.getElementById('maincontent').style.minHeight = size+'px';
	}
}

function movep(id) {
	var move = 0;
	if(portfolio[id][0]<portfolio[id][1]) {
		move = 4;
		if(move>(portfolio[id][1]-portfolio[id][0])) {
			move = portfolio[id][1]-portfolio[id][0];
		}
	}
	else if(portfolio[id][0]>portfolio[id][1]) {
		move = -4;
		if(move<(portfolio[id][1]-portfolio[id][0])) {
			move = portfolio[id][1]-portfolio[id][0];
		}
	}

	if(move!=0) {

		portfolio[id][0] += move;
		document.getElementById('pinfo'+id).style.marginTop = portfolio[id][0]+'px';
		setTimeout('movep('+id+')', 50);
	}
	else {
		portfolio[id][0][2] = false;
	}
}


function sp(id) {
	if(!portfolio[id][0][2]) {
		portfolio[id][0][2] = true;
		portfolio[id][1] = -33;
		movep(id);
	}
}

function hp(id) {
	if(!portfolio[id][0][2]) {
		portfolio[id][0][2] = true;
		portfolio[id][1] = 0;
		movep(id);
	}
}

function s(id) {
	document.getElementById(id).style.display = 'block';	
}

function h(id) {
	document.getElementById(id).style.display = 'none';	
}

function swapPortfolio(id, ext) {
	document.mainimage.src = '/images/portfolio/'+id+ext+'-large.png';
	return false;
}

var map;
var gdir;
var geocoder = null;
var addressMarker;
var localSearch;
var evolutedMarker;
function initialize() {
	if (GBrowserIsCompatible()) {
		map = new GMap2(document.getElementById("map"));
		var point = new GLatLng(37.168601,-8.365338);
		map.addControl(new GSmallMapControl());
	    map.addControl(new GMapTypeControl());
		map.setCenter(point, 11);
		
		var baseIcon = new GIcon();
		baseIcon.shadow = "/images/we-are-here-shadow.png";
		baseIcon.iconSize = new GSize(129, 42);
		baseIcon.shadowSize = new GSize(151, 42);
		baseIcon.iconAnchor = new GPoint(18, 42);

		var letteredIcon = new GIcon(baseIcon);
		letteredIcon.image = "/images/marker.png";
		markerOptions = { icon:letteredIcon };
		evolutedMarker = new GMarker(point, markerOptions);
		/*GEvent.addListener(evolutedMarker, "click", function() {
			alert("yes");
		});*/
		map.addOverlay(evolutedMarker);	
		
	}
}

function sz(t) {
	a = t.value.split('\n');
	b=1;
	for (x=0;x < a.length; x++) {
		if (a[x].length >= t.cols) b+= Math.floor(a[x].length/t.cols);
	}
	b+= a.length;
	if (b > t.rows) t.rows = b;
}

function fixPNG() {
	if (document.all && /MSIE (5\.5|6)/.test(navigator.userAgent) && document.styleSheets && document.styleSheets[0] && document.styleSheets[0].addRule) {
		document.styleSheets[0].addRule('img', 'behavior: url(/iepngfix.htc)');
	}
}