﻿/*===========Start JS Entities==========*/
function TellAFriend() {
    this.RequestType = 'TellAFriend';
    this.SenderName = document.getElementById('TellAFriend_SenderName').value;
    this.RecipientName = document.getElementById('TellAFriend_RecipientName').value;
    this.From = document.getElementById('TellAFriend_SendereMail').value;
    this.To = document.getElementById('TellAFriend_RecipienteMail').value;
    this.Comments = document.getElementById('TellAFriend_AreaMsgtoRecipient').value;
    this.Subject = document.getElementById('TellAFriend_EmailSubject').innerText;
    this.PageUrl = window.location.href;
    this.post = function (url, callback) {
        var entity = this.post;
        this.post = null;
        PostData(url, this, callback);
        this.post = entity;
    };
};
function SendShoppingListSMS() {
    this.RequestType = 'SMSShoppingList';
    this.To = document.getElementById('TellAFriend_RecipientPhoneNumber').value;
	this.From = "foetex";
    this.post = function (url, callback) {
        var entity = this.post;
        this.post = null;
        PostData(url, this, callback);
        this.post = entity;
    };
};
function SendShoppingListEmail() {
    this.RequestType = 'EmailShoppingList';
    this.SenderName = document.getElementById('TellAFriend_SenderName').value;
    this.RecipientName = document.getElementById('TellAFriend_RecipientName').value;
    this.From = document.getElementById('TellAFriend_SendereMail').value;
    this.To = document.getElementById('TellAFriend_RecipienteMail').value;
    this.Comments = document.getElementById('TellAFriend_AreaMsgtoRecipient').value;
    this.Subject = document.getElementById('TellAFriend_EmailSubject').innerText;
    this.PageUrl = window.location.href;
    this.post = function (url, callback) {
        var entity = this.post;
        this.post = null;
        PostData(url, this, callback);
        this.post = entity;
    };
};


function DownloadFile(fileContents) {
    this.RequestType = 'DownloadFile';
    this.FileName = 'abc.ics';
    this.FileContents = fileContents;
    this.post = function (url, callback) {
        var entity = this.post;
        this.post = null;
        PostData(url, this, callback);
        this.post = entity;
    };
};

function SubmitForm(MainContainerId) {
    //this.RequestType = 'SubmitForm';
    this.RequestData = GetSubmitRequestData(MainContainerId);
    this.post = function (url, callback) {
        var entity = this.post;
        this.post = null;
        PostData(url, this.RequestData, callback);
        this.post = entity;
    };

};

function CarouselVoteCount(productIDs) {
    this.RequestType = 'CarouselVoteCount';
    this.ProductIDs = productIDs;
    this.post = function (url, callback) {
        var entity = this.post;
        this.post = null;
        PostData(url, this, callback);
        this.post = entity;
    };
};


function ExceptionalHour() {
    this.RequestType = 'ExceptionalHour';
    this.StoreNumber;
    this.DepartmentNumbers;
    this.StartDate;
    this.EndDate;    
    this.post = function (url, callback) {
        var entity = this.post;
        this.post = null;
        PostData(url, this, callback);
        this.post = entity;
    };
};

function RecipeCategory() {
    this.RequestType = 'RecipeCategory';
    this.IsVisible;
    this.RecipeId;    
    this.post = function (url, callback) {
        var entity = this.post;
        this.post = null;
        PostData(url, this, callback);
        this.post = entity;
    };
};

function RecipeSearch() {
    this.RequestType = 'RecipeSearch';
    this.SearchText;
    this.StartIndex;
    this.RecordsToReturn;
    this.post = function (url, callback) {
        var entity = this.post;
        this.post = null;
        PostData(url, this, callback);
        this.post = entity;
    };
};

/*---------Search Service Generic Query Request handler------*/
function SearchQuery(searchserviceurl, querytext, startingrecord, recordcount) {

    this.RequestType = 'Search';
    this.SearchServiceUrl = searchserviceurl;
    this.QueryText = querytext;
    this.StartingRecord = startingrecord;
    this.RecordCount = recordcount;
    this.post = function (url, callback) {
        var entity = this.post;
        this.post = null;
        PostData(url, this, callback);
        this.post = entity;
    };
};


/*===========End JS Entities============*/
/*=======Start Request for Product Vote Cast=====*/
function VoteCast(productId, emailAddress, startDate, endDate) {

    this.RequestType = 'VoteCast';
    this.ProductID = productId;
    this.EmailAddress = emailAddress;
    this.StartDate = startDate;
    this.EndDate = endDate;

    this.post = function (url, callback) {
        var entity = this.post;
        this.post = null;
        PostData(url, this, callback);
        this.post = entity;
    };
};
/*=========End Request Type Product Vote Cast=====*/

/*======Generic jquery PostData Method to submit request to server=====*/
function PostData(url, data, callbackhandler) {

    $.post(url, data, callbackhandler);
}
