﻿function getPhotos(uid, plid) {
    $.ajax({
        url: 'gPhotoList.asmx/getpl?uid=' + uid + '&plid=' + plid,
        type: 'GET',
        dataType: 'xml',
        timeout: 20000,
        error: function() {
            alert('Error loading XML document');
        },
        success: function(xml) {
            // do something with xml
            $("#photodesc")[0].innerHTML = xml.getElementsByTagName("photolist")[0].attributes[0].nodeValue;
            var pl = $("#Photos");
            pl[0].innerHTML = "";
            var pll = xml.getElementsByTagName("photo");
            for (var i = 0; i < pll.length; i++) {
                var im = document.createElement("img");
                var aa = document.createElement("a");
                im.src = pll[i].attributes[0].nodeValue;
                aa.href = pll[i].attributes[0].nodeValue;
                aa.appendChild(im);
                pl[0].appendChild(aa);
            }
            pl.find("a").lightBox();
        }
    });
}

$(document).ready(
    function() {
        if ($("#plist span").length > 0) {
            $("#plist span:first").trigger('click');
        }
        $("#hjjsdv a").lightBox();
        //alert($('#plist').find("div"))
        $('#plist').setScroll(
        { img: 'images/sx/s_bk.gif', width: 11 }, //background-image and width
        {img: 'images/sx/s_up.gif', height: 18 }, //up
        {img: 'images/sx/s_down.gif', height: 18 }, //down
        {img: 'images/sx/s_bar.gif', height: 81}//bar
        );
        var detail = $(".cdetail").html().toLowerCase().split("<br>");
        var details = "time=" + detail[0].split("：")[1];
        details = details + "&mingzi=" + detail[1].split("：")[1];
        details = details + "&telephone=" + detail[2].split("：")[1];
        details = details + "&adress=" + detail[3].split("：")[1];
        details = details + "&day=" + detail[4].split("：")[1];
        $(".menu").html("<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0'" +
        " width='950' height='372'><param name='allowScriptAccess' value='sameDomain'><param name='movie' value='images/mmhq/mmhq.swf'><param name='quality' value='high'>" +
        "<param name='menu' value='false'><param name=wmode value='transparent'><param name='FlashVars' value='" + details + "'" +
        "<embed src='images/mmhq/mmhq.swf' wmode='transparent' menu='false' quality='high' width='950' height='372' FlashVars='" + details + "' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' /></object>");
        var topstr = "<div class='t1'><div class='t1t'></div><div class='t1c'>" + $(".bulletin").html() + "</div></div>";
        topstr = topstr + "<div class='t2'><div class='t2t'></div>" + $("#kx .condetail").html() + "</div>";
        topstr = topstr + "<div class='t3' id='t3'></div>";
        $("#flash").html("<div class='line'>" + topstr + "</div>");
        $("#newphoto").html("<div class='newphoto1'>" + $("#newphoto").html() + "</div>");
        $("#newphoto marquee a").lightBox();
        $("#dlwz").html("<div class='dlwz'></div><div class='condetail'><div id='map'></div></div>");
        load();
        $("#loginin")[0].value = "登录";
        $("#reg")[0].value = "注册";
        var constr = $(".controls").html().toLowerCase();
        var as = $(".cdetail a");
        constr = constr.replace("<a href=\"regcom.aspx\">商家加盟</a>", "<input style='vertical-align:bottom;' onclick='window.open(\""+as[0].href+"\");return false;' type='image' src='images/mmhq/bt2.jpg' ><input style='vertical-align:bottom;' onclick=\""+as[1].href.replace("javascript:","")+"\" type='image' src='images/mmhq/bt1.jpg'><a href=\"RegCom.aspx\">商家加盟</a>");
        $(".controls").html(constr);
        $("#search")[0].value = "";
        var mach = /\((\d+),\s?(\d+)\)/.exec($("#plist span:last").attr("onclick"));
        if (mach) {
            $.ajax({
                url: 'gPhotoList.asmx/getpl?uid=' + mach[1] + '&plid=' + mach[2],
                type: 'GET',
                dataType: 'xml',
                timeout: 20000,
                error: function() {
                    alert('Error loading XML document');
                },
                success: function(xml) {
                    // do something with xml
                    var pll = xml.getElementsByTagName("photo");
                    if (pll.length > 0) {
                        $("#t3").html("<img src='" + pll[0].attributes[0].nodeValue + "' />");
                        if (pll.length > 1) {
                            var j = pll.length, i = 0;
                            setInterval(function() { i == (j - 1) ? i = 0 : i++; $("#t3").html("<img src='" + pll[i].attributes[0].nodeValue + "' />"); }, 2000);
                        }
                    }
                }
            });
        }
    });
