﻿function flashObj(URL,width,height){
document.writeln('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="'+width+'" height="'+height+'" id="via" align="middle">')
document.writeln('<param name="allowScriptAccess" value="*" />')
document.writeln('<param name="wmode" value="transparent" />')
document.writeln('<param name="movie" value="'+URL+'" />')
document.writeln('<param name="quality" value="high" />')
document.writeln('<embed src="'+URL+'" quality="high" wmode="transparent" width="'+width+'" height="'+height+'" name="via" align="middle" allowScriptAccess="*" type="application/x-shockwave-flash" />')
document.writeln('</object>')
}

function val(language) {
    var enmsg = "Would you like to save your Language selection so that<br> you are automatically redirected in the future?";
    var demsg = "Möchten Sie die Sprachwahl für Ihre zukünftigen Besuche auf der Homepage speichern?";
    var frmsg = "Voulez-vous enregistrer votre choix de langue de sorte que vous puissiez y accéder directement dans le futur?";
    var itmsg = "Would you like to save your Language selection so that<br> you are automatically redirected in the future?";
    var cnmsg = "Would you like to save your Language selection so that<br> you are automatically redirected in the future?";
    if (language != "") {
        document.getElementById("msg").style.display = "";
        var msg_cont = document.getElementById("msg_cont");
        var yes = document.getElementById("yes");
        var no = document.getElementById("no");
    }
    if (language == "en") {
        msg_cont.innerHTML = enmsg;
        ss = "<a href=\"#\" onclick=\"gotourl(\'yes\')\">Yes</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#\" onclick=\"gotourl(\'no\')\">No </a>";
        document.getElementById("bit").innerHTML = ss;
        yes.value = "main.aspx?language=en";
        no.value = "main.aspx";
    }
    if (language == "de") {
        msg_cont.innerHTML = demsg;
        ss = "<a href=\"#\" onclick=\"gotourl(\'yes\')\">Ja</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#\" onclick=\"gotourl(\'no\')\">Nein </a>";
        document.getElementById("bit").innerHTML = ss;
        yes.value = "gr/main.asp?language=de";
        no.value = "gr/main.asp";

    }
    if (language == "fr") {
        msg_cont.innerHTML = frmsg;
        ss = "<a href=\"#\" onclick=\"gotourl(\'yes\')\">Oui</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#\" onclick=\"gotourl(\'no\')\">Non </a>";
        document.getElementById("bit").innerHTML = ss;
        yes.value = "fr/main.asp?language=fr";
        no.value = "fr/main.asp";
    }
    if (language == "it") {
        msg_cont.innerHTML = itmsg;
        yes.value = "error.html";
        no.value = "error.html";
    }
    if (language == "cn") {
        msg_cont.innerHTML = cnmsg;
        yes.value = "error.html";
        no.value = "error.html";
    }
    varnull(val);
    CollectGarbage();
}
function gotourl(x) {
    var yesurl = document.getElementById("yes").value;
    var nourl = document.getElementById("no").value;
    if (x == "yes") {
        window.location = yesurl;
    }
    if (x == "no") {
        window.location = nourl;
    }
    varnull(val());
    CollectGarbage();
}
function varnull(z) {
    z = null;
}

//*
//Input
//*
function mouse(name, value) {
    var input_state = document.getElementById(name);
    if (input_state.value == "") {
        input_state.value = value;
        return false;
    }
    if (input_state.value == value) {
        input_state.value = "";
        return false;
    }
}
//*
//Select Language
//*
function showlanguage() {
    var state = document.getElementById("languagetxt");
    if (state.className == "hidden") {
        state.className = "";
        state.focus();
    }
    else {
        state.className = "hidden";
    }
    state.onblur = function() {
        if (this.className == "") {
            window.setTimeout("hidelanguage()", 1000);
        }
    }
}

function hidelanguage() {
    document.getElementById("languagetxt").className = "hidden";
}

function myRequestObj() {
    var myhttp = null;
    try {
        myhttp = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e) {
        try {
            myhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch (e2) {
            myhttp = new XMLHttpRequest();
        }
    }
    return myhttp;
}

function show_select(input, btn, option, value) {
    inputobj = document.getElementById(input);
    btnobj = document.getElementById(btn);
    optionobj = document.getElementById(option);
    valueobj = document.getElementById(value);
    optionobj.style.display = optionobj.style.display == "" ? "none" : "";
    optionobj.onblur = function() {
        optionobj.style.display = "none";
    }

    for (var i = 0; i < optionobj.childNodes.length; i++) {
        optionobj.focus();
        optionobj.childNodes[i].onmouseover = function() {
            this.className = "qty_items_over";
        }
        optionobj.childNodes[i].onmouseout = function() {
            this.className = "qty_items_out";
        }
        optionobj.childNodes[i].onclick = function() {
            if (input == "pro_color") {
                dd = this.innerHTML.split(",");
                dd[1] = dd[1].toUpperCase();
                dd[1] = dd[1].replace("</SPAN>", " ");
            }
            inputobj.innerHTML = this.innerHTML;
            if (input == "pro_color") {
                valueobj.value = dd[1];
            }
            else {
                valueobj.value = this.innerHTML;
            }
            optionobj.blur();
            optionobj.style.display = "none";
            if (input == "pro_color") {
                document.getElementById("id").value = this.id;
                loadpic(this.id, "");
            }
            if (input == "pro_color") {
                if (dd[1] == 0) {
                    document.getElementById("xianze1").innerHTML = '<br><img src=image/out_of_stock.jpg border=0>';
                }
                else if (dd[1] = 1) {
                    document.getElementById("xianze1").innerHTML = "<br><div id='ctl00_ctl00_ContentPlaceHolder1_ContentPlaceHolder1_FormView1_Panel3'><input type='image' name='ctl00$ctl00$ContentPlaceHolder1$ContentPlaceHolder1$FormView1$ImageButton1' id='ctl00_ctl00_ContentPlaceHolder1_ContentPlaceHolder1_FormView1_ImageButton1' alt='Add to cart' src='/image/add_to_cart.png' style='border-width:0px;' /></div>";
                }
            }
        }
    }
}

function loadpic(id, table) {
    var geturl = "loadpic.aspx?id=" + id + "&table=" + table + "";
    var getDataObj = myRequestObj();
    getDataObj.open("GET", geturl, true) //异步通信
    getDataObj.onreadystatechange = function() {
        if (getDataObj.readyState == 4) {
            if (getDataObj.status == 200) {
                //alert(getDataObj.responseText);
                var pic = getDataObj.responseText;
                var picArr;
                picArr = pic.split("|");
                //alert(picArr[0]);
                document.getElementById("pro_pic").innerHTML = "<img src='productimg/" + picArr[0] + "'>";
                document.getElementById("zoom_pic").innerHTML = '<a href="productimg/' + picArr[1] + '" target="_blank"><img src="image/zoom_in.png" width="28" height="28" border="0" /></a>'
            }
            else {
                document.getElementById("pro_pic").innerHTML = "Error";
            }
        }
        else {
            document.getElementById("pro_pic").innerHTML = "<div style='height:80px;'>&nbsp;</div><img src='/image/loading.gif'>";
        }
    }
    getDataObj.send(null);
}

function create_bg() {
    var bg = document.createElement("div");
    document.body.style.overflow = "hidden";
    document.documentElement.style.overflow = "hidden";
    with (bg.style) {
        position = "absolute";
        top = "0px";
        left = "0px";
        width = document.documentElement.scrollWidth;
        height = document.documentElement.scrollHeight + 1000;
    }
    bg.id = "showbg_bgid";
    bg.className = "showbg_bg";
    document.body.appendChild(bg);
}

function show(filepath) {
    create_bg();
    var title = arguments[1] || "VETTA";
    var showbg = document.createElement("DIV")
    showbg.id = "showbg_showbg";
    var html = "";
    html = '<div class="showbg_top_bg"><div style="float:left;padding-top:7px;padding-left:10px;color:#C41F25;font-size:14px;font-weight:800;"> ' + title + '</div><div style="padding-top:5px;padding-right:15px;font-size:14px;color:#333333;cursor:pointer;" onclick="close_showbg()">X</div></div>';
    html += '<div id="showbg_content"><div style="height:50px;text-align:center;margin-top:150px;"><img src="/img/loading.gif"></div></div>'
    showbg.innerHTML = html;
    document.body.appendChild(showbg);
    filehtml = '<IFRAME marginWidth=0 marginHeight=0 src="' + filepath + '" frameBorder=0 scrolling=no width="610px" height="560px"></IFRAME>';
    document.getElementById("showbg_content").innerHTML = filehtml;
}

function show2(filepath) {
    //hidePreview(e);
    create_bg();
    var title = arguments[1] || "VETTA";
    var showbg = document.createElement("div")
    showbg.id = "showbg_showbg";
    var html = "";
    html = '<div class="showbg_top_bg"><div style="float:left;padding-top:7px;padding-left:10px;color:#C41F25;font-size:14px;font-weight:800;"> ' + title + '</div><div style="padding-top:5px;padding-right:15px;font-size:14px;color:#666666;font-weight:800;cursor:pointer;" onclick="close_showbg()">X</div></div>';
    html += '<div id="showbg_content"><div style="height:50px;margin-top:150px;"><img src="/image/loading.gif"></div></div>'
    showbg.innerHTML = html;
    document.body.appendChild(showbg);
    var qty = document.getElementById("qty").value;
    var price = document.getElementById("price").value;
    filehtml = '<IFRAME marginWidth=0 marginHeight=0 src="' + filepath + '&qty=' + qty + '&price=' + price + '" frameBorder=0 scrolling=no width="610px" height="560px"></IFRAME>';
    document.getElementById("showbg_content").innerHTML = filehtml;
}

function close_showbg() {
    document.documentElement.style.overflow = "";
    document.body.style.overflow = "";
    var showbg_bg = document.getElementById("showbg_bgid");
    var showbg_showbg = document.getElementById("showbg_showbg");
    showbg_bg.parentNode.removeChild(showbg_bg);
    showbg_showbg.parentNode.removeChild(showbg_showbg);
}
