var lastChangeId=0;
function change(index){
	if(lastChangeId == index && index == 0){
		index=1;
	}
	if(lastChangeId == index && index == 1){
		index=0;
	}
	var pLeft = -905 * index;
	if ($("#zt_main").position().left != pLeft) {
			$("#zt_main").animate({ opacity: "1", left: pLeft + "px" }, 1000);
			lastChangeId=index;
	}
}

var lastId="";
var obj=new Object();
function imageShow(name, id){
  var tag=document.getElementById(name+"_"+id);
  tag.style.display="block";
	lastId=obj[name];
	lastId=lastId == null ? "" : lastId;
  if(lastId != "" && lastId != id){
    document.getElementById(name+"_"+lastId).style.display="none";
  }
	if(lastId == ""){
		document.getElementById(name+"_1").style.display="none";
	}
  obj[name]=id;
}

function tabFolder(hideClass, displayClass, tabName, divName,  count, id){
  for(var i=1; i<count+1; i++){
    if(i != id){
      document.getElementById(divName+"_"+i).style.display="none";
      document.getElementById(tabName+"_"+i).className=hideClass;
    }else{
			document.getElementById(divName+"_"+i).style.display="block";
      document.getElementById(tabName+"_"+i).className=displayClass;
    }
  }
}

var SPG_ACTION="http://game.d.cn/keyword_search.html";
var CP_ACTION="http://game.d.cn/cp/keyword_search.html";
var SIM_ACTION="http://sim.d.cn/keyword_search.html";
var SOFTWARE_ACTION="http://soft.d.cn/keyword_search.html";
var THEME_ACTION="http://theme.d.cn/keyword_search.html";
var NEWS_ACTION="http://news.d.cn/search.html";

function searchTypeChange(){
	var type=document.getElementById("typeId").value;
	if(type == "spg"){
		changeFormAction("keyword_search", SPG_ACTION);
	}
	if(type == "cp"){
		changeFormAction("keyword_search", CP_ACTION);
	}
	if(type == "news"){
		document.getElementById("searchkey").value=document.getElementById("keyword").value;
		changeFormAction("keyword_search", NEWS_ACTION);
	}
	if(type == "software"){
		changeFormAction("keyword_search", SOFTWARE_ACTION);
	}
	if(type == "theme"){
		changeFormAction("keyword_search", THEME_ACTION);
	}
	if(type == "sim"){
		changeFormAction("keyword_search", SIM_ACTION);
	}
}

function changeFormAction(name, actionUrl){
	document.forms[name].action=actionUrl;
}

function addFav() {
    if (document.all) {
        window.external.addFavorite(location.href, document.title);
    }
    else if (window.sidebar) {
        window.sidebar.addPanel(document.title, location.href, "");
    }
}
