var start = 0;
var speed = 1;
var moveLeft = -72;
var cml = -72;
var moveRight = 0;
var cmr = 72;
var hehe = 0;

function items(obj) {
	if (document.getElementById) {   
	    if (document.getElementById(obj)) {
		    return document.getElementById(obj);
		} else {
		    return false;
		}
	}
	else if (document.all) {
		return eval('document.all.' + obj);
	}
	else if (document.layers) {
		return eval('document.layers[' + obj+']');
	}
	else {
		return false;
	}
}

function ChangeImage(obj) {
	var itm = items(obj);
	var itm2 = items('bwatch');
	if (itm && itm2) {
		itm2.src = itm.name;
		for (i=1;i<5;i++) {
			itm3 = items('variant'+i);
			if (itm3) {
				itm3.className = '';
			}
		}
		itm.className = 'imgActive';
	}
}

function ScrollRight() {
	if (maxmLeft<start) {
		var itm = items('watch_cat');
		if (itm) {
			start = start -3;
			itm.style.marginLeft = start + 'px';
		}
		func = "ScrollRight();";
		if (start > moveLeft) {
			setTimeout(func, speed*10);
		} else {
			hehe++;
			if (hehe>2) {
				now = cml -1;
				now2 = cmr +1;
			} else {
				now = cml;
				now2 = cmr;
			}
			moveLeft = moveLeft + now;
			if (start<=cml) {
				moveRight = start + now2;
			}
		}
	}
}

function ScrollLeft() {
	if (start<0)	{
		var itm = items('watch_cat');
		if (itm) {
			start = start +3;
			itm.style.marginLeft = start + 'px';
		}
		func = "ScrollLeft();";
		if (start < moveRight) {
			setTimeout(func, speed*10);
		} else {
			hehe++;
			if (hehe>2) {
				now = cmr +1;
			} else {
				now = cmr;
			}
			moveRight=start+now;
			moveLeft = moveLeft+now;
		}
	} else {
		moveLeft = cml;
	}
}

function DisplayImage(picURL,picWidth,picHeight){
var lw = screen.availWidth/2 - picWidth/2;
var lh = screen.availHeight/2 - picHeight/2;
newWindow=window.open(picURL,'newWin','left='+lw+',top='+lh+',toolbar=no,width='+picWidth+',height='+picHeight)
newWindow.document.write('<html><head><\/head><body background="'+picURL+'" style="background-repeat: no-repeat; background-position: center; background-color: #000; width: 626px; height: 480px;"><\/body><\/html>')

newWindow.resizeBy(picWidth-newWindow.document.body.clientWidth,picHeight-newWindow.document.body.clientHeight)
newWindow.focus()
}
