<!--
function ImagePreloader(images, callback)
{
   // store the call-back
   this.callback = callback;
   // initialize internal state.
   this.nLoaded = 0;
   this.nProcessed = 0;
   this.aImages = new Array;
   // record the number of images.
   this.nImages = images.length;
   // for each image, call preload()
   for ( var i = 0; i < images.length; i++ ) 
      this.preload(images[i]);
}

ImagePreloader.prototype.preload = function(image)
{
   // create new Image object and add to array
   var oImage = new Image;
   this.aImages.push(oImage);
   // set up event handlers for the Image object
   oImage.onload = ImagePreloader.prototype.onload;
   oImage.onerror = ImagePreloader.prototype.onerror;
   oImage.onabort = ImagePreloader.prototype.onabort;
   // assign pointer back to this.
   oImage.oImagePreloader = this;
   oImage.bLoaded = false;
   // assign the .src property of the Image object
   oImage.src = image;
}

ImagePreloader.prototype.onComplete = function()
{
   this.nProcessed++;
   if ( this.nProcessed == this.nImages )
   {
      this.call-back(this.aImages, this.nLoaded);
   }
}

ImagePreloader.prototype.onload = function()
{
   this.bLoaded = true;
   this.oImagePreloader.nLoaded++;
   this.oImagePreloader.onComplete();
}

ImagePreloader.prototype.onerror = function()
{
   this.bError = true;
   this.oImagePreloader.onComplete();
}

ImagePreloader.prototype.onabort = function()
{
   this.bAbort = true;
   this.oImagePreloader.onComplete();
}
//-->

<!-- Changes:  Sandeep V. Tamhankar (stamhankar@hotmail.com) -->

/* 1.1.2: Fixed a bug where trailing . in e-mail address was passing
            (the bug is actually in the weak regexp engine of the browser; I
            simplified the regexps to make it work).
   1.1.1: Removed restriction that countries must be preceded by a domain,
            so abc@host.uk is now legal.  However, there's still the 
            restriction that an address must end in a two or three letter
            word.
     1.1: Rewrote most of the function to conform more closely to RFC 822.
     1.0: Original  */

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
function emailCheck (emailStr) {
/* The following pattern is used to check if the entered e-mail address
   fits the user@domain format.  It also is used to separate the username
   from the domain. */
var emailPat=/^(.+)@(.+)$/
/* The following string represents the pattern for matching all special
   characters.  We don't want to allow special characters in the address. 
   These characters include ( ) < > @ , ; : \ " . [ ]    */
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
/* The following string represents the range of characters allowed in a 
   username or domainname.  It really states which chars aren't allowed. */
var validChars="\[^\\s" + specialChars + "\]"
/* The following pattern applies if the "user" is a quoted string (in
   which case, there are no rules about which characters are allowed
   and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
   is a legal e-mail address. */
var quotedUser="(\"[^\"]*\")"
/* The following pattern applies for domains that are IP addresses,
   rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
   e-mail address. NOTE: The square brackets are required. */
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
/* The following string represents an atom (basically a series of
   non-special characters.) */
var atom=validChars + '+'
/* The following string represents one word in the typical username.
   For example, in john.doe@somewhere.com, john and doe are words.
   Basically, a word is either an atom or quoted string. */
var word="(" + atom + "|" + quotedUser + ")"
// The following pattern describes the structure of the user
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
/* The following pattern describes the structure of a normal symbolic
   domain, as opposed to ipDomainPat, shown above. */
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")


/* Finally, let's start trying to figure out if the supplied address is
   valid. */

/* Begin with the coarse pattern to simply break up user@domain into
   different pieces that are easy to analyze. */
var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
  /* Too many/few @'s or something; basically, this address doesn't
     even fit the general mould of a valid e-mail address. */
	alert("Email address seems incorrect (check @ and .'s)")
	return false
}
var user=matchArray[1]
var domain=matchArray[2]

// See if "user" is valid 
if (user.match(userPat)==null) {
    // user is not valid
    alert("The username doesn't seem to be valid.")
    return false
}

/* if the e-mail address is at an IP address (as opposed to a symbolic
   host name) make sure the IP address is valid. */
var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {
    // this is an IP address
	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
	        alert("Destination IP address is invalid!")
		return false
	    }
    }
    return true
}

// Domain is symbolic name
var domainArray=domain.match(domainPat)
if (domainArray==null) {
	alert("The domain name doesn't seem to be valid.")
    return false
}

/* domain name seems valid, but now make sure that it ends in a
   three-letter word (like com, edu, gov) or a two-letter word,
   representing country (uk, nl), and that there's a hostname preceding 
   the domain or country. */

/* Now we need to break up the domain to get a count of how many atoms
   it consists of. */
var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 || 
    domArr[domArr.length-1].length>3) {
   // the address must end in a two letter or three letter word.
   alert("The address must end in a three-letter domain, or two letter country.")
   return false
}

// Make sure there's a host name preceding the domain.
if (len<2) {
   var errStr="This address is missing a hostname!"
   alert(errStr)
   return false
}

// If we've gotten this far, everything's valid!
return true;
}
//  End -->

<!--
var isNS4 = (navigator.appName=="Netscape")?1:0;
var text0Focus;
var text20Focus;
var maxChar = 22;
var maxCharPlus1 = maxChar + 1;

function EvalSound(soundobj) {
  var thissound= eval("document."+soundobj);
  thissound.Play();
}

function loading(){
  document.getElementById('colorselect').focus();
	text0Focus=false;
	text20Focus=false;
	document.forms['multibuy'].colorselect.selectedIndex=0;
	document.forms['multibuy'].colorselect.options[0].selected=true;
	document.forms['multibuy'].font0.selectedIndex=0;
	document.forms['multibuy'].font0.options[0].selected=true;
  document.getElementById('text0_old').value=document.getElementById('text0').value;
  document.getElementById('text20_old').value=document.getElementById('text20').value;
  var field1=document.getElementById('text0');
  var field2=document.getElementById('text20');
  disableSelection(field1);
  disableSelection(field2);
  document.getElementById('nts_ad').value='';
  document.getElementById('text0').value='';
  document.getElementById('text20').value='';
  document.getElementById('text0_old').value='';
  document.getElementById('text20_old').value='';
  document.getElementById('button1').style.visibility='visible';
  document.getElementById('button2').style.visibility='visible';
  document.getElementById('button3').style.visibility='visible';
  document.getElementById('button4').style.visibility='visible';
	//setMaxLength();
}

/*event functions*/

/***********************************************
* Disable "Enter" key in Form script- By Nurul Fadilah(nurul@REMOVETHISvolmedia.com)
* This notice must stay intact for use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
                
function handleEnter (field, event) {
		var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
		if (keyCode == 13) {
			var i;
			for (i = 0; i < field.form.elements.length; i++)
				if (field == field.form.elements[i])
					break;
			i = (i + 1) % field.form.elements.length;
			field.form.elements[i].focus();
			return false;
		} 
		else
		return true;
}      

function disableSelection(target){
  if (typeof target.onselectstart!="undefined") //IE route
	  target.onselectstart=function(){return false}
  else if (typeof target.style.MozUserSelect!="undefined") //Firefox route
	  target.style.MozUserSelect="none"
  else //All other route (ie: Opera)
	  target.onmousedown=function(){return false}
  target.style.cursor = "default";
}

function cancelEvent(e) {
    if (!e) e = window.event;
    if (e.preventDefault) {
        e.preventDefault();
    } else {
        e.returnValue = false;
    }
}

function stopEvent(e) {
    if (!e) e = window.event;
    if (e.stopPropagation) {
        e.stopPropagation();
    } else {
        e.cancelBubble = true;
    }
}

function disableCtrlKeyCombination(e)
{
  //list all CTRL + key combinations you want to disable
  var forbiddenKeys = new Array('a', 'n', 'c', 'x', 'v', 'j');
  var key;
  var isCtrl;

  if(window.event){
    key = window.event.keyCode;     //IE
    if(window.event.ctrlKey)
      isCtrl = true;
    else
      isCtrl = false;
  }else{
    key = e.which;     //firefox
    if(e.ctrlKey)
      isCtrl = true;
    else
      isCtrl = false;
  }
  //if ctrl is pressed check if other key is in forbidenKeys array
  if(isCtrl){
    for(i=0; i<forbiddenKeys.length; i++){
      //case-insensitive comparation
      if(forbiddenKeys[i].toLowerCase() == String.fromCharCode(key).toLowerCase()){
        //alert('Key combination CTRL + '+String.fromCharCode(key)+' has been disabled.');
        return false;
      }
    }
  }
  return true;
}

function disableShiftKeyCombination(e)
{
  //list all Shift + key combinations you want to disable
  var forbiddenKeys = new Array('33','34','35','36','37','38','39','40','96','97','98','99','100','101','102','103','104','105','106');
  var key;
  var isShift;

  if(window.event){
    key = window.event.keyCode;     //IE
    if(window.event.shiftKey)
      isShift = true;
    else
      isShift = false;
  }else{
    key = e.which;     //firefox
    if(e.shiftKey)
      isShift = true;
    else
      isShift = false;
  }
  //if Shift is pressed check if other key is in forbidenKeys array
  if(isShift){
    for(i=0; i<forbiddenKeys.length; i++){
      if(forbiddenKeys[i] == key){
        //alert('Key combination Shift + '+String.fromCharCode(key)+' has been disabled.');
        return false;
      }
    }
  }
  return true;
}

function ismaxlength(obj){
var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
if (obj.getAttribute && obj.value.length>mlength)
obj.value=obj.value.substring(0,mlength)
}

function setMaxLength() {
	var x = document.getElementsByTagName('textarea');
	var counter = document.createElement('div');
	counter.className = 'counter';
	for (var i=0;i<x.length;i++) {
		if (x[i].getAttribute('maxlength')) {
			var counterClone = counter.cloneNode(true);
			counterClone.relatedElement = x[i];
			counterClone.innerHTML = '<span>0</span>/'+x[i].getAttribute('maxlength');
			x[i].parentNode.insertBefore(counterClone,x[i].nextSibling);
			x[i].relatedElement = counterClone.getElementsByTagName('span')[0];

			x[i].onkeyup = x[i].onchange = checkMaxLength;
			x[i].onkeyup();
		}
	}
}

function checkMaxLength() {
	var maxLength = this.getAttribute('maxlength');
	var currentLength = this.value.length;
	if (currentLength > maxLength)
		this.relatedElement.className = 'toomuch';
	else
		this.relatedElement.className = '';
	this.relatedElement.firstChild.nodeValue = currentLength;
	// not innerHTML
}

/*end event functions*/


function background(color_name)
{
  var browser=navigator.appName;
	var color_display="";
	var onum01=0;
	var onum11=0;
	
	if(color_name=="white")
	{
	  color_display="white";
		onum01=46;
		onum11=47;
	}
	if(color_name=="gray")
	{
	  color_display="gray";
		onum01=48;
		onum11=49;
	}
	if(color_name=="metallic_silver")
	{
	  color_display="metallic silver";
		onum01=100;
		onum11=101;
	}
	if(color_name=="metallic_gold")
	{
	  color_display="metallic gold";
		onum01=102;
		onum11=103;
	}
	if(color_name=="carolina_blue")
	{
	  color_display="carolina blue";
		onum01=50;
		onum11=51;
	}
	if(color_name=="royal")
	{
	  color_display="royal";
		onum01=52;
		onum11=53;
	}
	if(color_name=="navy")
	{
	  color_display="navy";
		onum01=106;
		onum11=107;
	}
	if(color_name=="purple")
	{
	  color_display="purple";
		onum01=54;
		onum11=55;
	}
	if(color_name=="kelly")
	{
	  color_display="kelly";
		onum01=42;
		onum11=43;
	}
	if(color_name=="forest")
	{
	  color_display="forest";
		onum01=56;
		onum11=57;
	}
	if(color_name=="yellow")
	{
	  color_display="yellow";
		onum01=58;
		onum11=59;
	}
	if(color_name=="orange")
	{
	  color_display="orange";
		onum01=60;
		onum11=61;
	}
	if(color_name=="pink")
	{
	  color_display="pink";
		onum01=62;
		onum11=63;
	}
	if(color_name=="red")
	{
	  color_display="red";
		onum01=40;
		onum11=41;
	}
	if(color_name=="cardinal")
	{
	  color_display="cardinal";
		onum01=110;
		onum11=111;
	}
	if(color_name=="maroon")
	{
	  color_display="maroon";
		onum01=64;
		onum11=65;
	}
	if(color_name=="brown")
	{
	  color_display="brown";
		onum01=66;
		onum11=67;
	}
	if(color_name=="black")
	{
	  color_display="black";
		onum01=68;
		onum11=69;
	}
	var x=document.getElementById("color_label");
	x.innerHTML=color_display;
	document.getElementById("pId0").value = color_name;
	document.getElementById("pId1").value = color_name;
	document.getElementById("onum01").value = onum01;
	document.getElementById("onum11").value = onum11;
	document.getElementById("main_img").src="prodimages/"+color_name+".jpg";
}

function showphrases()
{
  var font=document.getElementById("font0").value;
	var fontf="";
	var fonts="12px";
	switch(font){
	  case "Arial":
		  fontf="Arial, Helvetica, sans-serif";
		  break;
		case "Arial Extra Bold":
		  fontf='"Arial Black", Gadget, sans-serif';
		  break;
		case "Brush Script":
		  fontf='Brush Script MT, script';
			fonts="18px";
		  break;
		case "College":
		  fontf='College';
		  break;
		case "Comic Sans":
		  fontf='"Comic Sans MS", "Comic Sans MS5", cursive';
		  break;
		case "Courier New":
		  fontf='"Courier New", Courier6, monospace';
		  break;
		case "Edwardian Script":
		  fontf='Edwardian Script ITC, script';
			fonts="18px";
		  break;
		case "Freshbot":
		  fontf='Freshbot';
		  break;
		case "Impact":
		  fontf='Impact, Impact5, Charcoal6, sans-serif';
		  break;
		case "Tahoma":
		  fontf='Tahoma, Geneva, sans-serif';
		  break;
		case "Times":
		  fontf='Times New Roman, Times, serif';
		  break;
		default:
		  fontf="Arial, Helvetica, sans-serif";
		  break;
	}
	
		var ta=document.getElementById("g_table");
		ta.style.fontFamily=fontf;
		var ta2=document.getElementById("g2_table");
		ta2.style.fontFamily=fontf;
		var text0=document.getElementById("text0");
		text0.style.fontSize=fonts;
		text0.style.fontFamily=fontf;
		var text20=document.getElementById("text20");
		text20.style.fontSize=fonts;
		text20.style.fontFamily=fontf;
		document.getElementById("font20").value=fontf;
}

function embolden(){
  var bv=document.getElementById("boldvalue").value;
  if(bv=="false"){
	  var ta=document.getElementById("g_table");
	  ta.style.fontWeight="bold";
	  var ta2=document.getElementById("g2_table");
	  ta2.style.fontWeight="bold";
	  var text0=document.getElementById("text0");
	  text0.style.fontWeight="bold";
	  var text20=document.getElementById("text20");
	  text20.style.fontWeight="bold";
		bv="true";
		document.getElementById("bold").style.backgroundColor="#847F80";
	}else{
	  var ta=document.getElementById("g_table");
	  ta.style.fontWeight="normal";
	  var ta2=document.getElementById("g2_table");
	  ta2.style.fontWeight="normal";
	  var text0=document.getElementById("text0");
	  text0.style.fontWeight="normal";
	  var text20=document.getElementById("text20");
	  text20.style.fontWeight="normal";
		bv="false";
		document.getElementById("bold").style.backgroundColor="";
	}
	document.getElementById("boldvalue").value=bv;
}

function italicize(){
  var iv=document.getElementById("italicvalue").value;
  if(iv=="false"){
	  var ta=document.getElementById("g_table");
	  ta.style.fontStyle="italic";
	  var ta2=document.getElementById("g2_table");
	  ta2.style.fontStyle="italic";
	  var text0=document.getElementById("text0");
	  text0.style.fontStyle="italic";
	  var text20=document.getElementById("text20");
	  text20.style.fontStyle="italic";
	  iv="true";
		document.getElementById("italic").style.backgroundColor="#847F80";
	}else{
	  var ta=document.getElementById("g_table");
	  ta.style.fontStyle="normal";
	  var ta2=document.getElementById("g2_table");
	  ta2.style.fontStyle="normal";
	  var text0=document.getElementById("text0");
	  text0.style.fontStyle="normal";
	  var text20=document.getElementById("text20");
	  text20.style.fontStyle="normal";
	  iv="false";
		document.getElementById("italic").style.backgroundColor="";
	}
	document.getElementById("italicvalue").value=iv;
}

function getprice()
{
  var color_name=document.getElementById("pId0").value;
	var text20=document.getElementById("text20").value;
	var m=0;
	var l=0;
	
	m=parseInt(document.getElementById("qty0").value);
	l=parseInt(document.getElementById("qty1").value);
	if(isNaN(m))m=0;
	if(isNaN(l))l=0;
	
	var piece_tot=m+l;	
	var piece_price=1.90;
	var second_side=0;
	if(piece_tot>=1 && piece_tot<=9)
  {
    piece_price=6.10;
	  second_side=0;
  }
	if(piece_tot>=10 && piece_tot<=49)
  {
    piece_price=1.90;
	  second_side=0;
  }
	if(piece_tot>=50 && piece_tot<=99)
  {
    piece_price=1.50;
	  second_side=0;
  }
	if(piece_tot>=100 && piece_tot<=190)
  {
    piece_price=1.15;
	  second_side=0;
  }
	if(piece_tot>=200 && piece_tot<=490)
  {
		piece_price=.80;
	  second_side=0;
  }
	if(piece_tot>=500 && piece_tot<=990)
  {
		piece_price=.70;
	  second_side=0;
  }
	if(piece_tot>=1000 && piece_tot<=4990)
  {
    piece_price=.50;
	  second_side=0;
  }
	if(piece_tot>=5000 && piece_tot<=9990)
  {
		piece_price=.30;
	  second_side=0;
  }
	if(piece_tot>10000)
  {
		piece_price=.20;
	  second_side=0;
	}
	
	if(text20!="")
	  piece_price+=second_side;
	
	var tot_price=piece_price*piece_tot;
	
	tot_price=Math.round(tot_price*100.0) / 100.0;
	
	document.getElementById("pPrice0").value=piece_price;
	document.getElementById("pPrice1").value=piece_price;
	var x=document.getElementById("price_label");
	var result = piece_price.toFixed(2); 
	x.innerHTML="$"+result;
}

function showdetails(){
  var phrase=document.getElementById("phrase_detail");
	phrase.style.visibility="visible";
}

function hidedetails(){
  var phrase=document.getElementById("phrase_detail");
	phrase.style.visibility="hidden";
}

/*Cursor Position Code*/
function countChars(text) {
  var n = 0;
  for (var i = 0; i<text.length; i++) { 
    if (text.charAt(i) != '\r') {
      n++;
    }
  }
  return n;
} 

function CursorPos(start, end) {
  this.start = start;
  this.end = end;
} 

function getCursorPosition(textArea) {
  var start = 0;
  var end = 0;
  if (document.selection) { // IE...
    textArea.focus();
    var sel1 = document.selection.createRange(); 
    var sel2 = sel1.duplicate();
    sel2.moveToElementText(textArea);
    var selText = sel1.text;
    sel1.text = "\001";
    var index = sel2.text.indexOf("\001");
    start = countChars((index == -1) ? sel2.text : sel2.text.substring(0, index));
    end = countChars(selText) + start;
    sel1.moveStart('character', -1);
    sel1.text = selText;
  } else if (textArea.selectionStart || (textArea.selectionStart == "0")) { // Mozilla/Netscape...
    start = textArea.selectionStart;
    end = textArea.selectionEnd;
  }
  return new CursorPos(start, end);
} 

function setCursorPosition(textArea, cursorPos) {
  if (document.selection) { // IE...
    var sel = textArea.createTextRange();
    sel.collapse(true);
    sel.moveStart("character", cursorPos.start);
    sel.moveEnd("character", cursorPos.end - cursorPos.start);
    sel.select();
  } else if (textArea.selectionStart || (textArea.selectionStart == "0")) { // Mozilla/Netscape...
    textArea.selectionStart = cursorPos.start;
    textArea.selectionEnd = cursorPos.end;
  }
  textArea.focus();
} 
/*End Cursor Position Code*/

/*Detect Key Pressed*/
var cur_pos=new CursorPos(0,0);
var end_pos=new CursorPos(0,0);
var end_pos2=new CursorPos(0,0);
var code;
var character;
var front_imgs=new Array(maxCharPlus1);
for(i=0;i<=maxChar;i++){
  front_imgs[i]='';
}
var back_imgs=new Array(maxCharPlus1);
for(i=0;i<=maxChar;i++){
  back_imgs[i]='';
}
var front_picname=new Array(maxCharPlus1);
for(i=0;i<=maxChar;i++){
  front_picname[i]='';
}
var back_picname=new Array(maxCharPlus1);
for(i=0;i<=maxChar;i++){
  back_picname[i]='';
}
var front_phrase='';
var back_phrase='';
var right_menu=0;

function checkKey(e) {
	if (!e) var e = window.event;
	if (e.keyCode) code = e.keyCode;
	else if (e.which) code = e.which;
	character = String.fromCharCode(code);
	//alert('Character is ' + code + ' ' + character + ', Position was ' + cur_pos.start + ',' + cur_pos.end);
}

function getPositions() {
  var f1='';
  if(document.getElementById('text0').hasFocus){
	  text0Focus=true;
		f1='text0';
	}else{
	  text0Focus=false;
	}
	if(document.getElementById('text20').hasFocus){
	  text20Focus=true;
		f1='text20';
	}else{
	  text20Focus=false;
	}
  if(f1!=''){
	  var fname=document.getElementById(f1);
    cur_pos=getCursorPosition(fname);
	}
}

function changeSpots() {
  var f1='';
	var text0=document.getElementById("text0").value;
	var text20=document.getElementById("text20").value;
	var text0_old=document.getElementById("text0_old").value;
	var text20_old=document.getElementById("text20_old").value;

  if(document.getElementById('text0').hasFocus){
	  text0Focus=true;
		f1='text0';
	}else{
	  text0Focus=false;
	}
	if(document.getElementById('text20').hasFocus){
	  text20Focus=true;
		f1='text20';
	}else{
	  text20Focus=false;
	}
  if(f1!=''){
	  var fname=document.getElementById(f1);
    end_pos2=getCursorPosition(fname);
	}
	
	/*Move Front Backspace Diamonds*/
	if(code==8&&text0Focus&&end_pos.start!=0){
		var place_rank1=1;
		for(i=1;i<=end_pos2.start;i++){
		  if(front_imgs[i]!=''){
			  place_rank1=place_rank1+1;
			}
		}
		var q=end_pos.end-end_pos2.start;
		var qq=maxChar-q;
		for(i=end_pos2.start+1;i<=end_pos.end;i++){
		  front_imgs[i]='';front_picname[i]='';
		}
		for(i=end_pos2.end+1;i<=qq;i++){
			if(front_imgs[i+q]!=''){
			  switch(place_rank1){
		      case 1:r1="st";break;
			    case 2:r1="nd";break;
			    case 3:r1="rd";break;
			    default:r1="th";break;			
		    }
				front_imgs[i]="Add "+front_picname[i+q]+"graphic where "+place_rank1+r1+" &#9674; is in Front Phrase.<br />";
				front_picname[i]=front_picname[i+q];
				place_rank1++;
			}else{front_imgs[i]='';front_picname[i]='';}
		}
		front_imgs[maxChar]='';front_picname[maxChar]='';
		if(document.getElementById('nts_ad').value!="")
		  document.getElementById('note').style.visibility = "visible";
		var nts=document.getElementById('nts');
		nts.innerHTML='';
		document.getElementById('nts_ad').value='';
		front_phrase='';
		for(i=1;i<maxCharPlus1;i++){
		  if(front_imgs[i]!=''){
			  nts.innerHTML+=front_imgs[i];
		    document.getElementById('nts_ad').value+=front_imgs[i];
				front_phrase+=front_imgs[i];
			}
		}
		nts.innerHTML+=back_phrase;
		document.getElementById('nts_ad').value+=back_phrase;
	}
	
	/*Move Front Delete Diamonds*/
	else if(code==46&&text0Focus&&end_pos.start!=maxChar){
		var place_rank1=1;
		for(i=1;i<=end_pos2.end;i++){
		  if(front_imgs[i]!=''){
			  place_rank1=place_rank1+1;
			}
		}
		var old_cnt=text0_old.length;
		var new_cnt=text0.length;
		var q=old_cnt-new_cnt;
		var qq=maxChar-q;		
		for(i=end_pos2.end+1;i<=qq;i++){
			if(front_imgs[i+q]!=''){
			  switch(place_rank1){
		      case 1:r1="st";break;
			    case 2:r1="nd";break;
			    case 3:r1="rd";break;
			    default:r1="th";break;			
		    }
				front_imgs[i]="Add "+front_picname[i+q]+"graphic where "+place_rank1+r1+" &#9674; is in front Phrase.<br />";
				front_picname[i]=front_picname[i+q];
				place_rank1++;
			}else{front_imgs[i]='';front_picname[i]='';}
		}
		front_imgs[maxChar]='';front_picname[maxChar]='';
		if(document.getElementById('nts_ad').value!="")
		  document.getElementById('note').style.visibility = "visible";
		var nts=document.getElementById('nts');
		nts.innerHTML='';
		document.getElementById('nts_ad').value='';
		front_phrase='';
		for(i=1;i<maxCharPlus1;i++){
		  if(front_imgs[i]!=''){
			  nts.innerHTML+=front_imgs[i];
		    document.getElementById('nts_ad').value+=front_imgs[i];
				front_phrase+=front_imgs[i];
			}
		}
		nts.innerHTML+=back_phrase;
		document.getElementById('nts_ad').value+=back_phrase;
	}
	
	/*Move Back Backspace Diamonds*/
	else if(code==8&&text20Focus&&end_pos.start!=0){
	  var place_rank2=1;
		for(i=1;i<=end_pos2.start;i++){
		  if(back_imgs[i]!=''){
			  place_rank2=place_rank2+1;
			}
		}
		var q=end_pos.end-end_pos2.start;
		var qq=maxChar-q;
		for(i=end_pos2.start+1;i<=end_pos.end;i++){
		  back_imgs[i]='';back_picname[i]='';
		}
		for(i=end_pos2.end+1;i<=qq;i++){
			if(back_imgs[i+q]!=''){
			  switch(place_rank2){
		      case 1:r2="st";break;
			    case 2:r2="nd";break;
			    case 3:r2="rd";break;
			    default:r2="th";break;			
		    }
				back_imgs[i]="Add "+back_picname[i+q]+"graphic where "+place_rank2+r2+" &#9674; is in Back Phrase.<br />";
				back_picname[i]=back_picname[i+q];
				place_rank2++;
			}else{back_imgs[i]='';back_picname[i]='';}
		}		
		back_imgs[maxChar]='';back_picname[maxChar]='';
		if(document.getElementById('nts_ad').value!="")
		  document.getElementById('note').style.visibility = "visible";
		var nts=document.getElementById('nts');
		nts.innerHTML=front_phrase;
		document.getElementById('nts_ad').value=front_phrase;
		back_phrase='';
		for(i=1;i<maxCharPlus1;i++){
		  if(back_imgs[i]!=''){
			  nts.innerHTML+=back_imgs[i];
		    document.getElementById('nts_ad').value+=back_imgs[i];
				back_phrase+=back_imgs[i];
			}
		}
	}
	
	/*Move Back Delete Diamonds*/
	else if(code==46&&text20Focus&&end_pos.start!=maxChar){
    var place_rank2=1;
		for(i=1;i<=end_pos2.end;i++){
		  if(back_imgs[i]!=''){
			  place_rank2=place_rank2+1;
			}
		}
		var old_cnt=text20_old.length;
		var new_cnt=text20.length;
		var q=old_cnt-new_cnt;
		var qq=maxChar-q;		
		for(i=end_pos2.end+1;i<=qq;i++){
			if(back_imgs[i+q]!=''){
			  switch(place_rank2){
		      case 1:r2="st";break;
			    case 2:r2="nd";break;
			    case 3:r2="rd";break;
			    default:r2="th";break;			
		    }
				back_imgs[i]="Add "+back_picname[i+q]+"graphic where "+place_rank2+r2+" &#9674; is in Back Phrase.<br />";
				back_picname[i]=back_picname[i+q];
				place_rank2++;
			}else{back_imgs[i]='';back_picname[i]='';}
		}
		back_imgs[maxChar]='';back_picname[maxChar]='';
		if(document.getElementById('nts_ad').value!="")
		  document.getElementById('note').style.visibility = "visible";
		var nts=document.getElementById('nts');
		nts.innerHTML=front_phrase;
		document.getElementById('nts_ad').value=front_phrase;
		back_phrase='';
		for(i=1;i<maxCharPlus1;i++){
		  if(back_imgs[i]!=''){
			  nts.innerHTML+=back_imgs[i];
		    document.getElementById('nts_ad').value+=back_imgs[i];
				back_phrase+=back_imgs[i];
			}
		}
	}
	
	/*Move Front Normal Char Diamonds*/
	else if((code<33||code>40)&&text0Focus&&end_pos.start!=maxChar){
	  var place_rank1=1;
		for(i=1;i<end_pos.start;i++){
		  if(front_imgs[i]!=''){
			  place_rank1=place_rank1+1;
			}
		}
		var front_rank=new Array(maxCharPlus1);for(i=0;i<=maxChar;i++){front_rank[i]='';}
		var front_rankpic=new Array(maxCharPlus1);for(i=0;i<=maxChar;i++){front_rankpic[i]='';}
		var q=end_pos2.end-end_pos.start;
		var qq=maxChar-q;
		for(i=end_pos.end+1;i<=qq;i++){
			if(front_imgs[i]!=''){
			  switch(place_rank1){
		      case 1:r1="st";break;
			    case 2:r1="nd";break;
			    case 3:r1="rd";break;
			    default:r1="th";break;			
		    }
				front_rank[i+q]="Add "+front_picname[i]+"graphic where "+place_rank1+r1+" &#9674; is in Front Phrase.<br />";
				front_rankpic[i+q]=front_picname[i];
				place_rank1++;
			}else{front_rank[i+q]='';front_rankpic[i+q]='';}
		}
		for(i=end_pos.start+1;i<=end_pos2.end;i++){
		  front_imgs[i]='';
		  front_picname[i]='';
		}
		for(i=end_pos2.end+1;i<=maxChar;i++){
		  front_imgs[i]=front_rank[i];
			front_picname[i]=front_rankpic[i];
		}
		//document.getElementById('note').style.visibility = "visible";
		var nts=document.getElementById('nts');
		nts.innerHTML='';
		document.getElementById('nts_ad').value='';
		front_phrase='';
		for(i=1;i<maxCharPlus1;i++){
		  if(front_imgs[i]!=''){
			  nts.innerHTML+=front_imgs[i];
		    document.getElementById('nts_ad').value+=front_imgs[i];
				front_phrase+=front_imgs[i];
			}
		}
		nts.innerHTML+=back_phrase;
		document.getElementById('nts_ad').value+=back_phrase;
	}
	
	/*Move Back Normal Char Diamonds*/
	else if((code<33||code>40)&&text20Focus&&end_pos.start!=maxChar){
	  var place_rank2=1;
		for(i=1;i<end_pos.start;i++){
		  if(back_imgs[i]!=''){
			  place_rank2=place_rank2+1;
			}
		}
		var back_rank=new Array(maxCharPlus1);for(i=0;i<=maxChar;i++){back_rank[i]='';}
		var back_rankpic=new Array(maxCharPlus1);for(i=0;i<=maxChar;i++){back_rankpic[i]='';}
		
		var q=end_pos2.end-end_pos.start;
		var qq=maxChar-q;
		for(i=end_pos.end+1;i<=qq;i++){
			if(back_imgs[i]!=''){
			  switch(place_rank2){
		      case 1:r2="st";break;
			    case 2:r2="nd";break;
			    case 3:r2="rd";break;
			    default:r2="th";break;			
		    }
				back_rank[i+q]="Add "+back_picname[i]+"graphic where "+place_rank2+r2+" &#9674; is in Back Phrase.<br />";
				back_rankpic[i+q]=back_picname[i];
				place_rank2++;
			}else{back_rank[i+q]='';back_rankpic[i+q]='';}
		}
		for(i=end_pos.start+1;i<=end_pos2.end;i++){
		  back_imgs[i]='';
		  back_picname[i]='';
		}
		for(i=end_pos2.end+1;i<=maxChar;i++){
		  back_imgs[i]=back_rank[i];
			back_picname[i]=back_rankpic[i];
		}
		//document.getElementById('note').style.visibility = "visible";
		var nts=document.getElementById('nts');
		nts.innerHTML=front_phrase;
		document.getElementById('nts_ad').value=front_phrase;
		back_phrase='';
		for(i=1;i<maxCharPlus1;i++){
		  if(back_imgs[i]!=''){
			  nts.innerHTML+=back_imgs[i];
		    document.getElementById('nts_ad').value+=back_imgs[i];
				back_phrase+=back_imgs[i];
			}
		}
	}
	/*End Move Back Normal Char Diamonds*/
	
	else if((code>=33&&code<=40)&&text0Focus){
	  var fname=document.getElementById('text0');
	  end_pos=getCursorPosition(fname);
	  end_pos2=getCursorPosition(fname);
	}
	else if((code>=33&&code<=40)&&text20Focus){
	  var fname=document.getElementById('text20');
	  end_pos=getCursorPosition(fname);
	  end_pos2=getCursorPosition(fname);
	}
	//var nts=document.getElementById('nts');
	document.getElementById('position').value='Character was , Position was '+end_pos.start+','+end_pos.end+', Position is '+end_pos2.start+','+end_pos2.end;
	//alert('Character was '+code+' '+character+', Position was '+end_pos.start+','+end_pos.end+', Position is '+end_pos2.start+','+end_pos2.end);
	end_pos.start=end_pos2.start;
	end_pos.end=end_pos2.end;
	document.getElementById("text0_old").value=document.getElementById("text0").value;
	document.getElementById("text20_old").value=document.getElementById("text20").value;
}
/*End Detect Key Pressed*/

/*Insert At Cursor and Pop-Ups*/
function insertAtCursor(myName, myField, myValue) {
  var spot=new CursorPos(0,0);
	//IE support
	if (navigator.appName=="Microsoft Internet Explorer"){
	  if(myName=='notes' || (myName=='text0' && !text0Focus) || (myName=='text20' && !text20Focus)){
			var inside=myField.value+myValue;
	    myField.value=inside;
		  var cnt=inside.length;document.getElementById(myName).focus(cnt);
    }else{
		  myField.focus();
      sel = document.selection.createRange();
      sel.text = myValue;
		}
  }
  /*MOZILLA/NETSCAPE support
	else if (myField.selectionStart || myField.selectionStart == '0') {
    var startPos = myField.selectionStart;
    var endPos = myField.selectionEnd;
    myField.value = myField.value.substring(0, startPos)
                  + myValue
                  + myField.value.substring(endPos, myField.value.length);
  }*/else{
	  cur_pos=getCursorPosition(myField);
	  var startPos = cur_pos.start;
    var endPos = cur_pos.end;
		spot.start=cur_pos.start+1;
		spot.end=cur_pos.end+1;
    myField.value = myField.value.substring(0, startPos)
                  + myValue
                  + myField.value.substring(endPos, myField.value.length);
		setCursorPosition(myField,spot);
	  //myField.value += myValue;
  }
}

var DHTML = (document.getElementById || document.all || document.layers);

function getObj(name)
{
  if (document.getElementById)
  {
  	this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  }
  else if (document.all)
  {
	this.obj = document.all[name];
	this.style = document.all[name].style;
  }
  else if (document.layers)
  {
   	this.obj = document.layers[name];
   	this.style = document.layers[name];
  }
}

function dlgColorPalette(element) {	 
	if (!DHTML) return;
	if(element!='note'){
	  if(element=='glyphs' || element=='img')
	    f1='text0';
	  else if(element=='glyphs2' || element=='img2')
	    f1='text20';
	  var fname=document.getElementById(f1);
	  var cnt=getCursorPosition(fname);
	}
	var x = new getObj(element);	
	if (x.obj.style.visibility == "hidden") {
		x.obj.style.visibility = "visible";
	} else {
		x.obj.style.visibility = "hidden";
	}
	if(element!='note'){
	  setCursorPosition(fname,cnt);
	  getPositions();
	}
}

function selectCharacter(schar,pic_value,this_text,pic_name) {		
	var fname='';
	var k=0;
	var place_rank1=1;
	var place_rank2=1;
	var p1="";
	var p2="";
	var pic_sent="";
	var r1="";
	var r2="";
	var text0=document.getElementById('text0').value;
	var text20=document.getElementById('text20').value;
	
	if((this_text=='glyphs'||this_text=='img')&&text0.length==maxChar){
		alert("You have reached the maximum number of characters for the Front Phrase.");
	}
	else if((this_text=='glyphs2'||this_text=='img2')&&text20.length==maxChar){
		alert("You have reached the maximum number of characters for the Back Phrase.");
	}
	
	if(this_text=='glyphs' && text0.length<maxChar){
		insertAtCursor('text0', document.getElementById('text0'), schar);
		fname=document.getElementById('text0');
    end_pos=getCursorPosition(fname);
		setCursorPosition(fname,end_pos);
	}else if(this_text=='glyphs2' && text20.length<maxChar){
	  insertAtCursor('text20', document.getElementById('text20'), schar);
		var fname=document.getElementById('text20');
    end_pos=getCursorPosition(fname);
		setCursorPosition(fname,end_pos);
	}else if(this_text=='img' && text0.length<maxChar){
	  insertAtCursor('text0', document.getElementById('text0'), schar);
    fname=document.getElementById('text0');
		end_pos=getCursorPosition(fname);
		/*Move Front Img Diamonds*/
		var place1=1;
		for(i=1;i<end_pos.end;i++){
		  if(front_imgs[i]!=''){
			  place1=place1+1;
			}
		}
		var front_rank=new Array(maxCharPlus1);for(i=0;i<=maxChar;i++){front_rank[i]='';}
		var front_rankpic=new Array(maxCharPlus1);for(i=0;i<=maxChar;i++){front_rankpic[i]='';}
		place_rank1=parseInt(place1);
		for(i=end_pos.end;i<maxChar;i++){
			if(front_imgs[i]!=''){
			  place_rank1++;
				switch(place_rank1){
		      case 1:r1="st";break;
			    case 2:r1="nd";break;
			    case 3:r1="rd";break;
			    default:r1="th";break;			
		    }
				front_rank[i+1]="Add "+front_picname[i]+"graphic where "+place_rank1+r1+" "+schar+" is in Front Phrase.<br />";
				front_rankpic[i+1]=front_picname[i];
			}else{front_rank[i+1]='';front_rankpic[i+1]='';}
		}
		for(i=end_pos.end+1;i<=maxChar;i++){
		  front_imgs[i]=front_rank[i];
			front_picname[i]=front_rankpic[i];
		}
		/*End Move Front Img Diamonds*/
		switch(place1){
		  case 1:p1="st";break;
			case 2:p1="nd";break;
			case 3:p1="rd";break;
			default:p1="th";break;			
		}
		pic_sent="Add "+pic_name+"graphic where "+place1+p1+" "+schar+" is in Front Phrase.<br />";//pic_name+"graphic added in Front Phrase.\n";
    document.getElementById('note').style.visibility = "visible";
		var nts=document.getElementById('nts');
		front_imgs[end_pos.end]=pic_sent;
		front_picname[end_pos.end]=pic_name;
		nts.innerHTML='';
		document.getElementById('nts_ad').value='';
		front_phrase='';
		for(i=1;i<maxCharPlus1;i++){
		  if(front_imgs[i]!=''){
			  nts.innerHTML+=front_imgs[i];
		    document.getElementById('nts_ad').value+=front_imgs[i];
				front_phrase+=front_imgs[i];
			}
		}
		nts.innerHTML+=back_phrase;
		document.getElementById('nts_ad').value+=back_phrase;
		setCursorPosition(fname,end_pos);
	}else if(this_text=='img2' && text20.length<maxChar){
	  insertAtCursor('text20', document.getElementById('text20'), schar);
		fname=document.getElementById('text20');
    end_pos=getCursorPosition(fname);
		/*Move Back Img Diamonds*/
	  var place2=1;
		for(i=1;i<end_pos.end;i++){
		  if(back_imgs[i]!=''){
			  place2=place2+1;
			}
		}
		var back_rank=new Array(maxCharPlus1);for(i=0;i<=maxChar;i++){back_rank[i]='';}
		var back_rankpic=new Array(maxCharPlus1);for(i=0;i<=maxChar;i++){back_rankpic[i]='';}
		place_rank2=parseInt(place2);
		for(i=end_pos.end;i<maxChar;i++){
			if(back_imgs[i]!=''){
			  place_rank2++;
				switch(place_rank2){
		      case 1:r2="st";break;
			    case 2:r2="nd";break;
			    case 3:r2="rd";break;
			    default:r2="th";break;			
		    }
				back_rank[i+1]="Add "+back_picname[i]+"graphic where "+place_rank2+r2+" "+schar+" is in Back Phrase.<br />";
				back_rankpic[i+1]=back_picname[i];
			}else{back_rank[i+1]='';back_rankpic[i+1]='';}
		}
		for(i=end_pos.end+1;i<=maxChar;i++){
		  back_imgs[i]=back_rank[i];
			back_picname[i]=back_rankpic[i];
		}
		/*End Move Back Img Diamonds*/
		switch(place2){
		  case 1:p2="st";break;
			case 2:p2="nd";break;
			case 3:p2="rd";break;
			default:p2="th";break;			
		}
		pic_sent="Add "+pic_name+"graphic where "+place2+p2+" "+schar+" is in Back Phrase.<br />";//pic_name+"graphic added in Back Phrase.\n";
		document.getElementById('note').style.visibility = "visible";
		var nts=document.getElementById('nts');
		back_imgs[end_pos.end]=pic_sent;
		back_picname[end_pos.end]=pic_name;
		nts.innerHTML=front_phrase;
		document.getElementById('nts_ad').value=front_phrase;
		back_phrase='';
		for(i=1;i<maxCharPlus1;i++){
		  if(back_imgs[i]!=''){
		    nts.innerHTML+=back_imgs[i];
			  document.getElementById('nts_ad').value+=back_imgs[i];
				back_phrase+=back_imgs[i];
			}
		}
		setCursorPosition(fname,end_pos);
	}
	showphrases();
	getprice();
  
	//alert('Character was '+code+' '+character+', Position was '+cur_pos.start+','+cur_pos.end+', Position is '+end_pos.start+','+end_pos.end);
	document.getElementById("text0_old").value=document.getElementById("text0").value;
	document.getElementById("text20_old").value=document.getElementById("text20").value;
}

function InitColorPalette() {
	if (document.getElementsByTagName)
		var x = document.getElementsByTagName('TD');
	else if (document.all)
		var x = document.all.tags('TD');
	for (var i=0; i < x.length; i++) {
		if(x[i].className=='on_hover')
		{
			x[i].onmouseover = over;
			x[i].onmouseout = out;
			x[i].onclick = click;
		}
	}
}

function over() {
	this.style.backgroundColor = '#777777';
	if(document.getElementById('text0').hasFocus)
	  text0Focus=true;
	else
	  text0Focus=false;
	if(document.getElementById('text20').hasFocus)
	  text20Focus=true;
	else
	  text20Focus=false;
}

function out() {
	this.style.backgroundColor = '#FFFFFF';
}

function click() {	
	var this_div=findParent(this, "div");
	var whole_id=this.id;
	var this_id = new Array();
	var pic_name="";
	this_id=whole_id.split("_");
	for(x=2;x<this_id.length;x++)
	{
	  pic_name+=this_id[x]+" ";
	}
	if(this_div.id=="img" || this_div.id=="img2")
	  selectCharacter(this_id[1],this_id[0],this_div.id,pic_name);
	else
	  selectCharacter(this.id,this.name,this_div.id,"");
}

function findParent(_c, tag) {
    tag = tag.toLowerCase();
    while (_c && _c.tagName) {
        if (_c.tagName.toLowerCase() == tag) 
            return _c;
        _c = _c.parentNode;
	}
	return false;
}
/*End Insert At Cursor and Pop-Ups*/
//-->

