//[Common]

//Initialise
function initialiseCheckOut(){
	//debug("@initialiseCheckOut");
	//	カート呼び出し: '#goCart'
	//	カート呼び出しサインインウィンドウを登録する: '#singnInWindow'		
	var SIGNIN_WINDOW_ID = '#singnInWindow';
	var GOCART_ID = '#goCart';
	$(GOCART_ID).click(function(){ estimateOrderPre(); });
}

function estimateOrderPre(){
	//debug("@orderPreSettlement");
    try{
        //http://localhost:8080/easy-buy/order/preCalculation?items=CTS=2,PG=2 [POST is better]
		var CHECKOUTPRE_URL = 'checkoutPre';//'order/estimateOrderPre';
		var CHECKOUT_URL = "checkout";
		//[jQuery extends]
		$.postJSON = function(url, data, callback) {
			　　jQuery.post(url, data, callback, "json");
		};
	        $.postJSON(            
	            CHECKOUTPRE_URL,
            	{
            	 dbVersion: getDBVersion(),
	             userName: getUserID(),
	             items: getCartStorePre(),
	             catalogID: getCatalogID()
            	},
	            function (json){
		            if(json.status=="success"){
		            	//debug("Success");
		            }else{
		            	//debug("Fail");
		            }
		            location.href= CHECKOUT_URL;
	            }
	        );

    }catch(e){
    	//TODO:ダイアログを出して問題送信した方が良い。
    	userMessage( MESSAGE_WARNING_DB_NOW_BUSY + e );
    	//"[" + uri + "]" );
    }
}
