function $id(id){
	return document.getElementById(id);
}
function hidediv(objectId){
	$id(objectId).style.display="none";
}
function showdiv(objectId){
	$id(objectId).style.display="block";
}
function remove(){
	var a=document.getElementsByTagName("a");
	for(var i=0;i<a.length;i++){
		a[i].onfocus=function(){
			this.blur();
		}
	}
}
remove();
function change(objectId,nav,len,index){
	for(var i=1;i<=len;i++){
		hidediv(objectId+i);
		$id(nav+i).className="dis";
	}
	$id(nav+index).className="act";
	showdiv(objectId+index);
}
function showlogin_(){
	showdiv("mask");
	showdiv("msgbox1");
	document.getElementById("login2").style.display="block"
	document.getElementById("login2").height = document.body.scrollHeight;
	hideAllSelect(true);
	
	//alert(document.getElementById("login2").style.display)
	//$id("msgbox1").style.display="block";
}

function addLoadEvent(func){
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function(){
			oldonload();
			func();
		}
	}
}

function moveElement(elementID,final_x,final_y,interval) {
  if (!document.getElementById) return false;
  if (!document.getElementById(elementID)) return false;
  var elem = document.getElementById(elementID);
  if (elem.movement) {
    clearTimeout(elem.movement);
  }
  if (!elem.style.left) {
    elem.style.left = "0px";
  }
  if (!elem.style.top) {
    elem.style.top = "0px";
  }
  var xpos = parseInt(elem.style.left);
  var ypos = parseInt(elem.style.top);
  if (xpos == final_x && ypos == final_y) {
		return true;
  }
  if (xpos < final_x) {
    var dist = Math.ceil((final_x - xpos)/10);
    xpos = xpos + dist;
  }
  if (xpos > final_x) {
    var dist = Math.ceil((xpos - final_x)/10);
    xpos = xpos - dist;
  }
  if (ypos < final_y) {
    var dist = Math.ceil((final_y - ypos)/10);
    ypos = ypos + dist;
  }
  if (ypos > final_y) {
    var dist = Math.ceil((ypos - final_y)/10);
    ypos = ypos - dist;
  }
  elem.style.left = xpos + "px";
  elem.style.top = ypos + "px";
  var repeat = "moveElement('"+elementID+"',"+final_x+","+final_y+","+interval+")";
  elem.movement = setTimeout(repeat,interval);
}

function classNormal(showBtnId,showTxtId){
	var iFocusBtns= $id(showBtnId).getElementsByTagName('li');
	var iFocusTxs = $id(showTxtId).getElementsByTagName('li');
	for(var i=0; i<iFocusBtns.length; i++) {
		iFocusBtns[i].className='normal';
		iFocusTxs[i].className='normal';
	}
}

function classCurrent(showBtnId,showTxtId,n){
	var iFocusBtns= $id(showBtnId).getElementsByTagName('li');
	var iFocusTxs = $id(showTxtId).getElementsByTagName('li');
	iFocusBtns[n].className='current';
	iFocusTxs[n].className='current';
}

function iFocusChange() {
	if(!$id('show')) return false;
	$id('show').onmouseover = function(){autokey = true};
	$id('show').onmouseout = function(){autokey = false};
	var iFocusBtns = $id('show_btn').getElementsByTagName('li');
	var listLength = iFocusBtns.length;
	iFocusBtns[0].onmouseover = function() {
		moveElement('show_piclist',0,0,5);
		classNormal('show_btn','show_tx');
		classCurrent('show_btn','show_tx',0);
	}
	if (listLength>=2) {
		iFocusBtns[1].onmouseover = function() {
			moveElement('show_piclist',0,-273,5);
			classNormal('show_btn','show_tx');
			classCurrent('show_btn','show_tx',1);
		}
	}
	if (listLength>=3) {
		iFocusBtns[2].onmouseover = function() {
			moveElement('show_piclist',0,-546,5);
			classNormal('show_btn','show_tx');
			classCurrent('show_btn','show_tx',2);
		}
	}
	if (listLength>=4) {
		iFocusBtns[3].onmouseover = function() {
			moveElement('show_piclist',0,-819,5);
			classNormal('show_btn','show_tx');
			classCurrent('show_btn','show_tx',3);
		}
	}
	if (listLength>=5) {
		iFocusBtns[4].onmouseover = function() {
			moveElement('show_piclist',0,-1092,5);
			classNormal('show_btn','show_tx');
			classCurrent('show_btn','show_tx',4);
		}
	}
}

setInterval('autoShow()',5000);
var autokey = false;
function autoShow() {
	if(!$id('show')) return false;
	if(autokey) return false;
	var focusBtnList = $id('show_btn').getElementsByTagName('li');
	var listLength = focusBtnList.length;
	for(var i=0; i<listLength; i++) {
		if (focusBtnList[i].className == 'current') var currentNum = i;
	}
	if (currentNum==0&&listLength!=1 ){
		moveElement('show_piclist',0,-273,5);
		classNormal('show_btn','show_tx');
		classCurrent('show_btn','show_tx',1);
	}
	if (currentNum==1&&listLength!=2 ){
		moveElement('show_piclist',0,-546,5);
		classNormal('show_btn','show_tx');
		classCurrent('show_btn','show_tx',2);
	}
	if (currentNum==2&&listLength!=3 ){
		moveElement('show_piclist',0,-819,5);
		classNormal('show_btn','show_tx');
		classCurrent('show_btn','show_tx',3);
	}
	if (currentNum==3&&listLength!=4 ){
		moveElement('show_piclist',0,-1092,5);
		classNormal('show_btn','show_tx');
		classCurrent('show_btn','show_tx',4);
	}
	if (currentNum==4 ){
		moveElement('show_piclist',0,0,5);
		classNormal('show_btn','show_tx');
		classCurrent('show_btn','show_tx',0);
	}
	if (currentNum==1&&listLength==2 ){
		moveElement('show_piclist',0,0,5);
		classNormal('show_btn','show_tx');
		classCurrent('show_btn','show_tx',0);
	}
	if (currentNum==2&&listLength==3 ){
		moveElement('show_piclist',0,0,5);
		classNormal('show_btn','show_tx');
		classCurrent('show_btn','show_tx',0);
	}
}
addLoadEvent(iFocusChange);
var sel=document.getElementsByName("sel");
function showlogin(){
	showdiv("mask");
	showdiv("msgbox");
	for(var i=0;i<sel.length;i++){
		sel[i].disabled=true;
	}
	
}
function hidelogin(){
	hidediv("mask");
	hidediv("msgbox");
	for(var i=0;i<sel.length;i++){
		sel[i].disabled=false;
	}
}

function hideAllSelect(hSwitch){ 
	if(hSwitch){
		var selects=document.getElementsByTagName("SELECT"); 
		for(var i=0;i <selects.length;i++){
			selects[i].style.backgroundColor="#DFDFDF";
			selects[i].disabled="disabled" ;
		} 
	}else{
		var selects=document.getElementsByTagName("SELECT"); 
		for(var i=0;i <selects.length;i++){
			selects[i].style.backgroundColor="#FFFFFF";
			selects[i].disabled="";
		}
	}
} 
