// JavaScript Document
function slideObj(){
    this.delay = 10;
    this.step = 1;
    this.counter = 0;
    this.width = 711;
    this.height = 170;
    this.itemWidth = 143;
    this.itemHeight = 170;
    this.itemCount = 0;
    this.inners = new Array();
	this.start = false;
}

slideObj.prototype.console = function(){
    //this.counter++;
    if (parseInt(this.p1.style.left) <= 0 - parseInt(this.p1.style.width)) 
        this.p1.style.left = this.p2.style.width;
    if (parseInt(this.p2.style.left) <= 0 - parseInt(this.p2.style.width)) 
        this.p2.style.left = this.p1.style.width;
    this.p1.style.left = String(parseInt(this.p1.style.left) - this.step).concat("px");
    this.p2.style.left = String(parseInt(this.p2.style.left) - this.step).concat("px");
}

slideObj.prototype.prepareItems = function(){
    var result = new Array();
    var container = document.getElementById("p_container");
    this.p1 = document.createElement("DIV");
    this.p1.className = "package";
    for (var i = 0; i < this.itemCount; i++) {
        var d = document.createElement("DIV");
        with (d) {
            innerHTML = this.inners[i % this.inners.length]; //	若使用代码生成DOM,则删除此句
            className = "item";
            
            id = "item_".concat(i);
            style.left = String(i * this.itemWidth).concat("px");
        }
        this.p1.appendChild(d);
        result[result.length] = d;
    }
    with (this.p1.style) {
        left = 0;
        width = String(result.length * this.itemWidth).concat("px");
        height = String(this.itemHeight).concat("px");
    }
    this.p2 = this.p1.cloneNode(true);
    this.p2.style.left = this.p1.style.width;
    container.appendChild(this.p1);
    container.appendChild(this.p2);
    return result;
}

slideObj.prototype.play = function(){
    this.itemCount = Math.ceil(this.width / this.itemWidth);
    this.prepareItems();
}
