﻿// JScript File
/*
What it does : This file is intended to be used for those wizards where Logo / Graphic is to be placed on templates.
				For eg. id badges, business cards etc.
			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, wizardy.asp
*/
/*
This section of functions are related to Graphic Section
*/
function showClipartWin(){
	var xurl;
	if (flag_Graphic_NewLibrary) {
		xurl='Clipart.asp'
		//12162010
		    //xwidth=565;
		    //xheight=525;
		xwidth=960;
		xheight=620;	
	}
	else {
		xurl='getClipart.asp'
		xwidth=440;
		xheight=400;	
	}
	
	xleft = (screen.width - xwidth) / 2
	xtop = (screen.height - xheight) / 2
	xurl=xurl + '?DefaultClip='+flag_Graphic_DefaultClip + '&Themes2Show='+flag_Graphic_Themes2Show + '&WizardFlags_AutoID='+WizardFlags_AutoID
	xurl = xurl + '&compname='+currobj.CompName.value+'&subcatgid='+currobj.SubCatgId.value
	winhandle = window.open(xurl, 'hidden', 'left='+xleft+',top='+xtop+',width='+xwidth+',height='+xheight+', location=no, resizable=yes, scrollbars=no')
}

function showClipartChangeDiv(yindex,tempfileid)
{
	var xurl;
	xurl='Clipart.asp'
	xwidth=920;
	xheight=620;	
	
	xleft = (screen.width - xwidth) / 2
	xtop = (screen.height - xheight) / 2
	
	if(currobj.SubCatgId.value=='PARKING2' && currobj.catgid.value=='40') {
		xurl=xurl + '?DefaultClip=Safety Symbols;Prohibited Actions&Themes2Show='+flag_Graphic_Themes2Show + '&WizardFlags_AutoID='+WizardFlags_AutoID }
	else {
		xurl=xurl + '?DefaultClip='+flag_Graphic_DefaultClip + '&Themes2Show='+flag_Graphic_Themes2Show + '&WizardFlags_AutoID='+WizardFlags_AutoID
	}
		
	xurl = xurl + '&compname='+currobj.CompName.value+'&subcatgid='+currobj.SubCatgId.value+'&yindex=' + yindex +'&tempfileid=' + tempfileid;
	winhandle = window.open(xurl, 'hidden', 'left='+xleft+',top='+xtop+',width='+xwidth+',height='+xheight+', location=no, resizable=yes, scrollbars=no')
}

function setTempClipArtImage(tempfileid,filename)
{
	if(tempfileid!="") {
	document.getElementById(tempfileid).src="/xp2/clipart/" + filename; }
}

function showCustomLogoWin(){
	var tcompname = "";
	if (document.preview.CompName) {
		tcompname = document.preview.CompName.value
	}
	winhandle = window.open('getCustomLogo.asp?compname='+tcompname+'&RasterOnly=1', 'hidden', CenterThisWindow(440, 600) +', location=no, resizable=yes, scrollbars=yes')
}
function showCustomLogoWinSteps(){
	var tindex, tdh, tdw;
	tdh = 0;
	tdw = 0;
	tindex=-1;
	if (flag_GraphicField) {
		if (flag_GraphicField.length > 0) {
			tindex = getobjectno(flag_GraphicField)
			tdh = (2 * div_h[tindex]) / (xzoomper * 96)
			tdw = (2 * div_w[tindex]) / (xzoomper * 96)
		}
	}
	
	// Step upload process discontinued since it has has not been integrated in the artwork creation process -- RJ
	//if (flag_Graphic_ColorConv) {
	showCustomLogoWin()
	//}
	//else {
	//	winhandle_steps = window.open('/xp5/xp5_upload_artwork_step1.asp?index='+tindex+'&designHeight='+tdh+'&designWidth='+tdw+'&SpotColors='+flag_Graphic_Spot_Colors+'&ColorConv='+flag_Graphic_ColorConv, 'steps', CenterThisWindow(400,430) +', location=no, resizable=yes, scrollbars=no')
	//}
}
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 DeleteLogo() {
	FlashDeleteLogo()
	
	//ET-28052010-VJ-START
	if (flag_Textreduction_logo_insert==true) {
		if (currobj.catgid.value==78 && currobj.SubCatgId.value.toLowerCase()=='mailing'){
			remove_Logo()
		}else if (currobj.catgid.value==512 && currobj.SubCatgId.value.toUpperCase()=='ADDRESSSTANDARD'){
			remove_Logo()
		} else if ( currobj.catgid.value==9 && (currobj.SubCatgId.value.toUpperCase()=='CORRIDOR' || currobj.SubCatgId.value.toUpperCase()=='CORRIDOR2')){
			remove_Logo()
		} else if (currobj.SubCatgId.value=='PARKING_CUSTOM' || currobj.SubCatgId.value=='PARKING_CUSTOM2'){
			remove_Logo()
		} else if ( currobj.SubCatgId.value=='GRAPHICAREA' ){
			if (currobj.areaSignBorder){
				if (currobj.areaSignBorder.value=='1'){
					yindex=getobjectno(flag_GraphicField)
					if (yindex!=-1){
						if (div_hidden[yindex]!=true){
							VAlignAll(2,'')
							AlignAll(2,'')
							backgroundimage = backgroundimage.toLowerCase().split('.gif').join('_b.gif');
							Flash_Update_BackImage(backgroundimage);
						}else{
							VAlignAll(1,'')
							AlignAll(1,'')
							backgroundimage = backgroundimage.toLowerCase().split('_b.gif').join('.gif');
							Flash_Update_BackImage(backgroundimage);
						}
					}
				}
			}
			
			remove_Logo()
		}else if (currobj.signtype){
			delete_symbol_sign()
		}
	}
	//ET-28052010-VJ-END
}
function delete_symbol_sign(){
	var actiontyp='hide', yindex
	yindex=getobjectno("symbol")
	if (yindex!=-1){
		if (div_hidden[yindex]==true){
			return
		}else{
			actiontyp='hide'
		}
	}
	yindex=getobjectno("symbol")
	if (yindex!=-1) {
		div_hidden[yindex]=true
		if (actiontyp=='hide'){
			FlashShowHideObject(yindex)
			if(currobj.signtype.value.toUpperCase() == 'PROJ')
			ShowHideBorder(Border_Style)
			else
			adjustTextsizes(yindex, '+')
		}
	}
	yindex=getobjectno("symspanish")
	if (yindex!=-1) {
		div_hidden[yindex]=true
		if (actiontyp=='hide'){
			FlashShowHideObject(yindex)
		}
	}
}
//ET-28052010-VJ-END
function placelogo_template(yindex, secondparam, xname, lastparam){
	var hindex, oshacaution, logouploaded, grayscale
	//alert("placelogo_template")
	if (flag_Graphic_ColorConv==true){
		//alert("placelogo_template1")
		if (currobj.signtype){
			//alert("placelogo_template2")
			hindex=getobjectno("headerimg")
			if (hindex!=-1) {
				if (div_text[hindex].toUpperCase().indexOf('OSHA-CAUTION-RADIATION')>=0){
					oshacaution=true
				}
			}
			if (currobj.signtype.value == 'OSHA' && oshacaution){
				grayscale=true	//When placing logo for the firsttime then set it to true
				convert_logo_color(yindex, xname, lastparam, grayscale)
			}else if (currobj.SubCatgId.value=='OSHA' && lastparam==1 || currobj.SubCatgId.value=='ANSI' && lastparam==1 || currobj.SubCatgId.value=='SAFETYFLOORSTAND' && lastparam==1 || currobj.SubCatgId.value=='FACILITY' && lastparam==1 || currobj.SubCatgId.value=='FACILITYLABEL' && lastparam==1 || currobj.SubCatgId.value=='PARKING_CUSTOM' || currobj.SubCatgId.value=='PARKING_CUSTOM2'){	//only uploaded logo will be color converted
				grayscale=true	//When placing logo for the firsttime then set it to true
				convert_logo_color(yindex, xname, lastparam, grayscale)
			}else if (currobj.SubCatgId.value.toUpperCase()=='PARKING2' && lastparam==1){	//only uploaded logo will be color converted
				grayscale=true	//When placing logo for the firsttime then set it to true
				convert_logo_color(yindex, xname, lastparam, grayscale)
			}else if (currobj.catgid.value == '520'){
				if (currobj.templateXML.value.substring(0,2)=="S0" || currobj.templateXML.value.substring(0,3)=="SV0" && ssColors.length>0){
					grayscale=true	//When placing logo for the firsttime then set it to true
					convert_logo_color(yindex, xname, lastparam, grayscale)
                }
			    //04282011
			    else if (currobj.multisymbol.value == "1"){
                    changeImage(yindex, secondparam, xname, xname, lastparam);		    
			    }
			    //04282011
				else{
					changeLibSymbol(xname)
				}
				
            //12162010
            }else if ((currobj.catgid.value == '515') && (currobj.SubCatgId.value.toUpperCase()=='FLOOR')){
					grayscale=true	//When placing logo for the firsttime then set it to true
					convert_logo_color(yindex, xname, lastparam, grayscale)
            //12162010
            }else if ((currobj.catgid.value == '40') && (currobj.SubCatgId.value.toUpperCase()=='STREETSIGN')){
					grayscale=true	//When placing logo for the firsttime then set it to true
					convert_logo_color(yindex, xname, lastparam, grayscale)
			}else{
				changeLibSymbol(xname)
			}
		} else {
			//alert("placelogo_template...A1")
			if (currobj.MultiColorDesign.value){
				//alert("placelogo_template...A2")
				changeImage(yindex, secondparam, xname, xname, lastparam);
			}else{
				//alert("placelogo_template...A3")
				grayscale=true	//When placing logo for the firsttime then set it to true
				convert_logo_color(yindex, xname, lastparam, grayscale)
			}
		}
	}else{
		var tflag = false;
		if (document.preview.cbLogoTrans) {
			if (document.preview.cbLogoTrans.checked) {
				tflag = true;
				grayscale=false	
				convert_logo_color(yindex, xname, lastparam, grayscale)
			}
		}
		if (!tflag) {
			changeImage(yindex, secondparam, xname, xname, lastparam);
		}
	}
	//	alert("placelogo_template...C1")
	ChangeLogoImageName(xname)
	//	alert("placelogo_template...C2")
	//added by vipin on 12-02-10
	if(xcatgid == '511' && xsubcatgid == 'improvedofficesign')
	{
		changeClipArtImageColorNew(currobj.hcolorno1.value);	
	}
}
function ChangeLogoImageName(ytext) {
	if (document.preview.LogoImageName) {
		document.preview.LogoImageName.value = ytext
	}
}
function AfterConvertLogo() {
	//Special treatment for logos for Quill's 2 color wizards such as business cards,
	//envelopes etc.
	if (Color_SchemeID.toUpperCase().indexOf('2COLOR') >= 0) {
		ChangeColor2(document.preview.hcolorno2.value, 2)
	}
}
function convert_logo_color(yindex, xname, lastparam, grayscale, ychangecolor){
	var urlstr
	var changecolorno
	
	changecolorno="3"
	if (currobj.catgid.value==115 || currobj.catgid.value==127){
		changecolorno=xlogocolorno;
	}
	if (currobj.catgid.value==40){
		changecolorno=0;
	}

    if (currobj.SubCatgId.value.toUpperCase()=='DESIGNER'){     //10202010
		changecolorno=3;
    }
    
	if (currobj.SubCatgId.value.toUpperCase()=='PARKING_CUSTOM2' || currobj.SubCatgId.value.toUpperCase()=='PARKING2'){
	    if (designcolortype.toLowerCase()=='reverse'){  //defined in wizardy
		    changecolorno=0;
	    }else{
		    changecolorno=1;
		}
	}

	if (flag_Graphic_ColorConv==false){
		return
	}
	
	if (xname.toLowerCase().indexOf('null.gif')>=0 || xname.toLowerCase().indexOf('logo/null_')>=0){
		return
	}
	if (xname.toLowerCase().indexOf('addimage.gif')>=0 || xname.toLowerCase().indexOf('logo/addimage_')>=0){
		return
	}
	if (xname.toLowerCase().indexOf('asset-tag-logo')>=0){	//exclude seeded logo
		return
	}
	if (xname.toLowerCase().indexOf('parking-sign-logo-')>=0){	//exclude seeded logo
		return
	}
	
	GenAppendString()
	
	if (ychangecolor) {
		xchangecolor=ychangecolor
	}
	else {
		if (currobj.catgid.value==117 || currobj.catgid.value==115 || currobj.catgid.value==127 || currobj.catgid.value==40){
			//hcolorno3 changed to ["hcolorno"+changecolorno]
			if (currobj["hcolorno"+changecolorno].value.toUpperCase() == 'FFFFFF') {
				currobj["hcolorno"+changecolorno].value = 'FFFFFE';
			}
			xchangecolor=currobj["hcolorno"+changecolorno].value
			
			//alert(grayscale +'\n'+xtranscolor +'\n'+xchangecolor)
		}else if (currobj.catgid.value==77){	//Parking Permit
			if (document.preview.LogoColorFlag) {
				if (document.preview.LogoColorFlag.value.toUpperCase() == 'C') {
					currobj.hcolorno2.value=currobj.hcolorno2.value.split('#').join('')
					if (currobj.hcolorno2.value.toUpperCase() == 'FFFFFF') {
						xchangecolor='FFFFFE'
					}else{
						xchangecolor=currobj.hcolorno2.value
					}
				}else{
					currobj.hcolorno0.value=currobj.hcolorno0.value.split('#').join('')
					if (currobj.hcolorno0.value.toUpperCase() == 'FFFFFF') {
						xchangecolor='FFFFFE'
					}else{
						xchangecolor=currobj.hcolorno0.value
					}
				}
			}
		}else{
			
			if (currobj["hcolorno" + xlogocolorno].value.toUpperCase() == 'FFFFFF') {
				currobj["hcolorno" + xlogocolorno].value = 'FFFFFE';
			}
			
			xchangecolor=currobj["hcolorno" + xlogocolorno].value
		}
		
		if (xchangecolor.toUpperCase()=='FFFFFF'){
			if (currobj.catgid.value==117 || currobj.catgid.value==115 || currobj.catgid.value==127){
				xtranscolor=currobj.hcolorno3.value
				xchangecolor=currobj.hcolorno2.value
				//alert(xtranscolor +'\n'+xchangecolor)
			}else if (currobj.catgid.value==77){	//Parking Permit
			}else{
				xtranscolor=currobj.hcolorno1.value
				xchangecolor=currobj.hcolorno2.value
			}
		}
	}
	div_transcolor[yindex] = '#' + xtranscolor
	if (document.preview.cbLogoTrans) {
		if (!document.preview.cbLogoTrans.checked) {
			div_transcolor[yindex] = ""
		}
	}
	//Special treatment for logos for Quill's 2 color wizards such as business cards,
	//envelopes etc.
	if (Color_SchemeID.toUpperCase().indexOf('2COLOR') >= 0) {
		var xrectexist = false;
		for (var n=1; n<num_divs; n++) {
			if (div_contents[n]){
				if (div_contents[n].toLowerCase().indexOf('rectangle') >= 0 ){
					xrectexist = true;
				}
			}
		}
		if (xrectexist) {
			xchangecolor = document.preview.hcolorno1.value  //color1 being black
		}else {
			xchangecolor = document.preview.hcolorno2.value
		}
	}
	div_imagecolor[yindex] = '#' + xchangecolor
	var xlogotrans = "0"
	if (document.preview.cbLogoTrans) {
		if (document.preview.cbLogoTrans.checked) {
			xlogotrans = "1"
		}
	}
	if (grayscale) {
		grayscale=true
	}else {
		grayscale=false
	}
	if (currobj.catgid.value == 514){
		yindexA=getobjectno('company')
		xchangecolor=currobj["hcolorno"+div_color[yindexA]].value
		if (currobj["hcolorno" + div_color[yindexA]].value.toUpperCase() == 'FFFFFF') { currobj["hcolorno" + div_color[yindexA]].value = 'FFFFFE'; }
		xchangecolor=currobj["hcolorno"+div_color[yindexA]].value
	}
	if (currobj.catgid.value == 12){
		yindexA=getobjectno('textline1')
		xchangecolor=currobj["hcolorno"+div_color[yindexA]].value
		if (currobj["hcolorno" + div_color[yindexA]].value.toUpperCase() == 'FFFFFF') { currobj["hcolorno" + div_color[yindexA]].value = 'FFFFFE'; }
		xchangecolor=currobj["hcolorno"+div_color[yindexA]].value
	}
	urlstr = '/xp5/ConvertLogo.asp?parsheet=&imagenum='+yindex + '&logo=1&fname='+xname+'&transcolor='+ div_transcolor[yindex].split('#').join('')
	urlstr = urlstr +'&changecolor='+xchangecolor + '&appendstr='+xappendstr+'&grayscale='+grayscale + '&upload='+lastparam+'&logotrans='+xlogotrans
	//102307xwin1 = window.open(urlstr, "win1", "width=500,height=400,left=3000, top=6000")
	//102307IsPopupBlocker(xwin1)
	//alert(urlstr)
	
	var resptext=CallPage(urlstr + '&xmlhttp=1')
	
	applyConvertedLogo(resptext)
	if (currobj.catgid.value.toLowerCase()==12 && currobj.SubCatgId.value.toLowerCase()=='visitorpass'){
		yindex=getobjectno('textline1')		//companyname
		if (yindex != -1){
			div_hidden[yindex] = true;
			FlashShowHideObject(yindex);
			changeText(div_text[yindex], yindex)
		}
		yindex=getobjectno('LOGOIMAGE')		//LOGO
		if (yindex != -1){
			//show flash object code here
			div_hidden[yindex]=false
			FlashShowHideObject(yindex);
		}
	}
}
var popUpsBlocked=false
function IsPopupBlocker(wintest){
	if(wintest==null || typeof(wintest)=="undefined"){
		popUpsBlocked = true
	}else{
		popUpsBlocked = false
	}
	if(popUpsBlocked){
		alert('We have detected that you are using popup blocking software.\nPlease disable the POP-UP BLOCKER and try again\nor\nPlease contact your system administrator. ');
	}
	return popUpsBlocked
}
//The changeimage function always call following function after placing image on the
//template
function userdefinedafterchange(yindex){
	if (div_fields[yindex].toLowerCase()=='hdrspanish' ||div_fields[yindex].toLowerCase()=='headerimg'){
		//do nothing for headers
	}else{	
		if (flag_Textreduction_logo_insert==true) {
			//Make visible to the previously hidden logo
			div_hidden[yindex]=false
			FlashShowHideObject(yindex);
			adjustTextsizes(yindex, '-')
			
			if (currobj.SubCatgId.value=='GRAPHICAREA'){	//For Graphic area signs set valign=bottom after logo is selected
				if (currobj.areaSignBorder){
					if (currobj.areaSignBorder.value=='1'){
						VAlignAll(1,'')
						backgroundimage = backgroundimage.toLowerCase().split('_b.gif').join('.gif');
						Flash_Update_BackImage(backgroundimage)
					}
				}
			}
		}
		if (currobj.signtype){
			if (currobj.SubCatgId.value.toUpperCase()=='PARKING2' || currobj.SubCatgId.value.toUpperCase()=='PARKING_CUSTOM' || currobj.SubCatgId.value.toUpperCase()=='PARKING_CUSTOM2' || currobj.SubCatgId.value.toUpperCase()=='DESIGNER'){
 			//12162010
 			} else if ((currobj.catgid.value.toUpperCase() == '40') && (currobj.SubCatgId.value.toUpperCase() == 'STENCIL')){
 			//12162010
 			} else if  ((currobj.catgid.value.toUpperCase() == '40') && (currobj.SubCatgId.value.toUpperCase() == 'STREETSIGN')){
 			//jp 02042011
			} else if (currobj.signtype.value.toUpperCase() != 'OSHA' || currobj.signtype.value.toUpperCase() != 'ANSI' || currobj.signtype.value.toUpperCase() != 'FACILITY' || currobj.signtype.value.toUpperCase() != 'FACILITYLABEL' || currobj.signtype.value.toUpperCase() != 'PROJ'){
				yesSymbol(yindex)
			}
		}
	}
}
xcounter = 0
xappendstr = "0000"
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;
}
//======Text reduction controlled by the flag flag_Textreduction_logo_insert=======
var oplusminus='+'
var plusminus='+'
function adjustTextsizes(yindex, plusminus){
	var xindex
	//don't apply text resizing rules on the materials page
	if (document.preview.MaterialPage){	
		return;
	}
	if (oplusminus==plusminus){ return }
	xindex=getobjectno("group1")
	if (xindex==-1) {
		xindex=getobjectno("group")
	}
	if (xindex!=-1) {
		if ( (currobj.catgid.value==78 && currobj.SubCatgId.value.toLowerCase()=='mailing') || (currobj.catgid.value==512 && currobj.SubCatgId.value.toUpperCase()=='ADDRESSSTANDARD') ){
			if (plusminus=='-'){	//set group X = backW-logow and W = W-logoW
				div_x[xindex]=parseFloat(div_x[xindex]) + parseFloat(div_w[yindex])*2
				div_w[xindex]=parseFloat(div_w[xindex])-parseFloat(div_w[yindex])-3	//leave some gap between text and symbol
			} else {
				div_x[xindex]=parseFloat(div_x[xindex]) - parseFloat(div_w[yindex])*2
				div_w[xindex]=parseFloat(div_w[xindex])+parseFloat(div_w[yindex])+3
			}
			oplusminus=plusminus
			changeDivLocation(xindex)
			changeDivSize(xindex)
			moveobject(xindex, 0, 0)
		} else if ( currobj.catgid.value==9 && (currobj.SubCatgId.value.toUpperCase()=='CORRIDOR' || currobj.SubCatgId.value.toUpperCase()=='CORRIDOR2')){
			if (plusminus=='-'){	//set group X = backW-logow and W = W-logoW
				div_w[xindex]=parseFloat(div_w[xindex])-parseFloat(div_w[yindex])-3	//leave some gap between text and symbol
			} else {
				div_w[xindex]=parseFloat(div_w[xindex])+parseFloat(div_w[yindex])+3
			}
			oplusminus=plusminus
			changeDivLocation(xindex)
			changeDivSize(xindex)
			moveobject(xindex, 0, 0)
		}else if (currobj.textReductiondir.value=='top' || currobj.signtype.value=='MULTICOLORLABEL' || currobj.signtype.value=='FACILITY' || currobj.signtype.value=='FACILITYLABEL' || currobj.signtype.value=='FACILITYFLOORSTAND' || currobj.signtype.value=='PROJH' || currobj.signtype.value=='SAFETYFLOORSTAND'){
			if (plusminus=='-'){	//set group X = backW-logow and h = h-logoh
				div_y[xindex]=div_y[xindex] + div_h[yindex]*2
				div_h[xindex]=parseFloat(div_h[xindex])-parseFloat(div_h[yindex])
			} else {
				div_y[xindex]= parseFloat(div_y[xindex])-parseFloat(div_h[yindex]*2)
				div_h[xindex]=parseFloat(div_h[xindex])+parseFloat(div_h[yindex])
			}
			oplusminus=plusminus
			changeDivLocation(xindex)
			changeDivSize(xindex)
			moveobject(xindex, 0, 0)
		}else if (currobj.SubCatgId.value=='PARKING_CUSTOM' || currobj.SubCatgId.value=='PARKING_CUSTOM2'){
			if (plusminus=='-'){
				div_y[xindex]=div_y[xindex]+ div_h[yindex]*2
				div_h[xindex]=parseFloat(div_h[xindex])-parseFloat(div_h[yindex])
			} else {
				div_y[xindex]= parseFloat(div_y[xindex])-parseFloat(div_h[yindex]*2)
				div_h[xindex]=parseFloat(div_h[xindex])+parseFloat(div_h[yindex])
			}
			oplusminus=plusminus
			changeDivLocation(xindex)
			changeDivSize(xindex)
			moveobject(xindex, 0, 0)
			
		}else if (currobj.signtype.value=='OSHA' || (currobj.signtype.value=='ANSI') || currobj.textReductiondir.value=='right'){
			//change this to check subcatgid
			//textReductiondir for graphic signs
			if (plusminus=='-'){
				//set group X = backW-logow and W = W-logoW
				div_w[xindex]=parseFloat(div_w[xindex])-parseFloat(div_w[yindex])-3
				//leave some gap between text and symbol
			} else {
				div_w[xindex]=parseFloat(div_w[xindex])+parseFloat(div_w[yindex])+3
			}
			oplusminus=plusminus
			changeDivLocation(xindex)
			changeDivSize(xindex)
			moveobject(xindex, 0, 0)
		}
	}
	
}
/* Graphic Section Ends */
function resizeobject(x, y) {
	yindex=getobjectno(flag_GraphicField)
	if (yindex == -1){
		return
	}
	currobjnum=yindex
	xchange= parseFloat((div_w[yindex] * x)/100)
	ychange= parseFloat((div_h[yindex] * y)/100)
	tx = parseFloat(div_x[yindex]) - xchange
	ty = parseFloat(div_y[yindex]) - ychange
	tw = parseFloat(div_w[yindex]) + xchange;
	th = parseFloat(div_h[yindex]) + ychange;
	if (2*tw + tx > back_width - xrightmargin || 2 * th + ty > back_height - xbottommargin || tx < xleftmargin || ty < xtopmargin) {
		//There is no margin to resize any further.
		return;
	}
	div_x[yindex] = tx  //parseFloat(div_x[yindex]) - xchange
	div_y[yindex] = ty  //parseFloat(div_y[yindex]) - ychange
	div_w[yindex] = tw  //parseFloat(div_w[yindex]) + xchange;
	div_h[yindex] = th  //parseFloat(div_h[yindex]) + ychange;
	FlashResizeImage(x, y)
}
function AssignLogoColor(ynum) {
	var yindex=getobjectno(flag_GraphicField)
	if (yindex <= 0) {
		return;
	}
	ycolor = document.preview["hcolorno" + ynum].value
	if (ycolor.indexOf("FFFFFF") < 0) {
		//after the logo is placed once, then gray scale should be set to false.
		var tgrayscale = false
		convert_logo_color(yindex, div_text[yindex], "0", tgrayscale, ycolor.split('#').join(''))
	}
}
function showGraphicGallery(){
	var xwidth = 780;
	var xheight = 600;
	var xleft = (screen.width - xwidth) / 2;
	var xtop = (screen.height - xheight) / 2;
	xurl = 'Gallery.asp?Graphictype=Logo'
	winhandle = window.open(xurl, 'logogallery', CenterThisWindow(xwidth, xheight) + ', location=no, resizable=yes, scrollbars=yes')
}
function showUploadObject(objname){
	document.getElementById(objname).style.display = "block";
	document.getElementById(objname).style.visibility = "visible";
}
function hideUploadObject(objname){
	document.getElementById(objname).style.display = "none";
	document.getElementById(objname).style.visibility = "hidden";
}
function PlaceImageOnTemplate(yindex, ysku) {
	//placelogo_template(yindex, "none", "/xp2/clipart/" + ysku + ".png", 0)
	changeImage(yindex, "", "/xp2/clipart/" + ysku + ".png", "/xp2/clipart/" + ysku + ".png", "")
}
function ChangeCabinetImage(yindex, ysku) {
	var ximage = ""
	if (ysku.toLowerCase().indexOf("stdcab") >= 0) {
		ximage = div_text[yindex].toLowerCase().split('litcab').join('stdcab')
	}
	else {
		ximage = div_text[yindex].toLowerCase().split('stdcab').join('litcab')
	}
	changeImage(yindex, "", ximage, ximage, "")
}
function ShowCustomProductBuilder() {
	var xtotalamount = 0
	var xstr = ""
	xstr = "<br><table border=0 cellpadding=0 cellspacing=0 width=100%>"
	xstr = xstr + "<tr><td colspan=3 class=rule><img src=/xp/images/space.gif height=1 width=100%></td></tr>"
	xstr = xstr + "<tr height=18>"
	xstr = xstr + " <td class=body8b align=left>"
	xstr = xstr + " # "
	xstr = xstr + " </td>"
	xstr = xstr + " <td class=body8b align=left>"
	xstr = xstr + " Product "
	xstr = xstr + " </td>"
	xstr = xstr + " <td class=body8b align=right>"
	xstr = xstr + " Price&nbsp;"
	xstr = xstr + " </td>"
	xstr = xstr + "</tr>"
	xstr = xstr + "<tr><td colspan=3 class=rule><img src=/xp/images/space.gif height=1 width=100%></td></tr>"
	var xobj, t;
	var xdesc = "";
	var xlist = 0
	var xcounter = 0;
	var xselectedadders = "";
	//xobj = document.getElementById("cabinet")
	//xcounter++;
	//xstr = xstr + GetProductRow(xcounter, "Big Safety Scoreboard", "1599.13")
	//xtotalamount = xtotalamount + 1599.13
	
	xdesc = "";
	xlist = 0
	xobj = document.preview.CustomProduct
	if (xobj) {
		xcounter++;
		xlist = document.preview["CustomProduct_list1"].value
		xdesc = document.preview["CustomProduct_desc"].value
		if (xdesc.length > 0 ) {
			xstr = xstr + GetProductRow(xcounter, xdesc, xlist)
		}
		xtotalamount = xtotalamount + parseFloat(xlist)
	}
	
	var MaxAdders = 5;
	for (var j=0; j <= MaxAdders; j++) {
		xdesc = "";
		xlist = 0
		xobj = document.preview["CustomAdder" + j]
		if (xobj) {
			xcounter++;
			for (t=0; t < xobj.length; t++) {
				if (xobj[t].checked) {
					xsku = xobj[t].value
					if (xselectedadders.length > 0) {
						xselectedadders = xselectedadders + ";"
					}
					xselectedadders = xselectedadders + xsku
					xlist = document.preview["CustomAdder" + j + "_" + xsku + "_list1"].value
					xdesc = document.preview["CustomAdder" + j + "_" + xsku + "_desc"].value
				}
			}
			if (xdesc.length > 0 ) {
				xstr = xstr + GetProductRow(xcounter, xdesc, xlist)
			}
			xtotalamount = xtotalamount + parseFloat(xlist)
		}
	}
	
	/*
	xdesc = "";
	xlist = 0
	xobj = document.preview.CustomAdder2
	if (xobj) {
		xcounter++;
		for (t=0; t < xobj.length; t++) {
			if (xobj[t].checked) {
				xsku = xobj[t].value
				if (xselectedadders.length > 0) {
					xselectedadders = xselectedadders + ";"
				}
				xselectedadders = xselectedadders + xsku
				xlist = document.preview["CustomAdder2_" + xsku + "_list1"].value
				xdesc = document.preview["CustomAdder2_" + xsku + "_desc"].value
			}
		}
		if (xdesc.length > 0 ) {
			xstr = xstr + GetProductRow(xcounter, xdesc, xlist)
		}
		xtotalamount = xtotalamount + parseFloat(xlist)
	}
	
	xdesc = "";
	xlist = 0
	xobj = document.preview.CustomAdder3
	if (xobj) {
		xcounter++;
		for (t=0; t < xobj.length; t++) {
			if (xobj[t].checked) {
				xsku = xobj[t].value
				if (xselectedadders.length > 0) {
					xselectedadders = xselectedadders + ";"
				}
				xselectedadders = xselectedadders + xsku
				xlist = document.preview["CustomAdder3_" + xsku + "_list1"].value
				xdesc = document.preview["CustomAdder3_" + xsku + "_desc"].value
			}
		}
		if (xdesc.length > 0 ) {
			xstr = xstr + GetProductRow(xcounter, xdesc, xlist)
		}
		xtotalamount = xtotalamount + parseFloat(xlist)
	}
	*/
	document.preview.selectedadders.value = xselectedadders
	
	xstr = xstr + "<tr><td colspan=3 class=rule><img src=/xp/images/space.gif height=1 width=100%></td></tr>"
	xstr = xstr + "<tr height=18>"
	xstr = xstr + " <td colspan=2 class=body8b align=right>"
	xstr = xstr + "Total:&nbsp;"
	xstr = xstr + " </td>"
	xstr = xstr + " <td class=body8b align=right>"
	xstr = xstr + "$" + SuffixZeros(xtotalamount, 2) + "&nbsp;"
	xstr = xstr + " </td>"
	xstr = xstr + "</tr>"
	xstr = xstr + "<tr><td colspan=3 class=rule><img src=/xp/images/space.gif height=1 width=100%></td></tr>"
	xstr = xstr + "</table>"
	document.getElementById("CustomProductBuilder").innerHTML = xstr
}
function GetProductRow(ycounter, ydesc, ylist) {
	var xstr = ""
	var xclass = "trwhite"
	if (ycounter % 2 == 1) {
		xclass = "atr1"
	}
	xstr = "<tr class="+xclass+" height=18>"
	xstr = xstr + " <td class=body8>"
	xstr = xstr + "&nbsp;" + ycounter + "."
	xstr = xstr + " </td>"
	xstr = xstr + " <td class=body8>"
	xstr = xstr + "&nbsp;" + ydesc
	xstr = xstr + " </td>"
	xstr = xstr + " <td class=body8 align=right>"
	xstr = xstr + "$" + SuffixZeros(ylist, 2) + "&nbsp;"
	xstr = xstr + " </td>"
	xstr = xstr + "</tr>"
	return xstr;
}
function ShowTextHelp(yindex, yfldname) {
	var xstr
	var xfieldname = "div_" + yfldname.toLowerCase()
	
	document.getElementById(xfieldname).style.left = (screen.width / 2) - 275
	document.getElementById(xfieldname).style.top = 200
	document.getElementById(xfieldname).style.display = "block";
}
function HideThisDiv(divname) {
	document.getElementById(divname).style.display = "none"
}
function ApplyHelpText(yfldname, yslogan) {
	var tindex=getobjectno(yfldname)
	document.getElementById("textfield" + tindex).value = yslogan
	showTextOnTemplate(yslogan, tindex)
}
