﻿// JScript File

        function showInfoPreno() {
            var modalPopupBehavior = $find('mpInfoPreno');
            modalPopupBehavior.show();
        }

    function PopupObj(url,type){
    
        var win;
        var name;
        var options;
        
        if (type=='0'){
            //url = '../App_Classes/Handlers/ObjectFetch.ashx?' + url;
            name='B2C';
            option='resizable=no, menubar=no, width=275, height=200';
            win = window.open(url,name,options);
            win.focus();
        }


        return false;
    
    }

    function LoadData(id, page) {

        var win;
        var name;
        var options;
        var url = '../Admin/ManageGen.aspx?ky=' + id + '&page=' + page;

        name = 'B2CMan';
        option = 'resizable=no, menubar=no, width=330, height=200';
        win = window.open(url, name, options);
        win.focus();

        return false;

    }
    



    RefreshSingleShop = function() {
        try {
            if (RefreshShopCartBox) {
                RefreshShopCartBox();
            }
        }
        catch (e) {
        }
        return false;
    }

    UpdateShopCartByWebServices = function(IDArticolo, Qta) {

        B2C_Web.MGSoft.Local.WebServices.ShopCartServices.UpdateShoppingCart(IDArticolo, Qta);

        try {
            if (RefreshShopCartBoxPage) {
                RefreshShopCartBoxPage();
            }
        }
        catch (e) {
        }

        try {
            if (RefreshShopCartBox) {
                RefreshShopCartBox();
            }
        }
        catch (e) {
        }

        return false;

    }
    
    
    
    UpdateShopCartPriceByWebServices = function(IDArticolo, Qta, Price) {
        
        /*
        var div_confirm;
        div_confirm = document.getElementById("ctl00_aggiunto_");
        div_confirm.style.visibility = 'visible';
        */
       
       
        Price = Price.toString().replace(",", ".");
        
        B2C_Web.MGSoft.Local.WebServices.ShopCartServices.UpdateShoppingCartPrice(IDArticolo, Qta, Price);
       
        /*       
        try {
            if (RefreshShopCartBoxPage) {
                RefreshShopCartBoxPage();
            }
        }
        catch (e) {
        }

        try {
            if (RefreshShopCartBox) {
                RefreshShopCartBox();
            }
        }
        catch (e) {
        }
        */
        

        
        var modalPopupBehavior = $find('ajax_splash');
        modalPopupBehavior.show();
        
        
        return false;

    }

    UpdateShopCartPriceByWebServices = function(IDArticolo, Qta, Price, _this) {
			return UpdateShopCartPriceByWebServices(IDArticolo, Qta, Price, _this, '');
		}

    UpdateShopCartPriceByWebServices = function(IDArticolo, Qta, Price, _this, _rif) {
        
        /*
        var div_confirm;
        div_confirm = document.getElementById("ctl00_aggiunto_");
        div_confirm.style.visibility = 'visible';
        */
       
            
	    if ((Qta == -1) || (Qta == -2)) {
	    		if (Qta == -1)
		        Qta = parseInt(_this.value);
	
					if (Qta == -2){
							_rif =  _rif + "_ddl";
							var e = document.getElementById(_rif);
							//alert(e.value);
		        	Qta=e.value;
					}
					
		      Price = Price.toString().replace(",", ".");
		      
		      B2C_Web.MGSoft.Local.WebServices.ShopCartServices.UpdateShoppingCartAll(IDArticolo, Qta, 0);
	    }
      else{
        Price = Price.toString().replace(",", ".");
        
        B2C_Web.MGSoft.Local.WebServices.ShopCartServices.UpdateShoppingCartPrice(IDArticolo, Qta, Price);
       }
        
        
    if (Qta > 0) {
        try {
            $(_this).effect("transfer", { to: $("#ctl00_ShoppingPreviewV21_updArtsBox") }, 1000);
        }
        catch (e) {
            //alert(e);
        }
    }
    else {
        try {
            $("#ctl00_ShoppingPreviewV21_updArtsBox").effect("transfer", { to: $(_this) }, 1000);
        }
        catch (e) {
            //alert(e);
        }

    }        

              
        try {
        if (RefreshShopCartBoxPage) {
        	RefreshShopCartBoxPage();
        	}
        }
        catch (e) {
        try {
        if (RefreshShopCartBox) {
        RefreshShopCartBox();
        }
        }
        catch (e) {
        }        	
        }


        /*
        var modalPopupBehavior = $find('ajax_splash');
        modalPopupBehavior.show();
        */
        
        return false;

    }

     function RefreshShopping() {
              
        try {
        if (RefreshShopCartBoxPage) {
        RefreshShopCartBoxPage();
        }
        }
        catch (e) {
        }

        try {
        if (RefreshShopCartBox) {
        RefreshShopCartBox();
        }
        }
        catch (e) {
        }
        
        
    }


    UpdateShoppingCartWithQtaByWebServices = function(IDArticolo, Qta, OldQta) {

    B2C_Web.MGSoft.Local.WebServices.ShopCartServices.UpdateShoppingCartWithQta(IDArticolo, Qta, OldQta);

        try {
            if (RefreshShopCartBoxPage) {
                RefreshShopCartBoxPage();
            }
        }
        catch (e) {
        }

        try {
            if (RefreshShopCartBox) {
                RefreshShopCartBox();
            }
        }
        catch (e) {
        }


        return false;

    }

    //funzione per la disabilitazione delle combinazioni di tasti CTRL + X
    function disableCtrlKeyCombination(e) {
        //list all CTRL + key combinations you want to disable
        var forbiddenKeys = new Array('a', 'n', 'c', 'x', 'v', 'j');
        var key;
        var isCtrl;

        if (window.event) {
            key = window.event.keyCode;     //IE
            if (window.event.ctrlKey)
                isCtrl = true;
            else
                isCtrl = false;
        }
        else {
            key = e.which;     //firefox
            if (e.ctrlKey)
                isCtrl = true;
            else
                isCtrl = false;
        }

        //if ctrl is pressed check if other key is in forbidenKeys array
        if (isCtrl) {
            for (i = 0; i < forbiddenKeys.length; i++) {
                //case-insensitive comparation
                if (forbiddenKeys[i].toLowerCase() == String.fromCharCode(key).toLowerCase()) {
                    //alert('Key combination CTRL + ' +String.fromCharCode(key) +' has been disabled.');
                    return false;
                }
            }
        }
        return true;
    }


    function LoadInfo() {
        var opWindUp;
        opWindUp = window.open('http://www.rcs.tipremia.it', 'Concorso', 'width=600,height=600,scrollbars=yes');
        opWindUp.focus();
        return false;
    }
