//Menu dropdown script
var menu=function(){
	var s=6,a;
	function dd(n){this.n=n; this.h=[]; this.c=[]}
	dd.prototype.init=function(p,c){
		a=c; var w=document.getElementById(p), s=w.getElementsByTagName('ul'), l=s.length, i=0;
		for(i;i<l;i++){
			var h=s[i].parentNode; this.h[i]=h; this.c[i]=s[i];
			h.onmouseover=new Function(this.n+'.st('+i+',true)');
			h.onmouseout=new Function(this.n+'.st('+i+')');
		}		
	}	
	dd.prototype.st=function(x,f){
		var c=this.c[x], h=this.h[x], p=h.getElementsByTagName('a')[0];
		if(f){
		    p.className+=' '+a;
		    c.style.display='block'; c.style.overflow='visible'; c.style.zIndex=900; c.style.opacity=1;
		    
		}
		else{c.style.display='none'; p.className=p.className.replace(a,'')}
	}
	
	/*dd.prototype.st=function(x,f){
		var c=this.c[x], h=this.h[x], p=h.getElementsByTagName('a')[0];
		clearInterval(c.t); c.style.overflow='hidden';
		if(f){
			p.className+=' '+a;
			if(!c.mh){c.style.display='block'; c.style.height=''; c.mh=c.offsetHeight; c.style.height=0}
			if(c.mh==c.offsetHeight){c.style.overflow='visible'}
			else{c.style.zIndex=z; z++; c.t=setInterval(function(){sl(c,1)},t)}
		}else{p.className=p.className.replace(a,''); c.t=setInterval(function(){sl(c,-1)},t)}
	}*/
	return{dd:dd}
}();


//Photo caption expand function
var caption=function(){
	var id = 'cp';
	var top = 3;
	var left = 3;
	var maxw = 560;
	var speed = 10;
	var timer = 20;
	var endalpha = 95;
	var alpha = 0;
	var cp,t,c,b,h;
	var ie = document.all ? true : false;
	return{
		show:function(v,w){
			if(cp == null){
				cp = document.createElement('div');
				cp.setAttribute('id',id);
				t = document.createElement('div');
				t.setAttribute('id',id + 'top');
				c = document.createElement('div');
				c.setAttribute('id',id + 'cont');
				b = document.createElement('div');
				b.setAttribute('id',id + 'bot');
				cp.appendChild(t);
				cp.appendChild(c);
				cp.appendChild(b);
				document.getElementById('photocaption').appendChild(cp);
				cp.style.opacity = 0;
				cp.style.filter = 'alpha(opacity=0)';
			}
			cp.style.display = 'block';
			c.innerHTML = v;
			cp.style.width = w ? w + 'px' : 'auto';
			if(!w && ie){
				t.style.display = 'none';
				b.style.display = 'none';
				cp.style.width = cp.offsetWidth;
				t.style.display = 'block';
				b.style.display = 'block';
			}
			if(cp.offsetWidth > maxw){cp.style.width = maxw + 'px'}
			h = parseInt(cp.offsetHeight) + top;
			clearInterval(cp.timer);
			cp.timer = setInterval(function(){caption.fade(1)},timer);
		},
		fade:function(d){
			var a = alpha;
			if((a != endalpha && d == 1) || (a != 0 && d == -1)){
				var i = speed;
				if(endalpha - a < speed && d == 1){
					i = endalpha - a;
				}else if(alpha < speed && d == -1){
					i = a;
				}
				alpha = a + (i * d);
				cp.style.opacity = alpha * .01;
				cp.style.filter = 'alpha(opacity=' + alpha + ')';
			}else{
				clearInterval(cp.timer);
				if(d == -1){cp.style.display = 'none'}
			}
		},
		hide:function(){
			clearInterval(cp.timer);
			cp.timer = setInterval(function(){caption.fade(-1)},timer);
		}
	};
}();
