/************************************************************************************************************
(c)2007 Jason W. Frey & Turning Point Propellers, Inc.

Sliding Divs

Terms of use:
You are free to use this script as long as the copyright message is kept intact. However, you may not
redistribute, sell or repost it without our permission.

Contact us @: jwfrey@gmail.com

Thank you!
************************************************************************************************************/
 //How many slides?
var slidePause = 200; //how long to pause before sliding?
var numberOfSlides = null;
var slideHeight = null;
var slideDiv = null;
var slideDivPrevious = null;
var setSlideZero = null;
var sldButtonChng = null;
var sldButtonChngBk = null;
var sldButton = null;
var slidingDiv = 0;
var containerName = null;
var startColor = null;
var endColor = null;
var gradintHeight = null;

function closeSlides(slideGroup,numberSlides) {
	numberOfSlides = numberSlides;
//CLOSES ALL SLIDES EXCEPT SLIDE NUMBER 1
for (i=2;i<=numberOfSlides;i=i+1) 
	{
	setSlideZero = document.getElementById(slideGroup+i);
	
	setSlideZero.style.display = 'block';
	setSlideZero.style.height = '0px';
	}
}




function slideMoveAction() {
	
  		if (parseInt(slideDiv.style.height) < slideHeight){
  		slideDiv.style.height = parseInt(slideDiv.style.height)+slideSpeed+'px';
		
    			slideDivUp = slideDivPrevious;
				slideDivUp = document.getElementById(slideDivUp);
				if (slideDivUp != slideDiv && parseInt(slideDivUp.style.height) >= slideSpeed){
					slideDivUp.style.height = parseInt(slideDivUp.style.height)-slideSpeed+'px';
					}
  		setTimeout(slideMoveAction,10);
  		}
	
}




function moveSlide(divToSlide,slideNumber,numberSlides,sldHeight,sldBtnName,sldBtnClass) {
	numberOfSlides = numberSlides;
	slideHeight = sldHeight;
	slideSpeed = slideHeight / 5;
	
	
	if (sldBtnName != ''){	sldBtn = document.getElementById(sldBtnName+slideNumber); }//CHANGES BUTTON CLASS
  
	
	

			//FINDS THE OPEN SLIDE OF THE GROUP
			for (i=1;i<=numberOfSlides;i=i+1) 
			{
			openDiv = document.getElementById(divToSlide+i);
			
			if (sldBtnName != ''){	changeSldBtn = document.getElementById(sldBtnName+i); }//CHANGES BUTTON CLASS
				if (parseInt(openDiv.style.height) == slideHeight || openDiv.style.height == 'auto' || openDiv.style.height > 1){ 
					slideDivPrevious = divToSlide+i;
					if (sldBtnName != ''){	changeSldBtn.className = sldBtnClass; }
			 	 	//SETS SLIDE TO ORIGINAL HEIGHT
					openDiv.style.height = slideHeight+'px';
				}
			
	
	}
  slideDiv = document.getElementById(divToSlide+slideNumber);
  
  
  	if (slideDiv != slideDivPrevious){
		if (sldBtnName != ''){	sldBtn.className = sldBtnClass + 'Dwn'; }//CHANGES BUTTON CLASS
		slideMoveAction(); 
	}
	
}


function chgContainerColor(containerName,startColor,endColor,gradintHeight,imgUrl){

chgContainer = document.getElementById(containerName);
chgContainer.style['backgroundImage'] = 'url(\''+imgUrl+'?startcolor='+startColor+'&endcolor='+endColor+'&height='+gradintHeight+'\')';
chgContainer.style['backgroundColor'] = '#'+endColor;

for (i=1;i<=6;i=i+1) 
			{
				chgContainer = document.getElementById(containerName+i);
				if (i<=3){
				chgContainer.style['backgroundColor'] = '#'+startColor;
				}else{
				chgContainer.style['backgroundColor'] = '#'+endColor;
				}
				
			}
	
}
