if(parent.frames.length){
	alert('This page was not meant to be framed, and will now be escaped from the frame');
	top.location.href=document.location;	
	}

function askQ(obj){
	if(confirm( 'Are you sure you wish to choose a new fill colour? All work will be lost')){
		window.location.replace('/litebrite.php?fill='+obj);
	}else{
		return;
		}
	}	

function colorclick(varX,varY){
	obj = document.getElementById(varX);
	dest = document.getElementById(varY);
	obj.src = eval(p);
	dest.value = color;
	}
	
function colorhover(varX,varY){
	hoverform = document.getElementById('hover_form');
	if(hoverform.hoveron.value == 1){
		colorclick(varX,varY);
		}
	}

function popup(page,w,h){
	OpenWin = this.open(page, "newwindow", "height="+h+",width="+w+',toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no');
	}

var p = "pic[color].src";
var x = color;
var color = 0;
var pic = new Array(10);
for(i=0;i<10;i++){
	pic[i] = new Image();
	}
pic['A'] = new Image();
pic['B'] = new Image();
pic['C'] = new Image();
var path = '/litebrite/media/';
pic[0].src = path+"blue.gif";
pic[1].src = path+"purp.gif";
pic[2].src = path+"mar.gif";
pic[3].src = path+"red.gif";
pic[4].src = path+"oran.gif";
pic[5].src = path+"yell.gif";
pic[6].src = path+"green.gif";
pic[7].src = path+"pale.gif";
pic[8].src = path+"black.gif";
pic[9].src = path+"hole.gif";
pic['C'].src = path+"gray.gif";
pic['B'].src = path+"skin.gif";
pic['A'].src = path+"brown.gif";

function pickColor(number) {
	color = number;
	document.pick.src=pic[color].src;
	document.pick.value=color.value;
	}

function hoverswap(){
	hoverform = document.getElementById('hover_form');
	if(hoverform.hoveron.value == 0){
		hoverform.hoveron.value = 1;
		hoverform.hover1.checked = true;
		hoverform.hover2.checked = false;
	}else{
		hoverform.hoveron.value = 0;
		hoverform.hover1.checked = false;
		hoverform.hover2.checked = true;
		}
	}

// RIGHT CLICK CODE

function clickIE4(){
	if (event.button==2){
		hoverswap(); 
		return false;
		}
	}

function clickNS4(e){
	if (document.layers||document.getElementById&&!document.all){
		if (e.which==2||e.which==3){
			hoverswap(); 
			return false;
			}
		}
	}

function clickIENS(){
	hoverswap()
	return false
	}

if (document.layers){
	document.captureEvents(Event.MOUSEDOWN);
	document.onmousedown=clickNS4;
}else if (document.all&&!document.getElementById){
	document.onmousedown=clickIE4;
	}

document.oncontextmenu=clickIENS;
document.onkeypress=keyevent;

function keyevent(e){
	var c;
	var target;
	var altKey;
	var ctrlKey;
	if (window.event != null) {
		c=String.fromCharCode(window.event.keyCode).toUpperCase();
		altKey=window.event.altKey;
		ctrlKey=window.event.ctrlKey;
	}else{
		c=String.fromCharCode(e.charCode).toUpperCase();
		altKey=e.altKey;
		ctrlKey=e.ctrlKey;
		}
	
	if (window.event != null){
		target=window.event.srcElement;
	}else{
		target=e.originalTarget;
		}
	
	if (target.nodeName.toUpperCase()=='INPUT' || target.nodeName.toUpperCase()=='TEXTAREA' || altKey || ctrlKey){
	}else{
		if (c == 'B') { pickColor(0);; return false; }
		if (c == 'P') { pickColor(1);; return false; }
		if (c == 'M') { pickColor(2);; return false; }
		if (c == 'R') { pickColor(3);; return false; }
		if (c == 'O') { pickColor(4);; return false; }
		if (c == 'Y') { pickColor(5);; return false; }
		if (c == 'G') { pickColor(6);; return false; }
		if (c == 'W') { pickColor(7);; return false; }
		if (c == 'K') { pickColor(8);; return false; }
		if (c == 'N') { pickColor('A');; return false; }
		if (c == 'S') { pickColor('B');; return false; }
		if (c == 'A') { pickColor('C');; return false; }
		}
	}

function formjump(form) {
	var myindex=form.filldrop.selectedIndex;
	var opt = form.filldrop.options[myindex].value;
	if (opt != "0") {
		javascript:askQ(opt);
		}
	}