﻿/// <reference path="js/Util.js" />

// web service to populate current ingreds for this recipe



function Ingredient() {

    this.recno;
    this.recsub;
    this.curRec;
    this.foodid;
    this.recamt;
    this.calcamt;
    this.gmwgt;
    this.totgms;
    this.recmeasid;
    this.saveFnid;
    this.seq;
    this.fracdisp;
    this.fracamt;
    this.recmeas;
    this.recmeasSingular;
    this.recmeasPlural;
    this.saveFriendText;
    this.fnid;
    this.recfnid
    this.cooktext
    this.cookid
    this.chk4CookedId
 
}

Ingredient.prototype.recno = 0;
Ingredient.prototype.recsub = 0;
Ingredient.prototype.curRec = 0;
Ingredient.prototype.foodid = 0;
Ingredient.prototype.recamt = 0;
Ingredient.prototype.calcamt = 0;
Ingredient.prototype.gmwgt = 0;
Ingredient.prototype.totgms = 0;
Ingredient.prototype.recmeasid = 0;
Ingredient.prototype.saveFnid = 0;
Ingredient.prototype.seq = 0;
Ingredient.prototype.fracdisp = "";
Ingredient.prototype.fracamt = 0;
Ingredient.prototype.recmeas = "";
Ingredient.prototype.recmeasSingular = "";
Ingredient.prototype.recmeasPlural = "";
Ingredient.prototype.recfnid = 0;
Ingredient.prototype.fnid = 0;
Ingredient.prototype.saveFriendText = "";
Ingredient.prototype.cooktext = "";
Ingredient.prototype.cookid = 0;

Ingredient.prototype.Clear = function() {


    //this.recno = 0;
    //this.recsub = 0;
    this.curRec = 0;
    this.foodid = 0;
    this.recamt = 0;
    this.calcamt = 0;
    this.gmwgt = 0;
    this.totgms = 0;
    this.recmeasid = 0;
    this.saveFnid = 0;
    this.seq = 0;
    this.fracdisp = "";
    this.fracamt = 0
    this.recmeas = "";
    this.recmeasSingular = "";
    this.recmeasPlural = "";
    this.saveFriendText = "";
    this.recfnid = 0;
    this.fnid = 0;
    this.cooktext = "";
    this.cookid = 0;
}






    function ParseTerm(ttest) {

        var resultTerm = ""
        termAr = ttest.split(" ")

        for (x = 0; x < termAr.length; x++) {

            first = termAr[x].substring(0, 1).toUpperCase()
            if (x > 0) {
                resultTerm += " " + first + termAr[x].substring(1, termAr[x].length).toLowerCase()
            }
            else {
                resultTerm += first + termAr[x].substring(1, termAr[x].length).toLowerCase()
            }


        }

        return resultTerm

    }

    // message pulsing vars    
    var cssStart = 1
    var css = 1
    var flashspeed = 600
    var letterInc = 8
    var flashing = 0;

    function StopMarquee() {
        clearInterval(flashing)
    }

    function clearList(obin) {
        for (var p = 0; obin.length; p++) {
            obin.remove(0);
        }
    }


    function CycleMessage() {

        amessage = document.getElementById(mid).innerText
        if (amessage == undefined) {
            amessage = document.getElementById(mid).textContent
        }
        document.getElementById(mid).innerHTML = "";
        mlen = amessage.length
        if (cssStart == 1) {
            cssStart = 6
        }
        else {
            cssStart--;
        }
        css = cssStart
        for (x = 0; x < amessage.length; x = x + letterInc) {
            messText = amessage.substring(x, x + letterInc);
            messText = messText.replace(" ", "&nbsp;");
            WriteMessage(messText, mid, "message" + css);
            if (css == 6) {
                css = 1
            }
            else {
                css++;
            }
        }
    }

    function WriteMessage(message, domid, cssclass) {

        aElement = document.createElement('span');
        aElement.setAttribute('className', cssclass);
        aElement.setAttribute('class', cssclass);
        aElement.innerHTML = message;
        document.getElementById(domid).appendChild(aElement);

    }


    function MessageAnimation(domElement) {

        mid = domElement;
        flashing = setInterval("CycleMessage()", flashspeed);

    }

    function ClearValue(obin) {

        obin.value = "";

    }


    