var optTimer;
var optMenuWidth;
var optMenuHeight;
var textTimer;
var textWidth;
var optServicesTop;

function toggleOptMenu(dir,e){
	optMenuHeight=document.getElementById("optMenu").style.height;
	optMenuHeight=Number(optMenuHeight.replace("px",""));
if (!e) var e = window.event; 
e.cancelBubble = true;
if (e.stopPropagation) e.stopPropagation();

	
	optServicesTop=document.getElementById("optServices").style.top;
	
	optServicesTop=Number(optServicesTop.replace("px",""));
	
	if(dir=="up"){
	
	if(document.getElementById("optMenu").style.width=="103px" && document.getElementById("optMenu").style.height=="130px")
	{
	return false;
	}
		
	clearInterval(optTimer);
	optMenuWidth=document.getElementById("optMenu").style.width;
	optMenuWidth=Number(optMenuWidth.replace("px",""));
	optTimer=setInterval('slideOptMenu(7,"103px")',35);
	}
	else if(dir=="down" && pageReady==true){
	if(document.getElementById("optMenu").style.width=="49px")
	{
	return false;
	}
	
	var menuItems = document.getElementById('optMenu').getElementsByTagName('h2');
		
			for (i=0; i<menuItems.length; i++) {
			menuItems[i].style.visibility = "hidden";
			}	
			
			
		
	clearInterval(optTimer);
	
			optTimer=setInterval('growOptMenu(-4,"76px")',35);	
	

	}
}

function slideOptMenu(step,stopPoint){

	optMenuWidth+=step;
	if(step>0)
	{
		if(optMenuWidth>Number(stopPoint.replace("px",""))){
		optMenuWidth=Number(stopPoint.replace("px",""));
		}
	}
	else{
	
		if(optMenuWidth<Number(stopPoint.replace("px",""))){
	    optMenuWidth=Number(stopPoint.replace("px",""));}
	}
	document.getElementById("optMenu").style.width = (optMenuWidth.toString()+'px');  
	if(document.getElementById("optMenu").style.width==stopPoint)
	{
		clearInterval(optTimer);
		if(step>0)
		{
			optTimer=setInterval('growOptMenu(4,"130px")',35);	
		}
		
	}
}


function growOptMenu(step,stopPoint){

	optMenuHeight+=step;
	if(step>0)
	{
		optServicesTop+=(step);
		if(optServicesTop>76){
		optServicesTop=76;
		}
		if(optMenuHeight>Number(stopPoint.replace("px",""))){
		optMenuHeight=Number(stopPoint.replace("px",""));
		}
	}
	else{
	if(optMenuHeight<94){
	optServicesTop+=(step);}
	if(optServicesTop<58){
		optServicesTop=58;}
		
		if(optMenuHeight<Number(stopPoint.replace("px",""))){
	    optMenuHeight=Number(stopPoint.replace("px",""));}
	}
	document.getElementById("optServices").style.top=(optServicesTop.toString()+'px');
	document.getElementById("optMenu").style.height = (optMenuHeight.toString()+'px');  
	if(document.getElementById("optMenu").style.height==stopPoint)
	{
		var menuItems = document.getElementById('optMenu').getElementsByTagName('h2');
		if(document.getElementById("optMenu").style.height=="130px"){
			for (i=0; i<menuItems.length; i++) {
			menuItems[i].style.visibility = "visible";
			}	
		}
		clearInterval(optTimer);
		if(step<0)
		{
			optMenuWidth=document.getElementById("optMenu").style.width;
	optMenuWidth=Number(optMenuWidth.replace("px",""));
	
	
	optTimer=setInterval('slideOptMenu(-7,"49px")',35);
	
		}
	}
}


function initializeOptMenu(){
	document.getElementById("optMenu").style.width="49px";
	document.getElementById("optMenu").style.height="76px";
	document.getElementById("optServices").style.top="58px";
	//setTimeout('waitThree()',700);
}



function waitThree(){
	if(!document.captureEvents){
	toggleOptMenu("down","MOUSEOUT");
	}
	else{
		toggleOptMenu("down", Event.MOUSEOUT);
	}
		
}

function toggleOptText(){
	 
	 if(document.getElementById("collectionText").style.width=="134px"){
	
		
	clearInterval(textTimer);
	textWidth=document.getElementById("collectionText").style.width;
	textWidth=Number(textWidth.replace("px",""));
	
			document.getElementById("readMore").style.visibility="hidden";
			document.getElementById("readLess").style.visibility="visible";
			document.getElementById("image").style.visibility="hidden";
			document.getElementById("imageDescription").style.visibility="hidden";
			document.getElementById("glow").style.visibility="hidden";
	textTimer=setInterval('slideText(15,"625px")',30);
	}
	else if(document.getElementById("collectionText").style.width=="625px"){
		
	clearInterval(textTimer);
	textWidth=document.getElementById("collectionText").style.width;
	textWidth=Number(textWidth.replace("px",""));
	
			document.getElementById("readMore").style.visibility="visible";
			document.getElementById("readLess").style.visibility="hidden";
	
	textTimer=setInterval('slideText(-15,"134px")',30);
	

	}
	 
 }
 
 function slideText(step,stopPoint){

	textWidth+=step;
	if(step>0)
	{
		if(textWidth>Number(stopPoint.replace("px",""))){
		textWidth=Number(stopPoint.replace("px",""));
		}
	}
	else{
	
		if(textWidth<Number(stopPoint.replace("px",""))){
	    textWidth=Number(stopPoint.replace("px",""));}
	}
	document.getElementById("collectionText").style.width = (textWidth.toString()+'px');  
	if(document.getElementById("collectionText").style.width==stopPoint)
	{
		if(document.getElementById("collectionText").style.width=="134px"){
			document.getElementById("image").style.visibility="visible";
			document.getElementById("imageDescription").style.visibility="visible";
			document.getElementById("glow").style.visibility="hidden";
		}
		else if(document.getElementById("collectionText").style.width="625px"){
		}
		clearInterval(textTimer);
	}
}
 