﻿/*
What it does : This file is intended to be used for Lockout Tag wizard.
			   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
*/
function change_selection(xvalue,xdivname){
	var xfire = new Array()
	var xhealth = new Array()
	var xreactivity = new Array()
	
	xfire[0] = "Flash point:<br><b>0</b> - Will not burn"
	xfire[1] = "Flash point:<br><b>1</b> - Above 200°F"
	xfire[2] = "Flash point:<br><b>2</b> - Below 200°F"
	xfire[3] = "Flash point:<br><b>3</b> - Below 100°F"
	xfire[4] = "Flash point:<br><b>4</b> - Below 73°F"
	xhealth[0] = "<b>0</b> - Normal material"
	xhealth[1] = "<b>1</b> - Slightly hazardous"
	xhealth[2] = "<b>2</b> - Hazardous"
	xhealth[3] = "<b>3</b> - Extreme danger"
	xhealth[4] = "<b>4</b> - Deadly"
	xreactivity[0] = "<b>0</b> - Stable"
	xreactivity[1] = "<b>1</b> - Unstable if heated"
	xreactivity[2] = "<b>2</b> - Violent chem. change"
	xreactivity[3] = "<b>3</b> - Shock+heat may detonate"
	xreactivity[4] = "<b>4</b> - May detonate"

	if (xdivname=='fire') {
	 	xdesc=xfire[xvalue]
	} else if	(xdivname=='health') {
	 	xdesc=xhealth[xvalue]
	} else if	(xdivname=='reactivity') {
	 	xdesc=xreactivity[xvalue]
	}
	MM_changeProp(xdivname,'','innerHTML',xdesc,'DIV')
	
		
}

function change_image_selection(imgindex, yindex){
	switch(imgindex)
	{
		case 0:
			changeImage(yindex,'dash.gif','dash.gif','dash.gif')
			break;
		case 1:
			changeImage(yindex,'acid.gif','acid.gif','acid.gif')
			break;
		case 2:
			changeImage(yindex,'alk.gif','alk.gif','alk.gif')
			break;
		case 3:
			changeImage(yindex,'cor.gif','cor.gif','cor.gif')
			break;
		case 4:
			changeImage(yindex,'ox.gif','ox.gif','ox.gif')
			break;
		case 5:
			changeImage(yindex,'nowater.gif','nowater.gif','nowater.gif')
			break;
		case 6:
			changeImage(yindex,'nowatox.gif','nowatox.gif','nowatox.gif')
			break;
		case 7:
			changeImage(yindex,'radioa.gif','radioa.gif','radioa.gif')
			break;
	}
	
}

function MM_changeProp(objName,x,theProp,theValue) { 
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
    if (theValue == true || theValue == false)
      eval("obj."+theProp+"="+theValue);
    else eval("obj."+theProp+"='"+theValue+"'");
  }
}

function setPhyState(xobj){
	var currobj=document.preview
	if (currobj.radiostate[0].checked==true){
		currobj.PHYSOLID.value='X'
		currobj.PHYLIQUID.value=' '

		ChangeFieldText('PHYSOLID', currobj.PHYSOLID, true)
		ChangeFieldText('PHYLIQUID', currobj.PHYLIQUID, false)
	}
	if (currobj.radiostate[1].checked==true){
		currobj.PHYSOLID.value=' '
		currobj.PHYLIQUID.value='X'

		ChangeFieldText('PHYSOLID', currobj.PHYSOLID, false)
		ChangeFieldText('PHYLIQUID', currobj.PHYLIQUID, true)
	}
	
}

function toggleVal(xobj){
	xobj.value=''
	if (xobj.checked==true){
		xobj.value='X'
	}
	for (var k=1; k< num_divs; k++) {
		if (div_contents[k]) {
			if (div_contents[k].indexOf('label') >= 0) {
				if (div_fields[k].toUpperCase() == xobj.name) {
					div_text[k] = xobj.value
					changeText(div_text[k], k)

					if (xobj.name == "OTHERHAZ") {
						ChangeFieldText('OTHERS', document.preview.OTHERS, document.preview.OTHERHAZ.checked)
					}
					
					break;
				}
			}
		}
	}
}

function checkSpecialChar(xKeyCode){
	if ((xKeyCode == 36) || (xKeyCode > 90 && xKeyCode < 97)) {
		return false;
	}else{
		return true;
	}
}

function ChangeFieldText(yfield, yobj, yflag) {
	for (var k=1; k< num_divs; k++) {
		if (div_contents[k]) {
			if (div_contents[k].indexOf('label') >= 0) {
				if (div_fields[k].toUpperCase() == yfield) {
					if (yflag) {
						div_text[k] = yobj.value
					}
					else {
						div_text[k] = ""
					}
					changeText(div_text[k], k)
					break;
				}
			}
		}
	}
}

function ChangeBkImage(xheader){
var imgname, letter, xdom, j

	currobj.headertype.value=xheader

	j=0;

	for(var i=1; i<num_divs; i++) {
		if (div_contents[i] == 'rectangle' || div_contents[i] == 'prectangle'){
			j = i;
			xdom = getRS('', "document", "all", joinParam(zz_div, j), zz_style)
		}
	}								
	
	j=xFooterIndex
	switch (xheader){
		case 'D':	//Danger selected, Change the color of the rectangle
			letter='D'
			if(j > 0 ){
				CB_setbgcolor(xdom, "#D42E12")//"#D52E26"
			}
			currobj.hcolorno2.value = "D42E12"
			theader='Danger'
			
			if(j.length > 0)
			{
				div_color_hex[j]= "#FFFFFF"
				div_color[j] = 0
				changeText(div_text[j],j)
			}			
			
			break;			
		case 'C':	//Caution 
			letter ='C'
			if(j > 0 ){
				CB_setbgcolor(xdom, "#F7D417")//"#F5D200"
			}
			currobj.hcolorno2.value = "F7D417"			
			div_color[j] = 1
			
			if(j.length > 0)
			{
				div_color_hex[j]= "#000000"
				div_color[j] = 1
				changeText(div_text[j],j)
			}
						
			theader='Caution'
			break;				
		case 'W':	//Warning
			letter ='W'
			if(j > 0 ){
				CB_setbgcolor(xdom, "#D97300")//"#DB7627"
			}
			currobj.hcolorno2.value = "D97300"			
			theader='Warning'
			
			if(j.length > 0)
			{
				div_color_hex[j]= "#000000"
				div_color[j] = 1
				changeText(div_text[j],j)
			}
			
			break;					
		case 'N':	//Notice
			letter ='N'
			if(j > 0 ){
				CB_setbgcolor(xdom, "#0057A6")//"#1F5A9B"			
			}
			currobj.hcolorno2.value = "0057A6"
			theader='Notice'
			
			if(j.length > 0)
			{
				div_color_hex[j]= "#FFFFFF"
				div_color[j] = 0
				changeText(div_text[j],j)
			}
			break;
	}

	imgname=getbackImage(xheader)
	document.images["bkimage"].src = imgname

    xpos = imgname.lastIndexOf('/')
	imgname=imgname.substring(xpos+1, imgname.length)

	backgroundimage = '/xp2/clipart/'+imgname

}

function getbackImage(xheader) {
var ximgname, xpos, ximgname0, ximgname1, ximgname2

    ximgname=document.images["bkimage"].src

    xpos = ximgname.lastIndexOf('/')
	ximgname0=ximgname.substring(0,xpos+1)
	ximgname1=ximgname.substring(xpos+1,xpos+8)
	ximgname2=ximgname.substring(xpos+9,xpos+13)
	switch (xheader){
		case 'D': 
			theader = 'Danger';
			break;
		case 'C': 
			theader = 'Caution';
			break;
		case 'W': 
			theader = 'Warning';
			break;
		case 'N': 
			theader = 'Notice';
			break;		
	 }
	 return ximgname0+ximgname1+xheader+ximgname2
}

function changeBorder(ximg) {
	document.images["header"+1].border="0"
	document.images["header"+2].border="0"
	document.images["header"+3].border="0"
	document.images["header"+4].border="0"
	document.images["header"+ximg].border="3"
}

function showSymbolsWin(){
	newsheetUrl='getSymbols.asp'
	winhandle = window.open(newsheetUrl, 'hidden', 'width=440,height=400,location=no,resizable=yes,scrollbars=yes')
}

function changeLibSymbol (fn1) {
var yindex, xdom, urlstr
	
	if (currobj.hcolorno1.value == 'FFFFFF') { currobj.hcolorno1.value = 'FFFFFE'; }

	yindex=getobjectno("symbol")
	if (yindex==-1) {
		return
	}

	//If it is facility sign or express sign, convert symbol to printcolor1
	GenAppendString()
	xchangecolor=currobj.hcolorno1.value
	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'
	imageSelector = window.open(urlstr, 'hidden2', 'width=100,height=100,location=no,resizable=yes,scrollbars=yes,left=3000,top=3000')

	if (div_hidden[yindex]==true){
		div_hidden[yindex]=false
		xdom = getRS(zz_bgnestref, zz_document, zz_all, joinParam(zz_div, yindex), zz_style)
		if (xdom){
			showtheobject(xdom)
		}
	}
}

function show_options()
{
	moreoptions.style.visibility = 'visible';
	moreoptions.style.display = 'block';
	
	buttonhideoptions.style.visibility = 'visible';
	buttonhideoptions.style.display = 'block';
	
	buttonmoreoptions.style.visibility = 'hidden';
	buttonmoreoptions.style.display = 'none';
}

function hide_options()
{
	moreoptions.style.visibility = 'hidden';
	moreoptions.style.display = 'none';

	buttonhideoptions.style.visibility = 'hidden';
	buttonhideoptions.style.display = 'none';
	
	buttonmoreoptions.style.visibility = 'visible';
	buttonmoreoptions.style.display = 'block';
	
}

function ChangeBkImage_BackSide(xheader, xbacktype){
var imgname, xdom, j

	LOTOBACKTYPE=xheader + ';' +  xbacktype

	currobj.backtype.value = xbacktype
	j=0;
	for(var i=1; i<num_divs; i++) {
		if (div_contents[i] == 'rectangle' || div_contents[i] == 'prectangle'){ 				
			j = i;
			xdom = getRS('', "document", "all", joinParam(zz_div, j), zz_style)
		}
	}
	
	switch (xheader){
		case 'D':	//Danger selected, Change the color of the rectangle
			if(j > 0 ){
				CB_setbgcolor(xdom, "#D42E12")
			}
			currobj.hcolorno2.value = "D42E12" //"D52E26"
			theader='Danger'			
			
			break;

		case 'C':	//Caution 
			if(j > 0 ){
				CB_setbgcolor(xdom, "#F7D417")
			}
			currobj.hcolorno2.value = "F7D417" //"F5D200"			
			theader='Caution'			
			
			break;				
		case 'W':	//Warning
			if(j > 0 ){
				CB_setbgcolor(xdom, "#D97300")
			}						
			currobj.hcolorno2.value = "D97300" 
			theader='Warning'
			
			break;					
		case 'N':	//Notice
			if(j > 0 ){
				CB_setbgcolor(xdom, "#0057A6") 						
			}
			currobj.hcolorno2.value = "0057A6" //"1F5A9B"
			theader='Notice'
			
			break;

		case 'B':	//Blank
			if(j > 0 ){
				CB_setbgcolor(xdom, "#FFFFFF")
			}
			currobj.hcolorno2.value = "FFFFFF"
			theader='Blank'
			break;				
	}

	if (xheader=='B'){
	    var pos1
	    imgname=getbackImage_BackSide(xheader,xbacktype)
	    xpos = imgname.lastIndexOf('/')
	    pos1 = imgname.indexOf('_') 
	    imgname = '/xp2/clipart/'+ imgname.substring(xpos+1,pos1) +'_1B.gif'		
		//imgname = '/xp2/clipart/loto1_1B.gif'		
		document.images["bkimage"].src = imgname		
		backgroundimage = imgname		
	}
	else if (xheader=='O'){
		imgname = '/xp2/clipart/loto1_2O.gif'		
		document.images["bkimage"].src = imgname		
		backgroundimage = imgname		
	}
	else if (xheader=='Y'){
		imgname = '/xp2/clipart/loto1_2Y.gif'		
		document.images["bkimage"].src = imgname		
		backgroundimage = imgname		
	}
	else{
		imgname=  getbackImage_BackSide(xheader,xbacktype)
		document.images["bkimage"].src = imgname

		xpos = imgname.lastIndexOf('/')
		imgname=imgname.substring(xpos+1, imgname.length)
		backgroundimage = '/xp2/clipart/'+imgname
	}
	if (xheader=='B' || xheader=='O' || xheader=='Y'  || xbacktype =='3'   || xbacktype =='4'){
		for (var z=1; z<num_divs; z++) {
			if (div_contents[z]){
				if(div_contents[z]=="label" || div_contents[z]=="plabel" || div_contents[z]=="rectangle" || div_contents[z]=="prectangle" || div_contents[z]=="image" || div_contents[z]=="pimage") {
					div_hidden[z]=true
				}
			}
		}
		hideHiddenObjs()
	}else{
		for (var z=1; z<num_divs; z++) {
			if (div_contents[z]){
				if(div_contents[z]=="label" || div_contents[z]=="plabel" || div_contents[z]=="rectangle" || div_contents[z]=="prectangle" || div_contents[z]=="image" || div_contents[z]=="pimage") {
					if (div_text[z].toLowerCase()=='null.gif'){
					}else{
						div_hidden[z]=false
					}
				}
			}
		}
		showallObjs()
	}
}

function changeBorder_BackSide(ximg) {

	document.images["design"+1].border="0"
	document.images["design"+2].border="0"
	
	if (document.images["design"+3])
		document.images["design"+3].border="0"

	if (document.images["design"+4])
		document.images["design"+4].border="0"
		
	document.images["design"+ximg].border="3"
}

function showallObjs(){
var xdom
	for (var i=1; i<num_divs; i++) {
		if (div_hidden[i]==false){
			xdom = getRS(zz_bgnestref, zz_document, zz_all, joinParam(zz_div, i))
			if (xdom){
				xdom = getRS(zz_bgnestref, zz_document, zz_all, joinParam(zz_div, i), zz_style)
				if (xdom){
					showtheobject(xdom)
				}
			}
		}
	}
}

function getbackImage_BackSide(xheader, xbacktype) {
var ximgname, xpos,xpos1, ximgname0, ximgname1, ximgname2

	ximgname=obkimage

    xpos = ximgname.lastIndexOf('/')
	ximgname0=ximgname.substring(0,xpos+1)
		
	xpos1 = ximgname.lastIndexOf('.')
	ximgname2=ximgname.substring(xpos1)
	
	ximgname1=ximgname.substring(xpos+1,xpos1-1)

	/*switch (xheader){
		case 'D': 
			//currobj.BacksidePrintCharge.value=1
			theader = 'Danger';
			if (xbacktype == '3')
			{
				var pos1, xstr, newext;				
				pos1 =ximgname1.indexOf('_') 
				xstr = ximgname1.substring(pos1-1,xpos1-1)				
				return ximgname0+ 'lotoback' + xstr + 'B' + xbacktype + ximgname2
			}
			else if (xbacktype == '4')
			{
				var pos1, xstr, newext;				
				pos1 =ximgname1.indexOf('_') 
				xstr = ximgname1.substring(pos1-1,xpos1-1)
				return ximgname0+ 'lotoback' + xstr + 'B' + xbacktype + ximgname2
			}
			else
			{
				return ximgname0+ximgname1+xheader+ximgname2
			}
			break;
		case 'C': 
			//currobj.BacksidePrintCharge.value=1
			theader = 'Caution';
			if (xbacktype != '1'){
			    return ximgname0+ximgname1+xbacktype +xheader+ximgname2
			    break;
			}else{
			    return ximgname0+ximgname1+xheader+ximgname2
			    break;
			}
		case 'W': 
			//currobj.BacksidePrintCharge.value=1
			theader = 'Warning';
			if (xbacktype != '1'){
			    return ximgname0+ximgname1+xbacktype+xheader+ximgname2
			    break;
			}else{
			    return ximgname0+ximgname1+xheader+ximgname2
			    break;
			}
		case 'N': 
			//currobj.BacksidePrintCharge.value=1
			theader = 'Notice';
			if (xbacktype != '1'){
			    return ximgname0+ximgname1+xbacktype+xheader+ximgname2
			    break;
			}else{
			    return ximgname0+ximgname1+xheader+ximgname2
			    break;
			}
	 }*/
	 
	switch (xheader){
		case 'D': 
			//currobj.BacksidePrintCharge.value=1
			theader = 'Danger';
			break;
		case 'C': 
			//currobj.BacksidePrintCharge.value=1
			theader = 'Caution';
			break;
		case 'W': 
			//currobj.BacksidePrintCharge.value=1
			theader = 'Warning';
			break;
		case 'N': 
			//currobj.BacksidePrintCharge.value=1
			theader = 'Notice';
			break;
	}
	if (xbacktype == '3'){
	    
		var pos1, xstr, newext;				
		pos1 =ximgname1.indexOf('_') 
		xstr = ximgname1.substring(pos1-1,xpos1-1)				
		return ximgname0+ 'lotoback' + xstr.replace('B'+ xheader,'') + 'B'+ xheader + xbacktype + ximgname2
	}
	else if (xbacktype == '4'){
	    
		var pos1, xstr, newext;				
		pos1 =ximgname1.indexOf('_') 
		xstr = ximgname1.substring(pos1-1,xpos1-1)
		return ximgname0+ 'lotoback' + xstr.replace('B'+ xheader,'') + 'B'+xheader + xbacktype + ximgname2
	}
	else if (xbacktype == '2'){
	    
		return ximgname0 + ximgname1.replace('lotoback','loto').replace(xheader,'') +xheader+ximgname2
	}
	else{
	    
		return ximgname0 + ximgname1.replace('lotoback','loto').replace(xheader,'') +xheader+ximgname2
	}
}
