﻿function placeholderSetup(id) {
	var el = $("#" + id);
	if(!el) return;
	var ph = el.attr("placeholder");
	if( ph && ph != "" ) {
		el.val(ph);
		el.css("color","#555");
		el.is_focused = 0;
		el.focus(placeholderFocus);
		el.blur(placeholderBlur);
    }
}
function placeholderFocus() {
    if(!this.is_focused) {
        this.is_focused = 1;
        this.value = '';
        this.style.color = '#000';
    }
}
function placeholderBlur() {
    var ph = this.getAttribute("placeholder")
    if( this.is_focused && ph && this.value == "" ) {
		this.is_focused = 0;
        this.value = ph;
        this.style.color = '#777';
    }
}
function ChangeTab(ID, Current, Total)
{
    for(var i = 1; i <= Total; i++)
    {
        $("#" + ID + i).removeClass("Active").addClass("InActive");
        $("#" + ID + "Link" + i).removeClass("Active").addClass("InActive");
    }
    $("#" + ID + Current).removeClass("InActive").addClass("Active");
    $("#" + ID + "Link" + Current).removeClass("InActive").addClass("Active");
}
function OnSucceeded(result, userContext, methodName) 
{
    if (methodName == "DoSave")
    {
        alert(result);
    }
}
function OnFailed(error, userContext, methodName) 
{
    if(error !== null) 
        alert(error.get_message());
}
function AddToBasket(ProductCode, Quantity, IsPromotion, IsRetailerProduct, IsProductOfDay, PromotionCode, IsPromotionPacket, IsValid)
{
    jQuery.facebox({ ajax: "AddBasket.aspx?ProductCode=" + ProductCode + 
    "&Quantity=" + Quantity + 
    "&IsPromotion=" + IsPromotion + 
    "&IsRetailerProduct=" + IsRetailerProduct + 
    "&IsProductOfDay=" + IsProductOfDay + 
    "&PromotionCode=" + PromotionCode + 
    "&IsPromotionPacket=" + IsPromotionPacket +
    "&IsValid=" + IsValid + ""
    });

    ET.Web.UI.Misc.Utility.GetBasketWidgetTotal(OnSucceededGetBasketWidgetTotal, OnFailedGetBasketWidgetTotal);
}
function ShowList(OrderCode)
{
    jQuery.facebox({ ajax: "ShowOrderProducts.aspx?OrderCode=" + OrderCode });
}
function Advise(ProductCode)
{
    jQuery.facebox({ ajax: "AdviseProducts.aspx?ProductCode=" + ProductCode });
}
function Inform(ProductCode) {
    jQuery.facebox({ ajax: "InformMe.aspx?ProductCode=" + ProductCode });
}
function OpenWin(sURL, sWinName, iX, iY) {
    window.open(sURL, sWinName, "toolbar=0, menubar=0, location=0, status=0, width=" + iX + ", height=" + iY + ", scrollbars=0, resizable=1");
}

function OnSucceededGetBasketWidgetTotal(result, userContext, methodName) {
    $('#BasketTotal').html('<a href="Card.aspx">' + result + '</a>');
}
function OnFailedGetBasketWidgetTotal(error, userContext, methodName) {

}