﻿
function showkefu(_this) {
    $('#kfleft1').show(); $('#kfleft').hide();
    var bwidth = $("body").width();
    var fleft = $(_this).offset().left;
    var fright = bwidth - fleft - 310 + "px";
    $("#rightDiv").css({ "right": fright });
}

var yqlztime = 0;
function yqlzidv(_this, typeid) {
    if (typeid == 1) {
        clearInterval(yqlztime);
        if ($("#yqlzidv").css("visibility") != "visible") {
            //alert($("#yqlzidv").css("visibility"));
            $("#yqlzidv").css({ "visibility": "visible" });
            var left = $(_this).offset().left  -70;
            var top = $(_this).offset().top - 160;
            $("#yqlzidv").css({ "top": top + "px", "left": left + "px" });
        }
    } else {
   var ss=' $("#yqlzidv").css({ "visibility": "hidden" });'
   yqlztime=setInterval(ss, 300);
    }
}
//搜索
function topsearch(_val) {
    if (_val == "输入商品名称" || _val == "")
        location.href = '/search.aspx';
    else
        location.href = '/search.aspx?ProName=' + _val;
}

function createFlashMove(obj, sName, src, width, height, wmode, fullscreen) {
    var swf = document.createElement("object");
    var param = document.createElement("param");
    param.setAttribute("name", "movie");
    param.setAttribute("value", src);
    param.setAttribute("allowFullScreen", "true");
    swf.appendChild(param);
    if (fullscreen) {
        var param = document.createElement("param");
        param.setAttribute("name", "allowScriptAccess");
        param.setAttribute("value", "always");
        swf.appendChild(param);
    }
    if (wmode) {
        param = document.createElement("param");
        param.setAttribute("name", "wmode");
        param.setAttribute("value", "transparent");
        swf.appendChild(param);
    }
    var embed = document.createElement("embed");
    embed.setAttribute("type", "application/x-shockwave-flash");
    embed.src = src;
    if (fullscreen) embed.setAttribute("allowScriptAccess", "always");
    if (wmode) embed.setAttribute("wmode", "transparent");
    embed.setAttribute("width", width);
    embed.setAttribute("height", height);
    embed.name = sName;
    obj.appendChild(swf);
    swf.setAttribute("type", "application/x-shockwave-flash");
    swf.setAttribute("data", src);
    swf.setAttribute("width", width);
    swf.setAttribute("height", height);
    if (sName) swf.id = sName;
}
changemenu.prototype.getClassName = function(_ArrayList, _classID) {
    for (i = 0; i < _ArrayList.length; i++) {
        if (_ArrayList[i][0] == _classID.toString())
            return _ArrayList[i][1];
    }
    return "";
}


/*index*/
function changClass(_id, _classname) {
    document.getElementById(_id).className = _classname;
}
function getsinproduct(_id, _type, page) {
    document.getElementById(_id).innerHTML = "<div style='text-align:center; height:16px;line-height:16px; vertical-align:middle'><img src='/images/ajax-loader.gif' height='16' width='16' >正在加载数据...</div>";
    var xmlhttp = $.ajax({
        type: "get",
        url: "/aspx/index.aspx",
        data: "act=" + _type + "&page=" + page,
        dataType: "html",
        success: function(result) {
            var _div = document.createElement("div");
            _div.innerHTML = result;
            document.getElementById(_id).innerHTML = "";
            document.getElementById(_id).appendChild(_div);
            $("div").each(function() {

//                if ($(this).attr("rel") == "1") {
//                 
//                    $(this).append("<div class='act200'>滿200<br>立减<br>100</div>");
//                    $(this).attr("rel", "0");
//                }
            });
           
        }
    });
}
function checklog() {
    $.ajax({
        type: "POST",
        url: "/Membercenter/ShowUserLoginState.aspx?type=top2",
        data: "",
        dataType: "html",
        success: function(retv) {

            if (retv.indexOf("login") >= 0) {
                
                    //  alert("登录成功,请您继续购物"); http://www.fashiongou.com
                   // parent.popdialog.openWithIframe('购物', '/aspx/LoR.aspx', 655, 412, true)
                location.href = '/logingou.aspx';
                
            }
            else {
            //http://www.fashiongou.com
                location.href = '/Membercenter/submitOrder.aspx';
            }
        }
    });
}
function getprogrouppage(_type) {
    if (_type == "next2") {//上一页
        var page = parseInt(document.getElementById("hidpage").value) + 1;
        if (page > 3) {
            page = 1;
            return;
        }
        document.getElementById("hidpage").value = page;
        var act = document.getElementById("hidact").value;
        getsinproduct("r3cen21", act, page);

    }
    else {//下一页
        var page = parseInt(document.getElementById("hidpage").value) - 1;
        if (page <= 0) {
            page = 1;
            // document.getElementById("errinfo");

            return;
        }
        document.getElementById("hidpage").value = page;
        var act = document.getElementById("hidact").value;
        getsinproduct("r3cen21", act, page);

    }
}
//单品
function getproduct(_classname1, _classname2, _act) {
    changClass('shxpss', _classname1);
    changClass('r2cen', _classname2);
    getsinproduct('shproduct', _act, '1');
}
//组合
function getgroup(_classname1, _classname2, _act) {
    changClass('r3top1', _classname1);
    changClass('r3cen', _classname2);
    getsinproduct('r3cen21', _act, '1');
    document.getElementById("hidact").value = _act;
    document.getElementById("hidpage").value = 1;
}
function changemenu() {
  
   
}

function Request(strName) {
    var strHref = window.document.location.href;
    var intPos = strHref.indexOf("?");
    var strRight = strHref.substr(intPos + 1);
    var arrTmp = strRight.split("&");
    for (var i = 0; i < arrTmp.length; i++) {
        var arrTemp = arrTmp[i].split("=");
        if (arrTemp[0].toUpperCase() == strName.toUpperCase()) return arrTemp[1];
    }
    return "";
}
function SetCookie(name, value)//两个参数，一个是cookie的名子，一个是值
{
    var Days = 0.001; //此 cookie 将被保存 30 天
    var exp = new Date();    //new Date("December 31, 9998");
    exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000);
    document.cookie = name + "=" + escape(value);  //+ ";expires="+ exp.toGMTString();
   
    
}
function getCookie(name)//取cookies函数        
{
    var arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
    if (arr != null) return unescape(arr[2]); return null;
}


function changmenubg(_this) {
    if ($(_this).find("div").attr("class") != "ap") {

        var _div = document.createElement("div");
        _div.width = "100%";
        _div.height = "50%";
        _div.className = "ap";
        $(_this).append(_div);
    }
}
function removemenu(_this) {
    if ($(_this).find("div").attr("mm") != "yes") {
        $(_this).find("div").removeClass("ap");
    }
}



function Topmenuout() {
    $("#loadtopmenu").hide();
}
function Topmenuover() {
    $("#loadtopmenu").show();
}


/*客服*/
function Getkefu(_type) {
    kefuinfo();
    $("#loadkefu").slideDown("fast");

}
var brandmtime = 0;
function showbrandmenu(_this, typeid) {
    if (typeid == 1) {
     
        clearTimeout(brandmtime);
        $(_this).removeClass("topmenu1bg1");
        $(_this).addClass("topmenu1bg2");
        $(".subbrandmenuss #brandmenu").css({ "visibility": "visible" });
      //  $(".subbrandmenuss #brandmenu").slideDown(300);

    } else {
        var nid = Math.random();

        if ($(_this).attr("id") != "brandmenut") {
            $(_this).attr("id", nid);
        } else
            nid = $(_this).attr("id");
        brandmtime = setTimeout("hidebrandmenu('.subbrandmenuss #" + nid + "')", 500);

    }
}
function hidebrandmenu(_this) {



    $(".subbrandmenuss #brandmenu").css({ "visibility": "hidden" })

    // $(".subbrandmenuss #brandmenu").slideUp(1000, function() {

    
        $(_this).removeClass("topmenu1bg2");
        $(_this).addClass("topmenu1bg1");

   // });


}
$(function() {
    ///product/ /brand/

    if (location.pathname.toLowerCase() == "/product/" || location.pathname.toLowerCase() == "/brand/") {
        showbrandmenu(".subbrandmenuss #brandmenut", 1);
        brandmtime = setTimeout("hidebrandmenu('.subbrandmenuss #brandmenut')", 5000);
    }
});
function showbrandsubmenu(_this, typeid) {
    if (typeid == 1) {
        $(_this).parent().children("li").removeClass("selected");
        $(_this).addClass("selected");
        $(_this).parent().children("li").removeClass("selected");
        $(_this).addClass("selected");
        $(_this).parent().children().children(".brandsubmenu").hide();
        $(_this).css({ "height": "41px" });

        var offset = $(_this).offset();
       
        var _top = offset.top-130;
        var _left = 211;
        window.status=_top+","+_left;
        if (navigator.userAgent.indexOf("MSIE") == -1) {
            //  _left = _left - 3;
            _top = offset.top - 130;
        } else if (navigator.userAgent.indexOf("MSIE 8") ==-1) {
        _top = offset.top - 129;
      
        }
        $(".brandsubmenu").css({ "top": _top + "px", "left": _left + "px" });
       
        $(_this).children(".brandsubmenu").show();
      
    } else {
        $(_this).parent().children("li").removeClass("selected");
      $(_this).parent().children().children(".brandsubmenu").hide();
        $(_this).css({ "height": "45px" });
    }

}
function nshowbrandsubmenu(_this, typeid) {
}
//menu color
function menucolor() {
    var pn = location.pathname.toLowerCase();
    var jk1 = '704,703,709,710,711,702,704,705,706,707,708';
    if (pn.indexOf("class") >= 0 || pn.indexOf("/product") >= 0 || pn.indexOf("shoesw") >= 0 || pn.indexOf("shoesm") >= 0 || pn.indexOf("peishi") >= 0 || pn.indexOf("sepcindex") >= 0 || pn.indexOf("qingcang.aspx") >= 0) {
        try {

            if (document.getElementById("hidbrandid") != undefined) {
                var brandidlist = ",53,44,281,94,239,";
                var brandids = "," + document.getElementById("hidbrandid").value + ",";

                if (brandidlist.indexOf(brandids) >= 0) {
                    $("#topheadermenu").addClass("menubgpos3");
                  
                } else {
                    $("#topheadermenu").addClass("menubgpos4");
                }
            } else {
                if (jk1.indexOf(_calssid) >= 0)
                    $("#topheadermenu").addClass("menubgpos3");
                else
                    $("#topheadermenu").addClass("menubgpos4");
            }
        }
        catch (ex) {
            $("#topheadermenu").addClass("menubgpos4");
        }

    }
    else if (pn.indexOf("brand") >= 0) {
        $("#topheadermenu").addClass("menubgpos3");
    }
    else if (pn.indexOf("life") >= 0)
        $("#topheadermenu").addClass("menubgpos2");
}


function loadppssh() {
    if (location.pathname == "/ppssh.aspx") {
        createFlashMove(document.getElementById("ppssh"), "ppsshtopr", "/flash/ppssh.swf", 70, 65, "1", "1");
    }
    else {
        $("#ppssh").html("<a href='/ppssh.aspx'><img src='/flash/ppssh.jpg'  height='52' width='60' style='margin:3px 0 0 7px' /></a>");
    }
}

function ChkLog() {
    $.ajax({
        type: "GET",
        url: "/Membercenter/ShowUserLoginState.aspx?t=" + Math.random(),
        data: "",
        dataType: "html",
        success: function(retv) {


            try {
                //您好！欢迎光临Fashion Gou时尚生活购物广场！
                //  $("#menberlnginfo1").html(retv.split("###")[0]);
                $(".memberinfo").html(retv);
            }
            catch (e) { }


        }
    });
}

function hidden_ivt() {
    try { setIsinvited(); } catch (e) { }
    try { document.getElementById("kfiframe").style.display = "none"; closeFreezeDiv(); } catch (e) { }
    document.getElementById("kfivtwin").style.display = "none";
    document.getElementById("mapdiv").style.display = "none";
    clearInterval(ivt_timer);
}

lastScrollY = 0;
function heartBeat() {
    var diffY;
    if (document.documentElement && document.documentElement.scrollTop)
        diffY = document.documentElement.scrollTop;
    else if (document.body)
        diffY = document.body.scrollTop
    percent = .1 * (diffY - lastScrollY);
    if (percent > 0) {
        percent = Math.ceil(percent);
    }
    else {
        percent = Math.floor(percent);
    }
    // document.getElementById("leftDiv").style.top = parseInt(document.getElementById("leftDiv").style.top)+percent+"px";
    document.getElementById("rightDiv").style.top = parseInt(document.getElementById("rightDiv").style.top) + percent + "px";
    lastScrollY = lastScrollY + percent;
}
//下面这段删除后，对联将不跟随屏幕而移动。

//关闭按钮
function close_left() {
    document.getElementById('left1').style.visibility = 'hidden';
}
function close_right() {
    document.getElementById('right1').style.visibility = 'hidden';
}




$(function() {

    ChkLog();
    changemenu();




    $("#urlgg").click(function() {
        $("#ggbox").show();
        $("#gginfo").attr("src", "/gg.htm");
    })
    $("#ggbox .boxclose img").click(function() {
        $("#ggbox").hide();
    })

    $(".ppsshclose").click(function() {
        $("#ppsshcen").html("");
        $("#ppsshdiv").hide("");

    })


    loadppssh();
    //pps社会
    $(".ppsshtop").click(function() {
        location.href = '/ppssh.aspx';


    })

    //搜索
    $("#btntopsearch").click(function() {
        var key = escape($("#ProName").val());
        location.href = "/search.aspx?ProName=" + key;
    })
    //登录状态更新




    //活动商品

    $(".ProductList").each(function() {

        //        if ($(this).attr("rel") == "1") {
        //            $(this).append("<div class='act200'>滿200<br>立减<br>100</div>");
        //            $(this).attr("rel", "0");
        //        }
    });

    //设置样式

    //------左侧开始
    //document.writeln("<div style=\"display:none\" id=\"leftDiv\" style=\"top:100px;left:5px\">");
    //document.writeln("<div id=\"left1\">");
    //document.writeln("<a href=\"javascript:close_left();\">点击我关闭<\/a>");
    //document.writeln("<\/div>");
    //document.writeln("<\/div>");
    //------左侧结束，右侧开始
    var str1 = "<div id=\"rightDiv\" style=\"top:180px;right:15px;height:331px; width:180px; z-index:3000 \">";
    str1 += "<div id=\"kfleft1\" style='display:none;background:url(/images/kf.png) no-repeat; height:331px; width:180px;'>";
    str1 += '<div class="flkftime">我们的营业时间<br>8：30－22：00</div>';
    str1 += '<ul class="kfullist">';

    str1 += '<li><a href="http://sighttp.qq.com/cgi-bin/check?sigkey=931c1527daca7c9c1961a5c65da6bd0a0149fcb1aacd29bc31d5570abb76d7c0" target="_blank" onclick="var tempSrc=\' http://sighttp.qq.com/wpa.js?rantime=' + Math.random() + '&sigkey=931c1527daca7c9c1961a5c65da6bd0a0149fcb1aacd29bc31d5570abb76d7c0\';var oldscript=document.getElementById(\'testJs\');var newscript=document.createElement(\'script\');newscript.setAttribute(\'type\',\'text/javascript\'); newscript.setAttribute(\'id\', \'testJs\');newscript.setAttribute(\'src\',tempSrc);if(oldscript == null){document.body.appendChild(newscript);}else{oldscript.parentNode.replaceChild(newscript, oldscript);}return false;"><img border="0" height="22" width="74" SRC=\' http://wpa.qq.com/pa?p=1:1149599661:41\' alt="">客服一</a></li>';
    str1 += '<li><a href="http://sighttp.qq.com/cgi-bin/check?sigkey=65106561d3d519f371259b441c074311633d61502a40808de3323c5687dc0542" target="_blank" onclick="var tempSrc=\' http://sighttp.qq.com/wpa.js?rantime=' + Math.random() + '&sigkey=65106561d3d519f371259b441c074311633d61502a40808de3323c5687dc0542\';var oldscript=document.getElementById(\'testJs\');var newscript=document.createElement(\'script\');newscript.setAttribute(\'type\',\'text/javascript\'); newscript.setAttribute(\'id\', \'testJs\');newscript.setAttribute(\'src\',tempSrc);if(oldscript == null){document.body.appendChild(newscript);}else{oldscript.parentNode.replaceChild(newscript, oldscript);}return false;"><img border="0" height="22" width="74" SRC=\' http://wpa.qq.com/pa?p=1:949765615:41\' alt="">客服二</a></li>';
    str1 += '<li><a href="http://sighttp.qq.com/cgi-bin/check?sigkey=a8a6ddf227c0d8aa56ba89ef8bca00e699748716d7ea8524bf6c76eb5b49b586" target="_blank" onclick="var tempSrc=\' http://sighttp.qq.com/wpa.js?rantime=' + Math.random() + '&sigkey=a8a6ddf227c0d8aa56ba89ef8bca00e699748716d7ea8524bf6c76eb5b49b586\';var oldscript=document.getElementById(\'testJs\');var newscript=document.createElement(\'script\');newscript.setAttribute(\'type\',\'text/javascript\'); newscript.setAttribute(\'id\', \'testJs\');newscript.setAttribute(\'src\',tempSrc);if(oldscript == null){document.body.appendChild(newscript);}else{oldscript.parentNode.replaceChild(newscript, oldscript);}return false;"><img border="0" height="22" width="74" SRC=\' http://wpa.qq.com/pa?p=1:1049448996:41\' alt="">新手咨询</a></li>';
    str1 += '<li><a href="http://sighttp.qq.com/cgi-bin/check?sigkey=da5333e3c678f8ca350bf70a88e506c405b639b010814ddb4490a037947f65ba" target="_blank" onclick="var tempSrc=\' http://sighttp.qq.com/wpa.js?rantime=' + Math.random() + '&sigkey=da5333e3c678f8ca350bf70a88e506c405b639b010814ddb4490a037947f65ba\';var oldscript=document.getElementById(\'testJs\');var newscript=document.createElement(\'script\');newscript.setAttribute(\'type\',\'text/javascript\'); newscript.setAttribute(\'id\', \'testJs\');newscript.setAttribute(\'src\',tempSrc);if(oldscript == null){document.body.appendChild(newscript);}else{oldscript.parentNode.replaceChild(newscript, oldscript);}return false;"><img border="0" height="22" width="74" SRC=\' http://wpa.qq.com/pa?p=1:1258743533:41\' alt="">售后服务</a></li>';
    str1 += '<li><a href="http://sighttp.qq.com/cgi-bin/check?sigkey=1079cc4cd58fab1080ebc9a1e73554c9189a1160177ae9ab230068834ca453db" target="_blank" onclick="var tempSrc=\' http://sighttp.qq.com/wpa.js?rantime=' + Math.random() + '&sigkey=1079cc4cd58fab1080ebc9a1e73554c9189a1160177ae9ab230068834ca453db\';var oldscript=document.getElementById(\'testJs\');var newscript=document.createElement(\'script\');newscript.setAttribute(\'type\',\'text/javascript\'); newscript.setAttribute(\'id\', \'testJs\');newscript.setAttribute(\'src\',tempSrc);if(oldscript == null){document.body.appendChild(newscript);}else{oldscript.parentNode.replaceChild(newscript, oldscript);}return false;"><img border="0" height="22" width="74" SRC=\' http://wpa.qq.com/pa?p=1:1422610528:41\' alt="">意见投诉</a></li>';
    str1 += '<li><a href="http://sighttp.qq.com/cgi-bin/check?sigkey=c7aacf493c534cdedcec1817a7e51c759b48252d53a573ce12ae098b90e0a695" target="_blank" onclick="var tempSrc=\' http://sighttp.qq.com/wpa.js?rantime=' + Math.random() + '&sigkey=c7aacf493c534cdedcec1817a7e51c759b48252d53a573ce12ae098b90e0a695\';var oldscript=document.getElementById(\'testJs\');var newscript=document.createElement(\'script\');newscript.setAttribute(\'type\',\'text/javascript\'); newscript.setAttribute(\'id\', \'testJs\');newscript.setAttribute(\'src\',tempSrc);if(oldscript == null){document.body.appendChild(newscript);}else{oldscript.parentNode.replaceChild(newscript, oldscript);}return false;"><img border="0" height="22" width="74" SRC=\' http://wpa.qq.com/pa?p=1:1345174039:41\' alt="">加盟合作</a></li>';


    str1 += '<li><a href="http://amos.im.alisoft.com/msg.aw?v=2&amp;uid=%E7%A6%BE%E7%94%B0%E6%9C%8D%E9%A5%B0&amp;site=cntaobao&amp;s=1&amp;charset=utf-8" target="_blank"><font color="#ff00ff" size="2"><img height="19" width="77" alt="点击这里给我发消息" border="0" src="http://amos.im.alisoft.com/online.aw?v=2&amp;uid=%E7%A6%BE%E7%94%B0%E6%9C%8D%E9%A5%B0&amp;site=cntaobao&amp;s=1&amp;charset=utf-8" /></font>旺旺客服</a></li>';


    str1 += "</ul>";

    str1 += '<div style="padding:5px 0 0 0;height:14px; border-top:1px solid #ccc; width:96%; margin:5px auto 0; text-align:center;"><a href="javascript:;"  onclick="$(\'#kfleft1\').hide();$(\'#kfleft\').show();">×关闭在线客服</a></div>';
    str1 += "</div>";

    str1 += '<div id="kfleft"  style="width:25px; height:114px;background:url(/images/kf1.png) no-repeat;float:right;"><div class="flkf1show" onclick="$(\'#kfleft1\').show();$(\'#kfleft\').hide();"></div><div class="flkf1colse"><a href="javascript:;" onclick="$(\'#kfleft\').hide();"><img src="/images/kf1close.png" /> </a></div>';
    str1 += "</div>";
    $("body").append(str1);
    window.setInterval("heartBeat()", 1);
})

/*qqonline*/
//$(function() {
//    //  var indexfloat='<div id="floatad"><a href="/Product/229.html" target="_blank" title="PPS＜高梆系带休闲鞋＞--白色" class="tjcp"></a><a href="javascript:popdialog.openWithIframe(\'PPSHOW网站调查\',\'/votesub.aspx\',684,342,true);" class="yqdc"></a><a href="/HelpIndex.html" target="_blank" title="购物指南" class="gwzn"></a></div>';
//    //  if(location.pathname=="/index.html")
//    //  {
//    //   $("body").append(indexfloat);
//    //  }
////    if (location.pathname.toLowerCase().indexOf("membercenter") == -1 && location.pathname.toLowerCase().indexOf("shoppingcart") == -1 && location.pathname.toLowerCase().indexOf("product") == -1) {
////        var qqhtml = '<div id="qqonline" onclick="popdialog.openWithIframe(\'快乐在线\',\'http://kefu.fashiongou.com/KeFuOnline.aspx\',644,352,true);"><div>快乐在线</div><ul id="news"><li><a  href="javascript:popdialog.openWithIframe(\'快乐在线\',\'http://kefu.fashiongou.com/KeFuOnline.aspx\',644,352,true);">客服在线请点击</a></li></ul></div>';
////        $("body").append(qqhtml);
////        var options = {
////            newsList: "#news",
////            startDelay: 10,
////            placeHolder1: " _" //打字等待符号
////        }
////        $().newsTicker(options);
////    }
//})

//$(this).scroll(function() {
//    var bodyTop = 0;
//    if (typeof window.pageYOffset != 'undefined') {
//        bodyTop = window.pageYOffset;
//    }
//    else if (typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat') {
//        bodyTop = document.documentElement.scrollTop;
//    }
//    else if (typeof document.body != 'undefined') {
//        bodyTop = document.body.scrollTop;
//    }
//    // $("#floatad").css("top", 173 + bodyTop);
//    $("#qqonline").css("top", 173 + bodyTop);
//});
/*qqonline*/


/*-----------------S:popdialogbox---------------------*/
var popdialog = new Object();

var ia = "ia"; //背景层

var tt = "tt";
var ic = "ic"; //对话框id

var pop_msg = "pop_content";
var pop_icon = "pop_icon";
var pop_title = "pop_title";


var sUserAgent = navigator.userAgent;
var isOpera = sUserAgent.indexOf("Opera") > -1;
var zIsIE = sUserAgent.indexOf("compatible") > -1 && sUserAgent.indexOf("MSIE") > -1 && (!isOpera);
var dd = zIsIE; //navigator.appVersion.toLowerCase().indexOf('msie')>=0;

var POSITION_CENTER = 1;
var POSITION_CUSTOM = 2;
var popdialog_position = POSITION_CENTER;
var popdialog_left = 300;
var popdialog_top = 200;

//得到id
function GO(tmpal) {
    if (document.getElementById) {
        return eval('document.getElementById("' + tmpal + '")');

    } else if (document.layers) {
        return eval("document.layers['" + tmpal + "']");

    } else {
        return eval('document.all.' + tmpal);

    }
}

var ci = 0;
var cj = 0;
var ck = 0;
var cl = 0;
var cm = true;
var cn = true; //显示在中心位置

//调整位置
function oO() {
    var co = AL("Width");
    var cp = AL("Height");
    var cq = GO(ia);
    cq.style.height = ((document.body.scrollHeight > cp) ? document.body.scrollHeight : cp) + "px";
    cq.style.width = ((document.body.scrollWidth > co) ? document.body.scrollWidth : co) + "px";
    var cr = zgetScroll("Top");

    var ct = GO(ic);
    if (ct.style.display != "none") {
        if (cn) {
            ck = (cp - ct.offsetHeight) / 2;
            cl = (co - ct.offsetWidth) / 2;
        } AU(ic, cl, (cr + ck))
    }

}

//得到scrollTop scroolWidth
function zgetScroll(TL) {
    var cv = 0;
    if (document.documentElement && document.documentElement.scrollTop) {
        cv = eval("document.documentElement.scroll" + TL);

    } else if (document.body) {
        cv = eval("document.body.scroll" + TL);

    }
    return cv;
}

//得到高度宽度
function AL(WH) {
    var cv = 0;
    if (self.innerWidth) {
        cv = eval("self.inner" + WH);

    } else if (document.documentElement && document.documentElement.clientWidth) {
        cv = eval("document.documentElement.client" + WH);

    } else if (document.body) {
        cv = eval("document.body.client" + WH);

    } else {
        cv = 0;

    } return cv;

}

//显示xx和背景
function AM(myObj) {
    GO(ia).style.display = 'block';
    GO(myObj).style.display = 'block';
    //document.getElementsByTagName('html')[0].style.overflow="hidden";	
    if (popdialog_position == POSITION_CUSTOM) { return }
    oO();

}
//隐藏xx和背景
function AN(myObj) {
    GO(ia).style.display = 'none';
    GO(myObj).style.display = 'none';
    //document.getElementsByTagName('html')[0].style.overflow="auto";


}

//显示信息
function AO(msg, closeFlag) {
    GO(pop_msg).innerHTML = msg;
    AM(ic);
    var dispText = closeFlag ? "block" : "none";
    //GO("ig").style.display=dispText;
    GO(pop_icon).style.display = dispText;

}

var Obj = null;
var oX = 0;
var oY = 0;
function AQ(Object, evt) {
    var evt = (evt) ? evt : (window.event) ? window.event : "";
    Obj = Object;
    oX = (dd) ? evt.offsetX : AR(evt, Obj);
    oY = (dd) ? evt.offsetY : AS(evt, Obj);

    document.body.onmousemove = function(event) {
        var event = (event) ? event : (window.event) ? window.event : "";
        var dragObj = event.srcElement ? event.srcElement : event.target;
        if (Obj != null && (dragObj.id != "Image1")) //.id==pop_title
        {
            try { document.selection.empty(); } catch (e) { try { window.getSelection().removeAllRanges(); } catch (e) { } }
            if (event.button ? ((event.button == 1) || (event.button == 1)) : ((event.which) ? (event.which == 1) : false)) {
                var cz = event.clientX - oX; if (dd) { cz += zgetScroll("Left"); }
                var da = event.clientY - oY; if (dd) { da += zgetScroll("Top"); }
                AU(Obj, cz, da);
            } else {
                AT();
            }
        }
        else {
            AT();
        }
    }
    document.body.onmouseup = AT;

}
function AR(evt, Object) {
    var cw = GO(Object);
    var cx = 0;
    while (cw.offsetParent && cw.tagName.toUpperCase() != "BODY") {
        cx += cw.offsetLeft;
        cw = cw.offsetParent;

    } return evt.clientX - cx;

}
function AS(evt, Object) {
    var cw = GO(Object);
    var cy = 0;
    while (cw.offsetParent && cw.tagName.toUpperCase() != "BODY") {
        cy += cw.offsetTop;
        cw = cw.offsetParent;

    } return evt.clientY - cy;

}
function AT() {
    if (Obj != null) {
        if (Obj == ic) {
            ck = parseInt(GO(Obj).style.top.replace('px')) - zgetScroll("Top");
            cl = parseInt(GO(Obj).style.left.replace('px')) - zgetScroll("Left");

        } Obj = null;
        document.body.onmouseup = null;
        document.body.onmousemove = null;


    }
}
function AU(myObj, cz, da) {
    if (popdialog_position == POSITION_CUSTOM) {
        GO(myObj).style.left = cz + "px";
        GO(myObj).style.top = da + "px";
        if (Obj == ic) {
            ck = da;
            cl = cz;

        }
    } else {
        var db = zgetScroll("Left");
        var de = zgetScroll("Top");
        if (cz < db) cz = db;
        if (da < de) da = de;
        var df = AL("Width") - GO(myObj).offsetWidth + zgetScroll("Left");
        var dg = AL("Height") - GO(myObj).offsetHeight + zgetScroll("Top");
        if (cz > df) cz = df;
        if (da > dg) da = dg;
        GO(myObj).style.left = cz + "px";
        GO(myObj).style.top = da + "px";
        if (Obj == ic) {
            ck = da;
            cl = cz;

        }
    }
}



//按钮图片切换
function pop_swapImgRestore() { //v3.0
    var i, x, a = document.MM_sr; for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc;
}

function pop_preloadImages() { //v3.0
    var d = document; if (d.images) {
        if (!d.MM_p) d.MM_p = new Array();
        var i, j = d.MM_p.length, a = pop_preloadImages.arguments; for (i = 0; i < a.length; i++)
            if (a[i].indexOf("#") != 0) { d.MM_p[j] = new Image; d.MM_p[j++].src = a[i]; }
    }
}

function pop_findObj(n, d) { //v4.01
    var p, i, x; if (!d) d = document; if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
        d = parent.frames[n.substring(p + 1)].document; n = n.substring(0, p);
    }
    if (!(x = d[n]) && d.all) x = d.all[n]; for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
    for (i = 0; !x && d.layers && i < d.layers.length; i++) x = pop_findObj(n, d.layers[i].document);
    if (!x && d.getElementById) x = d.getElementById(n); return x;
}

function pop_swapImage() { //v3.0
    var i, j = 0, x, a = pop_swapImage.arguments; document.MM_sr = new Array; for (i = 0; i < (a.length - 2); i += 3)
        if ((x = pop_findObj(a[i])) != null) { document.MM_sr[j++] = x; if (!x.oSrc) x.oSrc = x.src; x.src = a[i + 2]; }
}
pop_preloadImages('/images/closeb02.gif');



var pop_request = false;

popdialog.ajax_params = "";

popdialog.position = POSITION_CENTER; //

popdialog.suffix = false;

popdialog.ajax = function(url, onajax_callback, params) {
    this.ajax_params = "";
    if (!(typeof (params) == 'undefined')) {
        this.ajax_params = params;
    }
    if (popdialog.suffix) {
        if (url.indexOf("?") > -1) {
            url += "&";
        } else {
            url += "?";
        }
        url += "&sessionrand5468723=" + Math.random();
    }
    if (window.XMLHttpRequest) {
        pop_request = new XMLHttpRequest();
        pop_request.onreadystatechange = this.bb;
        if ((typeof onajax_callback) == 'function') {
            pop_request.onreadystatechange = onajax_callback;
        }
        pop_request.open("GET", url, true);
        pop_request.send(null);

    } else if (window.ActiveXObject) {
        dd = true;
        pop_request = new ActiveXObject("Microsoft.XMLHTTP");
        if (pop_request) {
            pop_request.onreadystatechange = this.bb;
            if ((typeof onajax_callback) == 'function') {
                pop_request.onreadystatechange = onajax_callback;
            }
            pop_request.open("GET", url, true);
            pop_request.send();
        }
    }
}
popdialog.showloading = function(w, h) {
    this.$("pop_content").innerHTML = '<div style="width:' + w + 'px;height:' + h + 'px"><img style="left:50%; top:40%; margin-left:-16px; margin-top:-16px;position:relative;"  src="icon_loading.gif" /></div>';

}


popdialog.bb = function() {
    if (pop_request.readyState == 4) {
        if (pop_request.status == 200) {
            var innerHtml = pop_request.responseText;
            document.getElementById("pop_content").innerHTML = innerHtml;
            pop_request = false;
        } else {
            //this.showmessage("error"+this.req.statusText,true);

        }
    }
}

popdialog.$ = function(objID) {
    return document.getElementById(objID);
}

popdialog.open = function(p_title, p_url, p_msg, p_width, p_height, p_closeFlag) {
    var w = 300;
    var h = 200;
    if (p_width) { w = p_width };
    if (p_height) { h = p_height };
    this.$("ic").style.width = w + "px";
    this.$("icc").style.width = w + "px";
    this.$("icc").style.height = h + "px";
    this.$("pop_title").innerHTML = p_title;
    if (p_url != "") {
        AO("", true);
        this.showloading(w, h);
        this.ajax(p_url)
    } else {
        if (p_closeFlag == true) {
            AO(p_msg, true);
        } else {
            AO(p_msg, false);
        }
    }
    return false;

}

popdialog.close = function(callBackFunction) {
    AN('ic');
    this.$("pop_title").innerHTML = "";
    this.$("pop_content").innerHTML = "";
    if (((typeof callBackFunction) == "function")) {
        callBackFunction.call();
    }
}

popdialog.replaceMsg = function(url) {
    this.ajax(url);
}


popdialog.createHtml = function() {
if (!this.$("ia")) {

          var html = '<div class="gray_background" id="ia" style="DISPLAY: none; WIDTH: 100%; HEIGHT: 100%"><iframe style="position:absolute;visibility:inherit; top:0px; left:0px; width:100%; height:100%; z-index:-1;opacity:.0;filter: alpha( opacity=0 ); -moz-opacity: 0;"></iframe></div>';
           html += '<div class="pop_shadowbox"  style="width:590px;" id="ic" >';
          html += '<div class="pop_dlgbox" id="icc" style="width:600px;" > ';
           //html+="<div class='boxtop'><div class='boxtopl'></div><div class='boxtopr'></div></div>";

          //html+="<div class='boxcen' id='boxcen'><div class='boxcenl'></div><div class='boxcenc' id='boxcenc'>";
        html += '<div id="pop_header"  onMouseDown="AQ(\'ic\',event)" class="poptitle">	';
           html += '<div id="pop_title" style="margin:0;font-size:12px;	font-weight: bold;" >对话框标题</div>';
        html += '<div class="close" id="pop_icon"><a href="javascript:AN(\'ic\')" onMouseOut="pop_swapImgRestore()" onMouseOver="pop_swapImage(\'Image1\',\'\',\'/css/skins/Skins1/images/pop_close2.gif\',1)"><img class="popcss_img" src="/css/skins/Skins1/images/pop_close1.gif" name="Image1" width="17" height="17" border="0" id="Image1" /></a></div>';
          html += '</div>';
          html += '<div id="pop_content"></div>';
           // html+="</div><div class='boxcenr'></div></div>";
         // html+="<div class='boxbtm'><div class='boxbtml'></div><div class='boxbtmr'></div></div>";

         html += '</div>';
          html += '</div>';
         var tempDiv = document.createElement('div');
           tempDiv.innerHTML = html;
          var first = document.body.firstChild;
            var newChild = document.body.insertBefore(tempDiv.childNodes[1], first);
         document.body.insertBefore(tempDiv.childNodes[0], newChild);
    
    
    
    
//        var html = '<div class="gray_background" id="ia" style="DISPLAY: none; WIDTH: 100%; HEIGHT: 100%"><iframe style="position:absolute;visibility:inherit; top:0px; left:0px; width:100%; height:100%; z-index:-1;opacity:.0;filter: alpha( opacity=0 ); -moz-opacity: 0;"></iframe></div>';
//        html += '<div class="pop_shadowbox"  style="width:590px;" id="ic" >';
//        html += '<div class="pop_dlgbox" id="icc" style="width:600px;" > ';
//        //html+="<div class='boxtop'><div class='boxtopl'></div><div class='boxtopr'></div></div>";

//        //html+="<div class='boxcen' id='boxcen'><div class='boxcenl'></div><div class='boxcenc' id='boxcenc'>";
//        html += '<div id="pop_header"  onMouseDown="AQ(\'ic\',event)" class="poptitle">	';
//        html += '<div id="pop_title" style="margin:0;font-size:12px;	font-weight: bold;" >对话框标题</div>';
//        html += '<div class="close" id="pop_icon"><a href="javascript:AN(\'ic\')" onMouseOut="pop_swapImgRestore()" onMouseOver="pop_swapImage(\'Image1\',\'\',\'/css/skins/Skins1/images/pop_close2.gif\',1)"><img class="popcss_img" src="/css/skins/Skins1/images/pop_close1.gif" name="Image1" width="17" height="17" border="0" id="Image1" /></a></div>';
//        html += '</div>';
//        html += '<div id="pop_content"></div>';
//        // html+="</div><div class='boxcenr'></div></div>";
//        // html+="<div class='boxbtm'><div class='boxbtml'></div><div class='boxbtmr'></div></div>";

//        html += '</div>';
//        html += '</div>';
//        var tempDiv = document.createElement('div');
//        tempDiv.innerHTML = html;
//        var first = document.body.firstChild;
//        var newChild = document.body.insertBefore(tempDiv.childNodes[1], first);
//        document.body.insertBefore(tempDiv.childNodes[0], newChild);
    }
}
popdialog.createHtmlkefu = function() {
    if (!this.$("ia")) {


        var html = '<div class="gray_background" id="ia" style="DISPLAY: none; WIDTH: 100%; HEIGHT: 100%"><iframe style="position:absolute;visibility:inherit; top:0px; left:0px; width:100%; height:100%; z-index:-1;opacity:.0;filter: alpha( opacity=0 ); -moz-opacity: 0;"></iframe></div>';
        html += '<div class="pop_shadowbox"  style="width:590px;" id="ic" >';
        html += '<div class="pop_dlgbox" id="icc" style="width:600px;" > ';
        //html+="<div class='boxtop'><div class='boxtopl'></div><div class='boxtopr'></div></div>";

        //html+="<div class='boxcen' id='boxcen'><div class='boxcenl'></div><div class='boxcenc' id='boxcenc'>";
        html += '<div id="pop_header"  onMouseDown="AQ(\'ic\',event)" class="poptitle">	';
        html += '<div id="pop_title" style="margin:0;font-size:12px;	font-weight: bold;" >对话框标题</div>';
        html += '<div class="close" id="pop_icon"><a href="javascript:AN(\'ic\')" onMouseOut="pop_swapImgRestore()" onMouseOver="pop_swapImage(\'Image1\',\'\',\'/css/skins/Skins1/images/pop_close2.gif\',1)"><img class="popcss_img" src="/css/skins/Skins1/images/pop_close1.gif" name="Image1" width="17" height="17" border="0" id="Image1" /></a></div>';
        html += '</div>';
        html += '<div id="pop_content"></div>';
        // html+="</div><div class='boxcenr'></div></div>";
        // html+="<div class='boxbtm'><div class='boxbtml'></div><div class='boxbtmr'></div></div>";

        html += '</div>';
        html += '</div>';
        var tempDiv = document.createElement('div');
        tempDiv.innerHTML = html;
        var first = document.body.firstChild;
        var newChild = document.body.insertBefore(tempDiv.childNodes[1], first);
        document.body.insertBefore(tempDiv.childNodes[0], newChild);


    }
}
popdialog.openWithIframekefu = function(p_title, p_url, p_width, p_height, p_closeFlag) {
    this.createHtmlkefu();

    var w = 300;
    var h = 200;
    if (p_width) { w = p_width };
    if (p_height) { h = p_height };
    this.$("ic").style.width = w + "px";
    this.$("icc").style.width = w + "px";
    this.$("icc").style.height = h + 18 + "px";

    this.$("pop_title").innerHTML = p_title;
    AO("", true);

    var pop_iframe = '<iframe id="pop_iframe_id" src="' + p_url + '" width="' + (w - 2) + 'px"  height="' + (h) + 'px" frameborder="0" scrolling="no"></iframe>';

    this.$("pop_content").innerHTML = pop_iframe;
    this.$("pop_content").innerHTML = pop_iframe;
    document.getElementById("ic").style.position = "absolute";
    document.getElementById("ic").style.top = "90px";
}

popdialog.openWithIframe = function(p_title, p_url, p_width, p_height, p_closeFlag) {
this.createHtml();
var w = 300;
var h = 200;
if (p_width) { w = p_width };
if (p_height) { h = p_height };
this.$("ic").style.width = w + "px";
this.$("icc").style.width = w + "px";
this.$("icc").style.height = h + 18 + "px";

this.$("pop_title").innerHTML = p_title;
AO("", true);
//var pop_iframe='<iframe id="pop_iframe_id" src="'+p_url+'" width="'+(w-18)+'px"  height="'+(h-40-18)+'px" frameborder="0" scrolling="no"></iframe>';
var pop_iframe = '<iframe id="pop_iframe_id" src="' + p_url + '" width="' + (w - 2) + 'px"  height="' + (h) + 'px" frameborder="0" scrolling="no"></iframe>';

this.$("pop_content").innerHTML = pop_iframe;

}

popdialog.openPicDialog = function(p_title, p_url, p_width, p_height) {
var w = 720;
var h = 610;
//if (p_width){w=p_width};
//if (p_height){h=p_height};
x = (window.screen.width - w) / 2;
y = (window.screen.height - h) / 2;
p_title = "title";
parameters = ',menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes';
w = window.open(p_url, p_title, 'width=' + w + ',height=' + h + ',screenX=' + x + ',screenY=' + y + ',top=' + y + ',left=' + x + parameters);
w.focus();
}

popdialog.setTitle = function(p_title) {
this.$("pop_title").innerHTML = p_title+"&nbsp;";

}

popdialog.setPosition = function(p_position) {
this.position = p_position;
popdialog_position = p_position;
}

popdialog.setDialogTopLeft = function(_top, _left) {
popdialog_left = _left;
popdialog_top = _top;
this.$("ic").style.left = popdialog_left + "px";
this.$("ic").style.top = popdialog_top + "px";
}

//在指定位置打开窗口 
popdialog.openWithIframe2 = function(p_title, p_url, p_top, p_left, p_width, p_height, p_closeFlag) {
popdialog.setPosition(POSITION_CUSTOM);
popdialog.setDialogTopLeft(p_top, p_left);
popdialog.openWithIframe(p_title, p_url, p_width, p_height, p_closeFlag);

}

/*-----------------E:popdialogbox---------------------*/

function SendAjaxB(op, OrderFiled, PageIndex, _brandid,_bcid) {
    var param = "act=" + op + "&OrderF=" + OrderFiled + "&PI=" + PageIndex + "&brandid=" + _brandid + "&bcid=" + _bcid + "&t=" + Math.random();
    $.ajax({
        type: "GET",
        url: "/aspx/BrandIndexNew.aspx",
        data: param,
        dataType: "html",
        success: function(retv) {
            document.getElementById("MainConent").innerHTML = retv.split('+')[0];
        }
    });
}

function getBrandContent(_hidepage, _hidpagecount, _pagetype) {
    var _page = parseInt($(_hidepage).val());
    var _pagecount = parseInt($(_hidpagecount).val());
    var oF = document.getElementById("hidOrderF");
    var _brandid = document.getElementById("hidBrandid").value;
    var _bcid = document.getElementById("hidbcid").value;    
    var OrderFiled = oF.value;
    
    if (_pagetype == "1") {
        _page = _page - 1;
        if (_page < 1) {
            _page = 1;
            alert("已是第一页");
        }
        else {
            $(_hidepage).val(_page);
            SendAjaxB("ConMain", OrderFiled, _page, _brandid, _bcid);
        }
    }
    else if (_pagetype == "2") {
        _page = _page + 1;
        if (_page <= _pagecount) {
            $(_hidepage).val(_page);
            SendAjaxB("ConMain", OrderFiled, _page, _brandid, _bcid);
        }
        else {
            _page = _pagecount;
            alert("已是最后一页");
        }
    }
    $(".pagenow").html(_page);
}

function getPageBrand(_hidepage, _oType) {
    var oF = document.getElementById("hidOrderF");
    if(_oType =="1")
    {
       oF.value = "Pro_ShopPriceD";
    }
    else if(_oType=="2")
    {
      oF.value="Pro_ShopPriceA";
    }
    else if(_oType=="3")
    {
      oF.value="Pro_CreateTime";
    }
    
    var OrderFiled = oF.value;
    var _brandid = document.getElementById("hidBrandid").value;
    var _bcid = document.getElementById("hidbcid").value;

    SendAjaxB("ConMain", OrderFiled, 1, _brandid, _bcid);
    $(_hidepage).val(1);
}

function showbrandlogmenu(types) {
    if (document.getElementById("brandmenulogs") != undefined) {
        if (types == 1)
            $("#brandmenulogs").css({ "visibility": "visible" });
        else
            $("#brandmenulogs").css({ "visibility": "hidden" });

    }
}

$(function() {
    $("#brandlinkm").mouseover(function() {
        //alert(document.getElementById("brandmenulogs"));
        if (document.getElementById("brandmenulogs") == undefined) {
            var offset = $(this).offset();
           
            var html = "<div id='brandmenulogs' onmouseover='showbrandlogmenu(1)' onmouseout='showbrandlogmenu(2)' class='brandmenulogs' style='left:" + (offset.left - 17) + "px; top:" + (offset.top + 17) + "px'><div class='brandmenulogsbg'></div><div class='brandmenulogscon'>";

            html += '<ul><li><a href="/brand~53/"><img src="http://img.fashiongou.com/Brand/53.jpg" /></a></li>';
            html += '<li><a href="/brand~44/"><img src="http://img.fashiongou.com/Brand/44.jpg" /></a></li>';
            html += ' <li><a href="/brand~281/"><img src="http://img.fashiongou.com/Brand/281.jpg" /></a></li>';
            html += '<li><a href="/brand~94/"><img src="http://img.fashiongou.com/Brand/94.jpg" /></a></li>';
            html += '<li><a href="/brand~239/"><img src="http://img.fashiongou.com/Brand/239.jpg" /></a></li>';
            html += '<li><a href="/brand~9/"><img src="http://img.fashiongou.com/Brand/9.jpg" /></a></li>';
            html += '<li><a href="/brand~8/"><img src="http://img.fashiongou.com/Brand/8.jpg" /></a></li>';
            html += '<li><a href="/brand~13/"><img src="http://img.fashiongou.com/Brand/13.gif" /></a></li>';

            html += "</ul></div></div>";
            $("body").append(html);
        } else {
            $("#brandmenulogs").css({ "visibility": "visible" });
        }
    });
    $("#brandlinkm").mouseout(function() {

        if (document.getElementById("brandmenulogs") != undefined) {
            $("#brandmenulogs").css({ "visibility": "hidden" });
        }
    });
  
});
