//background-color:rgb(180,0,180);border:1
fontCol = "Xi/letters/white"
alphaCol = "white"
alphaFace = "arial"
msg = ""
var jump = new Array(22)
	jump[0] = "_"
	jump[1] = "_"
	jump[2] = "_"
	jump[3] = "_"
	jump[4] = "_"
	jump[5] = "_"
	jump[6] = "_"
	jump[7] = "_"
	jump[8] = "_"
	jump[9] = "_"
	jump[10] = "_"

	jump[11] = "_"
	jump[12] = "_"
	jump[13] = "_"
	jump[14] = "_"
	jump[15] = "_"
	jump[16] = "_"
	jump[17] = "_"
	jump[18] = "_"
	jump[19] = "_"
	jump[20] = "_"
	jump[21] = "_"
firstTextH = 0
nextTextH = 0
alphaAln = 0
trype1 = 0
trype2 = 0
trype3 = 0
allCook = new Array(5)
//=====END===VARIABLES=======================================
function showJumps() {
a = document.all.firstText.value
b = document.all.nextText.value
a = a.toLowerCase()
b = b.toLowerCase()

	jump[0] = a.slice(0, 1)
	jump[1] = a.slice(1, 2)
	jump[2] = a.slice(2, 3)
	jump[3] = a.slice(3, 4)
	jump[4] = a.slice(4, 5)
	jump[5] = a.slice(5, 6)
	jump[6] = a.slice(6, 7)
	jump[7] = a.slice(7,8)
	jump[8] = a.slice(8, 9)
	jump[9] = a.slice(9, 10)
	jump[10] = a.slice(10, 11)

	jump[11] = b.slice(0, 1)
	jump[12] = b.slice(1, 2)
	jump[13] = b.slice(2, 3)
	jump[14] = b.slice(3, 4)
	jump[15] = b.slice(4, 5)
	jump[16] = b.slice(5, 6)
	jump[17] = b.slice(6, 7)
	jump[18] = b.slice(7,8)
	jump[19] = b.slice(8, 9)
	jump[20] = b.slice(9, 10)
	jump[21] = b.slice(10, 11)
if(alphaAln == 1){
	for (var i = 0; i < jump.length; i++) { 
		if (!jump[i]) { 
jump[i] = "_"
		} 
}
}
firstTextH = a.toUpperCase()
nextTextH = b.toUpperCase()
document.all.nextText.value = nextTextH.toUpperCase()
document.all.firstText.value = firstTextH.toUpperCase()
setTimeout('takePulse()', 100)
}
function checkIt() {
	a = document.all.firstText.value
	b = document.all.nextText.value
	if (useLetter(a)) {
setTimeout('showJumps()', 50)
	} else {
	document.all.firstText.value = firstTextH
		document.all.firstText.focus()
	}
	if (useLetter(b)) {
setTimeout('showJumps()', 50)
	} else {
	document.all.nextText.value = nextTextH
		document.all.nextText.focus()
	}
}
function useLetter(inputStr) {
	for (var i = 0; i < inputStr.length; i++) {
		var oneChar = inputStr.substring(i, i +1 )
		if (oneChar < '!' || oneChar > '!' && oneChar < '$' || oneChar > '$' && oneChar < '&' || oneChar > '&'  && oneChar < '+' || oneChar > '.'  && oneChar < '0' || oneChar > '9'  && oneChar < '=' || oneChar > '='  && oneChar < '@' || oneChar > 'Z'  && oneChar < '^' || oneChar > '_'  && oneChar < 'a' || oneChar > 'z' ) {
			return false
		}
	}
	return true
}

function palletChanger(type) {
	if (document.all.mainD) {
	document.all.alphPal.style.background = type
	alphaCol = type
setTimeout('takePulse()', 100)
if(type == "violet"){document.all.alphPal.style.background = "purple"}
	}
}
function takePulse(){
if(startUp == 0){infoHelp = document.all.mainD.innerHTML;document.all.mainD.innerHTML = "";startUp = 1}
alphaFace = document.all.alfaFace.value
directA = "http://www.coolplays.com/coloring-book/Xi/letters"
alphaAdOn0 = "<IMG ALIGN='TOP' SRC="
alphaAdOn = "BORDER=0 ALT='ERROR' UNSELECTABLE='on'"
	msg = "<DIV STYLE='position:absolute;left:0;top:44;height:160;width:100%' UNSELECTABLE='on'>"
	msg += "<TABLE STYLE='width:100%;height:100%;' cellpadding=0 cellspacing=0 border=0>"
	msg += "<TR><TD valign='middle' align='center' style='padding-top:15;'>" + alphaAdOn0 + directA + "/" + alphaCol + "/" + alphaFace +"-" + jump[0] + ".gif ID=alpha " + alphaAdOn + ">" + alphaAdOn0 + directA + "/" + alphaCol + "/" + alphaFace +"-" + jump[1] + ".gif ID=alpha1 " + alphaAdOn + ">" + alphaAdOn0 + directA + "/" + alphaCol + "/" + alphaFace +"-" + jump[2] + ".gif ID=alpha2 " + alphaAdOn + ">" + alphaAdOn0 + directA + "/" + alphaCol + "/" + alphaFace +"-" + jump[3] + ".gif ID=alpha3 " + alphaAdOn + ">"
	msg += alphaAdOn0 + directA + "/" + alphaCol + "/" + alphaFace +"-" + jump[4] + ".gif ID=alpha4 " + alphaAdOn + ">" + alphaAdOn0 + directA + "/" + alphaCol + "/" + alphaFace +"-" + jump[5] + ".gif ID=alpha5 " + alphaAdOn + ">"
	msg += alphaAdOn0 + directA + "/" + alphaCol + "/" + alphaFace +"-" + jump[6] + ".gif ID=alpha6 " + alphaAdOn + ">" + alphaAdOn0 + directA + "/" + alphaCol + "/" + alphaFace +"-" + jump[7] + ".gif ID=alpha7 " + alphaAdOn + ">" + alphaAdOn0 + directA + "/" + alphaCol + "/" + alphaFace +"-" + jump[8] + ".gif ID=alpha8 " + alphaAdOn + ">" + alphaAdOn0 + directA + "/" + alphaCol + "/" + alphaFace +"-" + jump[9] + ".gif ID=alpha9 " + alphaAdOn + ">" + alphaAdOn0 + directA + "/" + alphaCol + "/" + alphaFace +"-" + jump[10] + ".gif ID=alpha0 " + alphaAdOn + "></TD></TR>"
	msg += "<TR><TD VALIGN='TOP' ALIGN='CENTER' width=100% style='border:0pt solid'>" + alphaAdOn0 + directA + "/" + alphaCol + "/" + alphaFace +"-" + jump[11] + ".gif ID=alpha11 " + alphaAdOn + ">" + alphaAdOn0 + directA + "/" + alphaCol + "/" + alphaFace +"-" + jump[12] + ".gif ID=alpha12 " + alphaAdOn + ">" + alphaAdOn0 + directA + "/" + alphaCol + "/" + alphaFace +"-" + jump[13] + ".gif ID=alpha13 " + alphaAdOn + ">" + alphaAdOn0 + directA + "/" + alphaCol + "/" + alphaFace +"-" + jump[14] + ".gif ID=alpha14 " + alphaAdOn + ">"
	msg += alphaAdOn0 + directA + "/" + alphaCol + "/" + alphaFace +"-" + jump[15] + ".gif ID=alpha15 " + alphaAdOn + ">" + alphaAdOn0 + directA + "/" + alphaCol + "/" + alphaFace +"-" + jump[16] + ".gif ID=alpha16 " + alphaAdOn + ">" + alphaAdOn0 + directA + "/" + alphaCol + "/" + alphaFace +"-" + jump[17] + ".gif ID=alpha17 " + alphaAdOn + ">"
	msg += alphaAdOn0 + directA + "/" + alphaCol + "/" + alphaFace +"-" + jump[18] + ".gif ID=alpha18 " + alphaAdOn + ">" + alphaAdOn0 + directA + "/" + alphaCol + "/" + alphaFace +"-" + jump[19] + ".gif ID=alpha19 " + alphaAdOn + ">" + alphaAdOn0 + directA + "/" + alphaCol + "/" + alphaFace +"-" + jump[20] + ".gif ID=alpha20 " + alphaAdOn + ">" + alphaAdOn0 + directA + "/" + alphaCol + "/" + alphaFace +"-" + jump[21] + ".gif ID=alpha21 " + alphaAdOn + "></TD></TR></TABLE></DIV>"

	fixDivider()
}

function enterAll1(a,evt) {
	evt = (evt) ? evt : (window.event) ? window.event : ""
	if (evt) {
		var theKey = (evt.which) ? evt.which : evt.keyCode
		if (theKey == 13) {
			checkIt();
			return false	
		}
	}
	return true
}

//START COOKIES
function createCookie(name,value,days){
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	
	else var expires = "";
	var ck = name+"="+value+expires+"; path="
	if (days != -1) ;
	document.cookie = ck;
}

function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i<ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name)
{
	createCookie(name,"",-1);
}

function saveIt(name,x)
{
	if (!x){
	createCookie(name,'x',365)
}

	else{
		createCookie(name,x,365)

	}
}
function initCook() {
	for (var i = 0; i <5; i++) {
		var x = readCookie('apF' + i)
		var y = readCookie('bpF' + i)
		if (!x) 
		saveIt('apF' + i,"add_pref")
		if (!y) 
		saveIt('bpF' + i,"add_pref")
}
prefList()
}


function makePref(){
var curred = document.all.firstText.value
if(curred){
a = firstTextH.toUpperCase()
if(a){
b = document.all.firstText.value.toUpperCase()
c = nextTextH.toUpperCase()
d = document.all.nextText.value.toUpperCase()
if(a == b && c == d){
saveIt(trype2,a)
saveIt(trype3,c)
} else {
			alert("Name already on list.")
}
firstTextH = "" 
nextTextH = ""
prefList()
}}}





function prefList() {
allCook[0] = readCookie('apF0') +", "+readCookie('bpF0')
allCook[1] = readCookie('apF1')  +", "+readCookie('bpF1')
allCook[2] = readCookie('apF2') +", "+readCookie('bpF2')
allCook[3] = readCookie('apF3') +", "+readCookie('bpF3')
allCook[4] = readCookie('apF4') +", "+readCookie('bpF4')
	var sel1 = document.all.insertIndex
	var newOpt
		for (var i = 0; i <5; i++) {

			newOpt = document.createElement("OPTION")
			newOpt.text = allCook[i]
			 sel1.options[i] = newOpt
trype1 = "pF"+(sel1.options.length-1)
trype2 = "apF"+(sel1.options.length-1)
trype3 = "bpF"+(sel1.options.length-1)
var currSelected = document.all.insertIndex.selectedIndex
		}
	}
function writeIt(){
var currSelected = document.all.insertIndex.selectedIndex
document.all.firstText.value = readCookie('apF'+currSelected)
document.all.nextText.value = readCookie('bpF'+currSelected)
trype1 = 'pF'+currSelected
trype2 = 'apF'+currSelected
trype3 = 'bpF'+currSelected
showJumps()
}
function clearLine(n){
if(n == 1){
document.all.firstText.value= ""
}
if(n == 2){
document.all.nextText.value= ""
}
showJumps()
}






//===================================================================================
fkpl = "fkpl="
var holp = new Array(6)
function addImg(){
holp[0] = readCookie('yPc0')
holp[1] = readCookie('yPc1')
holp[2] = readCookie('yPc2')
holp[3] = readCookie('yPc3')
holp[4] = readCookie('yPc4')
holp[5] = readCookie('yPc5')
	for (var i = 0; i < holp.length; i++) { 
if (holp[i] == null){
		document.all("aPic" + [i] + "a").src = "images/back.gif"
holp[i] = "images/back.gif"
fkpl += holp[i] + ","
}}
document.all.aPic0a.src = holp[0]
document.all.aPic1a.src = holp[1]
document.all.aPic2a.src = holp[2]
document.all.aPic3a.src = holp[3]
document.all.aPic4a.src = holp[4]
document.all.aPic5a.src = holp[5]
setTimeout('checkImgX()',1000)
}

function checkImgX(){
var imgHeight0 = document.images.aPic0a.height/100
var imgWidth0 = document.images.aPic0a.width/100
var imgHeight1 = document.images.aPic1a.height/100
var imgWidth1 = document.images.aPic1a.width/100
var imgHeight2 = document.images.aPic2a.height/100
var imgWidth2 = document.images.aPic2a.width/100
var imgHeight3 = document.images.aPic3a.height/100
var imgWidth3 = document.images.aPic3a.width/100
var imgHeight4 = document.images.aPic4a.height/100
var imgWidth4 = document.images.aPic4a.width/100
var imgHeight5 = document.images.aPic5a.height/100
var imgWidth5 = document.images.aPic5a.width/100

	
if(imgHeight0>imgWidth0){
document.images.aPic0a.height = 88
document.images.aPic0a.width = imgWidth0 / imgHeight0 * 88
}
if(imgHeight1>imgWidth1){
document.images.aPic1a.height = 88
document.images.aPic1a.width = imgWidth1 / imgHeight1 * 88
}
if(imgHeight2>imgWidth2){
document.images.aPic2a.height = 88
document.images.aPic2a.width = imgWidth2 / imgHeight2 * 88
}
if(imgHeight3>imgWidth3){
document.images.aPic3a.height = 88
document.images.aPic3a.width = imgWidth3 / imgHeight3 * 88
}
if(imgHeight4>imgWidth4){
document.images.aPic4a.height = 88
document.images.aPic4a.width = imgWidth4 / imgHeight4 * 88
}
if(imgHeight5>imgWidth5){
document.images.aPic5a.height = 88
document.images.aPic5a.width = imgWidth5 / imgHeight5 * 88
}

}



var docPic
function cookMakr(x,vis) {
x=x
document.all.picChangerH.style.visibility = vis
document.all.picChangerM.style.visibility = "hidden"
var num = x+1
newYPic = num
var picChanger
picChanger ="<DIV style='height:295;width:270;background-Color:rgb(160,160,150)'><DIV style='position:absolute;left:10;top:10;color:black;' CLASS='menuCss'>"
picChanger +="<INPUT TYPE='file' SIZE=20  NAME='cookievalue' accept='images/*' onchange=updateDoc(" + x +")><br> Browse your computer for Image files</DIV>"
picChanger +="<DIV class=menuCss ID='menu" + x +"' style=position:absolute;left:10;top:60>"
picChanger +="<DIV CLASS='menuItem'  onClick=saveImg(" + x + "); onMouseOver='highlight()' onMouseOut='unhighlight()'>Save Picture " + num +" to Library</DIV>"
picChanger +="<DIV CLASS='menuItem'  onClick=eraseImg(" + x + ");hideMenu(" + x + "); onMouseOver='highlight()' onMouseOut='unhighlight()'>Remove Picture " + num +" from Library</DIV>"
picChanger +="<DIV CLASS='menuItem'  onClick=upDateyourPic(" + x + "); onMouseOver='highlight()' onMouseOut='unhighlight()'>Add Picture " + num +" to Document</DIV>"
picChanger +="<DIV CLASS='menuItem'  onClick=readImg(" + x + "); onMouseOver='highlight()' onMouseOut='unhighlight()'>Picture " + num +" url</DIV>"
picChanger +="<HR ALIGN=CENTER WIDTH=100%><DIV CLASS='menuItem'  onClick='hideMenu(" + x + ")' onMouseOver='highlight()' onMouseOut='unhighlight()'>close</DIV>"
picChanger +="<DIV style='position:absolute;left:20;top:110;'><a href='#' ><img ID='picDoc' src='" + holp[x] + "' width='120' onclick=upDateyourPic(" + x + ");hideMenu(" + x + ");></a></DIV>"
picChanger +="<DIV ID='picinfo' style='position:absolute;left:150;top:130;color:white;'></DIV>"
picChanger +="<DIV style=position:absolute;left:-3000;top:-1000;visibility:hidden><img name='picDocL' ID='picDocL' src='" + holp[x] + "' ></DIV>"
document.all.picChangerH.innerHTML = picChanger
imgHeight = document.images.picDocL.height*1
imgWidth = document.images.picDocL.width*1
var imgPost = "height " + imgHeight + " <br> width " + imgWidth
	document.all.picinfo.innerHTML = imgPost
if(imgHeight<imgWidth){
document.images.picDoc.width = 110
document.images.picDoc.height = imgHeight / imgWidth * 110
}
if(imgHeight>imgWidth){
document.images.picDoc.height = 88
document.images.picDoc.width = imgWidth / imgHeight * 88
	}
if(imgHeight == imgWidth){
document.images.picDoc.width = 110
document.images.picDoc.height = 110
}

}
var imgHeight
var imgWidth
var newYPic
var donuPic

function fixLink(fix){
var ret = " "
var re = /\\/ 
newfix = fix.replace(ret,"%")
newfix = fix.replace(re,"/")
newfix = fix.replace(re,"/")
newfix = fix.replace(re,"/")
newfix = fix.replace(re,"/")
newfix = fix.replace(re,"/")
newfix = fix.replace(re,"/")
newfix = fix.replace(re,"/")
newfix = fix.replace(re,"/")
newfix = fix.replace(re,"/")
return newfix
}
function updateDoc(x){
donuPic = document.all.cookievalue.value
donuPic = fixLink(donuPic)
holp[x] = donuPic
document.all.picDoc.src = holp[x]
document.all.picDocL.src = holp[x]
 setTimeout('newDoc()',500)
}
function newDoc(){
imgHeight = document.images.picDocL.height*1
imgWidth = document.images.picDocL.width*1
document.images.picDoc.width = 110
document.images.picDoc.height = imgHeight / imgWidth * 110
var imgPost = "height " + imgHeight + " <br> width " + imgWidth
	document.all.picinfo.innerHTML = imgPost
	
if(imgHeight>imgWidth){
document.images.picDoc.height = 88
document.images.picDoc.width = imgWidth / imgHeight * 88
	}
}

function eraseImg(x){
x=x
name = "yPc" + x
createCookie(name,'images/back.gif',7)
donuPic = "images/back.gif"
hideMenu(" + x + ")
addImg()
}

function saveImg(x){
x=x
name = "yPc" + x
		createCookie(name,holp[x],7)
	addNewImg(x)
addImg()
}

function readImg(x){
name = "yPc" + x
num = x+1
	alert('Picture ' + num + ' Url is:\n'  + readCookie(name));
}

function hideMenus() {
	document.releaseCapture()

}

function addNewImg(x){
x=x
if(imgHeight<imgWidth){
newWidth = 110
newHeight = imgHeight / imgWidth * 110
	}
if(imgHeight>imgWidth){
newHeight = 88
newWidth = imgWidth / imgHeight * 88
	}
if(imgHeight == imgWidth){
newHeight = 110
newWidth = 110
	}
showNewImg(x)
}
function showNewImg(x){
x=x
if(x){
document.images("aPic"+x+"a").height = newHeight
document.images("aPic"+x+"a").width = newWidth
document.images("aPic"+x+"a").src = holp[x]
	}
}
function showMenu(menus) {
	menus.setCapture()
	menus.style.pixeltop = window.event.clientY
	menus.style.pixleleft = window.event.clientX
		document.all.menus.style.visibility = "visible"
	event.returnValue = false
}

function hideMenu(x) {
	document.all.picChangerH.style.visibility = "hidden"
	document.all.picChangerM.style.visibility = "visible"
}
function highlight() {
	var elem = event.srcElement
	if (elem.className == "menuItem") {
		elem.className = "menuItemOn"
	}
}

function unhighlight() {
	var elem = event.srcElement
	if (elem.className == "menuItemOn") {
		elem.className = "menuItem"
	}
}
finalPictureVal = ""
function upDateyourPic(x){
if(startUp == 0){infoHelp = document.all.mainD.innerHTML;document.all.mainD.innerHTML = "";startUp = 1}
x=x
resetDiv()
fixDivider()
box[13][0] = holp[x]
document.all.box13I.scr = holp[x]
tide="box13I"
fixDivider()
donuPic = ""
}
function removeMain(){
if(startUp == 0){infoHelp = document.all.mainD.innerHTML;document.all.mainD.innerHTML = "";startUp = 1}
resetDiv()
fixDivider()
box[13][0] = "images/clear.gif"
document.all.box13I.scr = "images/clear.gif"
document.all.box13I.style.width = "400"
document.all.box13I.style.hight = "auto"
box[13][3] = "400"
tide=""
fixDivider()
donuPic = ""
}
