﻿

//获取首页焦点图是第几侦--------------首页焦点大图轮换脚本部分一
function Slideid() {
    var url = location.search;
    if (url.length > 1) {
        url = url.substring(1);
        var Url__ = url.split("&");
        var oid = "";
        for (var i = 0; i < Url__.length; i++) {
            var Url___ = Url__[i].split("=");
            if (Url___.length > 1) {
                if (Url___[0].toLowerCase() == "oid") {
                    oid = Url___[1] - 1;
                }
            }
        }
        if (oid < 0) {
            oid = -1;
            //alert("s1:"+oid);
        }
    } else {
        oid = -1;
        //alert("s3:"+oid);
    }
    return oid;
}

//首页endlinkdiv两轮图片轮换脚本
//            function f_img_change(p_num) {
//                var self_now = p_num;
//                var self_speed = 1000;
//                var self_auto_change = null;
//                var self_max = $('#f_img div.img').size();
//                function self_change(i) {
//                    $('#f_img div.img').hide();
//                    $('#f_img_txt li').removeClass('on');
//                    $('#f_img div.img:eq(' + i + ')').show();
//                    $('#f_img_txt li:eq(' + i + ')').addClass('on');
//                }
//                function self_interval() {
//                    return setInterval(function () {
//                        self_now++;
//                        if (self_now >= self_max) {
//                            self_now = 0;
//                        }
//                        self_change(self_now);
//                    }, self_speed);
//                }
//                $('#f_img div.img:eq(' + p_num + ')').show();
//                $('#f_img_txt li:eq(' + p_num + ')').addClass('on');
//                $('#f_img_txt li').each(function (i) {
//                    $(this).mouseover(function () {
//                        self_now = i;
//                        clearInterval(self_auto_change);
//                        self_change(i);
//                    }).mouseout(function () {
//                        self_auto_change = self_interval();
//                    });
//                });
//                $(function () {
//                    self_auto_change = self_interval();
//                });
//            }
//
//            orderid = 0;
//            f_img_change(orderid);





//小焦点图轮换---------------------------梦芭莎女装首页三轮广告ifocus图片轮换脚本
function moveElement(elementID, final_x, final_y, interval) {
    if (!document.getElementById) return false;
    if (!document.getElementById(elementID)) return false;
    var elem = document.getElementById(elementID);
    if (elem.movement) {
        clearTimeout(elem.movement);
    }
    if (!elem.style.left) {
        elem.style.left = "0px";
    }
    if (!elem.style.top) {
        elem.style.top = "0px";
    }
    var xpos = parseInt(elem.style.left);
    var ypos = parseInt(elem.style.top);
    if (xpos == final_x && ypos == final_y) {
        return true;
    }
    if (xpos < final_x) {
        var dist = Math.ceil((final_x - xpos) / 10);
        xpos = xpos + dist;
    }
    if (xpos > final_x) {
        var dist = Math.ceil((xpos - final_x) / 10);
        xpos = xpos - dist;
    }
    if (ypos < final_y) {
        var dist = Math.ceil((final_y - ypos) / 10);
        ypos = ypos + dist;
    }
    if (ypos > final_y) {
        var dist = Math.ceil((ypos - final_y) / 10);
        ypos = ypos - dist;
    }
    elem.style.left = xpos + "px";
    elem.style.top = ypos + "px";
    var repeat = "moveElement('" + elementID + "'," + final_x + "," + final_y + "," + interval + ")";
    elem.movement = setTimeout(repeat, interval);
}

function classNormal(iFocusBtnID, iFocusTxID) {
    var iFocusBtns = document.getElementById(iFocusBtnID).getElementsByTagName('li');
    //var iFocusTxs = $(iFocusTxID).getElementsByTagName('li');
    for (var i = 0; i < iFocusBtns.length; i++) {
        iFocusBtns[i].className = 'normal';
        //iFocusTxs[i].className='normal';
    }
}

function classCurrent(iFocusBtnID, iFocusTxID, n) {
    var iFocusBtns = document.getElementById(iFocusBtnID).getElementsByTagName('li');
    //var iFocusTxs = $(iFocusTxID).getElementsByTagName('li');
    iFocusBtns[n].className = 'current';
    //iFocusTxs[n].className='current';
}

function iFocusChange() {
    if (!document.getElementById('ifocus')) return false;
    document.getElementById('ifocus').onmouseover = function () { atuokey = true };
    document.getElementById('ifocus').onmouseout = function () { atuokey = false };
    var iFocusBtns = document.getElementById('ifocus_btn').getElementsByTagName('li');
    var listLength = iFocusBtns.length;
    iFocusBtns[0].onmouseover = function () {
        moveElement('ifocus_piclist', 0, 0, 5);
        classNormal('ifocus_btn', 'ifocus_tx');
        classCurrent('ifocus_btn', 'ifocus_tx', 0);
    }
    if (listLength >= 2) {
        iFocusBtns[1].onmouseover = function () {
            moveElement('ifocus_piclist', 0, -253, 5);
            classNormal('ifocus_btn', 'ifocus_tx');
            classCurrent('ifocus_btn', 'ifocus_tx', 1);
        }
    }
    if (listLength >= 3) {
        iFocusBtns[2].onmouseover = function () {
            moveElement('ifocus_piclist', 0, -506, 5);
            classNormal('ifocus_btn', 'ifocus_tx');
            classCurrent('ifocus_btn', 'ifocus_tx', 2);
        }
    }
    /*	if (listLength>=4) {
    iFocusBtns[3].onmouseover = function() {
    moveElement('ifocus_piclist',0,-603,5);
    classNormal('ifocus_btn','ifocus_tx');
    classCurrent('ifocus_btn','ifocus_tx',3);
    }
    }*/
}

setInterval('autoiFocus()', 5000);
var atuokey = false;
function autoiFocus() {
    if (!document.getElementById('ifocus')) return false;
    if (atuokey) return false;
    var focusBtnList = document.getElementById('ifocus_btn').getElementsByTagName('li');
    var listLength = focusBtnList.length;
    for (var i = 0; i < listLength; i++) {
        if (focusBtnList[i].className == 'current') var currentNum = i;
    }
    if (currentNum == 0 && listLength != 1) {
        moveElement('ifocus_piclist', 0, -253, 5);
        classNormal('ifocus_btn', 'ifocus_tx');
        classCurrent('ifocus_btn', 'ifocus_tx', 1);
    }
    if (currentNum == 1 && listLength != 2) {
        moveElement('ifocus_piclist', 0, -506, 5);
        classNormal('ifocus_btn', 'ifocus_tx');
        classCurrent('ifocus_btn', 'ifocus_tx', 2);
    }
    if (currentNum == 2 && listLength != 3) {
        moveElement('ifocus_piclist', 0, -759, 5);
        classNormal('ifocus_btn', 'ifocus_tx');
        classCurrent('ifocus_btn', 'ifocus_tx', 3);
    }
    if (currentNum == 3) {
        moveElement('ifocus_piclist', 0, 0, 5);
        classNormal('ifocus_btn', 'ifocus_tx');
        classCurrent('ifocus_btn', 'ifocus_tx', 0);
    }
    if (currentNum == 1 && listLength == 2) {
        moveElement('ifocus_piclist', 0, 0, 5);
        classNormal('ifocus_btn', 'ifocus_tx');
        classCurrent('ifocus_btn', 'ifocus_tx', 0);
    }
    if (currentNum == 2 && listLength == 3) {
        moveElement('ifocus_piclist', 0, 0, 5);
        classNormal('ifocus_btn', 'ifocus_tx');
        classCurrent('ifocus_btn', 'ifocus_tx', 0);
    }
}

window.onload = function () {
    iFocusChange();
}




//---------------------------梦芭莎女装首页上周热销榜hotsalediv图片点击轮换脚本
function showas(id) {
    for (var askid = 1; askid < 7; askid++) {
        $("#pppic" + askid).removeClass("on");
    }
    $("#pppic" + id).addClass("on");
}








