	var moodArr = new Array('black','red','green','blue');
	
	function writeUploadFlash(a, b) {
  var flashContent = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="300" height="180" id="fileUpload" align="middle">'
  + ' <param name="allowScriptAccess" value="sameDomain" />'
  + '<param name=FlashVars value="'+a+'"/>'
  + '<param name="movie" value="directinject_upload_popup.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />'
  + '<embed src="directinject_upload_popup.swf" '+b+' />'
  + '</object>';
     document.write(flashContent);
}
	
	function setMood(mood){
		document.getElementById('selMood').value = mood;
		var imgSource = document.getElementById(mood).src;
		for (var x=0;x<moodArr.length;x++){
			var imgStr = document.getElementById(moodArr[x]).src;
			imgStr = imgStr.replace("_over", "");
			imgStr = imgStr.replace(".gif", "");
			if (moodArr[x] == mood){
				var imgStr = imgStr.substring(0, (imgSource.length-4))+'_over';
			}
			document.getElementById(moodArr[x]).src = imgStr+".gif";
			//document.getElementById(mood).src = imgSource.substring(0, (imgSource.length-4))+'_over.gif';
		}
	}
	function setBgr(bgr){
		document.getElementById('selBgr').value = "bg"+bgr;
		var imgSource = document.getElementById('bgr'+bgr).src;
		for (var x=1;x<6;x++){
			var imgStr = document.getElementById('bgr'+x).src;
			imgStr = imgStr.replace("_over", "");
			imgStr = imgStr.replace(".gif", "");
			if (x == bgr){
				var imgStr = imgStr.substring(0, (imgSource.length-4))+'_over';
			}
			document.getElementById('bgr'+x).src = imgStr+".gif";
			//document.getElementById(mood).src = imgSource.substring(0, (imgSource.length-4))+'_over.gif';
		}		
	}
	function loadScreens(mood){
		var xmlhttp;if (window.ActiveXObject){xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}else{xmlhttp=new XMLHttpRequest();}
		var date			= new Date();	var random		= date.getTime();
		if (xmlhttp){
		    xmlhttp.open("GET","goal33_moodselect.php?screens="+mood+"&selBgr="+document.getElementById('selBgr').value+"&hash="+random,true);
		    xmlhttp.onreadystatechange=function() {  
		    	if (xmlhttp.readyState==4){
		            try{
		               document.getElementById('screens').innerHTML  = xmlhttp.responseText;
		               //alert(xmlhttp.responseText);
		            }
		            catch(e){};
		   		}
		 	}
		 	xmlhttp.send(null)
		}	
	}	

			function CountWords (this_field, show_word_count, show_char_count) {
				var char_count = this_field.value.length;
				var fullStr = this_field.value + " ";
				var initial_whitespace_rExp = /^[^A-Za-z0-9]+/gi;
				var left_trimmedStr = fullStr.replace(initial_whitespace_rExp, "");
				var non_alphanumerics_rExp = rExp = /[^A-Za-z0-9]+/gi;
				var cleanedStr = left_trimmedStr.replace(non_alphanumerics_rExp, " ");
				var splitString = cleanedStr.split(" ");
				var word_count = splitString.length -1;
				if (fullStr.length <2) {
					word_count = 0;
				}
				return word_count;
			}
			function check(field, numberWords,formName){
				var words = CountWords(document.getElementById(field));
				if (words > numberWords){
					alert(words+" words used, please reduce your story to "+numberWords+" words!");
				}else{
					document.getElementById(formName).submit();						
				}
			}
			function checkUpload(){
				if (document.getElementById('agree').checked != true && (document.getElementById('your_image').value != '' || document.getElementById('who').value != '')){
					alert("Please agree that your photo's and text are shown in the Hall of Fame at BOB33.com");
				}else{
					check('who', 300, 'form');				
				}
			}
    	function showDiv(div){
    		var show = document.getElementById(div);
    		if (show.style.display == 'none'){
    			show.style.display = 'block';
    		}else{
    			show.style.display = 'none';
    		}
    	}						
			
