function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
			node = document;
	if ( tag == null )
			tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}
//------------------------------------------------------------------------


//var m = 0;	//slide margin-left
//var MyMove;	//time interval
////var stopWidth = 10000; // set it in php
//
//function setMargin(dir){	
//	if(dir == 'R'){
//		if(m<0) m = (m+1);
//	}else{
//		if(m >- stopWidth) m = (m-3);
//	}
//	document.getElementById('slide').style.marginLeft = m+'px';	
//}
//function Move(dir){
//	// Move('L') / Move('R')
//	MyMove = window.setInterval("setMargin('"+dir+"')",1);
//	//alert(stopWidth);
//}
//function stopIt(){
//	window.clearInterval(MyMove);
//}
//------------------------------------------------------------------------


// content div scroller
var m = 0;	//content margin-top
var MyMove;	//time interval
function setMargin(dir){	
	if(dir == 'U'){
		if(m<0) m = (m+3);
	}else{
		if(m >-10000) m = (m-3);
	}
	document.getElementById('TEXT').style.marginTop = m+'px';	
}
function Move(dir){
	// Move('L') / Move('R')
	MyMove = window.setInterval("setMargin('"+dir+"')",50);
}
function stopIt(){
	window.clearInterval(MyMove);
}
//------------------------------------------------------------------------





//var infoIsOn = false;
//var currImg = 0;
//var arr = getElementsByClass('pic');
//
//
//function showInfo(){
//	if(infoIsOn == false){
//		hideClass();
//		infoIsOn = true;
//	}else{
//		showImg();
//	}
//}
//
//function hideClass(){
//	if(! arr)return;
//	var i = 0;
//	for(i=0;i < arr.length;i++){
//		arr[i].style.display = 'none';
//	}
//}
//
//function showImg(){
//	hideClass();
//	if(! arr)return;
//	if(arr.length >0){
//		arr[currImg].style.display = 'block';
//		infoIsOn = false;
//	}
//}
//
//function nextImg(){
//	if(! arr)return;
//	if(currImg < (arr.length -1)){
//		currImg = currImg +1;
//	}else{
//		currImg = 0;
//	}
//	showImg();
//}
//function prevImg(){
//	if(! arr)return;
//	if(currImg > 0){
//		currImg = currImg -1;
//	}else{
//		currImg = (arr.length-1);
//	}
//	showImg();
//}
//
//function listenToKey(event){
//	if(! arr)return;
//	switch (event.keyCode){
//		case 37: case 80: prevImg(); break;	
//		case 39: case 78: nextImg();
//	}
//}




// key navi slider

function keyMove(id,pos){
	parseInt(pos);
	new Effect.Move('dt_'+id, { x: pos, y: 0 , mode: 'absolute'});
	new Effect.Move('dd_'+id, { x: (pos +5), y: 0 , mode: 'absolute'});
}

function keyShift(id){

	var j = parseInt(id);
	var c = document.getElementById('dt_'+id);

	if(c.className == 'open'){
		for(i=j;i < key_total;i++){
			// first stay open!
			if(i>0) keyClose(i);
		}
	}else{
		for(i=j;i >=0;i--){
			keyOpen(i);
		}
	}
}
function keyClose(id){
	document.getElementById('dt_'+id).className = 'closed';
	var pos = (parseInt(id) * 45)+ key_startpos;
	keyMove(id,pos);
}
function keyOpen(id){
	document.getElementById('dt_'+id).className = 'open';
	var pos = (parseInt(id) * 45);
	keyMove(id,pos);
}


// sub_content.inc: show / hide dds

function show_dd(id){
	var c = document.getElementById('dd'+id);
	if(c.className == 'active'){
		make_all_inactive();
	}else{
		make_all_inactive();
		c.className = 'active';
		document.getElementById('dt'+id).className = 'active';
	}

}
function make_all_inactive(){
	var arr = getElementsByClass('active');
	if(! arr)return;
	var i = 0;
	for(i=0;i < arr.length;i++){
		arr[i].className = 'inactive';
	}
}
function setInactive(id){
	document.getElementById('dt'+id).className = 'inactive';
	document.getElementById('dd'+id).className = 'inactive';
}
