﻿
var siteUrl = 'http://www.l-sportal.co.il';
//------------------- endregion SETTING CART PROPERTY --------------------
function wsfSetCartPropertySelect(iCartRow, idProduct, idGroup, idProperty)
{
    Sportal.He.WebServices.wsStore.SetCartPropertySelect(iCartRow,idProduct,idGroup,idProperty,wsfSetCartPropertySelectOnSucceeded,wsfSetCartPropertySelectOnFailed);}
function wsfSetCartPropertySelectOnSucceeded(json){ if(json != null) { wsfSetCartProperty(json); }}
function wsfSetCartPropertySelectOnFailed(err){}

function wsfSetCartPropertyCheckBox(iCartRow, idProduct, idGroup, idProperty, isChecked)
{
    Sportal.He.WebServices.wsStore.SetCartPropertyCheckBox(iCartRow,idProduct,idGroup,idProperty,isChecked,wsfSetCartPropertyCheckBoxOnSucceeded,wsfSetCartPropertyCheckBoxOnFailed);}
function wsfSetCartPropertyCheckBoxOnSucceeded(json){ if(json != null) { wsfSetCartProperty(json); }}
function wsfSetCartPropertyCheckBoxOnFailed(err){}
//------------------------------------------------------------------------
function wsfSetCartPropertyRadioButton(iCartRow, idProduct, idGroup, idProperty)
{
    Sportal.He.WebServices.wsStore.SetCartPropertyRadioButton(iCartRow,idProduct,idGroup,idProperty,wsfSetCartPropertyRadioButtonOnSucceeded,wsfSetCartPropertyRadioButtonOnFailed);}
function wsfSetCartPropertyRadioButtonOnSucceeded(json){ if(json != null) { wsfSetCartProperty(json); }}
function wsfSetCartPropertyRadioButtonOnFailed(err){}
//------------------------------------------------------------------------
function wsfSetCartPropertyTextBox(iCartRow, idProduct, idGroup, idProperty, value)
{
    Sportal.He.WebServices.wsStore.SetCartPropertyTextBox(iCartRow,idProduct,idGroup,idProperty,value,wsfSetCartPropertyTextBoxOnSucceeded,wsfSetCartPropertyTextBoxOnFailed);}
function wsfSetCartPropertyTextBoxOnSucceeded(json){ if(json != null) { wsfSetCartProperty(json); }}
function wsfSetCartPropertyTextBoxOnFailed(err){}
//------------------------------------------------------------------------
function wsfSetCartProperty(json)
{
    if((json.sSideCart != null) && (json.sFullCart!=null))
    {
	    if(null != (e = $get('divSideCart')))
	        e.innerHTML = json.sSideCart;

	    if(null != (e = $get('divFullCart')))
	        e.innerHTML = json.sFullCart;
    }
    else
    {
        var id = '@' + json.sPID + '@' + json.sCRI;

	    if(null != (e = $get('spanSideCartCN'+id)))
	        e.innerHTML = json.sCN;

	    if(null != (e = $get('spanSideCartQuantity'+id)))
	        e.innerHTML = json.sQuantity;
	        
	    if(null != (e = $get('spanSideCartPriceSite'+id)))
	        e.innerHTML = json.sPriceSiteFormatted;

	    if(null != (e = $get('spanSideCartPrice'+id)))
	        e.innerHTML = json.sPriceFormatted;
	        
	    if(null != (e = $get('spanFullCartCN'+id))) {
	        e.innerHTML = json.sCN;}

	    if(null != (e = $get('spanFullCartPrice')))
	        e.innerHTML = json.sPriceFormatted;

	    if(null != (e = $get('spanFullCartPriceSite'+id)))
	        e.innerHTML = json.sPriceSiteFormatted;

	        
	    if(null != (e = $get('spanFullCartPrice'+id)))
	        e.innerHTML = json.sPriceFormatted;
	        
	    if(null != (e = $get('spanFullCartOrderPrice')))
	        e.innerHTML = json.sPriceFormatted;

        if(json.csStockLevels!=null)
        {
            for(i = 0; i < json.csStockLevels.length; i++)
            {
                id = '@' + json.csStockLevels[i].sPID + '@' + json.csStockLevels[i].sCRI;
	            if(null != (e = $get('divFullCartStockLevelStatus'+id)))
	                e.innerHTML = json.csStockLevels[i].sStockLevelStatus;
            }
        }
    }

	if(null != (e = $get('divSideCartSummation')))
	    e.innerHTML = json.sSideCartSummation;

	if(null != (e = $get('divFullCartSummation')))
	    e.innerHTML = json.sFullCartSummation;
}
//------------------------------------------------------------------------
//------------------- region SETTING PROPERTY ----------------------------
function wsfSetPropertySelect(idProduct, idGroup, idProperty)
{
    Sportal.He.WebServices.wsStore.SetPropertySelect(idProduct,idGroup,idProperty,wsfSetPropertySelectOnSucceeded,wsfSetPropertySelectOnFailed);}
function wsfSetPropertySelectOnSucceeded(json)
{
	if(null != (e = $get('m_cphBody_ucProduct_spanPriceSite')))
	    e.innerHTML =json.sCoin + '&nbsp;' + json.sPriceSiteFormatted;

	if(null != (e = $get('m_cphBody_ucProduct_spanSaving')))
	    e.innerHTML = json.sCoin + '&nbsp;' + json.sSavingFormatted;

	if(json.sStockMatrix == 'true')
	{
	    if(null != (e = $get('m_cphBody_ucProduct_spanCN')))
	        e.innerHTML = json.sCN;

	    if(null != (e = $get('m_cphBody_ucProduct_spanStockLevel')))
	        e.innerHTML = json.sStockLevelMinusQuantity;

	    if(null != (e = $get('m_cphBody_ucProduct_spanStockLevelStatus')))
	        e.innerHTML = json.sStockLevelStatus;
    }
}
function wsfSetPropertySelectOnFailed(err){}
//------------------------------------------------------------------------
function wsfSetPropertyCheckBox(idProduct, idGroup, idProperty, isChecked)
{
    Sportal.He.WebServices.wsStore.SetPropertyCheckBox(idProduct,idGroup,idProperty,isChecked, wsfSetPropertyCheckBoxOnSucceeded,wsfSetPropertyCheckBoxOnFailed);}
function wsfSetPropertyCheckBoxOnSucceeded(json)
{
	if(null != (e = $get('m_cphBody_ucProduct_spanPriceSite')))
	    e.innerHTML = json.sCoin + '&nbsp;' + json.sPriceSiteFormatted  ;

	if(null != (e = $get('m_cphBody_ucProduct_spanSaving')))
	    e.innerHTML = json.sCoin + '&nbsp;' + json.sPriceSiteFormatted;
}
function wsfSetPropertyCheckBoxOnFailed(err){}
//------------------------------------------------------------------------
function wsfSetPropertyRadioButton(idProduct, idGroup, idProperty)
{
    Sportal.He.WebServices.wsStore.SetPropertyRadioButton(idProduct,idGroup,idProperty,wsfSetPropertyRadioButtonOnSucceeded, wsfSetPropertyRadioButtonOnFailed);}
function wsfSetPropertyRadioButtonOnSucceeded(json)
{
	if(null != (e = $get('m_cphBody_ucProduct_spanPriceSite')))
	    e.innerHTML = json.sCoin + '&nbsp;' + json.sPriceSiteFormatted;

	if(null != (e = $get('m_cphBody_ucProduct_spanSaving')))
	    e.innerHTML = json.sCoin + '&nbsp;' + json.sPriceSiteFormatted;
}
function wsfSetPropertyRadioButtonOnFailed(err){}
//------------------------------------------------------------------------
function wsfSetPropertyTextBox(idProduct, idGroup, idProperty, value)
{
    Sportal.He.WebServices.wsStore.SetPropertyTextBox(idProduct,idGroup,idProperty,value,wsfSetPropertyTextBoxOnSucceeded,wsfSetPropertyTextBoxOnFailed);}
function wsfSetPropertyTextBoxOnSucceeded(json){}
function wsfSetPropertyTextBoxOnFailed(err){}
//------------------- endregion SETTING PROPERTY -------------------------
function wsfInfiniteSession()
{
    Sportal.He.WebServices.wsStore.InfiniteSession(
     wsfInfiniteSessionOnSucceeded,
     wsfInfiniteSessionOnFailed);
}
function wsfInfiniteSessionOnSucceeded(s){/*alert('infinite');*/}
function wsfInfiniteSessionOnFailed(s){alert('infinite');}
//------------------------------------------------------------------------
function wsfQuickToCart(idProductToCart)
{
//alert(idProductToCart);
Sportal.He.WebServices.wsStore.QuickToCart(idProductToCart, wsfQuickToCartOnSucceeded,wsfQuickToCartOnFailed);
}
function wsfQuickToCartOnSucceeded(json)
{
    //alert("g");
    if(null != json)
    {
        if(null != json.sUrl)
            window.location = json.sUrl;
    }
}
function wsfQuickToCartOnFailed(err){window.location='Cart.aspx';}
//----------------------------------------------------------------------------------
//------------------------------------------------------------------------
function swfAddToCartEscortProduct(idProductToCart)
{
    Sportal.He.WebServices.wsStore.QuickToCart(idProductToCart, swfAddToCartEscortProductOnSucceeded,swfAddToCartEscortProductOnFailed);
    }
function swfAddToCartEscortProductOnSucceeded(json)
{
   
}
function swfAddToCartEscortProductOnFailed(err){}

//------------------------------------------------------------------------
function wsfBuyNow(idProductToCart)
{Sportal.He.WebServices.wsStore.BuyNow(idProductToCart,wsfBuyNowOnSucceeded,wsfBuyNowOnFailed);}
function wsfBuyNowOnSucceeded(json)
{
    if(null != json)
    {
        if(null != json.sUrl)
            window.location = json.sUrl;
    }
}
function wsfBuyNowOnFailed(err){window.location=siteUrl; }
//------------------------------------------------------------------------
function wsfQuickBuyNow()
{
    Sportal.He.WebServices.wsStore.QuickBuyNow(
    wsfQuickBuyNowOnSucceeded,
    wsfQuickBuyNowOnFailed);
}
function wsfQuickBuyNowOnSucceeded(json)
{
    if(null != json)
    {
        if(null != json.sUrl)
            window.location = json.sUrl;
    }
}
function wsfQuickBuyNowOnFailed(err){window.location='Cart.aspx'}
//------------------------------------------------------------------------
//------------------------------------------------------------------------
function wsfDeleteHistoryProduct(idProductToDelete, idProductException)
{Sportal.He.WebServices.wsStore.DeleteHistoryProduct(idProductToDelete,idProductException,wsfDeleteHistoryProductOnSucceeded,wsfDeleteHistoryProductOnFailed);}
function wsfDeleteHistoryProductOnSucceeded(json)
{
    if(null != json)
    {
	    if(null != (e = $get('divSideHistory')))
	        if(null != json.sHistory)
	            e.innerHTML = json.sHistory;
    }
}
function wsfDeleteHistoryProductOnFailed(err){window.location=siteUrl; }
//------------------------------------------------------------------------
function wsfDeleteCartProduct(idProduct, idCartRowIndex)
{
    Sportal.He.WebServices.wsStore.DeleteCartProduct(
        idProduct,
        idCartRowIndex,
        wsfDeleteCartProductOnSucceeded,
        wsfDeleteCartProductOnFailed);
}
function wsfDeleteCartProductOnSucceeded(json)
{
	if(null != (e = $get('divSideCart')))
        if(null != json.sSideCart)
    	    e.innerHTML = json.sSideCart;

	if(null != (e = $get('divSideCartSummation')))
        if(null != json.sSideCartSummation)
    	    e.innerHTML = json.sSideCartSummation;

	if(null != (e = $get('divFullCart')))
        if(null != json.sFullCart)
    	    e.innerHTML = json.sFullCart;

	if(null != (e = $get('divFullCartSummation')))
        if(null != json.sFullCartSummation)
	        e.innerHTML = json.sFullCartSummation;

	if(null != (e = $get('divFullCartQuantity')))
	    if(null != json.sFullCartQuantity)
	        e.innerHTML = json.sFullCartQuantity;

	if(null != (e = $get('divOrderCart')))
	    if(null != json.sOrderCart)
	        e.innerHTML = json.sOrderCart;

	if(null != (e = $get('divOrderCartSummation')))
        if(null != json.sOrderCartSummation)
    	    e.innerHTML = json.sOrderCartSummation;

	if(null != (e = $get('divShipments')))
        if(null != json.sShipments)
            e.innerHTML = json.sShipments;

	if(null != (e = $get('divCreditCardPayments')))
        if(null != json.sCreditCardPayments)
            e.innerHTML = json.sCreditCardPayments;
}
function wsfDeleteCartProductOnFailed(err){window.location=siteUrl; }
//------------------------------------------------------------------------
function wsfUpdateCartProductQuantity(idProduct, idCartRowIndex, quantity)
{
    Sportal.He.WebServices.wsStore.UpdateCartProductQuantity(
        idProduct,
        idCartRowIndex,
        quantity,
        wsfUpdateCartProductQuantityOnSucceeded,
        wsfUpdateCartProductQuantityOnFailed);
}
function wsfUpdateCartProductQuantityOnSucceeded(json)
{
    var id = '@' + json.sPID + '@' + json.sCRI;

	if(null != (e = $get('spanSideCartQuantity' + id)))
        if(null != json.sQuantity)
    	    e.innerHTML = json.sQuantity;

	if(null != (e = $get('spanSideCartPrice' + id)))
        if(null != json.sPriceFormatted)
    	    e.innerHTML = json.sPriceFormatted;

	if(null != (e = $get('divSideCartSummation')))
        if(null != json.sSideCartSummation)
    	    e.innerHTML = json.sSideCartSummation;
    	    
	if(null != (e = $get('spanFullCartPrice' + id)))
        if(null != json.sPriceFormatted)
    	    e.innerHTML = json.sPriceFormatted;

	if(null != (e = $get('spanFullCartPrice')))
        if(null != json.sFullCartPriceFormatted)
    	    e.innerHTML = json.sFullCartPriceFormatted;

//	if(null != (e = $get('spanFullCartPrice' + id)))
//        if(null != json.sOrderPriceFormatted)
//    	    e.innerHTML = json.sOrderPriceFormatted;

//	if(null != (e = $get('spanFullCartPrice')))
//        if(null != json.sFullCartPriceFormatted)
//    	    e.innerHTML = json.sFullCartPriceFormatted;
	
	if(null != (e = $get('spanFullCartQuantity')))
        if(null != json.sFullCartQuantity)
    	    e.innerHTML = json.sFullCartQuantity;
	
	if(null != (e = $get('spanFullCartOrderTax')))
        if(null != json.sOrderTaxFormatted)
    	    e.innerHTML = json.sOrderTaxFormatted;
	//alert(json.sOrderPriceFormatted);
	if(null != (e = $get('spanFullCartOrderPrice')))
        if(null != json.sOrderPriceFormatted)
    	    e.innerHTML = json.sOrderPriceFormatted;

    for(i = 0; i < json.csStockLevels.length; i++)
    {
        id = '@' + json.csStockLevels[i].sPID + '@' + json.csStockLevels[i].sCRI;
        
	    if(null != (e = $get('divFullCartStockLevelStatus' + id)))
            if(null != json.csStockLevels[i].sStockLevelStatus)
    	        e.innerHTML = json.csStockLevels[i].sStockLevelStatus;
    	        
	    if(null != (e = $get('divFullCartStockLevelStatusPicture' + id)))
            if(null != json.csStockLevels[i].sStockLevelStatusPicture)
    	        e.innerHTML = json.csStockLevels[i].sStockLevelStatusPicture;
    }

	if(null != (e = $get('spanFullCartShipment')))
        if(null != json.sFullCartShipment)
            e.innerHTML = json.sFullCartShipment;
	if(null != (e = $get('divFullCartShipmentDescription')))
        if(null != json.sFullCartShipmentDescription)
            e.innerHTML = json.sFullCartShipmentDescription;
	if(null != (e = $get('spanFullCartShipmentPrice')))
        if(null != json.sFullCartShipmentPrice)
            e.innerHTML = json.sFullCartShipmentPrice;

	if(null != (e = $get('divShipments')))
        if(null != json.sShipments)
            e.innerHTML = json.sShipments;
            
	if((null != (tr = $get('trFullCartShipmentPrice'))) && (null != (e = $get('txtFullCartShipmentPrice'))))
	{
        if((jsfTrim(e.value).length == 0) && (trFullCartShipmentPrice.style.display != 'none'))
        {
            if(null != (tr = $get('trFullCartSupplyTime')))
                tr.className = tr.className == 'trFCRBW' ? 'trFCRBB':'trFCRBW';
            if(null != (tr = $get('trFullCartOrderTax')))
                tr.className = tr.className == 'trFCRBW' ? 'trFCRBB':'trFCRBW';
            if(null != (tr = $get('trFullCartOrderPrice')))
                tr.className = tr.className == 'trFCRBW' ? 'trFCRBB':'trFCRBW';
        }
        
	    trFullCartShipmentPrice.style.display = (jsfTrim(e.value).length == 0) ? 'none' : 'block';
    }
}
function wsfUpdateCartProductQuantityOnFailed(err){window.location=siteUrl; }
//------------------------------------------------------------------------
function wsfSuddenClearCart()
{
    Sportal.He.WebServices.wsStore.SuddenClearCart(
        wsfSuddenClearCartOnSucceeded,
        wsfSuddenClearCartOnFailed);
}
function wsfSuddenClearCartOnSucceeded(json)
{
	if(null != (e = $get('divSideCart')))
        if(null != json.sSideCart)
    	    e.innerHTML = json.sSideCart;

	if(null != (e = $get('divSideCartSummation')))
        if(null != json.sSideCartSummation)
    	    e.innerHTML = json.sSideCartSummation;

	if(null != (e = $get('divFullCart')))
        if(null != json.sFullCart)
	        e.innerHTML = json.sFullCart;

	if(null != (e = $get('spanFullCartPrice')))
        if(null != json.sFullCartPriceFormatted)
	        e.innerHTML = json.sFullCartPriceFormatted;
	    
	if(null != (e = $get('spanFullCartQuantity')))
        if(null != json.sFullCartQuantity)
    	    e.innerHTML = json.sFullCartQuantity;

	if(null != (e = $get('divOrderCart')))
        if(null != json.sOrderCart)
	        e.innerHTML = json.sOrderCart;

	if(null != (e = $get('divOrderCartSummation')))
        if(null != json.sOrderCartSummation)
	        e.innerHTML = json.sOrderCartSummation;

	if(null != (e = $get('divShipments')))
        if(null != json.sShipments)
            e.innerHTML = json.sShipments;

	if(null != (e = $get('divCreditCardPayments')))
        if(null != json.sCreditCardPayments)
    	    e.innerHTML = json.sCreditCardPayments;
}
function wsfSuddenClearCartOnFailed(err){}
//------------------------------------------------------------------------
function wsfBindQuickBuyById(id)
{  
  Sportal.He.WebServices.wsStore.BindQuickBuyById(id,
        wsfBindQuickBuyByIdOnSucceeded,
        wsfBindQuickBuyByIdOnFailed);
}
function wsfBindQuickBuyByIdOnSucceeded(json)
{
    if(json != null)
    {
	    if(null != (e = $get('divQuickBuy')))
	        if(null != json.sQuickBuy) {
	            e.innerHTML = json.sQuickBuy;
	            e.style.display = 'block';
                    jsfCalcQuickBuyOffset();}
    }
    else
    {
        alert('.מספר דגם שציינת לא קיים במערכת');
    }
}
function wsfBindQuickBuyByIdOnFailed(){window.location=siteUrl; }
//------------------------------------------------------------------------
function wsfBindQuickProductPicture(id)
{
    Sportal.He.WebServices.wsStore.BindQuickProductPicture(id,
        wsfBindQuickProductPictureOnSucceeded,
        wsfBindQuickProductPictureOnFailed);
}
function wsfBindQuickProductPictureOnSucceeded(innerHTML)
{
    if(null != (e = $get('divQuickProductPicture')))
        if(null != innerHTML) {
            e.innerHTML = innerHTML;
            e.style.display = 'block';
                jsfCalcQuickProductPictureOffset();}
}
function wsfBindQuickProductPictureOnFailed(){window.location=siteUrl; }
//------------------------------------------------------------------------
function wsfQuickBuy()
{
    Sportal.He.WebServices.wsStore.QuickBuy(
        wsfQuickBuyOnSucceeded,
        wsfQuickBuyOnFailed);
}
function wsfQuickBuyOnSucceeded(json)
{
    if(json != null)
    {
	    if(null != (e = $get('divSideCart')))
            if(null != json.sSideCart)
    	        e.innerHTML = json.sSideCart;

	    if(null != (e = $get('divSideCartSummation')))
	        if(null != json.sSideCartSummation)
    	        e.innerHTML = json.sSideCartSummation;

	    if(null != (e = $get('divFullCart')))
	        if(null != json.sFullCart)
	            e.innerHTML = json.sFullCart;

	    if(null != (e = $get('divFullCartSummation')))
	        if(null != json.sFullCartSummation)
    	        e.innerHTML = json.sFullCartSummation;

    	if(null != (e = $get('divFullCartQuantity')))
	        if(null != json.sFullCartQuantity)
	            e.innerHTML = json.sFullCartQuantity;
    }
    else
    {
        alert('.מספר דגם שציינת לא קיים במערכת');
    }
}
function wsfQuickBuyOnFailed(){window.location=siteUrl; }
//------------------------------------------------------------------------
function wsfSetProductQuantity(quantity)
{
    Sportal.He.WebServices.wsStore.SetProductQuantity(
        quantity,
        wsfSetProductQuantityOnSucceeded,
        wsfSetProductQuantityOnFailed);
}
function wsfSetProductQuantityOnSucceeded(json)
{
	if(null != (e = $get('divStockLevel')))
	    if(null != json.sStockLevelMinusQuantity)
	        e.innerHTML = (json.sStockLevelMinusQuantity < 0 ) ?
	            '0' : json.sStockLevelMinusQuantity;

	if(null != (e = $get('divStockLevelStatus')))
	    if(null != json.sStockLevelStatus)
	        e.innerHTML = json.sStockLevelStatus;

    //----------- from nyga -----------------    
    
	if(null != (e = $get('spanStockLevel')))
	    if(null != json.sStockLevelMinusQuantity)
	        e.innerHTML = (json.sStockLevelMinusQuantity < 0 ) ?
	            '0' : json.sStockLevelMinusQuantity;

	if(null != (e = $get('spanStockLevelStatus')))
	    if(null != json.sStockLevelStatus)
	        e.innerHTML = json.sStockLevelStatus;
}
function wsfSetProductQuantityOnFailed(err){window.location=siteUrl; }
//-- checkout 1 start ----------------------------------------------------
//------------------------------------------------------------------------
function wsfUpdateCustomerDetails(o)
{
    Sportal.He.WebServices.wsStore.UpdateCustomerDetails(o,
        wsfUpdateCustomerDetailsOnSucceeded,
        wsfUpdateCustomerDetailsOnFailed);
}
function wsfUpdateCustomerDetailsOnSucceeded(json){}
function wsfUpdateCustomerDetailsOnFailed(err){}
//------------------------------------------------------------------------
function wsfContinueCheckout()
{
    Sportal.He.WebServices.wsStore.ContinueCheckout(
        wsfContinueCheckoutOnSucceeded,
        wsfContinueCheckoutOnFailed);
}
function wsfContinueCheckoutOnSucceeded(answer)
{
    if(answer != null)
    {
        if(answer == '0' )
        {
             var msg = 
                'Registered e-mail.' + '\n' +
                'Use a password you have registered previously' + '\n' +
                'Forgotten Password Recovery can be performed at the left of the screen';
            
              alert(msg);
        }
        else
        {
            window.location.href=answer;
        }
    }
}
function wsfContinueCheckoutOnFailed(err){}
//------------------------------------------------------------------------
function wsfSignIn(o)
{
    Sportal.He.WebServices.wsStore.SignIn(o,
        wsfSignInOnSucceeded,
        wsfSignInOnFailed);
}
function wsfSignInOnSucceeded(json)
{
    if(json != null)
    {
        if(null != json.sID && json.sID != '0')
        {
            var prefix = 'm_cphBody_ucCheckout_';
            
            if(null != (e = $get(prefix + 'txtCustomerFirstName')) && null != json.sFirstName)
                e.value = json.sFirstName;
            if(null != (e = $get(prefix + 'txtCustomerLastName')) && null != json.sLastName)
                e.value = json.sLastName;
            if(null != (e = $get(prefix + 'txtCustomerCompany')) && null != json.sCompany)
                e.value = json.sCompany;
          
            if(null != (e = $get(prefix + 'txtCustomerCity')) && null != json.sCity)
                e.value = json.sCity;
            if(null != (e = $get(prefix + 'txtCustomerStreet')) && null != json.sStreet)
                e.value = json.sStreet;
            if(null != (e = $get(prefix + 'txtCustomerHome')) && null != json.sHome)
                e.value = json.sHome;
            if(null != (e = $get(prefix + 'txtCustomerZIP')) && null != json.sZIP)
                e.value = json.sZIP;
            if(null != (e = $get(prefix + 'txtCustomerPhone')) && null != json.sPhone)
                e.value = json.sPhone;
            if(null != (e = $get(prefix + 'txtCustomerCellular')) && null != json.sCellular)
                e.value = json.sCellular;
            if(null != (e = $get(prefix + 'txtCustomerFax')) && null != json.sFax)
                e.value = json.sFax;

            if(null != json.sCountryID)
                wsfSelect(prefix + 'ddlCustomerCountry', json.sCountryID);
                
//                if (json.sCountryID == '218' || json.sCountryID == '39' )
//                {
//                   if(null != (e = $get('State')))
//                        e.style.display = '';
//                }
                
            if(null != json.sStateID)
                wsfSelect(prefix + 'ddlCustomerState', json.sStateID);
            if(null != json.sBirthday)
                wsfSelect(prefix + 'ddlCustomerBirthdayMonth', json.sBirthday.split('.')[0]);
            if(null != json.sBirthday)
                wsfSelect(prefix + 'ddlCustomerBirthdayDay', json.sBirthday.split('.')[1]);
            if(null != json.sBirthday)
                wsfSelect(prefix + 'ddlCustomerBirthdayYear', json.sBirthday.split('.')[2]);
            if(null != json.sCustomerTypeID)
                wsfSelect(prefix + 'ddlCustomerType', json.sCustomerTypeID);
                
            if( null != (e1 = $get(prefix + 'txtCustomerEmail')) &&
                null != (e2 = $get(prefix + 'txtCustomerEmailHidden')) &&
                null != json.sEmail)
                {
                    e1.value = e2.value = json.sEmail;
                    if( null != (e3 = $get('m_cphBody_ucCheckout_tremNewRet')))
                        e3.style.display = 'none';
                }
                
            if( null != (e1 = $get(prefix + 'txtCustomerPassword')) &&
                null != (e2 = $get(prefix + 'txtCustomerPasswordHidden')) &&
                null != json.sPassword)
                { 
                    e1.value = e2.value = json.sPassword;
                    if( null != (e3 = $get('m_cphBody_ucCheckout_trpaNewRet')))
                        e3.style.display = 'none';
                }
                            
            if( null != (e1 = $get(prefix + 'txtValidatePassword')) &&                
                null != json.sPassword)
                { 
                    e1.value = json.sPassword;
                    if( null != (e3 = $get('m_cphBody_ucCheckout_trpavNewRet')))
                        e3.style.display = 'none';
                }
            if( null != (e3 = $get('m_cphBody_ucCheckout_trnoteNewRet')))
                        e3.style.display = 'none';
            
            if( null != (e3 = $get('m_cphBody_ucCheckout_tblRetCus')))
                        e3.style.display = 'none';
                            
            if(null != (e = $get(prefix + 'txtCustomerComments')) && null != json.sComments)
                e.value = json.sComments;
            if(null != (e = $get(prefix + 'txtCustomerSchoolName')) && null != json.sSchoolName)
                e.value = json.sSchoolName;
            
            if(null != (e = $get('m_cphBody_ucCheckout_trUserDoesNotExist')))
                e.style.display = 'none';
        }
        else
        {
            if(null != (e = $get('m_cphBody_ucCheckout_trUserDoesNotExist')))
                e.style.display = '';
        }
    }

    if(null != (e = $get(prefix + 'txtSignInEmail')))
        e.value = '';
    if(null != (e = $get(prefix + 'txtSignInPassword')))
        e.value = '';
}
function wsfSignInOnFailed(err){}
function wsfSelect(id, value)
{
    if(null != (e = $get(id))) {
        for(i=0;i<e.length;i++) {
            if(e.options[i].value == value) {
                e.selectedIndex = i; break; }}}
}
//------------------------------------------------------------------------
function wsfUpdateShipmentHours(from, to)
{
    Sportal.He.WebServices.wsStore.UpdateShipmentHours(
        from, to,
        wsfUpdateShipmentHoursOnSucceeded,
        wsfUpdateShipmentHoursOnFailed);
}
function wsfUpdateShipmentHoursOnSucceeded(json){}
function wsfUpdateShipmentHoursOnFailed(err){}
//------------------------------------------------------------------------
function wsfUpdateShipmentAddress(o)
{
    Sportal.He.WebServices.wsStore.UpdateShipmentAddress(o,
        wsfUpdateShipmentAddressOnSucceeded,
        wsfUpdateShipmentAddressOnFailed);
}
function wsfUpdateShipmentAddressOnSucceeded(res){}
function wsfUpdateShipmentAddressOnFailed(err){}
//------------------------------------------------------------------------
function wsfCatalogueToShipment(catToShip)
{
    Sportal.He.WebServices.wsStore.CatalogueToShipment(
        catToShip,
        wsfCatalogueToShipmentOnSucceeded,
        wsfCatalogueToShipmentOnFailed);
}
function wsfCatalogueToShipmentOnSucceeded(json){}
function wsfCatalogueToShipmentOnFailed(err){}
//------------------------------------------------------------------------
function wsfUpdatePurchaseDetails(idPurchase)
{
    Sportal.He.WebServices.wsStore.UpdatePurchaseDetails(
        idPurchase,
        wsfUpdatePurchaseDetailsOnSucceeded,
        wsfUpdatePurchaseDetailsOnFailed);
}
function wsfUpdatePurchaseDetailsOnSucceeded(res){}
function wsfUpdatePurchaseDetailsOnFailed(err){}

//------------------------------------------------------------------------
function wsfUpdateShipmentProductDetails(ShipmentName)
{
    Sportal.He.WebServices.wsStore.UpdateShipmentProductDetails(ShipmentName,
        wsfUpdateShipmentDetailsOnSucceeded,
        wsfUpdateShipmentDetailsOnFailed);
}
//------------------------------------------------------------------------
function wsfUpdateShipmentDetails(idShipment)
{
    Sportal.He.WebServices.wsStore.UpdateShipmentDetails(idShipment,
        wsfUpdateShipmentDetailsOnSucceeded,
        wsfUpdateShipmentDetailsOnFailed);
}
function wsfUpdateShipmentDetailsOnSucceeded(json)
{
	if(null != (e = $get('divSideCart')))
        if(null != json.sSideCart)
    	    e.innerHTML = json.sSideCart;

	if(null != (e = $get('divSideCartSummation')))
        if(null != json.sSideCartSummation)
    	    e.innerHTML = json.sSideCartSummation;

	if(null != (e = $get('divFullCart')))
        if(null != json.sFullCart)
    	    e.innerHTML = json.sFullCart;

	if(null != (e = $get('divFullCartSummation')))
        if(null != json.sFullCartSummation)
	        e.innerHTML = json.sFullCartSummation;

	if(null != (e = $get('divFullCartQuantity')))
	    if(null != json.sFullCartQuantity)
	        e.innerHTML = json.sFullCartQuantity;

	if(null != (e = $get('divOrderCart')))
	    if(null != json.sOrderCart)
	        e.innerHTML = json.sOrderCart;

	if(null != (e = $get('divOrderCartSummation')))
        if(null != json.sOrderCartSummation)
    	    e.innerHTML = json.sOrderCartSummation;

	if(null != (e = $get('divShipments')))
        if(null != json.sShipments)
            e.innerHTML = json.sShipments;

	if(null != (e = $get('divCreditCardPayments')))
        if(null != json.sCreditCardPayments)
            e.innerHTML = json.sCreditCardPayments;
}
function wsfUpdateShipmentDetailsOnFailed(err){}
//------------------------------------------------------------------------
//-- checkout 1 end ------------------------------------------------------
//------------------------------------------------------------------------
//-- checkout 2 begin ------------------------------------------------------
//------------------------------------------------------------------------
function wsfUpdateCreditCardDetails(o)
{
    Sportal.He.WebServices.wsStore.UpdateCreditCardDetails(o,
        wsfUpdateCreditCardDetailsOnSucceeded,
        wsfUpdateCreditCardDetailsOnFailed);
}
function wsfUpdateCreditCardDetailsOnSucceeded(res){}
function wsfUpdateCreditCardDetailsOnFailed(err){window.location=siteUrl;}
//------------------------------------------------------------------------
function wsfUpdateStandardsAcceptance(accepted)
{
    Sportal.He.WebServices.wsStore.UpdateStandardsAcceptance(
        accepted,
        wsfUpdateStandardsAcceptanceOnSucceeded,
        wsfUpdateStandardsAcceptanceOnFailed);
}
function wsfUpdateStandardsAcceptanceOnSucceeded(json){}
function wsfUpdateStandardsAcceptanceOnFailed(err){}
//------------------------------------------------------------------------
function wsfUpdateGift(accepted)
{
    Sportal.He.WebServices.wsStore.UpdateGift(
        accepted,
        wsfUpdateGiftOnSucceeded,
        wsfUpdateGiftOnFailed);
}
function wsfUpdateGiftOnSucceeded(json){}
function wsfUpdateGiftOnFailed(err){}
//------------------------------------------------------------------------
function wsfUpdateOrderComment(idComment, comment)
{
    Sportal.He.WebServices.wsStore.UpdateOrderComment(
        idComment,
        comment,
        wsfUpdateOrderCommentOnSucceeded,
        wsfUpdateOrderCommentOnFailed);
}
function wsfUpdateOrderCommentOnSucceeded(json){}
function wsfUpdateOrderCommentOnFailed(err){}
//-- checkout 2 end ------------------------------------------------------
//------------------------------------------------------------------------
function wsfHotProduct(divId)
{
    Sportal.He.WebServices.wsStore.HotProduct(
        divId,
        wsfHotProductOnSucceeded,
        wsfHotProductOnFailed);
}
function wsfHotProductOnSucceeded(json)
{
    if( (null != json) &&
        (null != json.Key) &&
        (null != json.Value) &&
        (null != (e = $get(json.Key))))
            e.innerHTML = json.Value;
}
function wsfHotProductOnFailed(){}
//------------------------------------------------------------------------
function wsfExSearchCategoriesOnChange(parentId)
{
    Sportal.He.WebServices.wsStore.ExSearchCategoriesOnChange(
        parentId,
        wsfExSearchCategoriesOnChangeOnSucceeded,
        wsfExSearchCategoriesOnChangeOnFailed);
}
function wsfExSearchCategoriesOnChangeOnSucceeded(json)
{
    if( (null != json) &&
        (null != (e = $get('divExSearchSubcategories'))))
            e.innerHTML = json;
}
function wsfExSearchCategoriesOnChangeOnFailed(){}
//------------------------------------------------------------------------
function wsfStateOnChangeOnSucceeded(json)
{
       if(null != (e = $get('State')))
        e.style.display = '';
}
function wsfStateOnChangeOnFailed(){}
//------------------------------------------------------------------------
function wsfUpdateShipmentPriceWithCountry(shipmentId, countryId)
{
    Sportal.He.WebServices.wsStore.UpdateShipmentPriceWithCountry(
        shipmentId, countryId,
        wsfUpdateShipmentPriceWithCountryOnSucceeded,
        wsfUpdateShipmentPriceWithCountryOnFailed);
}
function wsfUpdateShipmentPriceWithCountryOnSucceeded(json)
{
	if(null != (e = $get('divSideCart')))
        if(null != json.sSideCart)
    	    e.innerHTML = json.sSideCart;

	if(null != (e = $get('divSideCartSummation')))
        if(null != json.sSideCartSummation)
    	    e.innerHTML = json.sSideCartSummation;

	if(null != (e = $get('divFullCart')))
        if(null != json.sFullCart)
    	    e.innerHTML = json.sFullCart;

	if(null != (e = $get('divShipments')))
        if(null != json.sShipments)
            e.innerHTML = json.sShipments;
}
function wsfUpdateShipmentPriceWithCountryOnFailed(){}
//------------------------------------------------------------------------
function wsfContactUs()
{
    var o = new Object();
        o.sName = $get('txtContactName').value;
        o.sCompany = $get('txtContactCompany').value;
        o.sPhone = $get('txtContactPhone').value;
        o.sCellular = $get('txtContactCellular').value;
        o.sEmail = $get('txtContactEmail').value;
        o.sRegistered = 'false';
        o.sSubject = $get('txtContactSubject').value;
        o.sContent = $get('txtContactContent').value;
        o.sMailing = $get('oChkMailing').checked ? 'true':'false';;

    Sportal.He.WebServices.wsStore.ContactUs(o,
        wsfContactUsOnSucceeded,
        wsfContactUsOnFailed);
}
function wsfContactUsOnSucceeded(json)
{
    window.location = 'ContactSent.aspx';
}
function wsfContactUsOnFailed()
{
    alert('failure');
}

//------------------------------------------------------------------------
function wsfOurCustomers(divId)
{
    Sportal.He.WebServices.wsStore.OurCustomer(
        divId,
        wsfOurCustomersOnSucceeded,
        wsfOurCustomersOnFailed);
}
function wsfOurCustomersOnSucceeded(json)
{
    if( (null != json) &&
        (null != json.Key) &&
        (null != json.Value) &&
        (null != (e = $get(json.Key))))
            e.innerHTML = json.Value;
}
function wsfOurCustomersOnFailed(){}
//------------------------------------------------------------------------
//-----------------------------
function AddToCartTextEscortProduct(idProduct)
{
//alert("add");
if(null != (e = $get('txtIdProductsAddToCart')))
    e.value=e.value+","+idProduct;

}

function RemoveToCartTextEscortProduct(idProduct)
{
    if(null != (e = $get('txtIdProductsAddToCart')))
    {
        var arrTxt=e.value.split(",");
        var i;
        var str = "";
        for(i=0;i<(arrTxt.length);i++)
        { 
            if (arrTxt[i] != idProduct)
            {
                if(arrTxt[i]!="")
                {
                str=str+"," + arrTxt[i];
                }
            }
          
        }
        e.value=str;
    }
}

function addToCartFromTxt()
{
    if(null != (e = $get('txtIdProductsAddToCart')))
    {
        var arrTxt=e.value.split(",");
        var i;
        var str = "";
        for(i=0;i<(arrTxt.length);i++)
        { 
                if(arrTxt[i]!="")
                {
                    swfAddToCartEscortProduct(arrTxt[i]);
                }
        }
    }
    //alert("finish")
    return true;
}
