function redirect(){
	var preBtn = document.getElementById("present");
	var linksList = document.getElementById("links");
	linksList.style.display = "none";
	preBtn.onclick = function(){
		if(linksList.style.display == "none"){
			linksList.style.display = "block";
		}else{
			linksList.style.display = "none";
		}
	}
	alllinks = linksList.getElementsByTagName("li");
	for(i=0; i<alllinks.length; i++){
		alllinks[i].getElementsByTagName("a")[0].onclick = function(){
			preBtn.innerHTML = this.innerHTML;
			linksList.style.display = "none";
		}
	}
	document.getElementsByTagName("body")[0].onclick = function(evt){
		if(!evt) var evt = window.event;
		var evtObj = evt.target?evt.target:evt.srcElement;
		if(evtObj.id != "present"){
			linksList.style.display = "none";
		}
	}
}

function goBack(){
if(document.getElementById("goBack")){
	var wra = document.getElementById("goBack");
	wra.getElementsByTagName("a")[0].onclick = function(){
		history.back();
		return false;
	}
}
}

function honorImg(){
	if(document.getElementsByTagName("body")[0].getAttribute("id") == "honor"){
		var _a = document.getElementById("honorList");
		var _d = document.getElementById("honorImg");
		var _b = _a.getElementsByTagName("a");
		for(i=0; i<_b.length; i++){
			_b[i].url = _b[i].getAttribute("href");
			_b[i].onmouseover = function(){
				if(this.url){
					_d.innerHTML = "";
					var img = document.createElement("img");
					img.setAttribute("src",this.url);
					_d.appendChild(img);
				}
			}
		}
	}
}
function getElementByClassName(a,b){
	var d = new Array;
	var c = document.getElementsByTagName(a);
	for(i=0; i<c.length; i++){
		if(c[i].className == b){
			d.push(c[i]);
		}
	}
	return d;
}

function pdTab(){
	if(document.getElementsByTagName("body")[0].getAttribute("id") == "product"){
		var tabs = document.getElementById("pdTabs").getElementsByTagName("li");
		var tabCons = getElementByClassName("ul","pdList");
		for(i=0; i<tabs.length; i++){
			tabCons[i].style.display = "none";
			tabs[i]._i = i;
			tabs[i].onclick = function(){
				for(j=0; j<tabCons.length; j++){
					tabCons[j].style.display = "none";
					tabs[j].className = "";
				}
				tabCons[this._i].style.display = "block";
				this.className = "on";
			}
		}
		tabs[0].className = "on";
		tabCons[0].style.display = "block";
	}
}

function FAQ(){
	if(document.getElementsByTagName("body")[0].getAttribute("id") == "productDetail" || document.getElementsByTagName("body")[0].getAttribute("id") == "faq"){
		var allItems = document.getElementById("relatedFAQ").getElementsByTagName("li");
		for(i=0; i<allItems.length; i++){
			allItems[i].getElementsByTagName("div")[0].style.display = "none";
			allItems[i].onclick = function(){
				if(this.getElementsByTagName("div")[0].style.display == "none"){
					this.getElementsByTagName("div")[0].style.display = "block";
				}else if(this.getElementsByTagName("div")[0].style.display == "block"){
					this.getElementsByTagName("div")[0].style.display = "none";
				}
			}
		}
	}
}
var id = 0;
var auto;
function indexTab(){
if(document.getElementsByTagName("body")[0].getAttribute("id") == "home"){
	var ul = document.getElementById("Pdtabs");
	var tabs = ul.getElementsByTagName("li");
	var tabCons = getElementByClassName("div","tabCon");
	for(i=0; i<tabs.length; i++){
		tabs[i].style.className = "";
		tabCons[i].style.display = "none";
		tabs[i]._i = i;
		tabs[i].onmouseover = function(){
			clearTimeout(auto);
			id = this._i +1;
			for(j=0; j<tabs.length; j++){
				tabs[j].className = "";
				tabCons[j].style.display = "none";
			}
			this.className = "on";
			tabCons[this._i].style.display = "block";
		}
		tabs[i].onmouseout = function(){
			auto = setTimeout(function(){changePic(id,tabs,tabCons)},5000);
		}
	}
	tabs[0].className = "on";
	tabCons[0].style.display = "block";
	changePic(id,tabs,tabCons);
}
}
function changePic(id,tabs,tabCons){
	if(id>=3){
		id = 0;
	}
	for(j=0; j<tabs.length; j++){
		tabs[j].className = "";
		tabCons[j].style.display = "none";
	}
	tabs[id].className = "on";
	tabCons[id].style.display = "block";
	id += 1;
	auto = setTimeout(function(){changePic(id,tabs,tabCons)},4000);
}
if(window.attachEvent){
	window.attachEvent("onload",redirect);
	window.attachEvent("onload",honorImg);
	window.attachEvent("onload",pdTab);
	window.attachEvent("onload",FAQ);
	window.attachEvent("onload",goBack);
	window.attachEvent("onload",indexTab);
}else{
	window.addEventListener("load",redirect,false);
	window.addEventListener("load",honorImg,false);
	window.addEventListener("load",pdTab,false);
	window.addEventListener("load",FAQ,false);
	window.addEventListener("load",goBack,false);
	window.addEventListener("load",indexTab,false);
}