﻿// JScript File
/*
What it does : This file contains functions specific text entry section on the wizard page.
               It is an important file as almost all teh wizard have text entry section.
               Still, it is conditionally included on the wizard page. 
               This file will help us keep minimum functions within the wizard.asp page.

Referred by : wizarda.asp
*/

//This is default function to be called by spellcheck program
//This function can be overridden by writing a function with the same name in the
//  wizard js file
var curr_yindex	
function userDefinedAfterSpellCheck(ival, yindex){
	changeText(ival, yindex)
}

//This function is called after changing text on the template, 
//overridden by function with the same name in js file
function userdefinedafterchangeText(yindex) {

    if (cancelResizeCalled) {
        if (noweditingindex > 0) {
            nowediting.value = nowediting.value.substring(0, nowediting.value.length - 1)
            div_text[noweditingindex] = nowediting.value
            changeText(div_text[yindex], yindex)
        } else if (updoaction.length > 0) {
            tmp_array = updoaction.split(';')
            evalstr = tmp_array[0] + '('
            for (var i = 1; i < tmp_array.length; i++) {
                if (i = tmp_array.length) {
                    evalstr = evalstr + tmp_array[1]
                } else {
                    evalstr = evalstr + tmp_array[1] + ','
                }
            }
            evalstr = evalstr + ')'
            eval(evalstr)
        }
    }
    
    updoaction = ''

    if (currobj.catgid.value.toLowerCase() == 12 && currobj.SubCatgId.value.toLowerCase() == 'visitorpass') {
        //inWizard variable is used to determin if js to be executed on wizardpage only
        if (typeof(inWizard) != "undefined") {
            //VisitorPass wizard will either display company name or logo
            if (yindex != -1) {
                div_hidden[yindex] = false;
            }
            yindex = getobjectno('LOGOIMAGE') //LOGO
            if (yindex != -1) {
                div_hidden[yindex] = true
            }
        }
    } else if (currobj.catgid.value.toLowerCase() == 501 && currobj.SubCatgId.value.toLowerCase() == 'slider') {
        //Slider sign wizard
        var tindex = getobjectno('TEXTLINE2')
        if (yindex == tindex) {
            yindex = getobjectno('TEXTLINE2COPY')
            if (yindex != -1) {
                div_text[yindex] = div_text[tindex]
                div_text[yindex] = div_text[tindex]
                div_text[yindex] = div_text[tindex]
                div_font[yindex] = div_font[tindex]
                div_size[yindex] = div_size[tindex]
                div_style[yindex] = div_style[tindex]
                div_color[yindex] = div_color[tindex]
                div_align[yindex] = div_align[tindex]
                div_leading[yindex] = div_leading[tindex]
                div_color_hex[yindex] = div_color_hex[tindex]
                div_valign[yindex] = div_valign[tindex]

                flashChangeText(yindex, div_text[yindex])

            }
        }
    }
}

var nowediting=0, noweditingindex=0, updoaction=''

function showTextOnTemplate(ival, yindex, objref){
var xtsr, oval, fldname, spcobjno, oldtext

	/* Vaibhav 191009 - s */
    if(div_size[yindex] < flag_Text_MinFontSizeAllowed) {
        alert("font size is less than min font size allowed")
        return;
    }
    /* Vaibhav 191009 - s */
    
	if (flag_Text_ForceCase) {
		if (flag_Text_ForceCase == "1") {
			if (document.preview["textfield" + yindex]) {
				ival = ival.toUpperCase()
				document.preview["textfield" + yindex].value = ival
			}
		}
		if (flag_Text_ForceCase == "2") {
			if (document.preview["textfield" + yindex]) {
				ival = ival.toLowerCase()
				document.preview["textfield" + yindex].value = ival
			}
		}
	}
	if (flag_Text_AreaOrBox) {
		if (flag_Text_AreaRows == "1") {
			if (document.preview["textfield" + yindex]) {
				document.preview["textfield" + yindex].title = ival
			}
		}
	}
	if (flag_Text_CharLimit > 0) {
		if (trim_(ival).length > flag_Text_CharLimit) {
			ival = ival.substring(0, flag_Text_CharLimit)
			document.preview["textfield" + yindex].value = ival
			alert("You have reached the maximum number of characters for this design.")
		}
	}
	nowediting=objref
	noweditingindex=yindex

	if (currobj.catgid.value==9 & flag_Wizard_Flow != "idbadges"){
		//Evenly divide the available height among the elements 050906
		//adjustFontSizes_Group(yindex)
	}

	oldtext=div_text[yindex]
	allowdivexpandVert=false
	div_text[yindex]=ival;

//--------Enforce character limit if specified in the XML

	var tmpval ='';
	if (parseInt(div_maxchars[yindex]) > 0)	{
		if (document.preview["textfield"+yindex]){
			ival=document.preview["textfield"+yindex].value
			tmpval = ival.toLowerCase().split("&nbsp;").join(" ");
			if (tmpval.length > parseInt(div_maxchars[yindex])){
				alert('Maximum character limit for this line is '+ +parseInt(div_maxchars[yindex]))
				div_text[yindex] = oldtext.split("&nbsp;").join(" ");
				ival=div_text[yindex]	//Remove chars beyond char limit and set ival
				document.preview["textfield"+yindex].value=document.preview["textfield"+yindex].value.substring(0, parseInt(div_maxchars[yindex]))
			//}else{
				//if (document.preview["textfield"+yindex]){
					//document.preview["textfield"+yindex].value=div_text[yindex];
				//}
			}
		}
	}

//--------

	//If Textline is empty then make prev spacer also empty
	if (ival.length==0){
		fldname=div_fields[yindex].toLowerCase()
		spcobjno=parseInt( fldname.split('textline').join('') )-1
		spindex=getobjectno("space" + spcobjno )
		if ( spindex != -1){
			div_text[spindex]=''
			div_prompt[spindex]=''
		}
	}else{
		fldname=div_fields[yindex].toLowerCase()
		spcobjno=parseInt( fldname.split('textline').join('') )-1
		spindex=getobjectno("space" + spcobjno )
		if ( spindex != -1){
			div_text[spindex]='&nbsp;'
			div_prompt[spindex]='spacer'
		}
	}


	if (div_font[yindex]=='70 Helvetica Bold'){
		if (currobj.catgid.value==515 || (currobj.catgid.value==516 && currobj.SubCatgId.value.toLowerCase()=='osha' ) || currobj.catgid.value==518){
			ival=ival.split('&amp;').join('1~~~~~1')
			ival=ival.split('&quot;').join('2~~~~~2')
			ival=ival.toUpperCase()
			ival=ival.split('1~~~~~1').join('&amp;')
			ival=ival.split('2~~~~~2').join('&quot;')
		}
	}
	
	//Vj - Changed according to New JS
    flashChangeText(yindex, ival)
	userdefinedafterchangeText(yindex)
}


//If yindex belongs to a group then, check elements in the group to see if any element is empty, 
//then evenly divide the available height among the elements
function adjustFontSizes_Group(currindex){
var prev_elem_fontsize=0, yindex

	yindex=getgroupdivno(currindex)	//returns container div no.

	for(var i=(yindex+1); i<num_divs-1; i++) {	//for each object of this group type
		if (belongtosamegroup(div_group[i], div_group[yindex]) && (!div_hidden[i]) ){
			if (div_fields[i].toUpperCase().indexOf('SPACE') < 0) {
				prev_elem_fontsize = div_size[currindex]
				break;
			}
		}
	}
	if (parseFloat(prev_elem_fontsize) > 0) {
		for(var i=yindex; i<num_divs-1; i++) {	//for each object of this group type
			if (belongtosamegroup(div_group[i], div_group[yindex]) && (!div_hidden[i]) ){
				if (div_fields[i].toUpperCase().indexOf('SPACE') < 0) {
					if (i==currindex && div_text[currindex].length==0){
						div_size[currindex] = prev_elem_fontsize
					}
					if (div_text[i].length>0){
						prev_elem_fontsize=div_size[i]
					}
				}
			}
		}
	}
}

function callChangeFontStyle(yftype, yindex) {
	if (document.preview.selection) {
		var xobj = document.preview.selection
		yindex = xobj.options[xobj.selectedIndex].value
	}

	if (!ValidateLabel(yindex)) {
		return;
	}
	if (div_fields[yindex].toUpperCase().indexOf('BARCODE') >= 0 || div_fields[yindex].toUpperCase().indexOf('TRACK') >= 0) {
		return;
	}
	
	updoaction='callChangeFontStyle'+';'+yftype+';'+yindex
	
	if (yindex <= 0) return;

	noweditingindex=0

	if ((yftype==1) && (div_font[yindex]=='SS Clearview-Cond. Bold' || div_font[yindex]=='70 Helvetica Bold')){
	}else{
		changeStylebuttons(yftype, yindex)
		
		//changeText(div_text[yindex], yindex)
		flashChangeFontStyle(yftype,yindex)
		
		userdefinedafterchangeText(yindex)	//added on 05/12/09 so that after change function is executed after font style change also
		
	}
}

function callChangeThisFontStyle(yftype, yindex) {
	updoaction='callChangeThisFontStyle'+';'+yftype+';'+yindex
	
	if (yindex <= 0) return;

	noweditingindex=0

	if ((yftype==1) && (div_font[yindex]=='SS Clearview-Cond. Bold' || div_font[yindex]=='70 Helvetica Bold')){
	}else{
		changeText(div_text[yindex], yindex)
	}
}

function old_callChangeFontStyle(yftype, yval) {
var xval, xtempval

	xval = yval

	if (xval <= 0) return;
	if ((yftype==1) && (div_font[xval]=='SS Clearview-Cond. Bold' || div_font[xval]=='70 Helvetica Bold')){
	}else{
		changeStylebuttons(yftype, yval)
		changeText(div_text[xval], xval)
	}
}

function changeStylebuttons(yftype, yval) {
var xval, xtempval
	xval = yval
	if (xval <= 0) return;

    xtempval = parseInt(div_style[xval])
	if (yftype == 1) { 
		if ((xtempval&1)==1) {
			div_style[xval] = parseInt(div_style[xval]) - 1
			if (document.images["fbold"+xval]) {
				document.images["fbold"+xval].src="images/text-bold-n0.gif"
			}
		}else {
			div_style[xval] = parseInt(div_style[xval]) + 1
			if (document.images["fbold"+xval]) {
				document.images["fbold"+xval].src="images/text-bold-n2.gif"
			}
		}
	}
	if (yftype == 2) { 
		if ((xtempval&2)==2) {
			div_style[xval] = parseInt(div_style[xval]) - 2
			if (document.images["fitalic"+xval]) {
				document.images["fitalic"+xval].src="images/text-italic-n0.gif"
			}
		}else {
			div_style[xval] = parseInt(div_style[xval]) + 2
			if (document.images["fitalic"+xval]) {
				document.images["fitalic"+xval].src="images/text-italic-n2.gif"
			}
		}
	}
  	if (yftype == 3) { 
		if ((xtempval&4)==4) div_style[xval] = parseInt(div_style[xval]) - 4;
		else div_style[xval] = div_style[xval] + 4;
	}
  	if (yftype == 4) { 
		if ((xtempval&8)==8) {
			div_style[xval] = parseInt(div_style[xval]) - 8;
			if (document.images["fuline"+xval]) {
				document.images["fuline"+xval].src="images/text-underline-n0.gif"
			}
		}else {
			div_style[xval] = parseInt(div_style[xval]) + 8;
			if (document.images["fuline"+xval]) {
				document.images["fuline"+xval].src="images/text-underline-n2.gif"
			}
		}
	}
}

function increaseSpace(yindex) {
    FlashIncreaseSpace(yindex)
}

function increaseSpaceBig(yindex){
    FlashIncreaseSpaceBig(yindex)
}

function decreaseSpace(yindex){
    FlashDecreaseSpace(yindex)
}

function decreaseSpaceBig(yindex){
    FlashDecreaseSpaceBig(yindex)
}

function getobjectno(fldname) {
	for(var i=1; i<num_divs; i++) {
		if (div_fields[i]){
			if (div_fields[i].toUpperCase()==fldname.toUpperCase()) {
				return i
			}
		}
	}
	return -1
}

function IncreaseTypeSize(yindex){
    flashIncreaseFontSize(yindex)
}

function DecreaseTypeSize(yindex){
    flashDecreaseFontSize(yindex)
}

var maxlines=15
function changeFont(iFontName, objdd, ygroup) {
    flashChangeFont(iFontName,-1)
}

function GetFontGroupingName(i) {
	var xFontGroupingName = "";
	var tFontGroupingName = "";
	if (div_fields[i]) {
		t_fieldgroup = flag_Text_FieldGrouping.split(';')
		for (var m=0; m<t_fieldgroup.length; m++) {
			t_part =  t_fieldgroup[m].split(':')
			if (t_part.length == 2) {
				t_fieldnames = t_part[1].split(',')
				for (var j=0; j<t_fieldnames.length; j++) {
					if (div_fields[i].toUpperCase() == t_fieldnames[j].toUpperCase()) {
						xFontGroupingName = t_part[0].toUpperCase()
						break;
					}
					if (t_fieldnames[j].toUpperCase() == "*.*") {
						tFontGroupingName = t_part[0].toUpperCase()
					}
				}				
			}
			if (xFontGroupingName.length > 0) {
				break;
			}
		}
	}
	if (tFontGroupingName.length > 0 && xFontGroupingName.length <= 0) {
		//for all otherfields than specified
		xFontGroupingName = tFontGroupingName
	}
	//xFontGroupingName: H1, H2 etc.
	return xFontGroupingName;
}

function GetGroupingFont(iFontName, objdd, i) {	
	var xGroupingFontName="";
	if (flag_Text_FieldGrouping.length > 0) {
		tFontSelected = objdd.options[objdd.selectedIndex].text
		var xFontGroupingName = GetFontGroupingName(i);
		if (xFontGroupingName.length > 0) {
			for (var n=0; n<a_fontname.length; n++) {
				if (a_fontname[n].toLowerCase() == tFontSelected .toLowerCase()) {
					if (a_fontgrouping[n].length > 0) {
						t_fontgroup = a_fontgrouping[n].split(";")
						for (var j=0; j<t_fontgroup.length; j++) {
							if (t_fontgroup[j].toUpperCase().indexOf(xFontGroupingName + ':') >= 0) {
								xGroupingFontName = t_fontgroup[j].toUpperCase().split(xFontGroupingName + ':').join('')
								xGroupingFontName = xGroupingFontName.toLowerCase();
								break;
							}
						}
					}
				}
				if (xGroupingFontName.length > 0) {
					break;
				}
			}
		}
	}
	if (xGroupingFontName.length > 0) {
		iFontName = xGroupingFontName
	}
	return iFontName;
}

function GetGroupingStyle(iFontStyle, objdd, i) {	
	var xGroupingFontStyle="";
	if (flag_Text_FieldGrouping.length > 0) {
		tFontSelected = objdd.options[objdd.selectedIndex].text
		var xFontGroupingName = GetFontGroupingName(i);
		if (xFontGroupingName.length > 0) {
			for (var n=0; n<a_fontname.length; n++) {
				if (a_fontname[n].toLowerCase() == tFontSelected .toLowerCase()) {
					if (a_stylegrouping[n].length > 0) {
						t_fontgroup = a_stylegrouping[n].split(";")
						for (var j=0; j<t_fontgroup.length; j++) {
							if (t_fontgroup[j].toUpperCase().indexOf(xFontGroupingName + ':') >= 0) {
								xGroupingFontStyle = t_fontgroup[j].toUpperCase().split(xFontGroupingName + ':').join('')
								xGroupingFontStyle = xGroupingFontStyle.toLowerCase();
								break;
							}
						}
					}
				}
				if (xGroupingFontStyle.length > 0) {
					break;
				}
			}
		}
	}
	if (xGroupingFontStyle.length > 0) {
		iFontStyle = xGroupingFontStyle
	}
	return iFontStyle;
}

function GetGroupingSize(iFontSize, objdd, i) {	
	var xGroupingFontSize="";
	if (flag_Text_FieldGrouping.length > 0) {
		tFontSelected = objdd.options[objdd.selectedIndex].text
		var xFontGroupingName = GetFontGroupingName(i);
		if (xFontGroupingName.length > 0) {
			for (var n=0; n<a_fontname.length; n++) {
				if (a_fontname[n].toLowerCase() == tFontSelected .toLowerCase()) {
					if (a_sizegrouping[n].length > 0) {
						t_fontgroup = a_sizegrouping[n].split(";")
						for (var j=0; j<t_fontgroup.length; j++) {
							if (t_fontgroup[j].toUpperCase().indexOf(xFontGroupingName + ':') >= 0) {
								xGroupingFontSize = t_fontgroup[j].toUpperCase().split(xFontGroupingName + ':').join('')
								xGroupingFontSize = xGroupingFontSize.toLowerCase();
								break;
							}
						}
					}
				}
				if (xGroupingFontSize.length > 0) {
					break;
				}
			}
		}
	}
	if (xGroupingFontSize.length > 0) {
		iFontSize = xGroupingFontSize   
	}
	return iFontSize;
}

function DisplaySampleFont(yindex, yobj) {
	var xfont	
	if (yobj) {
		
		xfont = yobj.options[yobj.selectedIndex].text	
	}
	var xdom;	
	xdom = getRS('', zz_document, zz_all, "sampletext")	
	if (xdom) {		
		xdom.style.fontFamily = xfont
		xdom.style.fontSize = "10pt";
		xdom.innerHTML = xfont.split(' ').join('&nbsp;') 		
	}	
}
function AlignAll(ialigncode, ygroup){
    flashAlignAll(ialigncode,-1)
}

function RedrawText(yindex, ialigncode) {
    changeAlignment(yindex, ialigncode)
}

function showAlignimage(ival, ygroup) {
	if (ygroup) {
		var imgl=document.images["alignleft" + ygroup]
		var imgc=document.images["aligncenter" + ygroup]
		var imgr=document.images["alignright" + ygroup]
	}
	else {
		var imgl=document.images.alignleft
		var imgc=document.images.aligncenter
		var imgr=document.images.alignright
	}
	if (ival==0){ imgl.src="images/text-align-left-n2.gif"
	}else{ imgl.src="images/text-align-left-n0.gif" }

	if (ival==2){ imgc.src="images/text-align-center-n2.gif"
	}else{ imgc.src="images/text-align-center-n0.gif" }

	if (ival==1){ imgr.src="images/text-align-right-n2.gif"
	}else { imgr.src="images/text-align-right-n0.gif" }
}

function VAlignAll(ialigncode, ygroup){

     var ngroup = -1
     if (ygroup){
        if (ygroup !='') {
            ngroup = ygroup
        }
     }
     
	var yindex
	for(var i=1; i<num_divs; i++) {

		if (div_contents[i]) {
			if (div_contents[i].indexOf('label') >= 0) {
				var tflag = false;
				if (ygroup) {
					if (div_group[i].indexOf(ygroup + '-') >= 0) {
						tflag = true;
					}
				}
				else {
					tflag = true;
					if (div_group[i]) {
						tindex=getgroupdivno(i)
						if (div_fields[tindex].toUpperCase().indexOf('NUMBERING') >= 0) {
							tflag = false;
						}
					}
				}
				
				if (tflag) {
					div_valign[i]=ialigncode
					yindex=i
					if (div_group[i] && div_group[i].length>0){
						yindex=getgroupdivno(i)
					}
				}				
			}
		}
	}
	
    Flash_SetTextVAlign(ngroup)
}

function RedrawVText(yindex, ialigncode) {
    changeVAlignment(yindex, ialigncode)
}

function showVAlignimage(ival, ygroup) {
	if (ygroup) {
		var imgl=document.images["aligntop" + ygroup]
		var imgc=document.images["alignmiddle" + ygroup]
		var imgr=document.images["alignbottom" + ygroup]
	}
	else {
		var imgl=document.images.aligntop
		var imgc=document.images.alignmiddle
		var imgr=document.images.alignbottom
	}
	if (ival==0){ imgl.src="images/text-align-top-n2.gif"
	}else{ imgl.src="images/text-align-top-n0.gif" }

	if (ival==2){ imgc.src="images/text-align-middle-n2.gif"
	}else{ imgc.src="images/text-align-middle-n0.gif" }

	if (ival==1){ imgr.src="images/text-align-bottom-n2.gif"
	}else { imgr.src="images/text-align-bottom-n0.gif" }
}

var xok = false
function ChangeGroupTextSize(yflag, ygroup){

    if (yflag == 1) {
        flashDecreaseFontSize(-1)
        return;
    }
    else if (yflag == 2) {
        flashIncreaseFontSize(-1)
        return;
    }
}

function CalculateLabelHeights(ygroup) {
	var xheight = 0;
	if (ygroup.indexOf("-") >= 0) {
		var xpos = ygroup.indexOf("-")
		ygroup = ygroup.substring(0, xpos)
		for(var i=1; i<num_divs; i++) {
			if (div_contents[i] == "plabel" || div_contents[i] == "label") {
				if (div_group[i] == ygroup + "-0") {
				}
				else {
					if (div_group[i].indexOf(ygroup + "-") >= 0) {
						if (trim_(div_text[i]).length  > 0) {
							var xdom = calcHeightWidth(div_text[i], i)				
							xheight = parseFloat(xheight) + CB_clientHeight(xdom)/2
						}
					}
				}
			}
		}	
	}
	return xheight;
}


function getLabel_HeightWidth(ygroup) {
	var xheight = 0, xwidth = 0, newxwidth=0;
	if (ygroup.indexOf("-") >= 0) {
		var xpos = ygroup.indexOf("-")
		ygroup = ygroup.substring(0, xpos)
		for(var i=1; i<num_divs; i++) {
			if (div_contents[i] == "plabel" || div_contents[i] == "label") {
				if (div_group[i] == ygroup + "-0") {
				}
				else {
					if (div_group[i].indexOf(ygroup + "-") >= 0) {
						if (trim_(div_text[i]).length  > 0 && div_text[i] != '&nbsp;') {
							var xdom = calcHeightWidth(div_text[i], i)				
							xheight = parseFloat(xheight) + parseFloat(CB_clientHeight(xdom)/2)

							newxwidth = parseFloat(CB_clientWidth(xdom))/2
							if (xwidth < newxwidth){
								xwidth = newxwidth	
							}
						}
					}
				}
			}
		}	
	}
	return Array(xheight,xwidth);
}


var busyresizing = false;
var busybuffer = "";

function autofitText2() {
    FlashAutoFitText()
}

function autofitText() {
    showPleaseWaitImage()
	check_image_placed()
	showAutofitImage()
}

function showAutofitImage()
{
    if (document.images.imgautofit) {
	    document.images.imgautofit.src='images/button_auto_fit2.gif'
    }
}

function showPleaseWaitImage()
{
    if (document.images.imgautofit) {
	    document.images.imgautofit.src='images/button_auto_fit20.gif'
    }
}

var ytimeid
function check_image_placed(){
	if (document.images.imgautofit) {
		if (document.images.imgautofit.complete) {
			if (ytimeid != null)	clearTimeout(ytimeid);

			autofitText2()
		}
		else{
			ytimeid = setTimeout("check_image_placed()", 100)
		}
	}
	else {
		autofitText2()
	}
}

function SelectThisObject(yobj, yindex) {
	if (yindex) {
		currobjnum = yindex
		tcurrobjnum = yindex
	}
	for (var k=1; k<num_divs; k++) {
		if (div_contents[k]) {
			if (div_contents[k].indexOf('label') >= 0) {
				xobj = document.preview["textfield" + k]
				if (xobj) {
					if (div_color_hex[k] == "#FFFFFF") {
						xobj.style.backgroundColor = "#BBBBBB"
						xobj.style.fontWeight = "normal"
						xobj.style.color = div_color_hex[k] 
					}
					else {
						xobj.style.backgroundColor = "#FFFFFF"
						xobj.style.fontWeight = "normal"
						xobj.style.color = div_color_hex[k] 
					}
				}
			}
		}
	}
	if (yobj) {
		yobj.style.backgroundColor = "#DDDDFF" 
		yobj.style.fontWeight = "bold"
		yobj.style.color = "#000000"
	}
	if (document.preview.flistfonts) {
		SetDefaultFont(document.preview.flistfonts, div_font[yindex])
	}
}

function ValidateLabel(yindex) {
	xlabelflag = false
	if (div_contents[yindex]) {
		if (div_contents[yindex].indexOf('label') >= 0) {
			xlabelflag = true
		}
	}
	if (!xlabelflag) {
		if (tcurrobjnum > 0) {
			currobjnum = tcurrobjnum
		}
		else if (currobjnum > 0 ) {
		}
		else {
			alert("Select a text object by clicking on the text field")
		}
	}
	return xlabelflag;
}

function ShowHideAllDependentObjects(ygroup, yhidden) {
	var t_grp = ygroup.split("-")
	if (t_grp[0].length < 0) {
		return;
	}
	for (var k=1; k<num_divs; k++) {
		if (div_contents[k]) {
			if (div_contents[k].indexOf('label') >= 0) {
				if (div_group[k]) {
					if (div_group[k] != ygroup) {
						if (div_group[k].indexOf(t_grp[0] + "-") >= 0) {
							div_hidden[k] = yhidden
						}
					}
				}
			}
		}
	}
}

function ShowHideTextGroups(yobj) {
	for (var k=1; k<num_divs; k++) {
		if (div_contents[k]) {
			if (div_contents[k].indexOf('label') >= 0) {
				if (div_hidden[k] == true){
					div_hidden[k] = false;
				}
				else {
					div_hidden[k] = true;
				}

				if (div_group[k]) {
					if (div_group[k].indexOf("-0") >= 0) {
						ShowHideAllDependentObjects(div_group[k], div_hidden[k])
					}
				}
			}
			else if (div_contents[k].indexOf('rectangle') >= 0) {
				if (div_prompt[k].toUpperCase().indexOf('TITLERECT') >= 0) {
					var xobj = getRS(zz_bgnestref, zz_document, zz_all, joinParam(zz_div, k), zz_style)
					if (div_hidden[k] == true){
						div_hidden[k] = false;
					}
					else {
						div_hidden[k] = true;
					}
				}
			}
		}
	}
}

function GetStyleSectionHTML(yindex) {
	var xdivstr = "";
	PreloadAll()
	currobjnum = yindex
	
	var xnumcolor = 1
	if (document.preview.numcolor.value.length > 0)  {
		xnumcolor = document.preview.numcolor.value
	}
	
	var color1_hex = document.preview.hcolorno1.value 
	var color2_hex = document.preview.hcolorno2.value 
	var color3_hex = document.preview.hcolorno3.value 
	var color4_hex = document.preview.hcolorno4.value 
		

	xdivstr = xdivstr + "<table cellpadding=0 cellspacing=0 border=0>"
	xdivstr = xdivstr + "<tr><td bgcolor='#FFCC00'>"
	xdivstr = xdivstr + "<table cellpadding=3 cellspacing=1 border=0>"
	xdivstr = xdivstr + "	<tr>"

	if ( flag_Color_Scheme && SectionsDisplay_Order.toLowerCase().indexOf('color_scheme') >= 0 && SectionsDisplay_Order.toLowerCase().indexOf('color_scheme') < SectionsDisplay_Order.toLowerCase().indexOf('text') && xnumcolor > 1) {
		//when color_scheme section appears before the text section
		//but this logic may need improvement. May be addition of another flag in wizardflags
		if (!(xsubcatgid.toLowerCase() == "value" || xsubcatgid.toLowerCase() == "economy")) {
			xdivstr = xdivstr + "<td align='left' class='body7' valign='top' colspan='3' bgcolor='#F9F9F9'>Color:<br>"
			xdivstr = xdivstr + "<table cellpadding='0' cellspacing='0'>"

			xdivstr = xdivstr + "<td id='felementcolor_1' width='15' bgcolor='#" + color1_hex + "'><a href='javascript:changeColor(1, " + yindex + ")'><img src='images/space.gif'  width='15' height='15' style='border-type:solid; border-width:1px; border-color:#999999;'></a></td>"
			xdivstr = xdivstr + "<td><img src='images/space.gif' width='4' height='15'></td>"

			if (xnumcolor >= 2) {
				xdivstr = xdivstr + "<td id='felementcolor_2' width='15' bgcolor='#" + color2_hex + "'><a href='javascript:changeColor(2, " + yindex + ")'><img src='images/space.gif'  width='15' height='15' style='border-type:solid; border-width:1px; border-color:#999999;'></a></td>"
				xdivstr = xdivstr + "<td><img src='images/space.gif' width='4' height='15'></td>"
			}
			
			if (xnumcolor >= 3) {
				xdivstr = xdivstr + "<td id='felementcolor_3' width='15' bgcolor='#" + color3_hex + "'><a href='javascript:changeColor(3, " + yindex + ")'><img src='images/space.gif'  width='15' height='15' style='border-type:solid; border-width:1px; border-color:#999999;'></a></td>"
				xdivstr = xdivstr + "<td><img src='images/space.gif' width='4' height='15'></td>"
			}

			if (xnumcolor >= 4) {
				xdivstr = xdivstr + "<td id='felementcolor_4' width='15' bgcolor='#" + color4_hex + "'><a href='javascript:changeColor(4, " + yindex + ")'><img src='images/space.gif'  width='15' height='15' style='border-type:solid; border-width:1px; border-color:#999999;'></a></td>"
				xdivstr = xdivstr + "<td><img src='images/space.gif' width='4' height='15'></td>"
			}
				xdivstr = xdivstr + "</table>"
			xdivstr = xdivstr + "</td></tr><tr>"
		}
	}

	if (flag_Text_Style) {
		xdivstr = xdivstr + "<td valign='top' nowrap class='body7' bgcolor='#F9F9F9'>Style:<br>"
		xdivstr = xdivstr + "<a href='javascript:callChangeFontStyle(1, " + yindex + ")'><img src='images/text-bold-n0.gif' name='fbold" + yindex + "' id='fbold" + yindex + "' alt='Bold' border='0' width='18' height='18' align='absmiddle'></a><a href='javascript:callChangeFontStyle(2, " + yindex + ")'><img src='images/text-italic-n0.gif' name='fitalic" + yindex + "' id='fitalic" + yindex + "' alt='Italic' border='0' width='18' height='18' align='absmiddle'></a><a href='javascript:callChangeFontStyle(4, " + yindex + ")'><img src='images/text-underline-n0.gif' name='fuline" + yindex + "' id='fuline" + yindex + "' alt='Underline' border='0' width='18' height='18' align='absmiddle'></a></td>"
	}
	if (flag_Text_Size) {
		xdivstr = xdivstr + "<td valign='top' nowrap class='body7' bgcolor='#F9F9F9' colspan='2'>Size:<br>"
		xdivstr = xdivstr + "<img src='images/fontsize_trans.gif' border='0' align='absmiddle' usemap='#MapFontsize' + yindex></td>"
	}
	if (flag_Text_Style || flag_Text_Align || flag_Text_Size) {
		xdivstr = xdivstr + "</tr><tr>"
	}

	if (flag_Text_Align) {
		xdivstr = xdivstr + "<td valign='top' nowrap class='body7' bgcolor='#F9F9F9'>Alignment:<br>"
		xdivstr = xdivstr + "<a href='javascript:changeAlignment(" + yindex + ", 0)'><img name='alignleft' id='alignleft' alt='Left' src='images/text-align-left-n0.gif' width='18' height='18' border='0' align='absmiddle'></a><a href='javascript:changeAlignment(" + yindex + ", 2)'><img name='aligncenter' id='aligncenter' alt='Center' src='images/text-align-center-n0.gif' width='18' height='18' border='0' align='absmiddle'></a><a href='javascript:changeAlignment(" + yindex + ", 1)'><img name='alignright' id='alignright' alt='Right' src='images/text-align-right-n0.gif' width='18' height='18' border='0' align='absmiddle'></a></td>"
	}
	if (flag_Text_Leading) {
		xdivstr = xdivstr + "<td valign='top' nowrap class='body7' bgcolor='#F9F9F9'>Line Space:<br>"
		xdivstr = xdivstr + "<table width='100%' border='0' cellspacing='0' cellpadding='0'><tr><td colspan='2' align='center'><font size='1' face='Verdana, Arial, Helvetica, sans-serif'><a href='javascript:increaseLineSpacing(" + yindex + ")'><img src='images/button_plus.gif' width='14' height='14' align='absmiddle' name='plus' border='0' onMouseDown=\"MM_swapImage('plus','','images/button_plus2.gif',1)\" onMouseUp=\"MM_swapImage('plus','','images/button_plus.gif',1)\" alt='Increase the space between text blocks'></a>&nbsp;<a href='javascript:decreaseLineSpacing(" + yindex + ")'><img src='images/button_minus.gif' width='14' height='14' align='absmiddle' name='minus' border='0' onMouseDown=\"MM_swapImage('minus','','images/button_minus2.gif',1)\" onMouseUp=\"MM_swapImage('minus','','images/button_minus.gif',1)\" alt='Shrink the space between lines of text.'></a></font></td></tr></table></td>"
	}
	if (flag_Text_Rule) {
		xchecked=""
		if (div_rule[yindex]) {
			xchecked = "checked"
		}
		xdivstr = xdivstr + "<td valign='top' nowrap bgcolor='#F9F9F9'><span id='cb_rulediv" + yindex + "' style='display:block;' class='body7' valign='bottom'>Rule:<img src='images/space.gif' height='1' width='10'><br><table cellpadding='0' cellspacing='0'><tr><td width='30'><input type='checkbox' class='body8' name='cb_ruletext" + yindex + "' value='1' " + xchecked + " onclick='ShowHideRule(" + yindex + ", this)'></td><td width='10'></td><td class='body8' ></td></tr></table></span></td>"
	}
	if (flag_Text_Align || flag_Text_Leading || flag_Text_Rule) {
		xdivstr = xdivstr + "</tr><tr>"
	}


	if (flag_Text_Font) {
		xdivstr = xdivstr + "<td valign='top' nowrap class='body7' colspan='3' bgcolor='#F9F9F9'>Font:<br>"
		xdivstr = xdivstr + "<select name='list_toolbar_font" + yindex + "' class='body7' onchange=\"changeThisFont(this, '" + yindex + "');MatchSelectedFont(this, document.preview['listFonts' + " + yindex + "])\"></select></td>"
	}

	xdivstr = xdivstr + "	</tr>"
	xdivstr = xdivstr + "</table>"
	xdivstr = xdivstr + "</td></tr></table>"

	return xdivstr;
}

function GetStyleTitleHTML(yindex) {
	if (div_text[yindex].length <= 0) {
		return "Property Toolbar"
	}
	else if (div_text[yindex].length > 25) {
		return div_text[yindex].substring(0, 25) + "..."
	}
	else {
		return div_text[yindex]
	}
}

function ShowToolbarFonts(yindex) {
	
	FillFonts(GetElement("list_toolbar_font" + yindex))
	GetElement("list_toolbar_font" + yindex).selectedIndex = document.preview["listFonts" + yindex].selectedIndex
	return;
	
	if (GetElement("div_toolbar_font" + yindex)) {
		GetElement("div_toolbar_font" + yindex).innerHTML = GetElement("div_listFonts" + yindex).innerHTML
		GetElement("div_toolbar_font" + yindex).style.visibility = "visible";
	}
}

function HideToolbarFonts(yindex) {
	if (GetElement("div_toolbar_font" + yindex)) {
		GetElement("div_toolbar_font" + yindex).innerHTML = ""
		GetElement("div_toolbar_font" + yindex).style.visibility = "hidden";
	}
}

function SetTextfieldProperties(yindex, yflag) {
	if (yflag) {
		a_cleared[yindex] = true;
		if (document.preview["textfield" + yindex]) {
			document.preview["textfield" + yindex].style.fontStyle = "normal"
			document.preview["textfield" + yindex].style.borderWidth = "1px"
			document.preview["textfield" + yindex].style.borderStyle = "solid"
			document.preview["textfield" + yindex].style.borderColor = "#AAAAAA"
		}
	}
	else {
		a_cleared[yindex] = false;
		if (document.preview["textfield" + yindex]) {
			document.preview["textfield" + yindex].style.fontStyle = "italic"
			document.preview["textfield" + yindex].style.borderWidth = "1px"
			document.preview["textfield" + yindex].style.borderStyle = "solid"
			document.preview["textfield" + yindex].style.borderColor = "#FD8842"
		}
	}
}
