﻿jQuery.noConflict();


// File JScript
var siteUrl = "http://www.alporto.ch"
var productUrl = "/admin/25/shop_products.aspx"
var orderUrl = "/admin/23/shop_order.aspx"



function addcornerLeft() {
if (document.getElementById) {
    document.getElementById('cornerLeftDelete').style.display = "inline";
}
}
function removecornerLeft() {
if (document.getElementById) {
    document.getElementById('cornerLeftDelete').style.display = "none";
}
}

var myRequest
function CreateXmlHttpReq(handler) {
  var xmlhttp = null;
  try {
    xmlhttp = new XMLHttpRequest();
  } catch(e) {
    try {
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch(e) {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
  xmlhttp.onreadystatechange = handler;
  return xmlhttp;
}
function myHandler() {
    if (myRequest.readyState == 4 && myRequest.status == 200) {
        //alert(myRequest.responseText);
    } else {
     alert(myRequest.status);
     }
}
function cartAjaxDeleteProductVariable(idVar) {
    myRequest = CreateXmlHttpReq(myHandler);
    myRequest.open("GET", "http://" + window.location.hostname + "/admin/25/shop_products.aspx" + "?idVar=" + idVar);
    myRequest.send(null);
    document.getElementById('idVar'+idVar).style.display = "none";
}
function cartAjaxDeleteProductImage(idImage) {
    myRequest = CreateXmlHttpReq(myHandler);
    myRequest.open("GET", "http://" + window.location.hostname + "/admin/25/shop_products.aspx" + "?idImage=" + idImage);
    myRequest.send(null);
    document.getElementById('idImage'+idImage).style.display = "none";
}
function cartAjaxAdminShip(id,idOrder) {
    myRequest = CreateXmlHttpReq(myHandler);
    myRequest.open("GET", "http://" + window.location.hostname + "/admin/23/shop_order.aspx" + "?id=" + id + "&mode=setShip");
    myRequest.send(null);
    window.location.href = "http://" + window.location.hostname +"/admin/23/shop_order.aspx" + "?idOrder=" + idOrder;
}
function cartAjaxAdminCloseOrder(id) {
    myRequest = CreateXmlHttpReq(myHandler);
    myRequest.open("GET", "http://" + window.location.hostname + "/admin/23/shop_order.aspx" + "?id=" + id + "&mode=closeOrder");
    myRequest.send(null);
    window.location.href = "http://" + window.location.hostname + "/admin/23/shop_order.aspx" + "?idOrder=" + id;
}
function cartAjaxAdminOpenOrder(id) {
    myRequest = CreateXmlHttpReq(myHandler);
    myRequest.open("GET", "http://" + window.location.hostname + "/admin/23/shop_order.aspx" + "?id=" + id + "&mode=openOrder");
    myRequest.send(null);
    window.location.href = "http://" + window.location.hostname + "/admin/23/shop_order.aspx" + "?idOrder=" + id;
}
function cartAjaxAdminPayOrder(id) {
    myRequest = CreateXmlHttpReq(myHandler);
    myRequest.open("GET", "http://" + window.location.hostname + "/admin/23/shop_order.aspx" + "?id=" + id + "&mode=payOrder");
    myRequest.send(null);
    window.location.href = "http://" + window.location.hostname + "/admin/23/shop_order.aspx" + "?idOrder=" + id;
}
function viewattachNote(opt) {
if (opt == "view") {
    if (document.getElementById) {
        document.getElementById('cart_attachNote').style.display = "block";
        document.getElementById('cart_notes').style.display = "none";
    }
    }
    else if(opt == "hide") {
    document.getElementById('cart_attachNote').style.display = "none";
    document.getElementById('cart_notes').style.display = "block";
}
}

function changeImage(image) {
     document.getElementById('placeholder').src = image;
     document.getElementById('linklightbox').href = image;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}










    function checkIt(evt) {
        evt = (evt) ? evt : window.event
        var charCode = (evt.which) ? evt.which : evt.keyCode
        if (charCode > 31 && (charCode < 48 || charCode > 57)) {
            status = "This field accepts numbers only."
            return false
        }
        status = ""
        return true
    }


 var timer;
 function checkValue(senderId, minValue, maxValue, fromTimer) {
     if (!fromTimer) {
         clearTimeout(timer)
         timer = setTimeout('checkValue("' + senderId + '",' + minValue + ', ' + maxValue + ',true)', 1500);
     } else {
         
         clearTimeout(timer)
         if (jQuery("#"+senderId).val() > maxValue)
             jQuery("#" + senderId).val(maxValue)

         if (jQuery("#" + senderId).val() < minValue) 
             jQuery("#" + senderId).val(minValue)
     }
 }
