initPhotoalbum = function () {
	var els = $$('#photo-album div.pictures li a');
	for (i=0,j=els.length;i<j;i++) {
		Event.observe (els[i],'click',clickPhotoalbum);
	}
}

clickPhotoalbum = function (e) {
	Event.stop(e);
	var link = Event.findElement(e,'A');
	targetNode = $$('#showphoto li.active');
	if (targetNode.length==0) {
		return;
	}
	targetNode = targetNode[0];
	targetNode.className = '';
	targetNode = $$('#showphoto a[href='+link.getAttribute('hreffull')+'] img');
	if (targetNode.length==0) {
		return;
	}
	targetNode = targetNode[0];
	targetNode.parentNode.parentNode.className='active';
	targetNode.src = "/images/loading.gif";
	targetNode.src = link.href;
	targetNode.parentNode.href=link.getAttribute('hreffull');
	targetNode.parentNode.title=link.getAttribute('title');
	$('photo-title').update(link.getAttribute('title'));
}

document.observe ('dom:loaded', initPhotoalbum);

var ie6fixes = function () {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			cName = " sfhover";
			this.className+=cName;
		}
		sfEls[i].onmouseout=function() {
			cName = " sfhover";
			this.className=this.className.replace(new RegExp(cName+"\\b"), "");
		}
	}
}

initLanding = function () {
	Effect.Appear($('landingimage'),
		{ 
			duration: 1
		}
	);
	
	setCookie ('landing','1',30);
	
	$(document.body).style.height=$('landingimage').getHeight()+'px';
	$(document.body).style.overflow='hidden';
	Event.observe($('landingimage'),'click',hideLanding);
}

hideLanding = function (e) {
	$('landingimage').style.display = 'none';
	$(document.body).style.height='auto';
	$(document.body).style.overflow='visible';
}

function getCookie(c_name)
{
	if (document.cookie.length>0) {
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1) {
			c_start=c_start + c_name.length+1;
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) {
				c_end=document.cookie.length;
			}
			return unescape(document.cookie.substring(c_start,c_end));
		}
	}
	return "";
}

function setCookie(c_name,value,expiredays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

if (getCookie('landing')=='') {
	document.observe('dom:loaded',initLanding);
}