function selectTab(elem){
	$$('a.sel').each(function(el){
		el.removeClass('sel');
	});
	$(elem).addClass('sel');
	var count=0;
	$$('div.textsel').each(function(el){
		el.removeClass('textsel');
	});
	$('text'+elem.id).addClass('textsel');
}

function getBrowserHeight() { 
	if (window.innerHeight) {return window.innerHeight;}	
	else if (document.documentElement && document.documentElement.clientHeight != 0) {
		return document.documentElement.clientHeight;
	}
	else if (document.body) {return document.body.clientHeight;}
	return 0;
}

function getBrowserWidth() { 
	if (window.innerWidth) {return window.innerWidth;}	
	else if (document.documentElement && document.documentElement.clientWidth != 0) {
		return document.documentElement.clientWidth;
	}
	else if (document.body) {return document.body.clientWidth;}
	return 0;
}

function setViewportDim(){
	x = getBrowserWidth() - 100;
	y = getBrowserHeight() - 120;
	$$('a.mb').each(function(el){
		el.setAttribute("rel","mediabox ["+x+" "+y+"]");
	});
}

/*
function slideShow(no, sno) {
for(var q = 0; q < sno.parentNode.parentNode.childNodes.length; q++) {if(sno.parentNode.parentNode.childNodes[q].className) {sno.parentNode.parentNode.childNodes[q].className = sno.parentNode.parentNode.childNodes[q].className.replace(/ active/g, "");}}
sno.parentNode.className += " active";
var obj = document.getElementById("photo").getElementsByTagName("ul")[0];
if(obj.style.marginLeft != 0) {var x = parseInt(obj.style.marginLeft.replace(/px/g, "")); x = -x;}
else {var x = obj.style.marginLeft;}
--no;
var newx = no*300;
slideIt(x, newx);
}

function slideIt(x, newx) { //inspired by Jeremy Keith - www.adactio.com
	if (newx > x) {x += Math.ceil((newx-x)/2);}
	else if (newx < x) {x += Math.floor((newx-x)/2);}
	else if (newx == x) {return true;}
	document.getElementById("photo").getElementsByTagName("ul")[0].style.marginLeft = -x + 'px';
	var time = setTimeout('slideIt('+x+', '+newx+')', 75);
}
*/
function determineStyle() { //inspired by A List Apart - www.alistapart.com
	var browserWidth = getBrowserWidth();
	if(browserWidth <= 1150) {
	 	for(var q = 0; (a = document.getElementsByTagName("link")[q]); q++) {
	 		if(a.getAttribute("title") == "wide") a.disabled = true;
        	else if(a.getAttribute("title") == "narrow") a.disabled = false;
	 	}
 	}
 	if(browserWidth > 1150) {
		for(var q = 0; (a = document.getElementsByTagName("link")[q]); q++) {
	 		if(a.getAttribute("title") == "narrow") a.disabled = true;
			else if(a.getAttribute("title") == "wide") a.disabled = false;
 		}
 	}
}

function doResize() {
	setViewportDim();
	determineStyle();
	var author = document.getElementById("author");
	var browserWidth = getBrowserWidth();
	if(browserWidth <= 1150) {
		author.parentNode.removeChild(author);
		document.getElementById("body_tab").appendChild(author);
	}
	if(browserWidth > 1150) {
		author.parentNode.removeChild(author);
		document.getElementById("sidebar").appendChild(author);
	}
}

window.onresize = doResize;
window.onload = function(){
	doResize();	
	myShow = new Slideshow('my_slideshow', { 
	  							hu: 'ui/foto/',
								images: ['1.jpg', '2.jpg','3.jpg'], 
								type: 'combo', 
								duration: [1000, 5000], 
								width: 300, height: 300, 
								pan: '5',
								zoom: '30'
							});
}

