﻿//首页裸钻搜索
function searchDiamond() {
    var color = "", clarity = "", cut = "", weight_min = "", weight_max = "", price_min = "", price_max = "", search_url = "/diamondlist.aspx?j=" + Math.random();
    if (!isNaN($("#color").val())) { search_url += "&color=" + $("#color").val() };
    if (!isNaN($("#clarity").val())) { search_url += "&clarity=" + $("#clarity").val() };
    if (!isNaN($("#cut").val())) { search_url += "&cut=" + $("#cut").val() };
    if (!isNaN($("#weight_min").val())) { search_url += "&weight_min=" + $("#weight_min").val() };
    if (!isNaN($("#weight_max").val())) { search_url += "&weight_max=" + $("#weight_max").val() };
    if (!isNaN($("#price_min").val())) { search_url += "&price_min=" + $("#price_min").val() };
    if (!isNaN($("#price_max").val())) { search_url += "&price_max=" + $("#price_max").val() };

    window.location.href = search_url;
}

//首页国际报价查询
function searchQuotedPrice() {
    var params = { "color": $("#sp_Color").val(), "clarity": $("#sp_Clarity").val(), "cut": $("#sp_Cut").val(), "florescence": $("#sp_Florescence").val(), "weight": $("#sp_weight").val() }
    $("#sp_Price").show();
    $("#sp_Price").html("<img src=\"/themes/v1/images/loading.gif\" width=\"25\" height=\"25\" style=\"margin-left:60px;margin-top:5px;\" />");
    $.ajax({
        type: "post",
        data: params,
        url: "/ajaxHandler/getDiamondQuotedPrice.ashx",
        success: function(price) {
            if (price != "") {
                $("#sp_Price").html("参考价：<b>" + price + "</b>&nbsp;元");
            }
        }
    })
}


var marqueeContent = new Array();

var marqueeInterval = new Array();
var marqueeId = 0;
var marqueeDelay = 2000;
var marqueeHeight = 20;
function initMarquee() {
    var str = marqueeContent[0];
    document.write('<div id="marqueeBox" style="overflow:hidden;width:250px;height:' + marqueeHeight + 'px" onmouseover="clearInterval(marqueeInterval[0])" onmouseout="marqueeInterval[0]=setInterval(\'startMarquee()\',marqueeDelay)"><div>' + str + '</div></div>');
    marqueeId++;
    marqueeInterval[0] = setInterval("startMarquee()", marqueeDelay);
}
function startMarquee() {
    var str = marqueeContent[marqueeId];
    marqueeId++;
    if (marqueeId >= marqueeContent.length) marqueeId = 0;
    if (document.getElementById("marqueeBox").childNodes.length == 1) {
        var nextLine = document.createElement('DIV');
        nextLine.innerHTML = str;
        document.getElementById("marqueeBox").appendChild(nextLine);
    }
    else {
        document.getElementById("marqueeBox").childNodes[0].innerHTML = str;
        document.getElementById("marqueeBox").appendChild(document.getElementById("marqueeBox").childNodes[0]);
        document.getElementById("marqueeBox").scrollTop = 0;
    }
    clearInterval(marqueeInterval[1]);
    marqueeInterval[1] = setInterval("scrollMarquee()", 20);
}
function scrollMarquee() {
    document.getElementById("marqueeBox").scrollTop++;
    if (document.getElementById("marqueeBox").scrollTop % marqueeHeight == (marqueeHeight - 1)) {
        clearInterval(marqueeInterval[1]);
    }
}

