﻿
function Check_ImgType(str, o) {
    var pos = str.lastIndexOf(".");
    var lastname = str.substring(pos, str.length);

    if (lastname.toLowerCase() != ".gif" && lastname.toLowerCase() != ".jpg" && lastname.toLowerCase() != ".png") {
        o.outerHTML = o.outerHTML;
        alert("Please Input (.gif.jpg,.png) Type ");
        return false;
    }
    return true;
}
function Check_ExcelType(str, o) {
    var pos = str.lastIndexOf(".");
    var lastname = str.substring(pos, str.length);

    if (lastname.toLowerCase() != ".xls") {
        o.outerHTML = o.outerHTML;
        alert("Please Input (.xls) Type ");
        return false;
    }
    return true;
}
function view(o) {
    document.getElementById("img" + num).src = o.value;
    document.getElementById(obj).width = "100"
    document.getElementById(obj).height = "100"
}
//  this is Cover Picture
function viewCover(o, obj) {
    document.getElementById(obj).src = o.value;
    document.getElementById(obj).width = "100"
    document.getElementById(obj).height = "100"
}
var num = 0
function addImg() {
    num += 1;
    var str = '<br/><input type="file"  size="60"  name="File" onchange="if(Check_ImgType(this.value,this)) view(this)"/><img id="img' + num + '" src="../../Image/nopic.gif" style="height:100px;width:100px" />';
    document.getElementById("MyFile").insertAdjacentHTML("beforeEnd", str);
}



var count = 0;
var current = 1;
var begin;
var _time = 5000;
var li = "li_";
var Img = [{ url: "http://gps4buy.com/Product/ProductList.aspx?ProductCategoryID=9", src: "Image/body-right-promotion_ad1.jpg" }, { url: "http://gps4buy.com/Product/ProductList.aspx?ProductCategoryID=32", src: "Image/body-right-promotion_ad2.jpg" }, { url: "http://gps4buy.com/Product/ProductList.aspx?ProductCategoryID=74", src: "Image/body-right-promotion_ad3.jpg" }, { url: "http://gps4buy.com/Product/ProductList.aspx?ProductCategoryID=31", src: "Image/body-right-promotion_ad4.jpg"}];

function Adinit(Imgs) {
    count = Imgs.length;
    begin = setInterval(change, _time);
}



function Spanover(obj) {
    current = parseInt(obj.id);
    Clear(current);
    clearInterval(begin);
}


function SpanOut(obj) {
    current = parseInt(obj.id);
    begin = setInterval(change, _time);
}

function Clear(obj) {
    for (var q = 0; q < count; q++) {
        $(q.toString()).className = "";
    }
    $(obj.toString()).className = "pro-current";
    $("promotionads").style.background = "url('" + Img[parseInt(obj.toString())].src + "')";
    $("promotionads").style.cursor = "pointer";

    $("a_Product_a").href = Img[parseInt(obj.toString())].url
}
function change() {
    if (current > count - 1) {
        current = 0;
    }
    for (var q = 0; q < count; q++) {
        $(q.toString()).className = "";
    }
    $(current.toString()).className = "pro-current";
    $("promotionads").style.background = "url('" + Img[current].src + "')";
    $("a_Product_a").href = Img[current].url
    current++;

}
function $(obj) {
    return document.getElementById(obj)
}
