﻿// JScript File
/*
What it does:  This file is intended to be used for parking signs wizard.
			It is conditionally included on the wizard page.
			This file will help us keep minimum functions within the wizard.asp page.
Referred by : wizardy.asp
*/
function change_arrow_type(atype, fldname, th, tw, txml) {
	var yindex, oldtext
	yindex = getobjectno(fldname)
	if (yindex != -1) {
		if (atype == 0) {
			changeText('', yindex) //Restore group size
			expand = 1
			change_group_height(expand, th, tw, txml, yindex)
		} else if (atype == 1) {
			oldtext = div_text[yindex]
			changeText('ÏÈÈ', yindex)
			if (oldtext.length == 0) {
				expand = 0
				change_group_height(0, th, tw, txml, yindex)
			}
		} else if (atype == 2) {
			oldtext = div_text[yindex]
			changeText('ÈÈË', yindex)
			if (oldtext.length == 0) {
				expand = 0
				change_group_height(0, th, tw, txml, yindex)
			}
		} else if (atype == 3) {
			oldtext = div_text[yindex]
			changeText('ÏÈÈË', yindex)
			if (oldtext.length == 0) {
				expand = 0
				change_group_height(0, th, tw, txml, yindex)
			}
		} else if (atype == -1) {
			expand = 1
			change_group_height(1, th, tw, txml, yindex)
		} else if (atype == -2) {
			expand = 0
			change_group_height(0, th, tw, txml, yindex)
		}
	}
}
function New_change_group_height(expand, th, tw, txml, yindex) {
	for (var i = 0; i < num_divs; i++) {
		if (div_fields[i]) {
			if (div_fields[i].toUpperCase() == 'GROUP') {
				if (expand == 1) { //increase
					div_h[i] = parseFloat(div_h[i]) + parseFloat(div_h[yindex])
				} else { //decrease
					div_h[i] = parseFloat(div_h[i]) - parseFloat(div_h[yindex])
				}
				changeDivLocation(i)
				changeDivSize(i)
				moveobject(i, 0, 0)
			}
		}
	}
}
function change_group_height(expand, th, tw, txml) {
	var mul_factor = 96 * xzoomper
	var grp_height;
	for (var i = 0; i < num_divs; i++) {
		if (div_fields[i]) {
			if (div_fields[i].toUpperCase() == 'GROUP') {
				if ((th == 12) && (tw == 12)) {
					if (expand == 1) grp_height = olddiv_h[i] * 2
					else grp_height = 6.6 * mul_factor
				}
				else if ((th == 18) && (tw == 12)) {
					if (expand == 1) grp_height = olddiv_h[i] * 2
					else {
						txml = txml.toLowerCase();
						if (txml == 'parking1_18x12.xml') {
							grp_height = 8.35 * mul_factor;
						}
						else if ((txml == 'parking2_18x12.xml') || (txml == 'parking4_18x12.xml') || (txml == 'parking5_18x12.xml')) {
							grp_height = 5.15 * mul_factor;
						}
						else if ((txml == 'parking20_18x12.xml') || (txml == 'parking21_18x12.xml')) {
							grp_height = 6.15 * mul_factor;
						}
						else if (txml == 'parking22_18x12.xml') {
							grp_height = 4.3 * mul_factor;
						}
						else if (txml == 'parking23_18x12.xml') {
							grp_height = 2.75 * mul_factor;
						}
						else {
							//grp_height = 11.5 * mul_factor
							grp_height = olddiv_h[i] * 0.75 * 2
						}
					}
				}
				else if ((th == 12) && (tw == 18)) {
					if (expand == 1) grp_height = olddiv_h[i] * 2
					else {
						txml = txml.toLowerCase();
						if (txml == 'parkingc_12x18.xml') {
							grp_height = 5.35 * mul_factor;
						}
						if (txml.substring(0, 14) == 'parkingc_12x18') {
							grp_height = 5.35 * mul_factor;
						}
					}
				}
				else if ((th == 18) && (tw == 24)) {
					if (expand == 1) grp_height = olddiv_h[i] * 2
					else {
						txml = txml.toLowerCase();
						if (txml == 'parkingc_18x24.xml') {
							grp_height = 11 * mul_factor;
						}
						if (txml.substring(0, 14) == 'parkingc_18x24') {
							grp_height = 11 * mul_factor;
						}
					}
				}
				else if ((th == 6) && (tw == 12)) {
					if (expand == 1) grp_height = olddiv_h[i] * 2
					else {
						txml = txml.toLowerCase();
						if (txml == 'parkingc_6x12.xml') {
							grp_height = 3.35 * mul_factor;
						}
					}
				}
				else if ((th == 18) && (tw == 18)) {
					if (expand == 1) grp_height = olddiv_h[i] * 2
					else grp_height = 11 * mul_factor
				}
				else if ((th == 24) && (tw == 18)) {
					if (expand == 1) grp_height = olddiv_h[i] * 2
					else {
						txml = txml.toLowerCase();
						if (txml == 'parking1_24x18.xml') {
							grp_height = 11.7 * mul_factor;
						}
						else if ((txml == 'parking2_24x18.xml') || (txml == 'parking4_24x18.xml') || (txml == 'parking5_24x18.xml')) {
							grp_height = 6.6 * mul_factor;
						}
						else if ((txml == 'parking20_24x18.xml') || (txml == 'parking21_24x18.xml')) {
							grp_height = 7.5 * mul_factor;
						}
						else if (txml == 'parking22_24x18.xml') {
							grp_height = 4.5 * mul_factor;
						}
						else if (txml == 'parking23_24x18.xml') {
							grp_height = 2.5 * mul_factor;
						}
						else if (txml == 'parkingc_24x18-l.xml') {
							grp_height = div_h[i] * 0.85 * 2;
						}
						else grp_height = 16.4 * mul_factor
					}
				}
				else if ((th == 24) && (tw == 24)) {
					if (expand == 1) grp_height = olddiv_h[i] * 2
					else grp_height = 15 * mul_factor
				}
				else if ((th == 24) && (tw == 30)) {
					if (expand == 1) grp_height = olddiv_h[i] * 2
					else grp_height = 15 * mul_factor
				}
				else if ((th == 24) && (tw == 36)) {
					if (expand == 1) grp_height = olddiv_h[i] * 2
					else grp_height = 15 * mul_factor
				}
				else if ((th == 30) && (tw == 24)) {
					if (expand == 1) grp_height = olddiv_h[i] * 2
					else grp_height = olddiv_h[i] * 0.75 * 2 //20 * mul_factor
				}
				else if ((th == 30) && (tw == 30)) {
					if (expand == 1) grp_height = olddiv_h[i] * 2
					else grp_height = 19 * mul_factor
				}
				else if ((th == 30) && (tw == 36)) {
					if (expand == 1) grp_height = olddiv_h[i] * 2
					else grp_height = 19 * mul_factor
				}
				else if ((th == 36) && (tw == 36)) {
					if (expand == 1) grp_height = olddiv_h[i] * 2
					else grp_height = 19 * mul_factor
				}
				else if ((th == 36) && (tw == 48)) {
					if (expand == 1) grp_height = olddiv_h[i] * 2
					else grp_height = 19 * mul_factor
				}
				else if ((th == 36) && (tw == 24)) {
					if (expand == 1) grp_height = olddiv_h[i] * 2
					else grp_height = olddiv_h[i] * 0.85 * 2 //19 * mul_factor
				}
				else if ((th == 36) && (tw == 30)) {
					if (expand == 1) grp_height = olddiv_h[i] * 2
					else grp_height = olddiv_h[i] * 0.75 * 2 //19 * mul_factor
				}
				else if ((th == 48) && (tw == 36)) {
					if (expand == 1) grp_height = olddiv_h[i] * 2
					else grp_height = olddiv_h[i] * 0.75 * 2 //19 * mul_factor
				}
				else if ((th == 48) && (tw == 60)) {
					if (expand == 1) grp_height = olddiv_h[i] * 2
					else grp_height = olddiv_h[i] * 0.75 * 2 //19 * mul_factor
				}
				else if ((th == 48) && (tw == 72)) {
					if (expand == 1) grp_height = olddiv_h[i] * 2
					else grp_height = olddiv_h[i] * 0.75 * 2 //19 * mul_factor
				}
				div_h[i] = grp_height / 2;
				changeDivSize(i);
				ResetObject(i);
			}
		}
	}
}
var activeRow1 = null;
var activeRow2 = null;
var activeRow3 = null;
function trClickDOM(row, rn, buttonName, divName) {
	if (buttonName == 'signborder') {
		if (activeRow1) {
			activeRow1.bgColor = '#FFFFFF';
		}
		activeRow1 = row;
		activeRow1.bgColor = '#E8E3D9';
	}
	else if (buttonName == 'radiobutton2') {
		if (activeRow2) {
			activeRow2.bgColor = '#FFFFFF';
		}
		activeRow2 = row;
		activeRow2.bgColor = '#E8E3D9';
	}
	else if (buttonName == 'radiobutton3') {
		if (activeRow3) {
			activeRow3.bgColor = '#FFFFFF';
		}
		activeRow3 = row;
		activeRow3.bgColor = '#E8E3D9';
	}
	for (var i = 0; i < currobj[buttonName].length; i++) {
		GetElement(divName + i).style.fontWeight = "normal";
	}
	GetElement(divName + rn).style.fontWeight = "bold";
	currobj[buttonName][rn].checked = true;
	currobj[buttonName][rn].click();
}
//Without Click
function trClickDOMWOCLick(row, rn, buttonName, divName) {
	if (buttonName == 'signborder') {
		if (activeRow1) {
			activeRow1.bgColor = '#FFFFFF';
		}
		activeRow1 = row;
		activeRow1.bgColor = '#E8E3D9';
	}
	else if (buttonName == 'radiobutton2') {
		if (activeRow2) {
			activeRow2.bgColor = '#FFFFFF';
		}
		activeRow2 = row;
		activeRow2.bgColor = '#E8E3D9';
	}
	else if (buttonName == 'radiobutton3') {
		if (activeRow3) {
			activeRow3.bgColor = '#FFFFFF';
		}
		activeRow3 = row;
		activeRow3.bgColor = '#E8E3D9';
	}
	for (var i = 0; i < currobj[buttonName].length; i++) {
		GetElement(divName + i).style.fontWeight = "normal";
	}
	GetElement(divName + rn).style.fontWeight = "bold";
	currobj[buttonName][rn].checked = true;
}
function change_text(val, yindex) {
	changeText(val, yindex);
	var fldname = div_fields[yindex].toLowerCase()
	var spcobjno = parseInt(fldname.split('textline').join('')) - 1
	var spindex = getobjectno("space" + spcobjno)
	if (spindex != -1) {
		if (val.length == 0) {
			div_text[spindex] = ''
			changeText('', spindex)
		}
		else {
			div_text[spindex] = ' '
			changeText(' ', spindex)
		}
	}
}
function changeParkingColorScheme(colorrgb, textcolorcode, backcolorcode, colschemeindex, backcolor, isborder) {

	currobj.hcolorno0.value = backcolor; //052306
	currobj.hcolorno1.value = colorrgb;
	currobj.signcolor.value = textcolorcode;

	ChangeBackColor(backcolorcode, colschemeindex, isborder);

	backcolorcode = backcolorcode.split('W').join('White')
	backcolorcode = backcolorcode.split('Y').join('Yellow')
	backcolorcode = backcolorcode.split('O').join('Orange')
	backcolorcode = backcolorcode.split('B').join('Blue')
	backcolorcode = backcolorcode.split('R').join('Red')
	backcolorcode = backcolorcode.split('G').join('Green')
	backcolorcode = backcolorcode.split('N').join('Brown')
	backcolorcode = backcolorcode.split('K').join('Black')
	
	textcolorcode = textcolorcode.split('W').join('White')
	textcolorcode = textcolorcode.split('Y').join('Yellow')
	textcolorcode = textcolorcode.split('O').join('Orange')
	textcolorcode = textcolorcode.split('B').join('Blue')
	textcolorcode = textcolorcode.split('R').join('Red')
	textcolorcode = textcolorcode.split('G').join('Green')
	textcolorcode = textcolorcode.split('N').join('Brown')
	textcolorcode = textcolorcode.split('K').join('Black')
	
	currobj.colorscheme.value = backcolorcode + ' on ' + textcolorcode;
}
function ChangeBackColor(clrcode, index, isborder) {
	var txml //= currobj.templateXML.value.toLowerCase();
	
	var signcolor = currobj.signcolor.value;
	var clr = currobj.hcolorno1.value;
	var border;
	border = true
	//var tmpbgimage = document.images['bkimage'].src
	var tmpbgimage = backgroundimage;
	
	var imgtype = tmpbgimage.substring(tmpbgimage.length - 4, tmpbgimage.length)
	var tmpbgimage1 = tmpbgimage.substring(0, tmpbgimage.length - 4)
	arr_bgimage = tmpbgimage1.split('_')
	var strChar = "";
	var charBG, charText, charBorder;
	if (arr_bgimage.length > 0) {
		strChar = arr_bgimage[arr_bgimage.length - 1];
	}

/*	10222010
	if (currobj.signborder) {
		if (clrcode == "W") {
			//if (currobj.signborder[0].checked == true){
			//If white text on colored background is selected then disable border option
			currobj.signborder[1].checked = true
			//currobj.signborder[0].disabled = true;
			if (document.getElementById('trowA0')) {
				document.getElementById('trowA0').style.display = 'none';
			}
			else {
				currobj.signborder[0].disabled = true;
			}
			//}
		}
		else {
			if (clrcode.length > 0) {
				//currobj.signborder[0].disabled = false;
				if (document.getElementById('trowA0')) {
					document.getElementById('trowA0').style.display = 'block';
				}
				else {
					currobj.signborder[0].disabled = false;
				}
			}
		}
		if (currobj.signborder[0].checked == true) border = true;
		else border = false;
	}
*/

	border = false;
	if (isborder==1){
		border = true;
	}

	if (clrcode.length > 0) currobj.clrcode.value = clrcode;
	else clrcode = currobj.clrcode.value;
	for (var i = 0; i < num_divs; i++) {
		if (div_fields[i]) {
			if ((div_contents[i] == 'label') || (div_contents[i] == 'plabel')) {
				if (div_fields[i].toLowerCase() == 'textline1') {
					//052306if (div_color[i] != 0) {
					if (div_color[i] != 0) {
						div_color_hex[i] = clr;
					} else {
						div_color_hex[i] = currobj.hcolorno0.value;
					}
					if (strChar.length == 3) {
						charBG = strChar.substring(0, strChar.length - 2);
						charText = strChar.substring(1, strChar.length - 1);
						charBorder = strChar.substring(2, strChar.length);
						//alert('strChar: ' + strChar);
						//alert('clrcode: ' + clrcode);
						//alert('signcolor: ' + signcolor);
						//alert('clr: ' + clr);
						if (border == true) {
							charBorder = '1'; //clrcode;
						} else {
							charBorder = '0'; //'N';
						}
						charBG = signcolor;
						charText = clrcode;
						var temp_imgName;
						for (var i1 = 0; i1 <= arr_bgimage.length - 2; i1++) {
							if (i1 > 0) {
								temp_imgName = temp_imgName + '_' + arr_bgimage[i1];
							}
							else {
								temp_imgName = arr_bgimage[i1];
							}
						}
						//alert(charBG + charText + charBorder);
						temp_imgName = temp_imgName + '_' + charBG + charText + charBorder + imgtype;
						backgroundimage = temp_imgName.substring(temp_imgName.indexOf('/xp2/clipart'), temp_imgName.length) //txml					
						//document.images['bkimage'].src = temp_imgName;
					}
					else {
						//var tmpbgimage = document.images['bkimage'].src
						var tmpbgimage = backgroundimage;
						var imgtype = tmpbgimage.substring(tmpbgimage.length - 4, tmpbgimage.length)
						//-------
						txml = ''
						//a_bgimage=document.images['bkimage'].src.split('_')
						a_bgimage = backgroundimage.split('_')
						for (var n = 0; n < a_bgimage.length - 1; n++) {
							if (n > 0) {
								txml = txml + '_' + a_bgimage[n]
							} else {
								txml = txml + a_bgimage[n]
							}
						}
						if (border == true) {
							txml = txml + '_' + signcolor + clrcode
						} else {
							txml = txml + '_' + signcolor
							if (currobj.signborder) {
								currobj.signborder[1].click();
							}
						}
						txml = txml + imgtype;
						txml = txml.toLowerCase()
						//------
						//txml = '/xp2/clipart/' + txml + imgtype;
						backgroundimage = txml.substring(txml.indexOf('/xp2/clipart'), txml.length) //txml					
					}
				}
				if (div_fields[i].toLowerCase() == 'textline2') {
					div_color_hex[i] = clr;
				}
				if (div_fields[i].toLowerCase() == 'textline3') {
					div_color_hex[i] = clr;
				}
			} else if ((div_contents[i] == 'image') || (div_contents[i] == 'pimage')) {
				if (flag_GraphicField.length > 0 && flag_GraphicField.toUpperCase() == div_fields[i].toUpperCase()) {
					grayscale = false
					lastparam = ""
					convert_logo_color(i, div_text[i], lastparam, grayscale)
				}
			}
		}
	}	
	for (var i = 1; i <= 10; i++) {
		if (document.images['pickcolor' + i]) {
			if (i == index) document.images['pickcolor' + i].style.borderColor = '#3300CC';
			else document.images['pickcolor' + i].style.borderColor = '#FFFFFF';
		}
	}
	
	Flash_UpdateFlashObjects()
}
function bigarrow(arrowfldname) {
	var fldname, yindex
	yindex = getobjectno(arrowfldname)
	div_size[yindex] = parseFloat(div_size[yindex]) + (4 / xzoomper)
	if (parseFloat(div_size[yindex]) < 1) {
		div_size[yindex] = 6
	}
	//changeText(div_text[yindex], yindex)
	flashIncreaseFontSize(yindex)
}
function smallarrow(arrowfldname) {
	var fldname, txtobjno, txtindex
	yindex = getobjectno(arrowfldname)
	div_size[yindex] = parseFloat(div_size[yindex]) - (4 / xzoomper)
	if (parseFloat(div_size[yindex]) < 1) {
		div_size[yindex] = 6
	}
	//changeText(div_text[yindex], yindex)
	flashDecreaseFontSize(yindex)
}
function changeLibSymbol(fn1) {
	var yindex, xdom, urlstr, convcolor = false
	if (currobj.hcolorno1.value == 'FFFFFF') {
		currobj.hcolorno1.value = 'FFFFFE';
	}
	yindex = getobjectno(flag_GraphicField) //"symbol")
	if (yindex == -1) {
		return
	}
	//If it is facility sign or express sign, convert symbol to printcolor1
	GenAppendString()
	xchangecolor = currobj.hcolorno1.value

    if (currobj.SubCatgId.value.toUpperCase()=='DESIGNER'){	    //10202010
        xchangecolor=currobj.hcolorno3.value
    }


	if (currobj.SubCatgId.value.toUpperCase()=='PARKING_CUSTOM2' || currobj.SubCatgId.value.toUpperCase()=='PARKING2'){
	    //designcolortype defined in wizardy
	    if (designcolortype.toLowerCase()=='reverse'){
		    changecolorno=0;
	    }else{
		    changecolorno=1;
		}
	}

	if (xchangecolor.toUpperCase() == 'FFFFFF') {
		xtranscolor = currobj.hcolorno1.value
		xchangecolor = currobj.hcolorno2.value
	}
	div_transcolor[yindex] = xtranscolor;
	div_imagecolor[yindex] = xchangecolor
	urlstr = 'ConvertLogo.asp?imagenum=' + yindex + '&fname=' + fn1 + '&grayscale=true&transcolor=' + xtranscolor + '&changecolor=' + xchangecolor + '&appendstr=' + xappendstr
	urlstr = urlstr + '&facilityexpr=1'
	//102307imageSelector = window.open(urlstr, 'hidden2', 'width=100,height=100,location=no,resizable=yes,scrollbars=yes,left=3000,top=3000')
	var resptext = CallPage('/xp5/' + urlstr + '&xmlhttp=1')
	applyConvertedLogo(resptext)
	if (div_hidden[yindex] == true) {
		div_hidden[yindex] = false
		FlashShowHideObject(yindex);
	}
}
function change_color(pcolor, bkcolor, bkclrrgb) {

	var tlength = bkcolor.length + 5
	var fileext = backgroundimage.substring(backgroundimage.length - 4, backgroundimage.length)
	backgroundimage = backgroundimage.substring(0, backgroundimage.length - tlength) + '_' + bkcolor + fileext
	//Flash_Update_BackImage(backgroundimage);
	currobj.hcolorno3.value = pcolor;
	currobj.hcolorno0.value = bkclrrgb
	fill_color_RGB = bkclrrgb
	for (var i = 1; i < num_divs; i++) {
		if (div_color[i] == '3' || div_color[i] == '0') {
			div_color_hex[i] = "#" + currobj["hcolorno" + div_color[i]].value
		}
	}
	Flash_UpdateFlashObjects();

    if (currobj.SubCatgId.value.toUpperCase()=='DESIGNER'){	    //10202010
	    var yindex=getobjectno(flag_GraphicField)
	    if (yindex != -1) {
	        if (div_text[yindex].toLowerCase()!='addimage.gif' || div_text[yindex].toLowerCase()!='choose-clipart-Dome.gif'){ 
		        convert_logo_color(yindex, div_text[yindex], 0, false)
	        }
        }
    }
}
