// JavaScript Document
var browse = window.navigator.appName.toLowerCase();
var MyMar;
var speed = 1;		//速度，越大越慢
			//每次滚动的间距, 越大滚动越快
var minOpa = 50; 		//滤镜最小值
var maxOpa = 100; 		//滤镜最大值
//var spa = 2; 			//缩略图区域补充数值
var w = 0;
var thumb, show, cur_thumb, cur_show;
spec = (browse.indexOf("microsoft") > -1) ? spec : ((browse.indexOf("opera") > -1) ? spec*10 : spec*1);
function $(e) {return document.getElementById(e);}
function goleft() {$('idContent').scrollLeft -= spec;}
function goright() {$('idContent').scrollLeft += spec;}
function setOpacity(e, n) {
    if (browse.indexOf("microsoft") > -1) e.style.filter = 'alpha(opacity=' + n + ')';
    else e.style.opacity = n/100;
}
$('goleft').style.cursor = 'pointer';
$('goright').style.cursor = 'pointer';
//$('mainphoto').onmouseover = function() {setOpacity(this, maxOpa);}
//$('mainphoto').onmouseout = function() {setOpacity(this, minOpa);}
//$('mainphoto').onclick = function() {location = this.getAttribute('name');}
$('goleft').onmouseover = function() {this.src = 'images/left_b.gif'; MyMar=setInterval(goleft, speed);}
$('goleft').onmouseout = function() {this.src = 'images/left_a.gif'; clearInterval(MyMar);}
$('goright').onmouseover = function() {this.src = 'images/right_b.gif'; MyMar=setInterval(goright,speed);}
$('goright').onmouseout = function() {this.src = 'images/right_a.gif'; clearInterval(MyMar);}
window.onload = function() {
    //setOpacity($('mainphoto'), minOpa);
    //var rHtml = '';
    var p = $('showArea').getElementsByTagName('img');
    for (var i=0; i<p.length; i++) {
        w += parseInt(p[i].getAttribute('width')+10);// + spa;
        if (i!=0) setOpacity(p[i], minOpa);
       // p[i].onclick = function() {location = this.getAttribute('name');}
        p[i].onmouseover = function() {
			this.style.cursor='pointer';
			cur_thumb = this.getAttribute('src');
			cur_show = this.getAttribute('rel');
			$('thumbs').innerHTML = '';
			setOpacity(cur_img, minOpa);
            setOpacity(this, maxOpa);
			cur_img = this;
            $('mainphoto').src = this.getAttribute('rel');
            $('mainphoto').alt = this.getAttribute('title');
            $('mainphoto').setAttribute('name', this.getAttribute('name'));
            $('text_imgbig').innerHTML = '<h1>' + this.getAttribute('title') + '</h1><p>' + this.getAttribute('alt') + '</p>';
			$('thumbs').innerHTML = this.getAttribute('name');
        }
        //p[i].onmouseout = function() {
            //setOpacity(this, minOpa);
           // setOpacity($('mainphoto'), minOpa);
       // }
        //rHtml += '<img src="' + p[i].getAttribute('rel') + '" width="0" height="0" alt="" />';
    }
	var cur_img = p[0];
	$('showArea').style.width = parseInt(w) + 'px';
    //var rLoad = document.createElement("div");
    //$('idContent').appendChild(rLoad);
    //rLoad.style.width = "1px";
    //rLoad.style.height = "1px";
    //rLoad.style.overflow = "hidden";
    //rLoad.innerHTML = rHtml;
}

function control_rate(){
	if (spec == 1){spec = 4;$('control_ico').innerHTML = 'Scroll Slow >';}else{spec = 1;$('control_ico').innerHTML = 'Scroll Fast >>';}
}

function thumb_over(id){
//alert(id.src);
$('mainphoto').src = id.getAttribute('rel');
show = id.getAttribute('rel');
//Effect.BlindDown('mainphoto');
}

function thumb_out(id){
thumb = id.src;
id.src = cur_thumb;
cur_thumb = thumb;
id.rel = cur_show;
cur_show = show;
//alert(cur_thumb);
}

