<!--
imageSource = new Array(17)
for (var i=1;i<18; ++i) imageSource[i]=new Image()
imageSource[1].src = "btns/btnBold.gif"
imageSource[2].src = "btns/btnBoldClick.gif"
imageSource[3].src = "btns/btnBoldSet.gif"
imageSource[4].src = "btns/btnItalic.gif"
imageSource[5].src = "btns/btnItalicClick.gif"
imageSource[6].src = "btns/btnItalicSet.gif"
imageSource[7].src = "btns/btnUnderline.gif"
imageSource[8].src = "btns/btnUnderlineClick.gif"
imageSource[9].src = "btns/btnUnderlineSet.gif"
imageSource[10].src = "btns/btnBgColorOff.gif"
imageSource[11].src = "btns/btnBgColorOn.gif"
imageSource[12].src = "btns/btnLeftOff.gif"
imageSource[13].src = "btns/btnLeftOn.gif"
imageSource[14].src = "btns/btnCentreOff.gif"
imageSource[15].src = "btns/btnCentreOn.gif"
imageSource[16].src = "btns/btnRightOff.gif"
imageSource[17].src = "btns/btnRightOn.gif"


function init() {
preview.style.backgroundColor = document.form1.backgroundcolour.value
bnrText.innerHTML = document.form1.cusText.value
bnrText.style.color = document.form1.hidTextColour.value
bnrText.style.fontFamily = document.form1.selFont.value
checkButtons()
setFilter()
isDirty = false
}

function setText() {
	sd()
	BannerText = document.form1.cusText.value
	bnrText.innerHTML = BannerText
}

function setFont() {
	sd()
	FontName = document.form1.selFont.value
	bnrText.style.fontFamily = document.form1.selFont.value
}

function sd(){
	isDirty=true
}

function showPallette(targetTD, targetScript) {
	var bit1
	var bit2
	var bit3
	var hexvals = new Array(5)
	var pallete
	
	hexvals[0] = "00"
	hexvals[1] = "33"
	hexvals[2] = "66"
	hexvals[3] = "99"
	hexvals[4] = "CC"
	hexvals[5] = "FF"
	
	bit1 = hexvals[0]
	bit2 = hexvals[0]
	bit3 = hexvals[0]
	
	pallette =  "<Table cellpadding=0 cellSpacing=1 bgColor=black>"
	for(a=0; a<6; ++a){
		pallette += "<TR>"
		bit1 = hexvals[a]
		
		for(b=0; b<6; ++b){
			bit2 = hexvals[b]
		
			for(c=0; c<6; ++c){
				bit3 = hexvals[c]
				tdcolour = "#" + bit1 + bit2 + bit3
				pallette += "<TD class=hand width=10 height=10 bgcolor=" + tdcolour + " onClick=\"" + targetScript + "(\'" + tdcolour + "\')\"></TD>"
			}
		}
		pallette += "</TR>"
	}
	pallette += "</TABLE>"
	targetTD.innerHTML = pallette
}

function setFilter() {
	sd()
	effect = document.form1.selFilter.value
	if(document.form1.selFilter.value == 0) {
		Drop_navbar.style.display = "none";
		Shadow_navbar.style.display = "none";
		Def_navbar.style.display="none";
		Glow_navbar.style.display = "";
		showPallette(PalFontColour,'setFontColour')
		showPallette(PalGlowColour,'setGlowColour')
		bnrText.style.filter = "progid:DXImageTransform.Microsoft.Glow(color=" + document.form1.GlowColour.value + ",strength=" + document.form1.selGlowStrength.value + ")";
	}else if(document.form1.selFilter.value == 1){
		Glow_navbar.style.display = "none";
		Drop_navbar.style.display = "none";
		Def_navbar.style.display="none";
		Shadow_navbar.style.display = "";
		showPallette(PalShadowTextColour,'setFontColour')
		showPallette(PalShadowColour,'setShadowColour')
		bnrText.style.filter = "progid:DXImageTransform.Microsoft.Shadow(color=" + document.form1.ShadowColour.value + ",direction=" + document.form1.selShadowSource.value + ")";
	}else if(document.form1.selFilter.value == 2){
		Glow_navbar.style.display = "none";
		Shadow_navbar.style.display = "none";
		Def_navbar.style.display="none";
		Drop_navbar.style.display = "";
		showPallette(PalDropTextColour,'setFontColour')
		showPallette(PalDropShadowColour,'setDropShadowColour')
		bnrText.style.filter = "progid:DXImageTransform.Microsoft.dropShadow(color=" + document.form1.DropShadowColour.value + ",offx=" + document.form1.selHorShadow.value + ",offy=" + document.form1.selVerShadow.value + ")";
	}else{
		Glow_navbar.style.display = "none";
		Shadow_navbar.style.display = "none";
		Drop_navbar.style.display = "none";
		Def_navbar.style.display=""
		showPallette(DefTextColour,'setFontColour')
		bnrText.style.filter = ""
	}
}

function setFontColour(newColour){
	sd()
	TextColour = newColour
	document.form1.hidTextColour.value = newColour
	bnrText.style.color = TextColour	
}

function setGlowColour(newColour) {
	sd()
	GlowColour = newColour;
	document.form1.GlowColour.value = newColour
	bnrText.style.filter = "progid:DXImageTransform.Microsoft.Glow(color=" + GlowColour + ",strength=" + GlowStrength + ")";
}

function setGlowStrength() {
	sd()
	GlowStrength = document.form1.selGlowStrength.value;
	bnrText.style.filter = "progid:DXImageTransform.Microsoft.Glow(color=" + GlowColour + ",strength=" + GlowStrength + ")";
}

function setDropShadowColour(newColour) {
	sd()
	document.form1.DropShadowColour.value = newColour
	DropShadowColour = newColour
	bnrText.style.filter = "progid:DXImageTransform.Microsoft.dropShadow(color=" + DropShadowColour + ",offx=" + DropShadowX + ",offy=" + DropShadowY + ")"
}

function setHorShadow() {
	sd()
	DropShadowX = document.form1.selHorShadow.value
	bnrText.style.filter = "progid:DXImageTransform.Microsoft.dropShadow(color=" + DropShadowColour + ",offx=" + DropShadowX + ",offy=" + DropShadowY + ")"
}

function setVerShadow() {
	sd()
	DropShadowY = document.form1.selVerShadow.value
	bnrText.style.filter = "progid:DXImageTransform.Microsoft.dropShadow(color=" + DropShadowColour + ",offx=" + DropShadowX + ",offy=" + DropShadowY + ")"

}

function setShadowDirection() {
	sd()
	ShadowDirection = document.form1.selShadowSource.value
	ShadowColour = document.form1.ShadowColour.value
	bnrText.style.filter = "progid:DXImageTransform.Microsoft.Shadow(color=" + ShadowColour + ",direction=" + ShadowDirection + ")"
}

function setShadowColour(newColour) {
	sd()
	ShadowColour = newColour
	ShadowDirection = document.form1.selShadowSource.value
	document.form1.ShadowColour.value = newColour
	bnrText.style.filter = "progid:DXImageTransform.Microsoft.Shadow(color=" + ShadowColour + ",direction=" + ShadowDirection + ")"
}


function setBGColor(Color) {
	sd()
	preview.style.backgroundColor = Color
	BGroundColour = Color
	document.form1.backgroundcolour.value = Color
	bgColorDiv.style.display = "none"
	cellToSet = null
	document.form1.bgcolor.className="btn"
	document.form1.bgcolor.src=imageSource[10].src
}

function setBold() {
	bboldchanged = true

	if(isBold){
		isBold = false;
		document.form1.hidBold.value = "false"
		bnrText.style.fontWeight = 'normal'
		bbold.style.borderColor = ""
	}else{
		isBold = true;
		document.form1.hidBold.value = "true"
		bnrText.style.fontWeight = "bold"
		bbold.style.borderColor = "white"
		bbold.style.borderStyle = "inset"
		
	}
}
function over(Button){
	if(Button==document.form1.bold){
		if(isBold){
			Button.className = "btnSelected"
			Button.src = imageSource[1].src
		}else{
			Button.className = "btnNonOver"
		}
	}else if(Button==document.form1.italic){
		if(isItalic){
			Button.className = "btnSelected"
			Button.src = imageSource[4].src
		}else{
			Button.className = "btnNonOver"
		}
	}else if(Button==document.form1.underline){
		if(isUnderline){
			Button.className = "btnSelected"
			Button.src = imageSource[8].src
		}else{
			Button.className = "btnNonOver"
		}
	}else if(Button==document.form1.bgcolor){
		if(Button.className == "btnSelected"){
			Button.className = "btn"
		}else{
			Button.className = "btnNonOver"
		}
	}else if(Button==document.form1.aleft){
		if(isLeft){
			Button.className = "btnSelected"
			Button.src = imageSource[12].src
		}else{
			Button.className = "btnNonOver"
		}
	}else if(Button==document.form1.acenter){
		if(isCenter){
			Button.className = "btnSelected"
			Button.src = imageSource[14].src
		}else{
			Button.className = "btnNonOver"
		}
	}else if(Button==document.form1.aright){
		if(isRight){
			Button.className = "btnSelected"
			Button.src = imageSource[16].src
		}else{
			Button.className = "btnNonOver"
		}
	}
}

function setAlign(direction) {
		bnrText.style.textAlign=direction
		document.form1.align.value = direction
}
		
function setBtnState(Button){
	if(Button==document.form1.bold){
		boldClicked = true;
		document.form1.bold.src = imageSource[2].src
		document.form1.bold.className="btnSelected"
		if(isBold){
			isBold=false
			document.form1.hidBold.value = "false"
			bnrText.style.fontWeight="normal"
		}else{
			isBold=true
			document.form1.hidBold.value = "true"
			bnrText.style.fontWeight="bold"
		}
	}else if(Button==document.form1.italic){
		italicClicked = true;
		document.form1.italic.src = imageSource[5].src
		document.form1.italic.className="btnSelected"
		if(isItalic){
			isItalic=false
			document.form1.hidItalic.value = "false"
			bnrText.style.fontStyle="normal"
		}else{
			isItalic=true
			document.form1.hidItalic.value = "true"
			bnrText.style.fontStyle="italic"
		}
	}else if(Button==document.form1.underline){
		document.form1.underlineClicked=true;
		document.form1.underline.src = imageSource[8].src
		document.form1.underline.className="btnSelected";
		if(isUnderline){
			isUnderline=false;
			document.form1.hidUnderline.value = "false"
			bnrText.style.textDecorationUnderline=false
		}else{
			isUnderline=true;
			document.form1.hidUnderline.value = "true"
			bnrText.style.textDecorationUnderline=true
		}			
	}else if(Button==document.form1.aleft||Button==document.form1.acenter||Button==document.form1.aright){
		setAlignState(Button)
	}else{
		bgcolorClicked = true
		showBGColors()
	}
}

function showBGColors(){
	var bit1
	var bit2
	var bit3
	var hexvals = new Array(5)
	var pallete
	var targetScript = 'setBGColor'
	
	hexvals[0] = "00"
	hexvals[1] = "33"
	hexvals[2] = "66"
	hexvals[3] = "99"
	hexvals[4] = "CC"
	hexvals[5] = "FF"
	
	bit1 = hexvals[0]
	bit2 = hexvals[0]
	bit3 = hexvals[0]
	
	pallette =  "<Table cellpadding=0 cellSpacing=1 bgColor=black>"
	for(a=0; a<6; ++a){
		pallette += "<TR>"
		bit1 = hexvals[a]
		
		for(b=0; b<6; ++b){
			bit2 = hexvals[b]
		
			for(c=0; c<6; ++c){
				bit3 = hexvals[c]
				tdcolour = "#" + bit1 + bit2 + bit3
				pallette += "<TD class=hand width=10 height=10 bgcolor=" + tdcolour + " onClick=\"" + targetScript + "(\'" + tdcolour + "\')\"></TD>"
			}
		}
		pallette += "</TR>"
	}
	pallette += "</TABLE>"
	bgColorDiv.innerHTML = pallette
//alert(event.clientX)
//bgTable.setCapture()
bgColorDiv.style.posLeft = event.clientX - 5
bgColorDiv.style.posTop = event.clientY + 20
bgColorDiv.style.display = ""
}

function out(Button){

	if(Button==document.form1.bold){
		if(boldClicked){
			if(!isBold){ 
				//If its bold change to the default image
				//bold.src = theDefaultImage
				document.form1.bold.className="btn"
				document.form1.bold.src = imageSource[1].src
			}else{
				//if its not bold change to the Set bold image
				document.form1.bold.className= "btnSelected"
				document.form1.bold.src=imageSource[3].src
			}
		}else{
			if(isBold){
				document.form1.bold.className="btnSelected"
				document.form1.bold.src=imageSource[3].src
			}else{
				document.form1.bold.className="btn"
				document.form1.bold.src = imageSource[1].src
			}				
		}
		boldClicked = false
	}else if(Button==document.form1.italic){
		if(italicClicked){
			if(!isItalic){ 
				//If its not italic change to the default image
				//bold.src = theDefaultImage
				document.form1.italic.className="btn"
				document.form1.italic.src = imageSource[4].src
			}else{
				//if its not bold change to the Set bold image
				document.form1.italic.className= "btnSelected"
				document.form1.italic.src=imageSource[6].src
			}
		}else{
			if(isItalic){
				document.form1.italic.className="btnSelected"
				document.form1.italic.src=imageSource[6].src
			}else{
				document.form1.italic.className="btn"
				document.form1.italic.src = imageSource[4].src
			}				
		}
		italicClicked = false
	}else if(Button==document.form1.underline){
		if(underlineClicked){
			if(!isUnderline){ 
				//If its bold change to the default image
				//bold.src = theDefaultImage
				document.form1.underline.className="btn"
				document.form1.underline.src = imageSource[7].src
			}else{
				//if its not bold change to the Set bold image
				document.form1.underline.className= "btnSelected"
				document.form1.underline.src=imageSource[9].src
			}
		}else{
			if(isUnderline){
				document.form1.underline.className="btnSelected"
				document.form1.underline.src=imageSource[9].src
			}else{
				document.form1.underline.className="btn"
				document.form1.underline.src = imageSource[7].src
			}				
		}
		underlineClicked = false
	}else if(Button==document.form1.aleft){
		if(leftClicked){
			if(!isLeft){ 
				//If its not left aligned
				//set it to be left aligned and update the button
				document.form1.aleft.className="btn"
				document.form1.aleft.src = imageSource[12].src
			}else{
				//if its not bold change to the Set bold image
				document.form1.aleft.className = "btnSelected"
				document.form1.aleft.src = imageSource[13].src
			}
		}else{
			if(isLeft){
				document.form1.aleft.className = "btnSelected"
				document.form1.aleft.src = imageSource[13].src
			}else{
				document.form1.aleft.className="btn"
				document.form1.aleft.src = imageSource[12].src
			}				
		}
		leftClicked = false
	}else if(Button==document.form1.acenter){
		if(centerClicked){
			if(!isCenter){ 
				//If its not centered
				//set it to be centered and update the button
				document.form1.acenter.className="btn"
				document.form1.acenter.src = imageSource[14].src
			}else{
				//if its not bold change to the Set bold image
				document.form1.acenter.className= "btnSelected"
				document.form1.acenter.src= imageSource[15].src
			}
		}else{
			if(isCenter){
				document.form1.acenter.className="btnSelected"
				document.form1.acenter.src= imageSource[15].src
			}else{
				document.form1.acenter.className="btn"
				document.form1.acenter.src = imageSource[14].src
			}				
		}
		centerClicked = false
	}else if(Button==document.form1.aright){
		if(rightClicked){
			if(!isRight){ 
				//If its bold change to the default image
				//bold.src = theDefaultImage
				document.form1.aright.className="btn"
				document.form1.aright.src = imageSource[16].src
			}else{
				//if its not bold change to the Set bold image
				document.form1.aright.className= "btnSelected"
				document.form1.aright.src = imageSource[17].src
			}
		}else{
			if(isRight){
				document.form1.aright.className="btnSelected"
				document.form1.aright.src = imageSource[17].src
			}else{
				document.form1.aright.className="btn"
				document.form1.aright.src = imageSource[16].src
			}				
		}
		rightClicked = false
	}else if(Button==document.form1.bgcolor){
		if(bgcolorClicked){
			//show the bgcolor div and reset the button to btn class after select
			document.form1.bgcolor.className="btnSelected"
			document.form1.bgcolor.src = imageSource[11].src
		}else{
			document.form1.bgcolor.className="btn"
		}	
		bgcolorClicked = false
	}
}

function setDown(Button){
	if(Button==document.form1.bold){
		document.form1.bold.src = imageSource[2].src
	}else if(Button==document.form1.italic){
		document.form1.italic.src = imageSource[5].src
	}else if(Button==document.form1.underline){
		document.form1.underline.src = imageSource[8].src
	}	
}

function setAlignState(Button){
	if(Button==document.form1.aleft){
		if(isLeft){
			document.form1.acenter.src = imageSource[15].src
			document.form1.acenter.className = "btnSelected"
			document.form1.aleft.src = imageSource[12].src
			document.form1.aleft.className = "btn"
			document.form1.aright.src = imageSource[16].src
			document.form1.aright.className = "btn"
			document.form1.hidLeft.value = "false"
			document.form1.hidRight.value = "false"
			document.form1.hidCenter.value = "true"
			aligned="Center"
			isCenter = true
			isLeft = false
			isRight = false
			bnrText.style.textAlign="center"
		}else{
			document.form1.acenter.src = imageSource[14].src
			document.form1.acenter.className = "btn"
			document.form1.aleft.src = imageSource[13].src
			document.form1.aleft.className = "btnSelected"
			document.form1.aright.src = imageSource[16].src
			document.form1.aright.className = "btn"
			document.form1.hidLeft.value = "true"
			document.form1.hidRight.value = "false"
			document.form1.hidCenter.value = "false"
			aligned="Left"
			isCenter = false
			isLeft = true
			isRight = false	
			bnrText.style.textAlign="left"		
		}
	}else if(Button==document.form1.acenter){
		if(isCenter){
			document.form1.acenter.src = imageSource[14].src
			document.form1.acenter.className = "btn"
			document.form1.aleft.src = imageSource[13].src
			document.form1.aleft.className = "btnSelected"
			document.form1.aright.src = imageSource[16].src
			document.form1.aright.className = "btn"
			document.form1.hidLeft.value = "true"
			document.form1.hidRight.value = "false"
			document.form1.hidCenter.value = "false"
			aligned="Left"
			isCenter = false
			isLeft = true
			isRight = false			
			bnrText.style.textAlign="left"
		}else{
			document.form1.acenter.src = imageSource[15].src
			document.form1.acenter.className = "btnSelected"
			document.form1.aleft.src = imageSource[12].src
			document.form1.aleft.className = "btn"
			document.form1.aright.src = imageSource[16].src
			document.form1.aright.className = "btn"
			document.form1.hidLeft.value = "false"
			document.form1.hidRight.value = "false"
			document.form1.hidCenter.value = "true"
			aligned="Center"
			isCenter = true
			isLeft = false
			isRight = false
			bnrText.style.textAlign="center"
		}
	}else{
		if(isRight){
			alert("Yeah it's aligned right")
			document.form1.acenter.src = imageSource[15].src
			document.form1.acenter.className = "btnSelected"
			document.form1.aleft.src = imageSource[12].src
			document.form1.aleft.className = "btn"
			document.form1.aright.src = imageSource[16].src
			document.form1.aright.className = "btn"
			document.form1.hidLeft.value = "false"
			document.form1.hidRight.value = "false"
			document.form1.hidCenter.value = "true"
			aligned="Center"
			isCenter = true
			isLeft = false
			isRight = false
			bnrText.style.textAlign="center"
		}else{
			document.form1.hidLeft.value = "false"
			document.form1.hidRight.value = "true"
			document.form1.hidCenter.value = "false"
			document.form1.acenter.src = imageSource[14].src
			document.form1.acenter.className = "btn"
			document.form1.aleft.src = imageSource[12].src
			document.form1.aleft.className = "btn"
			document.form1.aright.src = imageSource[17].src
			document.form1.aright.className = "btnSelected"
			aligned="Right"
			isCenter = false
			isLeft = false
			isRight = true			
			bnrText.style.textAlign="right"
		}
	}
}

function checkButtons(){
	if(document.form1.hidBold.value=="true"){
		document.form1.bold.src = imageSource[3].src;
		document.form1.bold.className="btnSelected";
		bnrText.style.fontWeight="bold";
	}
	if(document.form1.hidItalic.value=="true"){
		document.form1.italic.src = imageSource[6].src;
		document.form1.italic.className="btnSelected";
		bnrText.style.fontStyle="italic";
	}
	if(document.form1.hidUnderline.value=="true"){
		document.form1.underline.src = imageSource[9].src;
		document.form1.underline.className="btnSelected";
		bnrText.style.textDecorationUnderline="true";
	}
	if(document.form1.hidLeft.value=="true"){
		isLeft = false
		setAlignState(document.form1.aleft)
		setAlign("left")
	}
	
	if(isRight){
		isRight = false
		setAlignState(document.form1.aright)
		setAlign("right")
	}
	if(document.form1.hidCenter.value=="true"){
		isCenter = false
		setAlignState(document.form1.acenter)
		setAlign("center")
	}
}

//-->
