function showDate(){
//alert('in fx');
var date=new Date();
var months=new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'Sepember', 'October', 'November', 'December');
var month=date.getMonth();
month=months[month];
var day=date.getDate();
var year=date.getFullYear();
date=month+" "+day+", "+year;
document.write(date);
}

function showTimeTravel(place){
var offset;
var date=new Date();
var hours=date.getUTCHours();
var min=date.getUTCMinutes();
if(place=="Oslo"){offset = 2;}
if(place=="Dublin"){offset = 1;}

hours=hours+offset;
var meridan;
(hours > 12 && hours < 24) ? meridan=" PM": meridan=" AM";

(hours > 24) ? hours=hours-24 : hours=hours;
(hours > 12) ? hours=hours-12 : hours=hours;


(min < 10) ? min="0"+min : min=min;
var time = hours+":"+min+ meridan;
document.write(time);
}


function pickStylesheet(agent,aver){
//alert(agent);
//alert(aver);
	if(agent=="Netscape"){
	document.write("<link rel='stylesheet' type='text/css' href='css/zma_event.css'>");
	}else{
	document.write("<link rel='stylesheet' type='text/css' href='css/zma_event_ie.css'>");
	}
}

function btnLink(link){
location.href=link;
}

function openVid(){
window.open("embedded_commercial(sa).html","winvid","height=446,width=660");
}

function valComment(comments){


	var prohibStr="";
        var prohibChars=new Array('\<a','href','\</a\>','[url','[/url]','[link','[/link','https','http','ftp','smtp','pop3','nntp','imap','irc','\#','\%','\^','\{','\}','com\?','\<','\>');
	
	for(p in prohibChars){
		//alert(prohibChars[p]);
		if(comments.lastIndexOf(prohibChars[p])!=-1){
		prohibStr+='\r\n'+prohibChars[p]+'\r\n';
	
		}
	}
	
	if(prohibStr.length>0){	
	alert('Your entry contains restricted or disallowed character(s): '+prohibStr+'\r\n\r\nPlease review your form entries and remove them to continue.');
	return false;
	}
	

	validContent(comments);
		
	if(semratio<0.4){
	alert("Following our review of your comments, it does not appear to be in English or make sense in English.\n\r\As a precaution this message has not been sent. \n\r\n\rPlease review your comments.");
	return false;
	}

//alert(semratio);
return true;
}



function validContent(comments){
var foundMatches, el,char_count, fullStr, initial_whitespace_rExp, left_trimmedStr, non_alphanumerics_rExp, cleanedStr, splitString, word_count, reqdWords
		
		el=comments;

		char_count=el.length;          // very crude measure
		fullStr=el+" "; // add space delimiter to end of text
		initial_whitespace_rExp= /^[^A-Za-z0-9]+/gi; //use for complex whitespace
		left_trimmedStr=fullStr.replace(initial_whitespace_rExp, " ");
		non_alphanumerics_rExp=/[^A-Za-z0-9]+/gi;   // and for delimiters
		cleanedStr=left_trimmedStr.replace(non_alphanumerics_rExp, " ");
		splitString=cleanedStr.split(" ");
		word_count=splitString.length -1;

		reqdWords=new Array("the","of","to","and","a","in","is","it","you","that","he","was","for","on","are","with","as","I","his","they","be","at","one","have","this","from","or","had","by","hot","but","some","what","there","we","can","out","other","were","all","your","when","up","use","word","how","said","an","each","she","which","do","their","time","if","will","way","about","many","then","them","would","write","like","so","these","her","long","make","thing","see","him","two","has","look","more","day","could","go","come","did","my","sound","no","most","number","who","over","know","water","than","call","first","people","may","down","side","been","now","find","any","new","work","part","take","get","place","made","live","where","after","back","little","only","round","man","year","came","show","every","good","me","give","our","under","open","seem","together","next","white","children","begin","got","walk","example","ease","paper","often","always","music","those","both","mark","book","letter","until","mile","river","car","feet","care","second","group","carry","took","rain","eat","room","friend","began","idea","fish","mountain","north","once","base","hear","horse","cut","sure","watch","color","face","wood","main","enough","plain","girl","usual","young","ready","above","ever","red","list","though","feel","talk","bird","soon","body","dog","family","direct","pose","leave","song","measure","state","product","black","short","numeral","class","wind","question","happen","complete","ship","area","half","rock","order","fire","south","problem","piece","told","knew","pass","farm","top","whole","king","size","heard","best","hour","better","true","during","hundred","am","remember","step","early","hold","west","ground","interest","reach","fast","five","sing","listen","six","table","travel","less","morning","name","very","through","just","form","much","great","think","say","help","low","line","before","turn","cause","same","mean","differ","move","right","boy","old","too","does","tell","sentence","set","three","want","air","well","also","play","small","end","put","home","read","hand","port","large","spell","add","even","land","here","must","big","high","such","follow","act","why","ask","men","change","went","light","kind","off","need","house","picture","try","us","again","animal","point","mother","world","near","build","self","earth","father","head","stand","own","page","should","country","found","answer","school","grow","study","still","learn","plant","cover","food","sun","four","thought","let","keep","eye","never","last","door","between","city","tree","cross","since","hard","start","might","story","saw","far","sea","draw","left","late","run","while","press","close","night","real","life","few","stop","ten","simple","several","vowel","toward","war","lay","against","pattern","slow","center","love","person","money","serve","appear","road","map","science","rule","govern","pull","cold","notice","voice","fall","power","town","fine","certain","fly","unit","lead","cry","dark","machine","note","wait","plan","figure","star","box","noun","field","rest","correct","able","pound","done","beauty","drive","stood","contain","front","teach","week","final","gave","green","oh","quick","develop","sleep","warm","free","minute","strong","special","mind","behind","clear","tail","produce","fact","street","inch","lot","nothing","course","stay","wheel","full","force","blue","object","decide","surface","deep","moon","island","foot","yet","busy","test","record","boat","common","gold","possible","plane","age","dry","wonder","laugh","thousand","ago","ran","check","game","shape","yes","hot","miss","brought","heat","snow","bed","bring","sit","perhaps","fill","east","weight","language","among");

		for(n in splitString){
			for(x in reqdWords){
				if(reqdWords[x]==splitString[n]){
				foundMatches+=reqdWords[x]+" ";
				}
			}
		}
		foundMatches=foundMatches.split(" ");
		foundMatches.length=foundMatches.length-1;
		semratio=foundMatches.length/word_count;
return semratio;
}

function validBushidoReg(){


fields_array=new Array("compet_lname", "compet_fname", "compet_straddr", "compet_city", "compet_state", "compet_zip", "compet_phone", "compet_email", "compet_age", "compet_rank");
fields_display=new Array("Last Name","First Name","Address","City","State","Zip Code","Phone","Email Address","Your Age","Belt Rank");

var prohibStr="";
var prohibChars=new Array('\<a','href','\</a\>','[url','[/url]','[link','[/link','https','http','ftp','smtp','pop3','nntp','imap','irc','\#','\%','\^','\{','\}','com\?','\<','\>');

//loop thru submitted values, if any blank then return false
	for(n in fields_array){
		fieldvalue=fields_array[n];
		if(document.getElementById(fieldvalue).value.length<1){
			alert(fields_display[n] + " is blank. All fields are required.\r\nPlease fill-in the missing information.");
		return false;
		}
	
		for(p in prohibChars){
		
			if(document.getElementById(fieldvalue).value.lastIndexOf(prohibChars[p])!=-1){
			prohibStr+='\r\n'+prohibChars[p]+'\r\n';

			}
		}

		if(prohibStr.length>0){	
		alert('Your entry contains restricted or disallowed character(s): '+prohibStr+'\r\n\r\nPlease review your form entries and remove them to continue.');
		return false;
		}	
	}
	if(document.getElementById('compet_email').value.lastIndexOf('@')==-1){
	alert('Your email address does not appear to be correctly formed.\r\nPlease review it and make the needed corrections.');
	return false;
	}


setRegisID();
return true;	
}

function setRegisID(){
part1 = document.getElementById('compet_lname').value.substring(0,4);
part2 = document.getElementById('compet_fname').value.substring(0,2);
part3 = document.getElementById('compet_age').value.substring(0);
part4 = document.getElementById('compet_zip').value.substring(0,5);
competid = part1+part2+part3+part4;
document.getElementById('regisid').value = competid;
}

