// JavaScript Document

function getObject(objectId) {
  if(document.getElementById && document.getElementById(objectId)) {
// W3C DOM
return document.getElementById(objectId);
  } else if (document.all && document.all(objectId)) {
// MSIE 4 DOM
return document.all(objectId);
  } else if (document.layers && document.layers[objectId]) {
// NN 4 DOM.. note: this won't find nested layers
return document.layers[objectId];
  } else {
return false;
  }
}	

/*classification tag*/
function cfTab1(n){
	for(var i=1;i<=2;i++){
		if(i==n){
			if (i==1){
				getObject("li"+i).className="cfbg1";
			}else if (i==2){ 
				getObject("li"+i).className="cfbg2";
			}
				getObject("picteam_"+i).className="cfcon";
			}else{		
				if (i==1){ 
					getObject("li"+i).className="cfbg11";
			}else if (i==2){
					getObject("li"+i).className="cfbg22";
			}	
			getObject("picteam_"+i).className="hidden";
		}
	}
}

/*xuan tag*/
function xuanTab1(n){
	for(var i=20;i<=21;i++){
		if(i==n){
			if (i==20){
				getObject("li"+i).className="xuanbg1";
			}else if (i==21){ 
				getObject("li"+i).className="xuanbg2";
			}
				getObject("picteam_"+i).className="tcon";
			}else{		
				if (i==20){ 
					getObject("li"+i).className="xuanbg11";
			}else if (i==21){
					getObject("li"+i).className="xuanbg22";
			}	
			getObject("picteam_"+i).className="hidden";
		}
	}
}

/*Focus_change js*/
function lunbo(id) { return document.getElementById(id); }

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(){
	var focusBtnList = lunbo('focus_change_btn').getElementsByTagName('li');
	for(var i=0; i<focusBtnList.length; i++) {
		focusBtnList[i].className='';
	}
}

function focusChange() {
	lunbo('focus_change').onmouseover = function(){atuokey = true};
	lunbo('focus_change').onmouseout = function(){atuokey = false};
	var focusBtnList = lunbo('focus_change_btn').getElementsByTagName('li');
		focusBtnList[0].onmouseover = function() {
			moveElement('focus_change_list',0,0,5);
			classNormal()
			focusBtnList[0].className='current'
		}
		focusBtnList[1].onmouseover = function() {
			moveElement('focus_change_list',-600,0,5);
			classNormal()
			focusBtnList[1].className='current'
		}
		focusBtnList[2].onmouseover = function() {
			moveElement('focus_change_list',-1200,0,5);
			classNormal()
			focusBtnList[2].className='current'
		}
		focusBtnList[3].onmouseover = function() {
			moveElement('focus_change_list',-1800,0,5);
			classNormal()
			focusBtnList[3].className='current'
		}
		/*focusBtnList[4].onmouseover = function() {
			moveElement('focus_change_list',-2188,0,7);
			classNormal()
			focusBtnList[4].className='current'
		}
		focusBtnList[5].onmouseover = function() {
			moveElement('focus_change_list',-2735,0,7);
			classNormal()
			focusBtnList[5].className='current'
		}*/
}

setInterval('autoFocusChange()', 5000);
var atuokey = false;
function autoFocusChange() {
	if(atuokey) return;
	var focusBtnList = lunbo('focus_change_btn').getElementsByTagName('li');
	for(var i=0; i<focusBtnList.length; i++) {
		if (focusBtnList[i].className == 'current') {
			var currentNum = i;
		}
	}
	if (currentNum==0 ){
		moveElement('focus_change_list',-600,0,5);
		classNormal()
		focusBtnList[1].className='current'
	}
	if (currentNum==1 ){
		moveElement('focus_change_list',-1200,5);
		classNormal()
		focusBtnList[2].className='current'
	}
	if (currentNum==2 ){
		moveElement('focus_change_list',-1800,0,5);
		classNormal()
		focusBtnList[3].className='current'
	}
	/*if (currentNum==3 ){
		moveElement('focus_change_list',-2188,0,7);
		classNormal()
		focusBtnList[4].className='current'
	}
	if (currentNum==4 ){
		moveElement('focus_change_list',-2735,0,7);
		classNormal()
		focusBtnList[5].className='current'
	}*/
	if (currentNum==3 ){
		moveElement('focus_change_list',0,0,5);
		classNormal()
		focusBtnList[0].className='current'
	}
}

addLoadEvent(focusChange);

/*dapei menu js*/
function isMatch(str1,str2) {  
	var index = str1.indexOf(str2); 
	if(index==-1) return false; 
	return true; 
	} 
function ResumeError() { 
	return true; 
} 
window.onerror = ResumeError; 
function menu(id) {
	return document.getElementById(id);
}
// 相对尺寸
function GetOffsetTop (el, p) {
	var _t = el.offsetTop;
	var _p = el.offsetParent;
	while (_p) {
	if (_p == p) break;
		_t += _p.offsetTop;
		_p = _p.offsetParent;
	}
	return _t;
};
function GetOffsetLeft (el, p) {
	var _l = el.offsetLeft;
	var _p = el.offsetParent;
	while (_p) {
	if (_p == p) break;
		_l += _p.offsetLeft;
		_p = _p.offsetParent;
	}
	return _l;
};
function showMenu (baseID, divID) {
	baseID = menu(baseID);
	divID  = menu(divID);
	//var l = GetOffsetLeft(baseID);
	//var t = GetOffsetTop(baseID);
	//divID.style.left = l + 'px';
	//divID.style.top = t + baseID.offsetHeight + 'px';
	if (showMenu.timer) clearTimeout(showMenu.timer);
	hideCur();
	divID.style.display = 'block';
	showMenu.cur = divID;
	if (! divID.isCreate) {
		divID.isCreate = true;
		//divID.timer = 0;
		divID.onmouseover = function () {
		if (showMenu.timer) clearTimeout(showMenu.timer);
		hideCur();
		divID.style.display = 'block';
		};
		function hide () {
			showMenu.timer = setTimeout(function () {divID.style.display = 'none';}, 10);
		}
		divID.onmouseout = hide;
		baseID.onmouseout = hide;
	}
	function hideCur () {
	showMenu.cur && (showMenu.cur.style.display = 'none');
	}
}

/*starshop*/
var CurrentHotScreen = 0 ;
function setStarshop(screen){
	var Vmotion = "forward" ;
	var MaxScreen = 2 ;
	if (screen >= MaxScreen) {
		screen = 0 ;
		Vmotion = "reverse" ;
	}
	cleanallstyle();
	document.getElementById("focus_"+screen).className = "up" ;
		  
	 if(null!=Starshop.filters){
	Starshop.filters[0].apply();
	Starshop.filters[0].motion = Vmotion;
  }
  for (i=0;i<MaxScreen;i++) {
	document.getElementById("switch_"+i).style.display = "none" ;
	 }
	 document.getElementById("switch_"+screen).style.display = "block" ;
	 if(null!=Starshop.filters){
	Starshop.filters[0].play();
	 }
	CurrentHotScreen = screen ;
}
function refreshStarshop(){
	refreshStarshopTimer = null;
	setStarshop(CurrentHotScreen+1);
	refreshStarshopTimer = setTimeout('refreshStarshop();', 5000);
}

/*flash 调用格式*/
function SwfWrite(Intro)
{
	document.write(Intro);
}