// JavaScript Document

var browse = window.navigator.appName.toLowerCase();
var MyMar;
var speed = 1; 
var spec = 1; 
var minOpa = 100; 
var maxOpa = 100; 
var spa = 20; 
var w_1 = 0;
var w_2 = 0;
spec = (browse.indexOf("microsoft") > -1) ? spec : ((browse.indexOf("opera") > -1) ? spec*10 : spec*1);
function getid(e) {return document.getElementById(e);}
function goleft() {getid('photos').scrollLeft -= spec;}
function goright() {getid('photos').scrollLeft += spec;}
function setOpacity(e, n) {
    if (browse.indexOf("microsoft") > -1) e.style.filter = 'alpha(opacity=' + n + ')';
    else e.style.opacity = n/100;
}
if(getid('goleft')!=null){
getid('goleft').style.cursor = 'pointer';
getid('goleft').onmouseover = function() { MyMar=setInterval(goleft, speed);}
getid('goleft').onmouseout = function() { clearInterval(MyMar);}
}
if(getid('goright')!=null){
getid('goright').style.cursor = 'pointer';

getid('goright').onmouseover = function() { MyMar=setInterval(goright,speed);}
getid('goright').onmouseout = function() { clearInterval(MyMar);}
}



/*for color*/

//spec = (browse.indexOf("microsoft") > -1) ? spec : ((browse.indexOf("opera") > -1) ? spec*10 : spec*20);
//function getid(e) {return document.getElementById(e);}
function goleft_color() {getid('colors').scrollLeft -= spec;}
function goright_color() {getid('colors').scrollLeft += spec;}
/*function setOpacity(e, n) {
    if (browse.indexOf("microsoft") > -1) e.style.filter = 'alpha(opacity=' + n + ')';
    else e.style.opacity = n/100;
}*/

if(getid('goleft_color')!=null){
	getid('goleft_color').style.cursor = 'pointer';
	getid('goleft_color').onmouseover = function() { MyMar=setInterval(goleft_color, speed);}
	getid('goleft_color').onmouseout = function() { clearInterval(MyMar);}
}

if(getid('goright_color')!=null){
	getid('goright_color').style.cursor = 'pointer';
	getid('goright_color').onmouseover = function() { MyMar=setInterval(goright_color,speed);}
	getid('goright_color').onmouseout = function() { clearInterval(MyMar);}
}







window.onload = function() {

    var rHtml = '';
    var p = getid('showArea');
    if(p!=null){
	    p=p.getElementsByTagName('img');
	    for (var i=0; i<p.length; i++) {
	    	w_1 += parseInt(p[i].width) + 30;
	    	//w_1 += parseInt(p[i].getAttribute('width')) + 30;
	        //w += parseInt(180) + spa;
	        setOpacity(p[i], minOpa);
	        rHtml += '<img src="' + p[i].getAttribute('rel') + '" width="0" height="0" alt="" />';
	    }
	    getid('showArea').style.width = parseInt(w_1) + 'px';
	    var rLoad = document.createElement("div");
	    getid('photos').appendChild(rLoad);
	    rLoad.style.width = "1px";
	    rLoad.style.height = "1px";
	    rLoad.style.overflow = "hidden";
	    rLoad.innerHTML = rHtml;

    }

    var rHtml = '';
    var p = getid('colorArea');
    if(p!=null){
    	p = p.getElementsByTagName('img');
	    for (var i=0; i<p.length; i++) {
	    	w_2 += parseInt(p[i].getAttribute('width')) + 22;
	        //w += parseInt(180) + spa;
	        setOpacity(p[i], minOpa);
	        rHtml += '<img src="' + p[i].getAttribute('rel') + '" width="0" height="0" alt="" />';
	    }
	    getid('colorArea').style.width = parseInt(w_2) + 'px';
	    var rLoad = document.createElement("div");
	    getid('colors').appendChild(rLoad);
	    rLoad.style.width = "1px";
	    rLoad.style.height = "1px";
	    rLoad.style.overflow = "hidden";
	    rLoad.innerHTML = rHtml;
    }
}
