﻿//Hoàng anh tuấn làm ngay 02/10/2008
//đoạn thứ nhất
//dùng để cuộn các ảnh hoặc chữ, chạy nối tiếp nhau, không tao ra khoang trắng
// có thể dùng để chạy ảnh hoặc chạy chữ tùy các ý
//chỉ cần gọi onMouseOver="stopScroll()" onMouseOut="scrollImgs()" ở chổ cần chạy ok
// và <BODY onload=setup();scrollImgs();> ok
//có 2 cái thẻ DIV là <DIV id=pics1> và <DIV id=pics2> trong đó cháy đoạn cần chạy 
// ok không hiểu liên hệ 098.6467.944 

var dom = document.getElementById ? true:false;
var ie4 = document.all ? true:false; 

function CheckAll(checked) {
    len = document.lightbox.elements.length;
    var i=0;
    for( i=0; i<len; i++) {
        if (document.lightbox.elements[i].name=='item') {
           document.lightbox.elements[i].checked=checked;
        }
    }
}

function CheckAllPPD(checked) {
    len = document.ppd.elements.length;
    var i=0;
    for( i=0; i<len; i++) {
        if (document.ppd.elements[i].name=='media') {
           document.ppd.elements[i].checked=checked;
        }
    }
    if (reprice_defined) reprice();
}

function setSpex () {
	var spex = "spex=";
	if (document.body) {
		spex += "sw&" + screen.width;
		spex += "&sh&" + screen.height;
		spex += "&cw&" + document.body.clientWidth;
		spex += "&ch&" + document.body.clientHeight;
	} else if (window.innerWidth) {
		spex += "cw&" + window.innerWidth;
		spex += "&ch&" + window.innerHeight;
	} else {
		return;
	}
	var now = new Date();
	var expiry = new Date(now.getFullYear() + 1, now.getMonth(), now.getDate());
	spex += "; path=/; expires=" + expiry.toGMTString();
	document.cookie = spex;
	return true;
}

window.onresize = setSpex;
//window.onload = setSpex;


function _als () {window.status = 'Add To Lightbox'; return true}
function _sls () {window.status = 'View Image Specs'; return true}
function _dls () {window.status = 'View Details'; return true}
function _pls () {window.status = 'Processing...'; return true}
function _cls () {window.status = ''; return true}


function smove(){
	if(ie4)
	{
		pics1.style.pixelLeft -= 1;
		pics2.style.pixelLeft -= 1;
		temp = pics2.clientWidth + pics2.style.pixelLeft;
		if (pics1.style.pixelLeft < -pics1.clientWidth) pics1.style.pixelLeft = temp;
		temp = pics1.clientWidth + pics1.style.pixelLeft;
		if (pics2.style.pixelLeft < -pics2.clientWidth) pics2.style.pixelLeft = temp;
	}
	else if (dom)
	{
		left1=parseInt(pics1.style.left);
		if(isNaN(left1)) left1=0;
		left1--;
		pics1.style.left = left1+"px";

		left2=parseInt(pics2.style.left);
		if(isNaN(left2)) left=0;
		left2--;
		pics2.style.left = left2+"px";

		temp = pics2.clientWidth + left2;
		if (left1 < -pics1.clientWidth) pics1.style.left = temp+"px";
		temp = pics1.clientWidth + left1;
		if (left2 < -pics2.clientWidth) pics2.style.left = temp+"px";

	}
}
function setup(){
	setMainPos()
	if(ie4) 
	{
		pics2.style.pixelLeft = pics1.clientWidth + pics1.clientLeft;
	}
	else if (dom)	
	{
		pics1.style.left = "-1000px"
		left=parseInt(pics1.style.left);
		if(isNaN(left)) left=0;
		pics2.style.left = (pics1.clientWidth + left)+"px";
	}
}
var Gtimer
function scrollImgs() {
	Gtimer = setInterval("smove()", 50);
//Gtimer = setTimeout("smove()", 50);
}
function stopScroll() {
  clearInterval(Gtimer);

}
function setMainPos() {
	if(typeof(main)=='object')
	{
		if(ie4) 
		{
			main.style.width = pics1tab.clientWidth;
			left = Math.ceil((document.body.clientWidth - pics1tab.clientWidth )/2)
			if(left<0) left=0
			main.style.pixelLeft = 0//left -main je centrovany. preto netreba nastavovat left
			
		}
		else if (dom)	
		{
			main.style.width = (pics1tab.clientWidth)+"px"
			left = Math.ceil((document.body.clientWidth - pics1tab.clientWidth )/2)
			if(left<0) left=0
			main.style.left = "0px" //left + "px"
		}
	}
}
window.onresize = setMainPos;
