//Jeff
//www.huntingground.freeserve.co.uk

/************************************************/
var browserName = navigator.appName
var ie = false;

if (browserName == "Microsoft Internet Explorer"){
	ie = true;
}
/************************************************/

speed3=50
hideLast3=1 // 1 = yes    0 = no (automatically hides the previously revealed content)

function initExpColB()
{ // create objects
	count=0
	numOfObj=0
	tags=document.getElementsByTagName("DIV")
	
	while(tags[count])
	{
		if(tags[count].id.indexOf("divexp")!= -1)
		{
			numOfObj++
		}
		count++
	}
	for(var i=1;i<=numOfObj;i++)
	{
		window["my_objectB"+i]=new crear("divexp"+i)
		document.getElementById("sup_tab"+i).i=i
	
		document.getElementById("sup_tab"+i).onclick=function(){
			
			//document.getElementById("divexp5").style.display='none';
			//document.getElementById("divexp5").style.opacity = 100;
			//alert("sesupone que puse el divexp5 en none...");
			
		window["my_objectB"+this.i].chk_statusB(this.i,'down')}
	}

// passing the divs number via the query string will automatically reveal the div when the page loads
	/*if (location.search.length > 0)
	{
		preNum = unescape(location.search.substring(1))
		window["my_object"+preNum].chk_status(preNum,'down')
	}*/
}

lastNum3=null

function crear(id)
{ //define properties, pass id
	this.id=id
	this.num=this.id.replace(/[A-z]/g,"") // get number in id
	this.element=document.getElementById(this.id)

	if(!ie){
		this.height=this.element.offsetHeight
	}

	//originalTopValue=this.element.style.top;
	this.timer=null
	this.running=0
	
	this.chk_statusB=function(num,d)
	{ // method & its properties, pass div number as argument
		if(hideLast3==1&&this.num!=lastNum3&&lastNum3!=null&&document.getElementById("divexp"+lastNum3).offsetHeight>0)
		{
			window["my_objectB"+lastNum3].chk_statusB(lastNum3,'up')
		}
	this.dir=d
	if(this.dir=="up")
	{	
		document.getElementById("sup_tab"+this.num).onclick=function(){
			window["my_objectB"+num].chk_statusB(num,'down');
		}
		
	}
	if(this.dir=="down")
	{
		//this.element.style.top=originalTopValue;
		if(ie){
			this.element.style.filter = 'alpha(opacity=' + 100 + ')';
		}
		document.getElementById("sup_tab"+this.num).onclick=function(){
			window["my_objectB"+num].chk_statusB(num,'up');
			closeOverlays();
		}
	}
	this.running=1
	
	this.step=speed3
	
	if("filter" in document.body && "alpha" in document.body.filter)
	{
		this.opac=0
	} else{
		this.opac=this.element.style.opacity*100
	}
	
	if(!ie){
		window["my_objectB"+num].animateB('my_objectB'+num,num);
	}else{
		window["my_objectB"+num].animateB_ie('my_objectB'+num,num);
	}
	
	lastNum3=this.num
	}
	
	this.animateB=function(myobject,num)
	{ // method & its properties, pass object name as argument		
		clearTimeout(this.timer)
		if(this.dir=="down")
		{	
			this.element.style.display="block";
			this.height+=this.step;
			//this.element.style.top=(parseInt(this.element.style.top, 10)  - this.step) + "px";
			this.opacStep=100/(this.element.scrollHeight/this.step);
			this.opac=(this.opac+this.opacStep)*1;
			
		} else{
			
			this.height-=this.step;
			//this.element.style.top=(parseInt(this.element.style.top, 10) + this.step) + "px";
			this.opacStep=100/(this.element.scrollHeight/this.step);
			this.opac=(this.opac-this.opacStep)*1;
		}
	
		this.stop=this.element.scrollHeight
		this.timer=setTimeout(myobject+".animateB('"+myobject+"','"+num+"')",50)
	
		if(this.dir=="down"&&this.height>this.stop)
		{
			this.running=0
			this.opac=100
			clearTimeout(this.timer)
		}
		if(this.dir=="up"&&this.height<=speed3)
		{
			this.height=0
			this.running=0
			this.opac=0
			clearTimeout(this.timer)
			this.element.style.display="none"
		}
		this.element.style.height=this.height
		if("filter" in document.body && "alpha" in document.body.filter)
		{
			this.element.filter.alpha.opacity=0
		}else{
			this.element.style.opacity=(this.opac/100)-0.01;
			//this.element.style.filter = 'alpha(opacity=' + 70 + ')';
		}
				
	}
	
	this.animateB_ie=function(myobject,num)
	{ // method & its properties, pass object name as argument		
		clearTimeout(this.timer)
		if(this.dir=="down")
		{	
			this.element.style.display="block";
			//this.element.style.borderColor="#000000";
		} else{
			this.element.style.display="none";
		}
		
	}
	
}// JavaScript Document

