﻿function prepare() {
	if (!document.getElementsByTagName) return false;
	if (!document.getElementById) return false;
	if($a('showpic0')){changed('showpic0',0)};
	if($a('showpic1')){changed('showpic1',1)};
	if($a('showpic2')){changed('showpic2',2)};
	if($a('showpic3')){changed('showpic3',3)};
	if($a('showpic4')){changed('showpic4',4)};
	if($a('showpic5')){changed('showpic5',5)};
	if($a('showpic6')){changed('showpic6',6)};
	if($a('showpic7')){changed('showpic7',7)};
}
function changed(which,num){
	var aBigimg = bigimg[num].split('|');
	if(aBigimg=='') return false;
	var aSmallimg = smallimg[num].split('|');
	var aTextinfo = textinfo[num].split('|');
	var oDiv = document.createElement('div');
	var oImg = document.createElement('img');
	oImg.src = aBigimg[0];
	oDiv.className = 'infopic';
	oDiv.appendChild(oImg);
	$a(which).appendChild(oDiv);
	if(oImg.clientWidth>920) oImg.style.width = '920px';
	var oSpan = document.createElement('span');
	oSpan.className = 'infospan';
	oSpan.id = 'infospan'+num;
	oSpan.innerHTML = aTextinfo[0];
	$a(which).appendChild(oSpan);
	var oUl = document.createElement('ul');
	for(var i=0; i<aBigimg.length; i++){
		var oLi = document.createElement('li');
		var oEm = document.createElement('em');
		var oImg = document.createElement('img');
		oImg.src = aSmallimg[i];
		oEm.appendChild(oImg);
		oLi.appendChild(oEm);
		var oSpan = document.createElement('span');
		oSpan.innerHTML = aTextinfo[i];
		oLi.appendChild(oSpan);
		oLi.sNum = i;
		oLi.onclick = function(){
			return changePic(this,this.sNum,aBigimg,aTextinfo,num);
		}
		oUl.appendChild(oLi);
	}
	$a(which).appendChild(oUl);
}
function changePic(which,num,aBigimg,aTextinfo,subn){
	var oPicNodes = $$a(which.parentNode.parentNode,'div');
	var oPic = oPicNodes[0];
	var oDiv = document.createElement('div');
	var oImg = document.createElement('img');
	oImg.src = aBigimg[num];
	oDiv.className = 'infopic';
	oDiv.appendChild(oImg);
	which.parentNode.parentNode.insertBefore(oDiv,oPic);
	which.parentNode.parentNode.removeChild(oPic);
	if(oImg.clientWidth>920) oImg.style.width = '920px';
	$a('infospan'+subn).innerHTML = aTextinfo[num];
}
function $a(id){
	return document.getElementById(id);
}
function $$a(elem,tagName){
	return elem.getElementsByTagName(tagName);
}
function addLoadEvent(func){
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
		window.onload = func;
	}else{
		window.onload = function(){
			oldonload();
			func();
		}
	}
}
addLoadEvent(prepare);