﻿//vaibhav 260809 updated
/*
Created on      : 16 July 2009
What It Does    : xp5_main_flash.js page contains many important functions, especially for
                    rendering the template correctly.
Referred By     : wizarda.asp, wizardy.asp, materialy.asp
*/

ie4ver = false
zz_all = "all"
zz_style = "style"
zz_document = "document"
zz_images = "images"
zz_preview = "preview"
zz_div = "div"
zz_window = "window"
zz_dot = "."
zz_status = "status"
zz_img = "img"
zz_complete = "complete"
zz_height = "height"
zz_width = "width"
zz_allobjects = "allobjects"
zz_selected = "selected"
zz_visibility = "visibility"
zz_show = "show"
zz_backgroundColor = "backgroundColor"
zz_transparent = "transparent"
zz_onresize = "onresize"
zz_plabel = "plabel"
zz_label = "label"
zz_pimage = "pimage"
zz_image = "image"
zz_prectangle = "prectangle"
zz_rectangle = "rectangle"
zz_GetSize = "GetSize"
zz_RectFgColor = "RectFgColor"
zz_RectBgColor = "RectBgColor"
zz_FgColor = "FgColor"
zz_BgColor = "BgColor"
zz_background = "background"
zz_border = "border"
zz_line = "line"
zz_divofsize = "divofsize"
zz_objwidth = "objwidth"
zz_objheight = "objheight"
zz_length = "length"
zz_text = "text"
zz_textboxofsize = "textboxofsize"
zz_src = "src"
zz_parsheet = "parsheet"

zz_size = "size"
zz_dspecs = "dspecs"
zz_addoredit = "addoredit"
zz_action = "action"
zz_target = "target"
zz_value = "value"
zz_step2 = "step2"
zz_pdf = "pdf"
zz_designwidth = "designwidth"
zz_designheight = "designheight"
zz_text = "text"
zz_textarea = "textarea"
zz_PR = "PR"
zz_R = "R"
zz_PI = "PI"
zz_I = "I"
zz_PL = "PL"
zz_L = "L"

zz_zIndex = "zIndex"
zz_left = "left"
zz_top = "top"
zz_align = "align"
zz_right = "right"
zz_center = "center"

zz_ptfill = "ptfill"
zz_pstyle = "pstyle"
zz_palign = "palign"
zz_ptresize = "ptresize"
zz_pdelete = "pdelete"
zz_pduplicate = "pduplicate"
zz_ptextarea = "ptextarea"
zz_pfontname = "pfontname"
zz_pfontsize = "pfontsize"
zz_phimage = "phimage"
zz_pchangeimage = "pchangeimage"
zz_pchangebarcode = "pchangebarcode"
zz_pchangenumbering = "pchangenumbering"

zz_textfield = "textfield"

zz_vbackground = "vbackground"
zz_background2 = "background2"
zz_templatespecs = "templatespecs"
zz_toolBox = "toolBox"
zz_FewLinks = "FewLinks"

zz_divproof = "divproof"

zz_pleading = "pleading"
zz_prule = "prule"
zz_textboxofleading = "textboxofleading"
zz_divofleading = "divofleading"
zz_checkboxofrule = "checkboxofrule"
zz_lineHeight = "lineHeight"
zz_emptydiv = "emptydiv"
zz_leading = "leading"

zz_templatetext = "templatetext"
zz_templatetextfield = "templatetextfield"
zz_bgnestref = "document.background.document"
zz_divnestref = "document.background.document.div"
zz_dotdoc = ".document"

linescreated = false;
zz_ALIGNMENT = "ALIGNMENT"

VerticalAlignment = false
decreasefontsize = true

var flashrandomnumber = null;
var designid = null;

shadowflag = false

var cancelResizeCalled = false
var allreachedmin = true

defborderwidth = 1;
defbordercolor = '#AAAAAA';
defborderstyle = 'solid';

var t_image = new Array()

var imageSelector = null;

zz_visible = "visible"
zz_hidden = "hidden"
if (ns6dom) {
    zz_pixelLeft = "left"
    zz_pixelTop = "top"
    zz_pixelWidth = "width"
    zz_pixelHeight = "height"
    zz_clientHeight = "offsetHeight"
    zz_clientWidth = "offsetWidth"
}
else {
    zz_pixelLeft = "pixelLeft"
    zz_pixelTop = "pixelTop"
    zz_pixelWidth = "pixelWidth"
    zz_pixelHeight = "pixelHeight"
    zz_clientHeight = "clientHeight"
    zz_clientWidth = "clientWidth"
}

var CurrBgColor = "#FFFFFF"
var CurrPrintColor = "#000000"
var xtranscolor = "FFFFFF"
var xchangecolor = "";
var xcounter = 0
var xappendstr = "0000"

function DisplayObjects() {

    for (var i = 1; i < num_divs; i++) {
        if (div_contents[i] == zz_plabel || div_contents[i] == zz_label) {
            if (div_valign[i].toLowerCase() == 'undefined') {
                div_valign[i] = "0";
            }
            if (div_rotateangle[i].toLowerCase() == 'undefined') {
                div_rotateangle[i] = ''
            }
        }
    }

    for (var i = 1; i < num_divs; i++) {
        if (div_contents[i] == zz_plabel || div_contents[i] == zz_label) {
            if (div_group[i]) {
                if (div_group[i].length > 0 && div_group[i].indexOf('-') >= 0) {
                    t_grp = div_group[i].split('-')
                    if (t_grp.length == 2) {
                        if (t_grp[1] == '0' || div_fields[i].toLowerCase().indexOf('space') >= 0) {} else {
                            showTextOnTemplate(div_text[i], i, "textfield" + i)
                        }
                    }
                }
            }
        }
    }

}

function getgroupdivno(yindex) {
    var i, grpname, retval

    grpname = div_group[yindex]
    i = grpname.indexOf('-')

    if (i >= 0) {
        retval = grpname.substring(0, i)
    }
    grpname = retval + '-0'

    for (var i = 1; i < num_divs; i++) {
        if (div_group[i]) {
            if (div_group[i].toUpperCase() == grpname.toUpperCase()) {
                return i
            }
        }
    }
    return - 1
}

function getgroupindex(ygroup) {
    for (var i = 1; i < num_divs; i++) {
        if (div_group[i]) {
            if (div_group[i].toUpperCase() == ygroup.toUpperCase()) {
                return i
            }
        }
    }
    return - 1
}

function setgroupdivHeight(yindex) {
    var gdiv_h = 0

    for (var i = 1; i < num_divs - 1; i++) {
        if (div_group[i]) {
            if (div_group[i].indexOf(div_group[yindex]) >= 0) {
                gdiv_h = gdiv_h + parseFloat(div_h[i])
            }
        }
    }
    div_h[yindex] = gdiv_h
}

function setSizeSelections(divno, cfontsize) {
    if (document.txtpreview) {
        var currobj = document.txtpreview
        if (currobj["optfontsize" + divno]) {
            currobj["optfontsize" + divno].selectedIndex = 0;
        }
    }
}

function fetchXyz() {
    if (fetchXyz.arguments.length <= 0) {
        return
    }
    var xstr = "",
    kk;
    for (kk = 0; kk < fetchXyz.arguments.length; kk++) {
        xstr = xstr + lookupstring[parseInt(fetchXyz.arguments[kk])]
    }
    return xstr;
}

function belongtosamegroup(grpname1, grpname2) {
    var i, j, retval

    i = grpname1.indexOf('-')
    j = grpname2.indexOf('-')

    retval = (grpname1.substring(0, i) == grpname2.substring(0, j))
    return retval
}

function jshtmlencode(ystr) {
    ystr = ystr.split("&quot;").join("\"")
    ystr = ystr.split("\"").join("&quot;")

    return ystr

    if (ystr == null) {
        ystr = ''
    }

    if (ystr == '&nbsp;') {
        return ystr;
    }

    ystr = ystr.split("&#").join("^^^^^")
    ystr = ystr.split("&nbsp;").join("^nbsp;")
    ystr = ystr.split("&NBSP;").join("^NBSP;")

    ystr = ystr.split("&gt;").join(">")
    ystr = ystr.split("&GT;").join(">")

    ystr = ystr.split("&lt;").join("<")
    ystr = ystr.split("&LT;").join("<")

    ystr = ystr.split("&quot;").join("\"")
    ystr = ystr.split("&QUOT;").join("\"")

    ystr = ystr.split("&amp;").join("&")
    ystr = ystr.split("&AMP;").join("&")

    ystr = ystr.split("&").join("&amp;")
    ystr = ystr.split("\"").join("&quot;")
    ystr = ystr.split("<").join("&lt;")
    ystr = ystr.split(">").join("&gt;")
    ystr = ystr.split("^nbsp;").join("&nbsp;")

    ystr = ystr.split("^^^^^").join("&#")

    return ystr;
}

function changeAlignment(yindex, yval) {
    if (yindex <= 0) {
        return;
    }
    flashAlignAll(yval, yindex);
    return;
}

function changeVAlignment(yindex, yval) {
    if (yindex <= 0) {
        return;
    }
    div_valign[yindex] = yval
    Flash_SetTextVAlign(yindex)
    return;
}

function debug(ystr) {
    if (debugflag || xdebugon == '1') {
        alert(ystr)
    }
}

var reschars = "~|"
var a_reschars = reschars.split('')
function changeSecondText(ytext) {
    var yindex = getobjectno("NUMBERING2")
    if (yindex > 0) changeText(ytext, yindex)
}

function changeText(ytext, yindex, shflag) {
    var xfound = false;
    
	/* Vaibhav 191009 - s */
    if(div_size[yindex] < flag_Text_MinFontSizeAllowed) {
        alert("font size is less than min font size allowed")
        return;
    }
    /* Vaibhav 191009 - s */
    
    for (var k = 0; k < a_reschars.length; k++) {
        if (ytext.indexOf(a_reschars[k]) >= 0) {
            ytext = ytext.split(a_reschars[k]).join('')
            xfound = true
        }
    }
    if (xfound) {
        if (currobj["textfield" + yindex]) {
            currobj["textfield" + yindex].value = ytext
        }
    }

    if (div_fields[yindex]) {
        xfield = div_fields[yindex]

    }
    
    UpdateSimilarFields(ytext, yindex, shflag)

    currobjnum = yindex;

    div_text[yindex] = ytext;
    flashChangeText(yindex, ytext);
}

function UpdateSimilarFields(ytext, yindex, shflag) {
    if (div_fields[yindex].length > 0) {
        for (var nn = 1; nn < num_divs; nn++) {
            if (div_contents[nn]) {
                if (div_contents[nn].indexOf('label') >= 0) {
                    if (div_fields[nn]) {
                        if (nn != yindex) {
                            if (div_fields[nn] == div_fields[yindex]) {
                                div_text[nn] = ytext;
                                changeText(ytext, nn, shflag)
                            }
                        }
                    }
                }
            }
        }
    }
}

function GetAlignString(yindex) {
    if (div_align[yindex] == 0) return "Left"
    else if (div_align[yindex] == 1) return "Right"
    else if (div_align[yindex] == 2) return "Center"
    else return "Left"
}

function GetVAlignString(yindex) {
    if (div_valign[yindex] == 0) return "Top"
    else if (div_valign[yindex] == 1) return "Bottom"
    else if (div_valign[yindex] == 2) return "Middle"
    else return ""
}

function ChangeInnerHTML(yobject, ystr, yself) {
    xdom = getRS('', zz_document, zz_all, yobject)
    xdom.innerHTML = ystr
}

function refreshDesign() {
    var tmpobj
    tmpobj = document.preview
    if (fill_color == 1) fill_color_RGB = tmpobj.optcolor1.options[tmpobj.optcolor1.selectedIndex].value
    else if (fill_color == 2) fill_color_RGB = tmpobj.optcolor2.options[tmpobj.optcolor2.selectedIndex].value
    else if (fill_color == 3) fill_color_RGB = tmpobj.optcolor3.options[tmpobj.optcolor3.selectedIndex].value
    else if (fill_color == 4) fill_color_RGB = tmpobj.optcolor4.options[tmpobj.optcolor4.selectedIndex].value

    for (var i = 1; i < num_divs; i++) {
        if (div_contents[i] == "plabel" || div_contents[i] == "label") {
            if (div_color[i] == 1) {
                div_color_hex[i] = "#" + tmpobj.optcolor1.options[tmpobj.optcolor1.selectedIndex].value
            } else if (div_color[i] == 2) {
                div_color_hex[i] = "#" + tmpobj.optcolor2.options[tmpobj.optcolor2.selectedIndex].value
            } else if (div_color[i] == 3) {
                div_color_hex[i] = "#" + tmpobj.optcolor3.options[tmpobj.optcolor3.selectedIndex].value
            } else if (div_color[i] == 4) {
                div_color_hex[i] = "#" + tmpobj.optcolor4.options[tmpobj.optcolor4.selectedIndex].value
            }
        }

        if (div_contents[i] == "prectangle" || div_contents[i] == "rectangle") {
            if (div_bgcolor[i] == 1) {
                div_bgcolor_hex[i] = "#" + tmpobj.optcolor1.options[tmpobj.optcolor1.selectedIndex].value
            } else if (div_bgcolor[i] == 2 && colorsallowed >= 2) {
                div_bgcolor_hex[i] = "#" + tmpobj.optcolor2.options[tmpobj.optcolor2.selectedIndex].value
            } else if (div_bgcolor[i] == 3 && colorsallowed >= 3) {
                div_bgcolor_hex[i] = "#" + tmpobj.optcolor3.options[tmpobj.optcolor3.selectedIndex].value
            } else if (div_bgcolor[i] == 4 && colorsallowed >= 4) {
                div_bgcolor_hex[i] = "#" + tmpobj.optcolor4.options[tmpobj.optcolor4.selectedIndex].value
            }

        }

        Flash_Update_RectAndTextObjColors()
    }
}

function HextoDec(yhex) {
    HextoDec1 = convdigit(yhex.substring(0, 1)) * 16 * 16 * 16 * 16 * 16
    HextoDec1 = HextoDec1 + convdigit(yhex.substring(1, 2)) * 16 * 16 * 16 * 16
    HextoDec1 = HextoDec1 + convdigit(yhex.substring(2, 3)) * 16 * 16 * 16
    HextoDec1 = HextoDec1 + convdigit(yhex.substring(3, 4)) * 16 * 16
    HextoDec1 = HextoDec1 + convdigit(yhex.substring(4, 5)) * 16
    HextoDec1 = HextoDec1 + convdigit(yhex.substring(5, 6))
    return HextoDec1
}

function convdigit(ycurrdigit) {
    ycurrdigit = ycurrdigit.toUpperCase()
    var xcurrnum = 0
    if (ycurrdigit == "0") xcurrnum = 0;
    else if (ycurrdigit == "1") xcurrnum = 1;
    else if (ycurrdigit == "2") xcurrnum = 2;
    else if (ycurrdigit == "3") xcurrnum = 3;
    else if (ycurrdigit == "4") xcurrnum = 4;
    else if (ycurrdigit == "5") xcurrnum = 5;
    else if (ycurrdigit == "6") xcurrnum = 6;
    else if (ycurrdigit == "7") xcurrnum = 7;
    else if (ycurrdigit == "8") xcurrnum = 8;
    else if (ycurrdigit == "9") xcurrnum = 9;
    else if (ycurrdigit == "A") xcurrnum = 10;
    else if (ycurrdigit == "B") xcurrnum = 11;
    else if (ycurrdigit == "C") xcurrnum = 12;
    else if (ycurrdigit == "D") xcurrnum = 13;
    else if (ycurrdigit == "E") xcurrnum = 14;
    else if (ycurrdigit == "F") xcurrnum = 15;
    return xcurrnum;
}

if (ns6dom) {
    HTMLElement.prototype.insertAdjacentElement = function (where, parsedNode) {
        switch (where) {
        case 'beforeBegin':
            this.parentNode.insertBefore(parsedNode, this);
            break;
        case 'afterBegin':
            this.insertBefore(parsedNode, this.firstChild);
            break;
        case 'beforeEnd':
            this.appendChild(parsedNode);
            break;
        case 'afterEnd':
            if (this.nextSibling) {
                this.parentNode.insertBefore(parsedNode, this.nextSibling);
            }
            else {
                this.parentNode.appendChild(parsedNode);
            }
            break;
        }
    };
    HTMLElement.prototype.insertAdjacentHTML = function (where, htmlStr) {
        var r = this.ownerDocument.createRange();
        r.setStartBefore(this);
        var parsedHTML = r.createContextualFragment(htmlStr);
        this.insertAdjacentElement(where, parsedHTML);
    };
    HTMLElement.prototype.insertAdjacentText = function (where, txtStr) {

        var parsedText = document.createTextNode(txtStr);
        this.insertAdjacentElement(where, parsedText);
    };
}

function getRS() {
    var xstr = "",
    kk;
    xnestref = getRS.arguments[0];

    for (kk = 1; kk < getRS.arguments.length; kk++) {
        xstr = xstr + getRS.arguments[kk];
        if (getRS.arguments[kk].length > 0) {
            if (kk < getRS.arguments.length - 1) {
                xstr = xstr + zz_dot;
            }
        }
    }
    return eval(xstr);
}

function joinParam() {
    var xstr = "",
    kk;
    for (kk = 0; kk < joinParam.arguments.length; kk++) {
        xstr = xstr + joinParam.arguments[kk];
    }
    return xstr;
}

function userdefinedafterchange() {}

function changeImage(index, imgname, wmfname, gifname, uploaded, t_image_ctr) {
    var xdom, obj
    div_text[index] = gifname;
    
    //Vj - In case of Image object deleted
    if (typeof(gifname) == "undefined") {
        return;
    }

    if (uploaded == 1) {
        div_text[index] = gifname;
        //gifname = gifname
    }

    if (gifname.substring(0, 4).toLowerCase() == '/xp2' || gifname.substring(0, 4).toLowerCase() == '\\xp2') {} else {
        gifname = "/xp2/clipart/" + gifname
        div_text[index] = gifname;
    }
    
    //vaibhav - wait for image to ready
    //using sync call for wait to complete the 
	//true async call; false sync call

	Flash_update_image(index);

//    var oHttp = GetXMLHttpRequestObject();
//    oHttp.open("GET", gifname, false); //true async call; false sync call
//    oHttp.send();
//    if (oHttp.status==200) {
//        Flash_update_image(index);
//    }

}

function GetXMLHttpRequestObject() {
    var xmlhttp = null;
    if (window.XMLHttpRequest) {
        xmlhttp = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    return xmlhttp
}


//vaibhav 
function sleep(delay)
{
    var start = new Date().getTime();
    while (new Date().getTime() < start + delay);
}

function checkImageQuality(yindex) {
    var xfinaldpi = 0,
    xquality = "",
    targetheight, targetwidth, xcropwidth, xcropheight
    var libsymbol = false,
    xretval, strlogoquality = ''

    if (!div_hidden[yindex]) {
        if (typeof(crop_w) == "undefined" || typeof(crop_h) == "undefined") {
            libsymbol = true
        }

        if (div_text[yindex].substring(0, 12).toLowerCase() == "/xp2/clipart") {
            libsymbol = true
        }

        if (!libsymbol) {
            targetheight = parseFloat((2 * div_h[yindex]) / xzoomper)
            targetwidth = parseFloat((2 * div_w[yindex]) / xzoomper)

            var xretval = parseInt(crop_w[yindex] / (targetwidth / 96))

            if (document.all.div_imgquality) {
                var xsignature = false
                if (typeof(xcatgid) != "undefined" && typeof(xsubcatgid) != "undefined") {
                    if (xcatgid == '512' && xsubcatgid.toLowerCase() == 'stampsignature') {
                        xsignature = true
                    }
                }

                if (crop_w[yindex] > 0 && crop_h[yindex] > 0) {
                    if (xretval < flag_Graphic_AcceptableDPI) {
                        strlogoquality = '<img src="/xp/images/spacer.gif" width="1" height="5"><br>'
                        if (xsignature) {
                            strlogoquality = strlogoquality + '<font class=body7>Your Uploaded Signature : ' + crop_w[yindex] + ' x ' + crop_h[yindex] + 'px <br>'
                        } else {
                            strlogoquality = strlogoquality + '<font class=body7>Your Uploaded logo : ' + crop_w[yindex] + ' x ' + crop_h[yindex] + 'px <br>'
                        }
                        strlogoquality = strlogoquality + 'Print size : ' + round_(targetwidth / 96, 2) + '" x ' + round_(targetheight / 96, 2) + '" '
                        strlogoquality = strlogoquality + '(' + parseInt(crop_w[yindex] / (targetwidth / 96)) + ' dpi) Required ' + flag_Graphic_AcceptableDPI + ' dpi<br>'

                        if (xsignature) {
                            strlogoquality = strlogoquality + '<font color=red>A Heads Up on Your Signature!</font><br>'
                            strlogoquality = strlogoquality + 'Your signature does not have sufficient resolution to print well. '
                            strlogoquality = strlogoquality + 'Please find or create a file that shows more detail. Or, reduce the size '
                            strlogoquality = strlogoquality + "of the signature by clicking on 'Resize' buttons above.<br>"
                        } else {
                            strlogoquality = strlogoquality + '<font color=red>A Heads Up on Your Logo!</font><br>'
                            strlogoquality = strlogoquality + 'Your logo does not have sufficient resolution to print well. '
                            strlogoquality = strlogoquality + 'Please find a logo that shows more detail. Or, reduce the size '
                            strlogoquality = strlogoquality + "of the logo by clicking on 'Resize' buttons above.<br>"
                        }
                        document.all.div_imgquality.innerHTML = strlogoquality

                    } else {

                        strlogoquality = '<img src="/xp/images/spacer.gif" width="1" height="5"><br>'
                        if (xsignature) {
                            strlogoquality = strlogoquality + '<font class=body7>Your Uploaded signature : ' + crop_w[yindex] + ' x ' + crop_h[yindex] + 'px <br>'
                        } else {
                            strlogoquality = strlogoquality + '<font class=body7>Your Uploaded logo : ' + crop_w[yindex] + ' x ' + crop_h[yindex] + 'px <br>'
                        }
                        strlogoquality = strlogoquality + 'Print size : ' + round_(targetwidth / 96, 2) + '" x ' + round_(targetheight / 96, 2) + '" '
                        strlogoquality = strlogoquality + '(' + parseInt(crop_w[yindex] / (targetwidth / 96)) + ' dpi) Required ' + flag_Graphic_AcceptableDPI + ' dpi<br>'
                        document.all.div_imgquality.innerHTML = strlogoquality
                    }
                }
            }
        } else {
            if (document.all.div_imgquality) {
                document.all.div_imgquality.innerHTML = ''
            }
        }
    }
}

function check_download_completed(yindex, gifname, t_image_ctr) {
    var ri, nw, nh, xobj, xdom, ow, oh, ox, oy, xtimeid;
    if (t_image[t_image_ctr].complete) {

        graphic_w = t_image[t_image_ctr].width
        graphic_h = t_image[t_image_ctr].height

        ow = div_w[yindex] * 2;
        oh = div_h[yindex] * 2;
        ox = div_x[yindex] * 2;
        oy = div_y[yindex] * 2

        if (graphic_w == 0 || graphic_h == 0) {
            ri = 1
        }
        else {
            ri = graphic_w / graphic_h
        }
        nw = ow
        nh = ow / ri
        if (nh > oh) {
            nh = oh
            nw = ri * oh
        }

        div_w[yindex] = nw / 2
        div_h[yindex] = nh / 2
        div_x[yindex] = (ox + ow - nw) / 2
        div_y[yindex] = (oy + oh - nh) / 2

        changeDivSize(yindex)

        writeLayer(yindex, "<IMG ID=\"div" + yindex + "img\" NAME=\"div" + yindex + "img\" SRC=\"" + gifname + "\" WIDTH=\"" + div_w[yindex] * 2 + "\"><DIV ID=\"div" + yindex + "border\" style=\"position:absolute; left:0px; top:0px; background-color:transparent; layer-background-color:transparent; border-color:" + defbordercolor + "; border-width:" + defborderwidth + "; border-style:" + defborderstyle + "; visibility:hidden;\">", true);

        changeDivLocation(yindex);
        userdefinedafterchange(yindex)
        changeImage_afterchange(yindex)

        resizeborder(yindex)
        if (gifname.toLowerCase().indexOf('addimage') >= 0 || gifname.toLowerCase().indexOf('null.gif') >= 0) {} else {
            if (xLogoPositions.length > 0) {
                if (document.preview.logo_pos) {
                    if (div_text[yindex].toLowerCase().indexOf('null') < 0) {
                        xcurrposition = document.preview.logo_pos.options[document.preview.logo_pos.selectedIndex].value
                        ChangeLogoPosition(xcurrposition)
                    }
                }
            }
        }

        if (typeof(flag_GraphicField) != "undefined" && flag_GraphicField.length > 0) {
            if (div_fields[yindex] == flag_GraphicField) {
                checkImageQuality(yindex)
            }
        }

    } else {
        xtimeid = setTimeout("check_download_completed(" + yindex + ",'" + gifname + "'," + t_image_ctr + ")", 100)
    }

    fixPngDisplay()

}

var objXMLHTTP
function CallPage(urlstr) {
    var tmp
    var urlHalves = String(document.location).split('?');
    tmp = urlHalves[0].split("http://").join("")
    urlHalves = tmp.split("/")

    var sURL = 'http://' + urlHalves[0] + urlstr

    objXMLHTTP = null;

    if (window.XMLHttpRequest) { // code for Mozilla, etc.
        objXMLHTTP = new XMLHttpRequest()
    } else if (window.ActiveXObject) { // code for IE
        objXMLHTTP = new ActiveXObject("Microsoft.XMLHTTP");
    }

    if (objXMLHTTP != null) { 
        objXMLHTTP.onreadystatechange = XMLHttpstate_Change;
        objXMLHTTP.open("GET", sURL, false);
        objXMLHTTP.send(null);
    } else {
        //alert("Your browser does not support XMLHTTP.")
    }

    return objXMLHTTP.responseText;
}

function XMLHttpstate_Change() {
    if (objXMLHTTP.readyState == 4) {
        if (objXMLHTTP.status == 200) {
        } else {
            //alert("Problem retrieving XML data")
        }
    }
}

function applyConvertedLogo(resptext) {
    var retval, a_retval, a_a_retval, newfname

    retval = resptext
    a_retval = retval.split("|")
    for (var i = 0; i < a_retval.length; i++) {
        if (a_retval[i].length > 0) {
            a_a_retval = a_retval[i].split(';')
            if (a_a_retval[0].toLowerCase() == "newfname") {
                newfname = a_a_retval[1]
                break;
            }
        }
    }

    yindex = getobjectno(flag_GraphicField)
    if (yindex != -1) {
        div_text[yindex] = newfname;
        changeImage(yindex, "none", newfname, newfname, '', 0);
    }
}

function hidetheobject(ydom) {
    if (ydom) {
        ydom.visibility = 'hidden'
        ydom.display = 'none'
    }
}
function showtheobject(ydom) {
    if (ydom) {
        ydom.visibility = 'visible'
        ydom.display = 'block'
    }
}

function isobjectvisible(ydom) {
    var xstate;
    xstate = ydom.visibility
    if ((xstate == zz_visible) || (xstate == zz_show)) return true;
    else return false;
}

function GetCurrentMarketingIndex() {
    var tindex = -1;
    if (document.preview.selection) {
        var tobj = document.preview.selection
        var tval = tobj.options[tobj.selectedIndex].value
        if (tval.length > 0) {
            tindex = getgroupdivno(tval)
        }
    }
    return tindex;
}

function ShowSpellWin() {
    var spellstr = "";
    var indexstr = "";
    var fieldstr = "";
    var xsep = "~" //"•"
    var xctr = 0
    if (document.preview.textentry1) {
        if (document.preview["textentry1"]) {
            if (trim_(document.preview["textentry1"].value).length > 0) {
                var tindex = CurrMXPIndex;
                if (tindex <= 0) {
                    alert("Text object not found.")
                    return;
                }
                if (CurrMXPIndex > 0) {
                    spellstr = spellstr + document.preview["textentry1"].value;
                    indexstr = indexstr + tindex;
                    fieldstr = "textentry1";
                }
            }
        }
    }
    else {
        for (i = 1; i <= 10; i++) {
            if (document.preview["textfield" + i]) {
                if (trim_(document.preview["textfield" + i].value).length > 0) {
                    xctr = xctr + 1
                    if (xctr == 1) {
                        spellstr = spellstr + document.preview["textfield" + i].value;
                        indexstr = indexstr + i;
                        fieldstr = "textfield" + i;
                    }
                    else {
                        spellstr = spellstr + xsep + document.preview["textfield" + i].value;
                        indexstr = indexstr + xsep + i;
                        fieldstr = fieldstr + xsep + "textfield" + i;
                    }
                }
            }
        }
    }
    spellstr = spellstr.split("'").join("\'");
    spellstr = spellstr.split("&nbsp;").join(" ");
    document.preview.spellstr.value = spellstr;
    document.preview.indexstr.value = indexstr;
    document.preview.fieldstr.value = fieldstr;

    document.preview.sep.value = xsep

    winspell = window.open("about:blank", "winspell", "width=370,height=260")
    document.preview.action = "CheckSpelling.asp"
    document.preview.target = "winspell"
    document.preview.submit()
}

function round_(ynum, ydec) {
    var xstr = "1";
    var xnum, xinter;
    for (k = 0; k < ydec; k++) {
        xstr = xstr + "0";
    }
    xnum = parseFloat(xstr);
    xinter = Math.round(ynum * xnum);
    return (xinter / xnum);
};

function trim_(ystr) {
    var xfound = false
    if (ystr.length == 0) return ""
    for (var k = 0; k < ystr.length; k++) {
        if (!xfound) {
            if (ystr.charAt(k) == " ") {} else {
                ystr = ystr.substring(k, ystr.length)
                xfound = true
                break
            }
        }
    }
    if (!xfound) ystr = ""

    xfound = false
    if (ystr.length == 0) return ""
    for (k = ystr.length - 1; k >= 0; k--) {
        if (!xfound) {
            if (ystr.charAt(k) == " ") {} else {
                ystr = ystr.substring(0, k + 1)
                xfound = true
                break
            }
        }
    }
    if (!xfound) ystr = ""
    return ystr
}

function SuffixZeros(ynum, ydec) {
    ynum = round_(ynum, ydec)
    ystr = ynum + ""
    if (ystr.indexOf(".") < 0) {
        ystr = ystr + "."
    }
    xpos = ystr.indexOf(".")
    xlen = ystr.length
    xst = xlen - xpos
    for (var k = xst; k <= ydec; k++) {
        ystr = ystr + "0"
    }
    return ystr;
}

function edit_design() {
    if (document.preview.chkEdit) {
        Flsh_Edit_Design(document.preview.chkEdit.checked)
    }
}

function GetOffsets() {
    var xdom = document.getElementById(zz_background)
    x_offset = xdom["offsetLeft"] - self.document.body.scrollLeft
    y_offset = xdom["offsetTop"] - self.document.body.scrollTop
}

function takeAction(ival) {
    var dispzoomper, urlstr
    if (flag_Graphic_QualitySensor) {
        if (!VerifyImageResolution()) {
            return;
        }
    }
    xprintlocally = '0';
    if (currobj.PrintLocally) {
        if (currobj.PrintLocally.value.length > 0) {
            xprintlocally = currobj.PrintLocally.value
        }
    }
    if (ival == 'Proof' || ival == 'SaveDesign') {
        if (flag_Preview_Image_Size.indexOf('%') >= 0) {
            dispzoomper = parseFloat(flag_Preview_Image_Size) / 100
        } 
        else {
            if (oback_width > oback_height) {
                dispzoomper = (parseFloat(flag_Preview_Image_Size) * 15 / oback_width)
            } 
            else {
                dispzoomper = (parseFloat(flag_Preview_Image_Size) * 15 / oback_height)
            }
        }

        SendVars(ival)

        window.open('about:blank', 'previewdesign', 'width=450,height=500,left=4000,top=4000,location=no,scrollbars=no')

        if (ival == 'SaveDesign') {
            urlstr = 'SaveDesignDetails.asp?designwidth=' + back_width + '&designheight=' + back_height + '&zoomper=' + dispzoomper
            urlstr = urlstr + '&currzoomper=' + xcurrzoomper + '&IE=4&formref=preview&compname=' + currobj.CompName.value
        } 
        else {
            urlstr = 'previewdesign.asp?designwidth=' + back_width + '&designheight=' + back_height + '&zoomper=' + dispzoomper
            urlstr = urlstr + '&currzoomper=' + xcurrzoomper + '&IE=4&formref=preview&compname=' + currobj.CompName.value
        }
        currobj.target = 'previewdesign';
        currobj.action = urlstr
        currobj.submit();
        currobj.target = '_self'
    }
    else if (ival == 'KPDF') {
        SendVars(ival)
        if (xprintlocally == '1') {
            urlstr = 'GenCalPDF.asp?designwidth=' + back_width + '&designheight=' + back_height + '&zoomper=' + xcurrzoomper + '&IE=4&formref=preview&compname=' + currobj.CompName.value + '&ShapeId=' + currobj.ShapeId.value + '&currside=' + currobj.currside.value + '&PrintLocally=' + xprintlocally
            currobj.target = '_self'
            currobj.action = urlstr
            currobj.submit();
        }
        else {
            window.open('GenCalPDF.asp?designwidth=' + back_width + '&designheight=' + back_height + '&zoomper=' + xcurrzoomper + '&IE=4&formref=preview&compname=' + currobj.CompName.value + '&ShapeId=' + currobj.ShapeId.value + '&currside=' + currobj.currside.value)
        }
    }
    else if (ival == 'PDF') {
        SendVars(ival)
        if (xprintlocally == '1') {
            urlstr = 'pagesetupY.asp?designwidth=' + back_width + '&designheight=' + back_height + '&zoomper=' + dispzoomper + '&currzoomper=' + xcurrzoomper + '&IE=4&formref=preview&compname=' + currobj.CompName.value + '&PrintLocally=' + xprintlocally
            currobj.target = '_self'
            currobj.action = urlstr
            currobj.submit();
        }
        else {

            if (xcatgid == '520' || xcatgid == '40' || xcatgid == '72') {
                var objwin = window.open('about:blank', 'previewdesign', 'width=675,height=400,location=no,scrollbars=no')
                objwin.focus()
                if (xcatgid == '520' && currobj.ssDesign) {
                    if (currobj.ssDesign.value.toUpperCase() == 'RRC' || currobj.ssDesign.value.toUpperCase() == 'RRS' || currobj.ssDesign.value.toUpperCase() == 'RWS' || currobj.ssDesign.value.toUpperCase() == 'RWC') {
                        urlstr = 'AssetTagPDF.aspx?designwidth=' + back_width + '&designheight=' + back_height + '&zoomper=' + dispzoomper
                        urlstr = urlstr + '&currzoomper=' + xcurrzoomper + '&IE=4&formref=preview&compname=' + currobj.CompName.value
                    } else {
                        urlstr = 'PDFPrintHelp.asp?designwidth=' + back_width + '&designheight=' + back_height + '&zoomper=' + dispzoomper
                        urlstr = urlstr + '&currzoomper=' + xcurrzoomper + '&IE=4&formref=preview&compname=' + currobj.CompName.value
                    }
                } else {
                    urlstr = 'PDFPrintHelp.asp?designwidth=' + back_width + '&designheight=' + back_height + '&zoomper=' + dispzoomper
                    urlstr = urlstr + '&currzoomper=' + xcurrzoomper + '&IE=4&formref=preview&compname=' + currobj.CompName.value
                }

                currobj.target = 'previewdesign';
            } else if (xcatgid == '117') {
                window.open('about:blank', 'previewdesign', 'width=675,height=400,location=no,scrollbars=no')
                urlstr = 'AssetTagPDF.aspx?designwidth=' + back_width + '&designheight=' + back_height + '&zoomper=' + dispzoomper
                urlstr = urlstr + '&currzoomper=' + xcurrzoomper + '&IE=4&formref=preview&compname=' + currobj.CompName.value
                currobj.target = 'previewdesign';
            } else {
                window.open('about:blank', 'previewdesign', 'width=450,height=500,left=4000,top=4000,location=no,scrollbars=no')
                urlstr = 'PreviewPDF.asp?designwidth=' + back_width + '&designheight=' + back_height + '&zoomper=' + dispzoomper
                urlstr = urlstr + '&currzoomper=' + xcurrzoomper + '&IE=4&formref=preview&compname=' + currobj.CompName.value
                currobj.target = 'previewdesign';
            }
            currobj.action = urlstr
            currobj.submit();

            currobj.target = '_self'

        }
    }
    else if (ival == 'VPDF') {
        SendVars(ival)
        if (xprintlocally == '1') {
            urlstr = 'pagesetupY.asp?designwidth=' + back_width + '&designheight=' + back_height + '&zoomper=' + dispzoomper + '&currzoomper=' + xcurrzoomper + '&IE=4&formref=preview&compname=' + currobj.CompName.value + '&PrintLocally=' + xprintlocally
            currobj.target = '_self'
            currobj.action = urlstr
            currobj.submit();
        }
        else {
            window.open('pagesetupY.asp?designwidth=' + back_width + '&designheight=' + back_height + '&zoomper=' + dispzoomper + '&currzoomper=' + xcurrzoomper + '&IE=4&formref=preview&compname=' + currobj.CompName.value)
        }
    }
    else if (ival == 'MULTIPLEPDF') {
        tqty = 0
        field_list = ""
        qty_list = ""
        for (var k = 1; k < num_divs; k++) {
            if (div_contents[k]) {
                if (div_contents[k].indexOf('label') >= 0) {
                    if (currobj["Qty" + k]) {
                        if (currobj["Qty" + k].value > 0) {
                            if (currobj["textfield" + k]) {
                                if (trim_(currobj["textfield" + k].value).length > 0) {
                                    tqty = tqty + parseInt(currobj["Qty" + k].value)
                                    if (field_list.length > 0) {
                                        field_list = field_list + ";"
                                        qty_list = qty_list + ";"
                                    }
                                    field_list = field_list + div_fields[k]
                                    qty_list = qty_list + currobj["Qty" + k].value
                                }
                            }
                        }
                    }
                }
            }
        }
        if (tqty <= 0) {
            alert("Nothing to print.")
            return;
        }
        currobj.Qty.value = tqty
        currobj.Field_List.value = field_list
        currobj.Qty_List.value = qty_list

        SendVars(ival)

        window.open('about:blank', 'pdfwin', 'width=450,height=500,left=4000,top=4000,location=no,scrollbars=yes,resizable')
        urlstr = 'pagesetupPDF_Multiple.asp?designwidth=' + back_width + '&designheight=' + back_height + '&zoomper=' + dispzoomper + '&currzoomper=' + xcurrzoomper + '&IE=4&formref=preview&compname=' + currobj.CompName.value + '&ShapeId=' + currobj.ShapeId.value + '&currside=' + currobj.currside.value

        currobj.target = 'pdfwin';
        currobj.action = urlstr
        currobj.submit();

        currobj.target = '_self'
    } else if (ival == 'SaveTemplate') {
        SendVars(ival)
        window.open('savegroups.asp?designwidth=' + back_width + '&designheight=' + back_height + '&zoomper=' + xcurrzoomper + '&IE=4&formref=preview&compname=' + currobj.CompName.value)
    }
}

var req;
function getPreviewImage(dispzoomper, xcurrzoomper) {
    var zoomper = dispzoomper;
    var currzoomper = xcurrzoomper;
    var dspecs = document.preview.dspecs.value;

    if (typeof XMLHttpRequest != "undefined") {
        req = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
    }
    req.open('POST', 'PreviewMozilla.asp', false);
    req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    req.send('zoomper=' + encodeURIComponent(zoomper) + '&currzoomper=' + encodeURIComponent(currzoomper) + '&dspecs=' + encodeURIComponent(dspecs));

    if (req.status == 200) {

        var aResult = req.responseText.split('&')
        var atmp = aResult[0].split('=')
        document.getElementById("divrefresh").innerHTML = "<img src='/xp/images/space.gif' id='nonieimage', name='nonieimage'>"

        document.images.nonieimage.src = '/xp2/template_images/' + atmp[1]

        atmp = aResult[2].split('=')
        if (atmp[1].length > 0) {
            var asizestr, aasizestr
            asizestr = atmp[1].split('|')
            for (var j = 0; j < asizestr.length - 1; j++) {
                aasizestr = asizestr[j].split(';')
                div_size[aasizestr[0]] = aasizestr[1]
            }

        }
    }
}

function waitmessage() {
    var m

    m = '<TABLE WIDTH=' + document.images.nonieimage.width + ' BORDER=0 CELLPADDING=1 CELLSPACING=0 BGCOLOR="#000000">'
    m = m + '<TR>'
    m = m + '	<TD><img src="/xp/images/space.gif" width=1 height=' + document.images.nonieimage.height + '></TD>'
    m = m + '	<TD>'
    m = m + '		<TABLE WIDTH=100% BORDER=0 CELLPADDING=1 CELLSPACING=0 BGCOLOR="#FFFFFF">'
    m = m + '			<TR>'
    m = m + '				<TD width="80%" VALIGN=TOP BGCOLOR="#000000"><FONT COLOR="#FFFFFF" FACE="Verdana,Arial,Helvetica" SIZE="2"><b>Refreshing</b></FONT></TD>'
    m = m + '			</TR>'
    m = m + '			<TR>'
    m = m + '				<TD VALIGN=TOP><FONT COLOR="#000000" FACE="Verdana,Arial,Helvetica" SIZE="2">Please wait...</FONT></TD>'
    m = m + '			</TR>'
    m = m + '		</TABLE>'
    m = m + '	</TD>'
    m = m + '</TR>'
    m = m + '</TABLE>'
    return m
}

function GetDesignName(custid) {

    GenerateNVP()
    SendVars()

    if (currobj.currside) {
        if (currobj.currside.value == 0) {
            currobj.dspecsF.value = currobj.dspecs.value
        } else if (currobj.currside.value == 1) {
            currobj.dspecsB.value = currobj.dspecs.value
        }
    }

    if (flag_SaveDesign_SeedField.length <= 0) {
        flag_SaveDesign_SeedField = "textline1"
    }

    if (designname == '') {
        yindex = getobjectno(flag_SaveDesign_SeedField)
        if (yindex != -1) {
            designname = div_text[yindex]
            designname = unescape(escape(designname).split("%0D%0A").join(" "))
        } else {
            for (var i = 1; i < num_divs; i++) {
                if (div_contents[i] == "label" || div_contents[i] == "plabel") {
                    if (div_text[i].length > 0) {

                        if (div_group[i]) {
                            if (div_group[i].indexOf("-0") < 0) {

                                designname = div_text[i];
                                designname = unescape(escape(designname).split("%0D%0A").join(" "));
                                break;

                            }
                        }

                    }
                }
            }

        }
    }

    currobj.designname.value = designname
    window.open('about:blank', 'savedesign', 'width=450,height=500,left=4000,top=4000,location=no,scrollbars=no');
    currobj.target = 'savedesign';
    currobj.action = 'getdesignname.asp';
    currobj.submit();
    currobj.target = '_self'

}

function GenerateNVP() {
    var afldcollection = new Array("catgid", "SubCatgId", "wizardid", "templateH", "templateW", "templateXML", "openwith", "ProductHeading", "SplHelpID", "designname", "productname", "signtype", "signtypelong", "signsize_desc", "signcolor", "clrcode", "FlagBackImage", "trafficsignshape", "fversion", "vendor", "PrintColors", "Image", "ShapeId", "InitConcode", "EnvCode", "VerseImageName", "numcolor", "idblogo", "idbbarcode", "idbback", "idbmag", "Theme", "Orientation", "DBID", "AdderQualifier", "chkborder", "group", "qualifier", "GroupId", "headertype", "htagtype", "htagsize", "numbering_prefix", "numbering_start", "numbering_suffix", "numbering_numdigits", "productgroup", "LogoColorFlag", "tabstyle", "tabcuts", "tabstartpos", "radartwork", "perforation", "numcount", "ffstartnumber", "ffminlength", "ffprefix", "ffsuffix", "ssSKU", "ssDesign", "ssOrientation", "ssSizeCode", "ssW", "ssH", "ssColors")

    if (xcatgid == "118" || xcatgid == "119" || xcatgid == "120" || xcatgid == "121") {
        for (i = 1; i < num_divs; i++) {
            if (div_contents[i] == "label" || div_contents[i] == "plabel") {
                tctr = afldcollection.length
                afldcollection[tctr] = 'Qty' + i
                afldcollection[tctr + 1] = 'color' + i
            }
        }
    }
    var xfieldnames = ""
    var xfieldvalues = ""
    var xctr = 0;

    for (var k = 0; k < afldcollection.length; k++) {
        if (document.preview[afldcollection[k]]) {
            if (k > 0) {
                xfieldnames = xfieldnames + "¨"
                xfieldvalues = xfieldvalues + "¨"
            }
            xfieldnames = xfieldnames + afldcollection[k]
            if (document.preview[afldcollection[k]]) {
                xfieldvalues = xfieldvalues + trim_(document.preview[afldcollection[k]].value)
            }
            else {
                xfieldvalues = xfieldvalues + ""
            }
        }
    }

    if (currobj.iPricePK) {
        xfieldnames = xfieldnames + "¨" + "StampiPricePK"
        xfieldvalues = xfieldvalues + "¨" + currobj.iPricePK.value

    }

    if (currobj.ffnonumber) {
        if (currobj.ffnonumber.checked == true) {
            xfieldnames = xfieldnames + "¨" + "ffnonumber"
            xfieldvalues = xfieldvalues + "¨" + currobj.ffnonumber.value
        }
    }

    if (currobj.ffpadtype) {
        if (currobj.ffpadtype.checked == true) {
            xfieldnames = xfieldnames + "¨" + "ffpadtype"
            xfieldvalues = xfieldvalues + "¨" + currobj.ffpadtype.value
        }
    }

    if (currobj.numbering_padding) {
        for (var i = 0; i < currobj.numbering_padding.length; i++) {
            if (currobj.numbering_padding[i].checked == true) {
                xfieldnames = xfieldnames + "¨" + "numbering_padding"
                xfieldvalues = xfieldvalues + "¨" + currobj.numbering_padding[i].value
                break
            }
        }
    }

    if (currobj.numbering_type) {
        for (var i = 0; i < currobj.numbering_type.length; i++) {
            if (currobj.numbering_type[i].checked == true) {
                xfieldnames = xfieldnames + "¨" + "numbering_type"
                xfieldvalues = xfieldvalues + "¨" + currobj.numbering_type[i].value
                break
            }
        }
    }

    if (currobj.numbering_font) {
        for (var i = 0; i < currobj.numbering_font.length; i++) {
            if (currobj.numbering_font[i].selected == true) {
                xfieldnames = xfieldnames + "¨" + "numbering_font"
                xfieldvalues = xfieldvalues + "¨" + currobj.numbering_font[i].value
                break
            }
        }
    }

    if (currobj.catgid.value == 40 && currobj.SubCatgId.value.toLowerCase() != 'parking3') {
        if (currobj.signborder) {
            if (currobj.signborder[0].checked == true) {
                xfieldnames = xfieldnames + "¨" + "parksign_border"
                xfieldvalues = xfieldvalues + "¨" + "true"
            } else {
                xfieldnames = xfieldnames + "¨" + "parksign_border"
                xfieldvalues = xfieldvalues + "¨" + "false"
            }
        }

        if (currobj.arrow) {
            for (var i = 0; i < currobj.arrow.length; i++) {
                if (currobj.arrow[i].checked == true) {
                    xfieldnames = xfieldnames + "¨" + "parksign_arrow"
                    xfieldvalues = xfieldvalues + "¨" + i
                    break
                }
            }
        }

    }

    document.preview.savefieldnames.value = xfieldnames
    document.preview.savefieldvalues.value = xfieldvalues
}

function GetColorCount() {
    var tctr = 0;
    for (var k = 1; k <= 4; k++) {
        if (currobj["hcolorno" + k].value.length > 0) {
            if (!AlreadyCounted(k)) {
                tctr++;
            }
        }
    }
    if (colorsallowed > tctr) {
        tctr = colorsallowed
    }

    return tctr;
}

function AlreadyCounted(k) {
    var thexcolor = currobj["hcolorno" + k].value.toUpperCase()
    xcounted = false
    if (k > 1) {
        for (var j = 1; j < k; j++) {
            if (currobj["hcolorno" + j].value.toUpperCase() == thexcolor) {
                xcounted = true
                break;
            }
        }
    }
    return xcounted;
}

function ApplyRecord(xdatanames, xdatavalues) {
    var a_datanames = xdatanames.split('~')
    var a_datavalues = xdatavalues.split('~')

    for (var i = 1; i < num_divs; i++) {
        if (div_contents[i] == "label" || div_contents[i] == "plabel") {
            if (div_fields[i]) {
                if (div_fields[i].length > 0) {
                    if (document.preview["textfield" + i]) {
                        div_text[i] = GetDataValue(i, div_fields[i], a_datanames, a_datavalues)
                        document.preview["textfield" + i].value = div_text[i]
                        changeText(div_text[i], i)

                    }
                }
            }
        }
    }
}

function GetDataValue(yindex, yfield, y_datanames, y_datavalues) {
    var xvalue = div_text[yindex]
    for (var m = 0; m < y_datanames.length; m++) {
        if (y_datanames[m].toUpperCase() == yfield.toUpperCase()) {
            xvalue = y_datavalues[m]
            if (flag_Text_ClearOnFocus) {
                SetTextfieldProperties(yindex, true)
            }
        }
    }
    return xvalue;
}

function SetDataFieldValues() {
    var xfieldnames = '',
    xfieldvalues = '';
    for (var i = 1; i < num_divs; i++) {
        if (div_contents[i] == "label" || div_contents[i] == "plabel") {
            if (document.preview["textfield" + i]) {
                if (xfieldnames.length > 0) {
                    xfieldnames = xfieldnames + "~"
                    xfieldvalues = xfieldvalues + "~"
                }
                xfieldnames = xfieldnames + div_fields[i];
                xfieldvalues = xfieldvalues + document.preview["textfield" + i].value;
            }
        }
    }
    if (document.preview) {
        if (document.preview.DataFieldNames) {
            document.preview.DataFieldNames.value = xfieldnames
            document.preview.DataFieldValues.value = xfieldvalues
        }
    }
}

function SetNumColors() {
    if (currobj.selnumcolor) {
        var tUsedColors = CalcColorsUsed()
        var tSelNumColor = tUsedColors
        tSelNumColor = currobj.selnumcolor.value
        if (tSelNumColor > tUsedColors) {
            currobj.numcolor.value = tSelNumColor
        }
        else {
            currobj.numcolor.value = tUsedColors
        }
    }
}

function SendVars(yType) {
    SendVarsFull(yType)
}

function storeArrays(xdestarray, xarrayname) {
    xdestarray.length = 0
    for (var i = 1; i < xarrayname.length; i++) {
        xdestarray[i] = xarrayname[i]
    }
}

function showHelpDiv(helphdg, helpstr, x, y, yhcolor, ytcolor) {
    var helpstr1 = "",
    helpstr2 = "",
    tmpstr = ""

    helpstr1 = '	<TABLE WIDTH=200 BORDER=0 CELLPADDING=1 CELLSPACING=0 BGCOLOR="' + yhcolor + '">'
    helpstr1 = helpstr1 + '<TR>'
    helpstr1 = helpstr1 + '			<TD>'
    helpstr1 = helpstr1 + '				<TABLE WIDTH=100% BORDER=0 CELLPADDING=1 CELLSPACING=0 BGCOLOR="' + ytcolor + '">'
    helpstr1 = helpstr1 + '					<TR>'
    helpstr1 = helpstr1 + '						<TD witdth="80%" VALIGN=TOP BGCOLOR=' + yhcolor + '><FONT COLOR="#FFFFFF" FACE="Verdana,Arial,Helvetica" SIZE="1"><b>' + helphdg + '</b></FONT></TD>'
    helpstr1 = helpstr1 + '						<TD align="right" VALIGN=TOP height=10 BGCOLOR=' + yhcolor + '><FONT class="body8" COLOR="#FFFFFF"><a href="javascript:hideHelp()">Close</a></FONT></TD>'
    helpstr1 = helpstr1 + '					</TR>'

    helpstr1 = helpstr1 + '					<TR>'
    helpstr1 = helpstr1 + '						<TD VALIGN=TOP colspan="2">'
    helpstr1 = helpstr1 + '							<FONT COLOR="#000000" FACE="Verdana,Arial,Helvetica" SIZE="1">'

    helpstr2 = '									</FONT>'
    helpstr2 = helpstr2 + '						</TD>'
    helpstr2 = helpstr2 + '					</TR>'
    helpstr2 = helpstr2 + '				</TABLE>'
    helpstr2 = helpstr2 + '			</TD>'
    helpstr2 = helpstr2 + '		</TR>'
    helpstr2 = helpstr2 + '	</TABLE>'

    if (ns4dom) {
        document.layers.helpdiv.moveTo(x, y)
        document.layers.helpdiv.visibility = "show"
    } else {
        document.getElementById("helpdiv").style.top = x
        document.getElementById("helpdiv").style.left = y
        document.getElementById("helpdiv").style["visibility"] = "visible"
    }
    if (ns4dom) {
        tmpstr = helpstr1 + helpstr + helpstr2
        document.layers["helpdiv"].document.open()
        document.layers["helpdiv"].document.write(tmpstr)
        document.layers["helpdiv"].document.close()
    } else {
        tmpstr = helpstr1 + helpstr + helpstr2
        document.getElementById("helpdiv").innerHTML = tmpstr
    }
}

thelphide = null
function hideHelp() {
    GetElement("helpdiv").style["visibility"] = "hidden"
}

function callHideHelpDiv() {
    if (thelphide != null) clearTimeout(thelphide);
    thelphide = setTimeout('hideHelp()', 7000)
}

function clearHelpDiv() {
    if (thelphide != null) clearTimeout(thelphide);
    hideHelp()
}

function ChangeInkColor(tColor, tColorType) {
    for (var i = 1; i < num_divs; i++) {
        if (div_color[i]) {
            if (div_color[i] > 0) {
                if (div_fields[i]) {
                    if (div_fields[i].toLowerCase().indexOf('code') >= 0 || div_fields[i].toLowerCase().indexOf('number') >= 0) {
                        //do not convert barcode color, it should always remain black
                    }
                    else {
                        var xallowit = true
                        if (div_group[i]) {
                            if (div_group[i].indexOf('-0') > 0) {
                                xallowit = false
                            }
                        }
                        if (xallowit) {
                            div_color_hex[i] = tColor
                            currobj['hcolorno' + div_color[i]].value = tColor.split('#').join('')
                        }
                    }
                }
                else if (div_contents[i].indexOf('rectangle') >= 0) {
                    div_color_hex[i] = tColor
                }
            }
        }

    }
    for (var i = 1; i < num_divs; i++) {
        if (div_bgcolor[i]) {
            if (div_bgcolor[i] > 0) {
                if (div_bgcolor[i] == div_color[i] || div_color[i] == "0") { 
                    div_bgcolor_hex[i] = tColor
                    currobj['hcolorno' + div_bgcolor[i]].value = tColor.split('#').join('')
                }
            }
        }
    }
    if (bkoutline_weight > 0) {
        if (GetElement(background)) {
            GetElement(background).style.borderColor = tColor
        }
        if (GetElement(["Cell_Bg_OutlineColor"])) {
            GetElement(["Cell_Bg_OutlineColor"]).bgColor = tColor
        }
    }
    yindex = getobjectno(flag_GraphicField)
    if (yindex > 0) {
        //vaibhav condition added to del image object
        if (div_text[yindex] != "" ){
			if (div_text[yindex].toLowerCase().indexOf('null.gif') < 0) {
				ChangeLogoColor(yindex, tColor)
				div_transcolor[yindex] = "#" + xtranscolor.split('#').join('')
				div_imagecolor[yindex] = "#" + tColor.split('#').join('')
			}
		}
	}

    Flash_Update_RectAndTextObjColors()
}

function GenAppendString() {
    xcounter++;
    if (xcounter < 10) xappendstr = "000" + xcounter;
    else if (xcounter < 100) xappendstr = "00" + xcounter;
    else if (xcounter < 1000) xappendstr = "0" + xcounter;
    else if (xcounter < 10000) xappendstr = "" + xcounter;
}

function setCookie_(name, value, expires, path, domain, secure) {
    var curCookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path: "") + ((domain) ? "; domain=" + domain: "") + ((secure) ? "; secure": "")
    if ((name + "=" + escape(value)).length <= 4000) {
        document.cookie = curCookie
    }
    else {
        document.cookie = curCookie

    }
}

function getCookie_(name) {
    var prefix = name + "="
    var cookieStartIndex = document.cookie.indexOf(prefix)
    if (cookieStartIndex < 0) {
        return '';
    }

    var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length)
    if (cookieEndIndex < 0) {
        cookieEndIndex = document.cookie.length
    }
    return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex))
}

function CenterThisWindow(xwidth, xheight, xpercent) {
    if (xpercent) {
        xwidth = screen.width * xpercent * 0.01
        xheight = screen.height * xpercent * 0.01
    }
    var xleft = (screen.width - xwidth) / 2;
    var xtop = (screen.height - xheight) / 2;
    return 'left=' + xleft + ', top=' + xtop + ', width=' + xwidth + ', height=' + xheight;
}

function attachseprator(ystr, yseprator) {
    ystr = trim_(ystr)
    while (ystr.indexOf("  ") >= 0) {
        ystr = ystr.split("  ").join(yseprator)
    }
    while (ystr.indexOf(yseprator + yseprator) >= 0) {
        ystr = ystr.split(yseprator + yseprator).join(yseprator)
    }
    return ystr
}

function pulloutfield(ystr, yseprator) {
    var k;
    var a_line = new Array();
    var xposition;
    ystr = ystr.toString();
    xposition = ystr.indexOf(yseprator)
    k = 0;
    while ((xposition = ystr.indexOf(yseprator)) >= 0) {
        a_line[k] = ystr.substring(0, xposition)
        ystr = ystr.substring(xposition + 1, ystr.length)
        k++;
    }
    ystr = trim_(ystr)
    if (ystr.length > 0) {
        a_line[k] = ystr
    }
    return a_line;
}

var a_cleared = new Array()
function ClearSeedText(yobj, yindex) {
    if (flag_Text_ClearOnFocus) {
        if (!a_cleared[yindex]) {
            SetTextfieldProperties(yindex, true)
            yobj.value = ""
            div_text[yindex] = ""
            changeText(div_text[yindex], yindex)
        }
    }
}

function IfStockBgImageExists() {
    var xImageExists = false
    if (flag_StockBgImage) {
        if (flag_StockBgImage_Field.length > 0) {
            for (var k = 1; k < num_divs; k++) {
                if (div_contents[k]) {
                    if (div_contents[k].indexOf("image") >= 0) {
                        if (div_fields[k].toUpperCase() == flag_StockBgImage_Field) {
                            xImageExists = true
                            break;
                        }
                    }
                }
            }
        }
    }
    return xImageExists;
}

function IfPhotoImageExists() {
    var xImageExists = false
    if (flag_PhotoImage) {
        if (flag_PhotoImage_Field.length > 0) {
            for (var k = 1; k < num_divs; k++) {
                if (div_contents[k]) {
                    if (div_contents[k].indexOf("image") >= 0) {
                        if (div_fields[k].toUpperCase() == flag_PhotoImage_Field) {
                            xImageExists = true
                            break;
                        }
                    }
                }
            }
        }
    }
    return xImageExists;
}

function IfBarcodeExists() {
    var xBarcodeExists = false
    if (flag_BarCode) {
        if (flag_BCField.length > 0) {
            for (var k = 1; k < num_divs; k++) {
                if (div_contents[k]) {
                    if (div_contents[k].indexOf("label") >= 0) {
                        if (div_fields[k].toUpperCase() == flag_BCField) {
                            xBarcodeExists = true
                            break;
                        }
                    }
                }
            }
        }
    }
    return xBarcodeExists;
}

function TB_changeColor(colorno) {
    if (typeof(curr_yindex) == "undefined") {
        alert('Please select text first')
    } else {
        changeColor(colorno, curr_yindex)
    }
}

function TB_callChangeFontStyle(fontstyle) {
    if (typeof(curr_yindex) == "undefined") {
        alert('Please select text first')
    } else {
        callChangeFontStyle(fontstyle, curr_yindex)
    }
}

function TB_changeAlignment(alignmenttype) {
    if (typeof(curr_yindex) == "undefined") {
        alert('Please select text first')
    } else {
        changeAlignment(curr_yindex, alignmenttype)
    }
}

function TB_increaseLineSpacing() {
    if (typeof(curr_yindex) == "undefined") {
        alert('Please select text first')
    } else {
        increaseLineSpacing(curr_yindex)
    }
}

function TB_decreaseLineSpacing() {
    if (typeof(curr_yindex) == "undefined") {
        alert('Please select text first')
    } else {
        decreaseLineSpacing(curr_yindex)
    }
}

function TB_ShowHideRule(currobj) {
    if (typeof(curr_yindex) == "undefined") {
        alert('Please select text first')
    } else {
        ShowHideRule(curr_yindex, currobj)
    }
}

function TB_changeThisFont(currobj) {
    if (typeof(curr_yindex) == "undefined") {
        alert('Please select text first')
    } else {
        changeThisFont(currobj, curr_yindex)
    }
}

function tool_barInit(yindex) {
    if (flag_Text_Toolbar == 3) {
        if (typeof(curr_yindex) != "undefined") {
            document.images['TB_selimg' + curr_yindex].src = "/xp/images/space.gif"
        }
        curr_yindex = yindex
        document.images['TB_selimg' + curr_yindex].src = "/xp/images/arrowfirst.gif"

        TB_setFont(yindex)

        if (flag_Text_Rule) {
            if (currobj.cb_ruletext) {
                if (div_rule[yindex] == true) {
                    currobj.cb_ruletext.checked = true;
                }
                else {
                    currobj.cb_ruletext.checked = false;
                }
            }
        }

        GetElement('TB_ImgFontsize').useMap = '#MapFontsize' + yindex;
    }
    else if (flag_Text_Toolbar == 4) {
        var tflag = true
        if (typeof(curr_yindex) != "undefined") {
            if (document.images['TB_selimg' + curr_yindex]) {
                document.images['TB_selimg' + curr_yindex].src = "/xp/images/space.gif"
            }
        }
        else {
            tflag = false
        }
        curr_yindex = yindex
        if (document.images['TB_selimg' + curr_yindex]) {
            document.images['TB_selimg' + curr_yindex].src = "/xp/images/arrowfirst.gif"
        }
        if (!tflag) {
            TB_setFont(yindex)
        }

        GetElement('TB_ImgFontsize_' + yindex).useMap = '#MapFontsize' + yindex;
    }

}

function TB_setFont(yindex) {
    var yfontvalue
    yfontvalue = div_font[curr_yindex]
    if (flag_Text_Toolbar == 3) {
        if (currobj.list_toolbar_font) {
            if (yfontvalue.length > 0 && currobj.list_toolbar_font.options.length > 0) {
                for (var k = 0; k < currobj.list_toolbar_font.options.length; k++) {
                    if (currobj.list_toolbar_font.options[k].value.toLowerCase() == yfontvalue.toLowerCase()) {
                        currobj.list_toolbar_font.options.selectedIndex = k;
                        break;
                    }
                }
            }
        }
    }
    else if (flag_Text_Toolbar == 4) {
        if (currobj["list_toolbar_font_" + yindex]) {
            if (yfontvalue.length > 0 && currobj["list_toolbar_font_" + yindex].options.length > 0) {
                for (var k = 0; k < currobj["list_toolbar_font_" + yindex].options.length; k++) {
                    if (currobj["list_toolbar_font_" + yindex].options[k].value.toLowerCase() == yfontvalue.toLowerCase()) {
                        currobj["list_toolbar_font_" + yindex].options.selectedIndex = k;
                        break;
                    }
                }
            }
        }
    }
}

function changeColor_FromTB(RGBVal, ColorName) {
    var xusedcolors, k, i, colorsallowed

    colorsallowed = xnumcolor
    xusedcolors = ""

    if (typeof(curr_yindex) == "undefined") {

        alert('Please select text first')

    } else {

        xusedcolors = ""
        for (var k = 1; k < num_divs; k++) {
            if (k != curr_yindex) {
                if (div_contents[k]) {
                    if (div_contents[k].indexOf('label') >= 0) {
                        if (div_color[k]) {
                            xusedcolors = getColorsused(k, div_color[k], xusedcolors)
                        }
                    }
                    else if (div_contents[k].indexOf('rectangle') >= 0) {
                        if (div_color[k]) {
                            xusedcolors = getColorsused(k, div_color[k], xusedcolors)
                        }
                        if (div_bgcolor[k]) {
                            xusedcolors = getColorsused(k, div_bgcolor[k], xusedcolors)
                        }
                    }
                }
            }
        }
    }

    a_usedcolors = xusedcolors.split(',')
    xTotalUsedColors = a_usedcolors.length

    if (xusedcolors.indexOf(div_color[curr_yindex]) >= 0) { 
        for (var k = 1; k <= colorsallowed; k++) {
            if (xusedcolors.indexOf(k) < 0) {
                break;
            }
        }
    } else {
        k = div_color[curr_yindex]
    }

    for (var i = 1; i <= colorsallowed; i++) {
        if (currobj["hcolorno" + i].value == RGBVal) {
            k = i
            break;
        }
    }

    if (k > colorsallowed) {
        k = div_color[curr_yindex]
    }

    currobj["hcolorno" + k].value = RGBVal
    currobj["hcolorname" + k].value = ColorName

    div_color[curr_yindex] = k
    div_color_hex[curr_yindex] = "#" + currobj["hcolorno" + k].value

    for (var i = 1; i < num_divs; i++) {
        if (div_color[i]) {
            if (div_color[i] == k) {
                div_color[i] = k
                div_color_hex[i] = "#" + currobj["hcolorno" + k].value
            }
        }

        if (div_bgcolor[i]) {
            if (div_bgcolor[i] == k) {
                div_bgcolor[i] = k
                div_bgcolor_hex[i] = "#" + currobj["hcolorno" + k].value
            }
        }

    }

    Flash_UpdateFlashObjects()

    TB_countColorsUsed()

    return
}

function TB_countColorsUsed() {
    var xusedcolors, a_usedcolors, xTotalUsedColors

    xusedcolors = ""
    for (var k = 1; k < num_divs; k++) {
        if (div_contents[k]) {
            if (div_contents[k].indexOf('label') >= 0) {
                if (div_color[k]) {
                    xusedcolors = TB_getColorsused(k, div_color[k], xusedcolors)
                }
            }
            else if (div_contents[k].indexOf('rectangle') >= 0) {
                if (div_color[k]) {
                    xusedcolors = TB_getColorsused(k, div_color[k], xusedcolors)
                }
                if (div_bgcolor[k]) {
                    xusedcolors = TB_getColorsused(k, div_bgcolor[k], xusedcolors)
                }
            }
        }
    }

    a_usedcolors = xusedcolors.split(',')
    xTotalUsedColors = a_usedcolors.length

    document.preview.usedcolors.value = xTotalUsedColors

    return xusedcolors
}

function TB_getColorsused(k, ycolor, xusedcolors) {
    var checkcolor = true

    if (div_group[k]) {
        if (div_text[k].length <= 0 || div_group[k].indexOf("-0") >= 0 || div_fields[k].toUpperCase().indexOf("SPACE") >= 0) {
            checkcolor = false
        }
    }

    if (checkcolor) {
        if (ycolor != 0) {
            if (xusedcolors.indexOf(ycolor) < 0) {
                if (xusedcolors.length > 0) {
                    xusedcolors = xusedcolors + ","
                }
                xusedcolors = xusedcolors + ycolor
            }
        }
    }
    return xusedcolors;
}

function getColorsused(k, ycolor, xusedcolors) {
    var checkcolor = true

    if (div_group[k]) {
        if (div_group[k].indexOf("-0") >= 0 || div_fields[k].toUpperCase().indexOf("SPACE") >= 0) {
            checkcolor = false
        }
    }

    if (checkcolor) {
        if (ycolor != 0) {
            if (xusedcolors.indexOf(ycolor) < 0) {
                if (xusedcolors.length > 0) {
                    xusedcolors = xusedcolors + ","
                }
                xusedcolors = xusedcolors + ycolor
            }
        }
    }
    return xusedcolors;
}

function getCurrTextColorNo() {}

function getNextfreeColorNo() {}

function GetElement(yid) {
    return document.getElementById(yid);
}

function GetOpenerElement(yid) {
    return opener.document.getElementById(yid);
}

function DoNothing(yindex) {}

function fixPngDisplay() {

    var arVersion = navigator.appVersion.split("MSIE")
    var version = parseFloat(arVersion[1])

    if ((version >= 5.5 && version < 7) && (document.body.filters)) {
        for (var i = 0; i < document.images.length; i++) {
            var img = document.images[i]
            var imgName = img.src.toUpperCase()
            if (imgName.substring(imgName.length - 3, imgName.length) == "PNG") {
                var imgID = (img.id) ? "id='" + img.id + "' ": ""
                var imgClass = (img.className) ? "class='" + img.className + "' ": ""
                var imgTitle = (img.title) ? "title='" + img.title + "' ": "title='" + img.alt + "' "
                var imgStyle = "display:inline-block;" + img.style.cssText
                if (img.align == "left") imgStyle = "float:left;" + imgStyle
                if (img.align == "right") imgStyle = "float:right;" + imgStyle
                if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
                var strNewHTML = "<span " + imgID + imgClass + imgTitle + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";" + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader" + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
                img.outerHTML = strNewHTML
                i = i - 1
            }
        }
    }
}

function setMaxLength(obj, offset) {
    currobj[obj].maxLength = currobj[obj].maxLength + offset
}

function SendVarsFull(yType) {

    SetDataFieldValues()

    var xdom, i, xco, yco, specs
    var icolor0, icolor1, icolor2, icolor3, icolor4
    var txtcolor0, txtcolor1, txtcolor2, txtcolor3, txtcolor4

    colorsallowed = GetColorCount()
    if (colorsallowed >= 1) {
        icolor1 = HextoDec(currobj.hcolorno1.value.substring(4, 6) + currobj.hcolorno1.value.substring(2, 4) + currobj.hcolorno1.value.substring(0, 2))
        icolor2 = -1;
        icolor3 = -1;
        icolor4 = -1
        txtcolor1 = currobj.hcolorname1.value;
        txtcolor2 = "";
        txtcolor3 = "";
        txtcolor4 = ""
    }

    if (colorsallowed >= 2) {
        icolor2 = HextoDec(currobj.hcolorno2.value.substring(4, 6) + currobj.hcolorno2.value.substring(2, 4) + currobj.hcolorno2.value.substring(0, 2))
        icolor3 = -1;
        icolor4 = -1
        txtcolor2 = currobj.hcolorname2.value;
        txtcolor3 = "";
        txtcolor4 = ""
    }

    if (colorsallowed >= 3) {
        icolor3 = HextoDec(currobj.hcolorno3.value.substring(4, 6) + currobj.hcolorno3.value.substring(2, 4) + currobj.hcolorno3.value.substring(0, 2))
        icolor4 = -1
        txtcolor3 = currobj.hcolorname3.value;
        txtcolor4 = ""
    }

    if (colorsallowed == 4) {
        icolor4 = HextoDec(currobj.hcolorno4.value.substring(4, 6) + currobj.hcolorno4.value.substring(2, 4) + currobj.hcolorno4.value.substring(0, 2))
        txtcolor4 = currobj.hcolorname4.value
    }

    icolor0 = HextoDec(currobj.hcolorno0.value.substring(4, 6) + currobj.hcolorno0.value.substring(2, 4) + currobj.hcolorno0.value.substring(0, 2))
    txtcolor0 = currobj.hcolorname0.value

    if (currobj.catgid.value == 77) {
        xswapped = false
        if (icolor0 == icolor2) {
            xswapped = true
        }

        if (xPadColor == 'None') {
            colorsallowed = 4
            icolor4 = HextoDec("FCDFC2")
            txtcolor4 = "Transparent"
        }

    }

    SetNumColors()

    specs = ""

    specs = specs + "WORKAREA~background," + back_color + "~width," + (back_width * scaling_x) / xcurrzoomper + "~height," + (back_height * scaling_y) / xcurrzoomper + "~label_style," + label_style + "~zoom,"
    specs = specs + xcurrzoomper + "~pdf," + pdf_allowed + "~svg," + svg_allowed + "~database," + Database + "~page_border," + border_allowed + "~keyfield," + keyField + "~keyfieldvalue," + keyfieldvalue + "~palette_number,"
    specs = specs + ipalettenumber + "~colors_allowed," + colorsallowed + "~color0," + icolor0 + "~color1," + icolor1 + "~color2," + icolor2 + "~color3," + icolor3 + "~color4," + icolor4 + "~color0_name,"

    specs = specs + txtcolor0 + "~color1_name," + txtcolor1 + "~color2_name," + txtcolor2 + "~color3_name," + txtcolor3 + "~color4_name," + txtcolor4 + "~print_color,"
    specs = specs + prodprintcolor + "~mat_color," + prodmatcolor + "~printwidth," + printwidth + "~printheight," + printheight

    if (fworkarea.indexOf('LEFTMARGIN') >= 0) {
        specs = specs + "~leftmargin," + (xleftmargin * scaling_x) / xcurrzoomper
        specs = specs + "~topmargin," + (xtopmargin * scaling_x) / xcurrzoomper
        specs = specs + "~rightmargin," + (xrightmargin * scaling_x) / xcurrzoomper
        specs = specs + "~bottommargin," + (xbottommargin * scaling_x) / xcurrzoomper
    }
    specs = specs + "~<END>"

    tbkoutline_weight = bkoutline_weight
    if (yType) {
        yType = yType.toUpperCase()
        if (yType.indexOf('PDF') >= 0 && flag_Pdf_Hide_Border) {
            tbkoutline_weight = 0
        }
        if (yType.indexOf('PROOF') >= 0 && flag_Proof_Hide_Border) {
            tbkoutline_weight = 0
        }
    }
    if (document.getElementById("background").style.borderColor.toUpperCase() == "#AAAAAA") {
        if (tbkoutline_weight > 0) {
            tbkoutline_weight = 0.25
        }
    }

    specs = specs + "BACKGROUND~placeholder," + "pbackground~background," + 0 + "~fill_color," + ibackcolornum + "~outline_color," + iforecolornum + "~outline_weight,"
    specs = specs + tbkoutline_weight + "~lowres_file," + backgroundimage + "~image_width," + round_((back_width * scaling_x) / xcurrzoomper, 0) + "~image_height,"
    specs = specs + round_((back_height * scaling_y) / xcurrzoomper) + "~image_position," + ibkimage_position + "~showbleed," + bkshowbleed + "~<END>"

    storeArrays(olddiv_h, div_h)
    storeArrays(olddiv_y, div_y)

    var ctr = 0
    for (i = 1; i < num_divs; i++) {
        if (div_contents[i] == "label" || div_contents[i] == "plabel") {

            ctr = ctr + 1
            xco = (div_x[i] * scaling_x) / xcurrzoomper
            yco = (div_y[i] * scaling_y) / xcurrzoomper

            var tdiv_text = div_text[i].split("&quot;").join("\"")
            tdiv_text = tdiv_text.split("&nbsp;").join(" ")

            var tcolor = div_color[i]

            specs = specs + "LABEL~placeholder," + div_contents[i] + "~prompt," + div_prompt[i].split("&nbsp;").join(" ") + "~text," + tdiv_text + "~font,"
            specs = specs + div_font[i] + "~size," + div_size[i] + "~style," + div_style[i] + "~xpos," + xco + "~ypos," + yco + "~height,"
            specs = specs + (div_h[i] * 2 * scaling_y) / xcurrzoomper + "~width," + (div_w[i] * 2 * scaling_x) / xcurrzoomper + "~align," + div_align[i] + "~layer,"
            specs = specs + (ctr) + "~color," + tcolor + "~group," + div_group[i] + "~anchored," + div_anchor[i] + "~nonprint," + tdiv_nonprint[i]
            specs = specs + "~font_change," + div_fontchange[i] + "~size_change," + div_sizechange[i] + "~color_change," + div_colorchange[i] + "~field,"
            specs = specs + div_fields[i] + "~leading," + div_leading[i] + "~rule," + div_rule[i] + "~hidden," + div_hidden[i] + "~valign,"
            specs = specs + div_valign[i] + "~rotateangle," + div_rotateangle[i] + "~maxchars," + div_maxchars[i] + "~<END>"

        }
        else if (div_contents[i] == "rectangle" || div_contents[i] == "prectangle") {

            tcolor = div_color[i]
            tbgcolor = div_bgcolor[i]

            if (currobj.catgid.value == 77) {
                if (xPadColor == 'None') {
                    if (div_color[i] == 0) {
                        tcolor = 4;
                    }
                    if (div_bgcolor[i] == 0) {
                        tbgcolor = 4;
                    }
                }
                if (div_prompt[i].toUpperCase() == 'NOSWAP' && xswapped) {
                    if (div_color[i] == 2) {
                        tcolor = 3;
                    }
                    if (div_bgcolor[i] == 2) {
                        tbgcolor = 3;
                    }
                }
            }

            ctr = ctr + 1
            xco = (div_x[i] * scaling_x) / xcurrzoomper
            yco = (div_y[i] * scaling_y) / xcurrzoomper

            specs = specs + "RECTANGLE~placeholder," + div_contents[i] + "~xpos," + xco + "~ypos," + yco + "~height," + (div_h[i] * 2 * scaling_y) / xcurrzoomper
            specs = specs + "~width," + (div_w[i] * 2 * scaling_x) / xcurrzoomper + "~fgcolor," + tcolor + "~bgcolor," + tbgcolor + "~layer," + (ctr)
            specs = specs + "~anchored," + div_anchor[i] + "~nonprint," + tdiv_nonprint[i] + "~fill_change," + div_fillchange[i] + "~outline_change,"
            specs = specs + div_outlinechange[i] + "~corner_radius," + div_rectcorner[i] + "~outline_weight," + div_outlinewt[i] + "~prompt,"
            specs = specs + div_prompt[i] + "~hidden," + div_hidden[i] + "~showbleed," + div_showbleed[i] + "~<END>"
        }
        else if (div_contents[i] == "image" || div_contents[i] == "pimage") {

            ctr = ctr + 1
            xco = ((parseFloat(div_x[i]) + parseFloat(div_w[i])) * scaling_x) / xcurrzoomper
            yco = ((parseFloat(div_y[i]) + parseFloat(div_h[i])) * scaling_y) / xcurrzoomper

            specs = specs + "IMAGE~placeholder," + div_contents[i] + "~prompt," + div_prompt[i].split("'").join("&apos;") + "~file," + div_text[i] + "~xpos,"
            specs = specs + xco + "~ypos," + yco + "~theme," + div_theme[i] + "~height," + (div_h[i] * 2 * scaling_y) / xcurrzoomper + "~width,"
            specs = specs + (div_w[i] * 2 * scaling_x) / xcurrzoomper + "~layer," + (ctr) + "~anchored," + div_anchor[i] + "~nonprint," + tdiv_nonprint[i]
            specs = specs + "~field," + div_fields[i] + "~hidden," + div_hidden[i] + "~trans_color," + div_transcolor[i]
            specs = specs + "~image_color," + div_imagecolor[i] + "~<END>"
        }
    }

    currobj.dspecs.value = specs;
    storeArrays(div_h, olddiv_h) //restore array back
    storeArrays(div_y, olddiv_y) //restore array back
    if (currobj.currside) {
        if (currobj.currside.value == 0) {
            currobj.dspecsF.value = currobj.dspecs.value
        } else if (currobj.currside.value == 1) {
            currobj.dspecsB.value = currobj.dspecs.value
        }
    }

}

function start_new() {
	//vaibhav 10/07/09
	//since at the time of font load flash object should be in ready state
    flash_sign = null;
    flash_sign = getFlashMovieObject("design");
    updateVarsNew();
    /* --------------------------------*/ 
	/* vaibhav temp added to debug msgs */
	/* vaibhav 01 Dec 2009 */
	flash_debug = true;
    SetFlashDebugging();
    /* --------------------------------*/ 
    
    CreateFontsArrayForFlash()
}


function updateVarsNew() {
    var xmWizardid = null;
    if (document.preview.wizardid) {
        xmWizardid = document.preview.wizardid.value
    }
    if (xmWizardid) {
        if (xmWizardid == "30301812") {
            flag_BarCode = true
        }
        else if (xmWizardid == "30301212") {
            flag_BarCode = true
        }
        else if (xmWizardid == "30301822") {
            flag_BarCode = true
        }
        else if (xmWizardid == "303061") {
            flag_BarCode = true
        }
        else if (xmWizardid == "303062") {
            flag_BarCode = true
        }
        else if (xmWizardid == "30303") {
            flag_BarCode = true
            flag_NumField1 = 'NUMBERING1';
            flag_Numbering1 = true;
            flag_NumField2 = 'NUMBERING2';
            flag_Numbering2 = true;
        }
        else if (xmWizardid == "303063") {
            flag_BarCode = true
        }
        else if (xmWizardid == "303822") {
            flag_BarCode = true
        }
        /* vaibhav 160909 starts*/
        else if (xmWizardid == "30301122") {
            flag_BarCode = true
        }
        /* vaibhav 160909 ends*/
    }

    /* vaibhav j on 19 oct to handle min font size */
    if (flag_Text_MinFontSizeAllowed) {
        if (typeof(flag_Text_MinFontSizeAllowed) == "undefined") {
            flag_Text_MinFontSizeAllowed = 8
        }

        for (i = 0; i < div_size.length; i++) {
            if (typeof(div_size[i]) != "undefined") {
                if (parseFloat(div_size[i]) < flag_Text_MinFontSizeAllowed) {
                    //flag_Text_MinFontSizeAllowed = parseFloat(div_size[i])
                    div_size[i] = flag_Text_MinFontSizeAllowed
                }
            }
        }
    }
    /* vaibhav end */
}

function RightOfString(str, n) {
    if (n <= 0) return "";
    else if (n > String(str).length) return str;
    else {
        var iLen = String(str).length;
        return String(str).substring(iLen, iLen - n);
    }
}

function LeftOfString(str, n) {
    if (n <= 0) return "";
    else if (n > String(str).length) return str;
    else return String(str).substring(0, n);
}

function hideHiddenObjs() {

}

function changeDivSize(iIndex) {
    //	xdom = getRS(zz_bgnestref, zz_document, zz_all, joinParam(zz_div, iIndex), zz_style)
    //	xdom["width"] = (2*div_w[iIndex])
    //	xdom["height"] = (2*div_h[iIndex])
}

function changeDivLocation(iIndex) {
    //	xdom = getRS(zz_bgnestref, zz_document, zz_all, joinParam(zz_div, iIndex), zz_style)
    //	xdom[zz_pixelLeft] = div_x[iIndex];
    //	xdom[zz_pixelTop] = div_y[iIndex];
}

function moveobject(yindex, x, y) {
    //	currobjnum=yindex
    //	div_x[yindex] = parseFloat(div_x[yindex]) + parseFloat(x)
    //	div_y[yindex] = parseFloat(div_y[yindex]) + parseFloat(y)
}



//vaibhav 20809
//how many divs contained in the group except group container
function GetGroupLength(gno)
{
    var cgrp,cgrp1,grpnstr, grp1, grp2;
    var l=0;
    
    if (div_group[gno]) {
        cgrp = div_group[gno].split("-");
        cgrp1 = cgrp[0].toString();
        
        for (var i = 1; i < num_divs; i++) {
            if (div_group[i]) {
                grpnstr = div_group[i].split("-");
                grp1 = grpnstr[0].toString();
                grp2 = grpnstr[1].toString();
                if ((grp1 == cgrp1) && (grp2 != "0")){
                    l = l + 1;
                }
            }
        }

    }
    return l;
}
