﻿var s;
function newXMLHttpRequest() {
    var xmlreq = null;
    if (window.XMLHttpRequest) xmlreq = new XMLHttpRequest();
    else if (window.ActiveXObject) xmlreq = new ActiveXObject("Microsoft.XMLHTTP");
    return xmlreq;
}
function ff1(y) {
    var req = newXMLHttpRequest();
    if (!y) y = 1;
    req.onreadystatechange = function() {
        T("divMessage").style.display = "block";
        updateCart(req);
    }
    req.open("get", "/AjaxServer/DiamondJewelry.ashx?page=" + y + "&s=" + s + "", true);
    req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    req.send(null);
}
function ff(y) {
    T("divMessage").style.display = "block";
    if (!y) y = 1;
    var url = "/AjaxServer/DiamondJewelry.ashx?rnd=" + Math.random();
    var data = { page: y, s: s };
    $.ajax({ url: url, data: data, method: "get", async: true,
        success: function(result) {
            T("pageDiv").innerHTML = result;
            T("divMessage").style.display = "none";
        },
        error: function() { T("divMessage").style.display = "none"; }
    });
}
function updateCart(req) {
    if (req.readyState != 4) return; 
    if (req.status != 200) {
        alert("HTTP ERROR : " + req.status + "\n\n" + req.statusText);
        return;
    }
    T("pageDiv").innerHTML = req.responseText;
    T("divMessage").style.display = "none";
}
function Jumping1() {
    var a = T("jumpage1").value;
    T("jumpage2").value = a;
    ff(a);
}
function Jumping2() {
    var a = T("jumpage2").value;
    ff(a);
}
function T(obj) {
    return document.getElementById(obj);
}
var mysrc;
function showSrcOut(whichpic) {
    if (document.getElementById) {
        var x = whichpic.src;
        var y = x.substr(0, x.indexOf("-"));
        if (y == "none") whichpic.src = y + "-2A.jpg";
        else whichpic.src = mysrc + "-2A.jpg";
        return false;
    } else { return true; }
}
function showSrcMove(whichpic) {
    if (document.getElementById) {
        var x = whichpic.src;
        mysrc = x.substr(0, x.indexOf("-"));
        var sFile = mysrc + "-2C.jpg";
        sFile = "../.." + sFile.substr(sFile.indexOf(".cc") + 3);
        var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        xmlhttp.open("GET", sFile, false);
        xmlhttp.send();
        if (xmlhttp.readyState == 4) {
            if (xmlhttp.status == 200) whichpic.src = mysrc + "-2C.jpg";
            else if (xmlhttp.status == 404) whichpic.src = x;   
            else whichpic.src = x;
        }
        return false;
    } else { return true; }
}
