/**
 * @author NguyenNhanTam
 */

var tickspeed1=4000 //ticker speed in miliseconds (2000=2 seconds)
var displaymode1="auto" //displaymode ("auto" or "manual"). No need to modify as form at the bottom will control it, unless you wish to remove form.

if (document.getElementById){
	document.write('<style type="text/css">\n')
	document.write('.gallerycontent2{display:none;}\n')
	document.write('</style>\n')
}

var selectedDiv1=0
var totalDivs1=0

function getElementbyClass2(classname){
	partscollect1=new Array()
	var inc=0
	var alltags1=document.all? document.all.tags("DIV") : document.getElementsByTagName("*")
	for (i=0; i<alltags1.length; i++){
		if (alltags1[i].className==classname)
			partscollect1[inc++]=alltags1[i]
	}
}

function contractall_1(){
	var inc=0
	while (partscollect1[inc]){
		partscollect1[inc].style.display="none"
		inc++
	}
}

function expandone1(){
	var selectedDivObj1=partscollect1[selectedDiv1]
	contractall_1()
	selectedDivObj1.style.display="block"
	if (document.gallerycontrol)
		temp.options[selectedDiv1].selected=true
	selectedDiv1=(selectedDiv1<totalDivs1-1)? selectedDiv1+1 : 0
	if (displaymode1=="auto")
		autocontrolvar1=setTimeout("expandone1()",tickspeed1)
}

function populatemenu1(){
	temp=document.gallerycontrol.menu
	for (m=temp.options.length-1;m>0;m--)
		temp.options[m]=null
		for (i=0;i<totalDivs1;i++){
			var thesubject1=partscollect1[i].getAttribute("subject")
			thesubject1=(thesubject1=="" || thesubject1==null)? "HTML Content "+(i+1) : thesubject1
			temp.options[i]=new Option(thesubject1,"")
		}
	temp.options[0].selected=true
}

function manualcontrol1(menuobj){
	if (displaymode1=="manual"){
		selectedDiv1=menuobj
		expandone1()
	}
}

function preparemode1(themode){
	displaymode1=themode
	if (typeof autocontrolvar1!="undefined")
	clearTimeout(autocontrolvar1)
	if (themode=="auto"){
		document.gallerycontrol.menu.disabled=true
		autocontrolvar1=setTimeout("expandone1()",tickspeed1)
	}else
		document.gallerycontrol.menu.disabled=false
}

function startgallery2(){
	if (document.getElementById("controldiv")) //if it exists
		document.getElementById("controldiv").style.display="none"
	getElementbyClass2("gallerycontent2")
	totalDivs1=partscollect1.length
	if (document.gallerycontrol){
		populatemenu1()
		if (document.gallerycontrol.mode){
			for (i=0; i<document.gallerycontrol.mode.length; i++){
				if (document.gallerycontrol.mode[i].checked)
					displaymode1=document.gallerycontrol.mode[i].value
			}
		}
	}
	if (displaymode1=="auto" && document.gallerycontrol)
		document.gallerycontrol.menu.disabled=true
	expandone1()
}

if (window.addEventListener)
	window.addEventListener("load", startgallery2, false)
else if (window.attachEvent)
	window.attachEvent("onload", startgallery2)
else if (document.getElementById)
	window.onload=startgallery2




