﻿// JScript 文件
    $(document).ready(function(){
        $.ajax({
            url:"xml/product.xml",
            dataType:"xml",
            success:function(xml)
            {
                $(xml).find("products>product").each(function(a,b){
                var s = "<li><a href='#'><img id="+$(b).attr("id")+" src='"+$(b).find("productimg").text()+"' /></a><h4><a href='#' id="+$(b).attr("id")+">"+$(b).find("productname").text()+"</a></h4></li>" 
                    $("#v_content_list").append(s);
                });
                $("#v_content_list li img").click(function(){
                var id = $(this).attr("id");
                        $.ajax({
                               url:"xml/product.xml",
                                dataType:"xml",
                                success:function(xml)
                                {     
                                     $("#productdetail").empty();
                                    $(xml).find("products>product").each(function(){
                                        if($(this).attr("id") == id)
                                        {
                                            $("#productdetail").append($(this).find("producthtml").text());
                                        }
                                    });
                                }
                        });
                        return false;
                });
                $("#v_content_list li h4 a").click(function(){
                var id = $(this).attr("id");
                        $.ajax({
                               url:"xml/product.xml",
                                dataType:"xml",
                                success:function(xml)
                                {     
                                     $("#productdetail").empty();
                                    $(xml).find("products>product").each(function(){
                                        if($(this).attr("id") == id)
                                        {
                                            $("#productdetail").append($(this).find("producthtml").text());
                                        }
                                    });
                                }
                        });
                        return false;
                });
                $(xml).find("products>product:eq(0)").each(function(){
                  $("#productdetail").append($(this).find("producthtml").text());
                });
            }
        });
    });

