
	

//opacity changing functions 


navFaded = true;

var timerID = null;
var timecount = 300;
timerOn = false;


function startTimer(timing) {

	if (timerOn == false) {
			if (timing){
				timerID=setTimeout( "fadeOut()" , timing);
			}else {
				timerID=setTimeout( "fadeOut()" , timecount);
			}
		timerOn = true;
	}
}

function clearTimer(){
	if (timerOn) {
		clearTimeout(timerID);
		timerID = null;
		timerOn = false;
	}
}

function fadeOut(){
	if (! navFaded){
		navFaded = true;
		currentOpac('nav', 50, 3500);
	}
}


function fadeIn(){
	if (navFaded){
		navFaded = false;
		currentOpac('nav', 85, 3500);
	}
}

function currentOpac(id, opacEnd, millisec) { 
    //standard opacity is 100 
    var currentOpac = 50; 
     
    //if the element has an opacity set, get it 
    if(document.getElementById(id).style.opacity < 100) { 
        currentOpac = document.getElementById(id).style.opacity * 100; 
    } 

    //call for the function that changes the opacity 
    opacity(id, currentOpac, opacEnd, millisec) 
}



function opacity(id, opacStart, opacEnd, millisec) { 
    //speed for each frame 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 

    //determine the direction for the blending, if start and end are the same nothing happens 
    if(opacStart > opacEnd) { 
        for(i = opacStart; i >= opacEnd; i--) { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } else if(opacStart < opacEnd) { 
        for(i = opacStart; i <= opacEnd; i++) 
            { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } 
    
} 

//change the opacity for different browsers 
function changeOpac(opacity, id) { 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 101); 
    object.MozOpacity = (opacity / 101); 
    object.KhtmlOpacity = (opacity / 101); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
}










// menu sliding functions 

	
subNavPos = -100;
subNavOpen = false;
	
function showSubnav(subnav){
	subNavOpen = true;
	document.getElementById(subnav).style.visibility = 'visible';
	document.getElementById('nav').style.clip = 'rect(61px auto auto auto)';
	currentPos(subnav,61,500);
}	



function currentPos(id, posEnd, millisec) { 

     currentPosition = subNavPos;  

    //call for the function that changes the opacity 
    moveSubnav(id, currentPosition, posEnd, millisec);
   }



function moveSubnav(id, posStart, posEnd, millisec) { 
    //speed for each frame 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 
    //determine the direction for the blending, if start and end are the same nothing happens 
    
    
    if(posStart > posEnd) { 

        for(i = posStart; i >= posEnd; i--) { 
            setTimeout("changePos(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } else if(posStart < posEnd) {
        for(i = posStart; i <= posEnd; i++) 
            { 
            setTimeout("changePos(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
            
            
        } 
    } 
    
    subNavPos = i;
    
}

var output = '';

function changePos(pos, id) { 
    document.getElementById(id).style.top = pos.toString() + 'px';
 	document.getElementById(id).style.clip = 'rect(' + Math.abs(61-pos) + 'px auto auto auto)';
 	
 	output += 'rect(' + (61-pos) + 'px auto auto auto) - ';

}






var timerIDSubnav = null;
var timecountSubnav = 100;
timerOnSubnav = false;


function startSubnavTimer(id) {
	if (timerOnSubnav == false) {
		timerIDSubnav=setTimeout( "hideSubnav('" + id + "')" , timecount);
		timerOnSubnav = true;
	}
}

function clearSubnavTimer(){
	if (timerOnSubnav) {
		clearTimeout(timerIDSubnav);
		timerIDSubnav = null;
		timerOnSubnav = false;
	}
}

function hideSubnav(id){
	subNavOpen = false;
	currentPos(id,-100,500);
	document.getElementById('nav').style.clip = 'rect(0px auto auto auto)';


}


function toggleSubnav(id){
	if (subNavOpen){
		hideSubnav(id);
	}else {
		showSubnav(id);
		
	}
}


function init(){
	currentOpac('nav', 50, 500);
	document.getElementById('collectionsNav').style.top = '-100px';
	document.getElementById('nav').style.clip = 'rect(61px auto auto auto)';

}

window.onload = init;



function popImage(file,width,height){

	if (! height){ height=500;}

	window.open(file,'pop','width=' + width + ',height=' + height + ',scrollbars=no,bookmarksbar=no,addressbar=no');

}