// Programmed by Shawn Olson http://www.shawnolson.net
// Copyright (c) 2006. All Rights Reserved
// Permission to use the HTML generated from this script
// provided that there is credit given to Shawn Olson
// or there is a link provided to http://www.word-search-maker.webonizer.com
	
	var linkCheck = false;
	
	function clickThis(cellid){
	 theCell = document.getElementById(cellid);
	 if(theCell.style.color == 'black'){
	   theCell.style.color = 'red';
	 } else {theCell.style.color = 'black';}
	verifyBackLink();
	}
	
	function checkoff(id){
	  verifyBackLink();
	  checkId = 'wordSearchWord'+id;
	  labelId = 'wordSearchLabel'+id;
	  var css = 'unchecked';
	  if(document.getElementById(checkId).checked){
	    css = 'checked';
	  }
	  document.getElementById(labelId).className = css;
	}
	
	function changecss(theClass,element,value) {
	//documentation for this function at http://www.shawnolson.net/a/503/
     verifyBackLink();
	 var cssRules;
	 if (document.all) {
	  cssRules = 'rules';
	 }
	 else if (document.getElementById) {
	  cssRules = 'cssRules';
	 }
	 for (var S = 0; S < document.styleSheets.length; S++){
	  for (var R = 0; R < document.styleSheets[S][cssRules].length; R++) {
	   if (document.styleSheets[S][cssRules][R].selectorText == theClass) {
	    document.styleSheets[S][cssRules][R].style[element] = value;
	   }
	  }
	 }	
	}
	
	function findOurLink(linkname){
	 var x = 0;
	 var linknamea = linkname + '/';
	 if(document.links.length > 0){
	  for(x in document.links){
	   if(document.links[x].href){
        if(document.links[x].href==linkname || document.links[x].href==linknamea){
         return true;
        }
	   }
	  }
	 }
	 return false;
	}
	
	
	function verifyBackLink(){

 if(linkCheck==false){
 if(findOurLink('http://www.word-search-maker.webonizer.com')==false){

		 var wordlink = '<p style="text-align:center">Created using the <a href="http://www.word-search-maker.webonizer.com">Webonizer Word Search Maker</a><br/><a href="http://www.word-search-maker.webonizer.com">www.word-search-maker.webonizer.com</a></p>'; 

        if(document.getElementById('myWordSearchContainer')){
		
		 document.getElementById('myWordSearchContainer').innerHTML += wordlink;
		} else {document.body.innerHTML += wordlink;}
	  }
	  linkCheck = true;
	  }
	}