// JavaScript Document

function poptip () {
	if (document.tune.lookfor[0].checked) { //words
		document.getElementById('fragtip').className="data";
		document.getElementById('wordtip').className="pop1";
		setTimeout("document.getElementById('wordtip').className='pop2'", 100);
		setTimeout("document.getElementById('wordtip').className='pop3'", 200);
		setTimeout("document.getElementById('wordtip').className='pop4'", 300);
		setTimeout("document.getElementById('wordtip').className='pop5'", 400);
		setTimeout("document.getElementById('wordtip').className='pop6'", 500);

	} else { 
		document.getElementById('wordtip').className="data";
		document.getElementById('fragtip').className="pop1";
		setTimeout("document.getElementById('fragtip').className='pop2'", 100);
		setTimeout("document.getElementById('fragtip').className='pop3'", 200);
		setTimeout("document.getElementById('fragtip').className='pop4'", 300);
		setTimeout("document.getElementById('fragtip').className='pop5'", 400);
		setTimeout("document.getElementById('fragtip').className='pop6'", 500);
		}
	}

function check ()
{
	temp = document.tune.term.value;
	temp = temp.replace(/\s+/g, " ");
	document.tune.term.value = temp;
	if (document.tune.lookfor[1].checked) { //fragment
		if (temp.length > 8) {
			document.tune.term.focus();
			return confirm("Alert: " + temp + " may be too long.\nThis greatly increases the chance that spelling variations will hurt your search. Please click OK to search anyway, or CANCEL to try a shorter fragment.");
		}
	} else if (document.tune.lookfor[0].checked) { //words
		if (temp.match(/^#?[0-9]{2,4}$/)) {
			return true;
			}
		stopwords = new Array("able", "about", "above", "according", "accordingly", "across", "actually", "after", "afterwards", "again", "against", "ain't", "allow", "allows", "almost", "alone", "along", "already", "also", "although", "always", "among", "amongst", "another", "anybody", "anyhow", "anyone", "anything", "anyway", "anyways", "anywhere", "apart", "appear", "appreciate", "appropriate", "aren't", "around", "aside", "asking", "associated", "available", "away", "awfully", "became", "because", "become", "becomes", "becoming", "been", "before", "beforehand", "behind", "being", "believe", "below", "beside", "besides", "best", "better", "between", "beyond", "both", "brief", "c'mon", "came", "can't", "cannot", "cant", "cause", "causes", "certain", "certainly", "changes", "clearly", "come", "comes", "concerning", "consequently", "consider", "considering", "contain", "containing", "contains", "corresponding", "could", "couldn't", "course", "currently", "definitely", "described", "despite", "didn't", "different", "does", "doesn't", "doing", "don't", "done", "down", "downwards", "during", "each", "eight", "either", "else", "elsewhere", "enough", "entirely", "especially", "even", "ever", "every", "everybody", "everyone", "everything", "everywhere", "exactly", "example", "except", "fifth", "first", "five", "followed", "following", "follows", "former", "formerly", "forth", "four", "from", "further", "furthermore", "gets", "getting", "given", "gives", "goes", "going", "gone", "gotten", "greetings", "hadn't", "happens", "hardly", "hasn't", "have", "haven't", "having", "he's", "hello", "help", "hence", "here", "here's", "hereafter", "hereby", "herein", "hereupon", "hers", "herself", "himself", "hither", "hopefully", "howbeit", "however", "i'll", "i've", "ignored", "immediate", "inasmuch", "indeed", "indicate", "indicated", "indicates", "inner", "insofar", "instead", "into", "inward", "isn't", "it'd", "it'll", "it's", "itself", "just", "keep", "keeps", "kept", "know", "knows", "known", "last", "lately", "later", "latter", "latterly", "least", "less", "lest", "let's", "like", "liked", "likely", "little", "look", "looking", "looks", "mainly", "many", "maybe", "mean", "meanwhile", "merely", "might", "more", "moreover", "most", "mostly", "much", "must", "myself", "name", "namely", "near", "nearly", "necessary", "need", "needs", "neither", "never", "nevertheless", "new", "next", "nine", "nobody", "none", "noone", "normally", "nothing", "novel", "nowhere", "obviously", "often", "okay", "once", "ones", "only", "onto", "other", "others", "otherwise", "ought", "ours", "ourselves", "outside", "over", "overall", "particular", "particularly", "perhaps", "placed", "please", "plus", "possible", "presumably", "probably", "provides", "quite", "rather", "really", "reasonably", "regarding", "regardless", "regards", "relatively", "respectively", "right", "said", "same", "saying", "says", "second", "secondly", "seeing", "seem", "seemed", "seeming", "seems", "seen", "self", "selves", "sensible", "sent", "serious", "seriously", "seven", "several", "shall", "should", "shouldn't", "since", "some", "somebody", "somehow", "someone", "something", "sometime", "sometimes", "somewhat", "somewhere", "soon", "sorry", "specified", "specify", "specifying", "still", "such", "sure", "take", "taken", "tell", "tends", "than", "thank", "thanks", "thanx", "that", "that's", "thats", "their", "theirs", "them", "themselves", "then", "thence", "there", "there's", "thereafter", "thereby", "therefore", "therein", "theres", "thereupon", "these", "they", "they'd", "they'll", "they're", "they've", "think", "third", "this", "thorough", "thoroughly", "those", "though", "three", "through", "throughout", "thru", "thus", "together", "took", "toward", "towards", "tried", "tries", "truly", "trying", "twice", "under", "unfortunately", "unless", "unlikely", "until", "unto", "upon", "used", "useful", "uses", "using", "usually", "value", "various", "very", "want", "wants", "wasn't", "we'd", "we'll", "we're", "we've", "welcome", "well", "went", "were", "weren't", "what", "what's", "whatever", "when", "whence", "whenever", "where", "where's", "whereafter", "whereas", "whereby", "wherein", "whereupon", "wherever", "whether", "which", "while", "whither", "who's", "whoever", "whole", "whom", "whose", "will", "willing", "wish", "with", "within", "without", "won't", "wonder", "would", "would", "wouldn't", "you'd", "you'll", "you're", "you've", "your", "yours", "yourself", "yourselves", "zero");
		warning="";
		for (i in stopwords) {
			rgx = new RegExp("\\b"+stopwords[i]+"\\b","gi");
			if (rgx.test(temp)) {
				temp=temp.replace(rgx,"");
				if (warning.length>0) {
					warning += ", "+stopwords[i];
				} else {warning = stopwords[i];
					}
				}
			}
		document.tune.term.value = temp;
		rgx = /[^\w\d'][\w\d']{4,}?(?=[^\w\d'])/i;
		// test whether browser supports this regex 
			rxtest = " 1234 ";
			if (rgx.test(rxtest)) {
				document.getElementById('rxfail').value = "false";
				}
		if (temp.length>1) {
			temp = ' '+ temp +' ';
			if (!rgx.test(temp)) {
				if (warning.length>0) {
					alert("Alert: to find tune titles containing these common words:\n-> "+warning+" <-\nthen you need to use the Fragment search.\n\nAlso, all the other words you entered were less than 4 letters long. Consider using Fragment search for a word or phrase.");
				} else {
					alert("Sorry, all the words you entered were less than 4 letters long. Consider using Fragment search for a word or phrase.");
					}
				return false;
				}
			}
		if (warning.length>0) {
			alert("Alert: to find tune titles containing these common words:\n-> "+warning+" <-\nthen you need to use the Fragment search.");
			}
	} else {
		alert ("You didn't select a \"Search How?\" method.\nPlease choose either \"Complete words\" or \"One fragment.\"");
		return false;
		}
	temp = document.tune.term.value;
	temp = temp.replace(/\s+/g, " ");
	document.tune.term.value = temp;
	temp2 = temp.replace(/\s/g, "");
	if (temp2.length == 0) {
		alert("Oops, you asked to search for nothing.");
		document.tune.term.focus();
		return false;
		}
	if ((temp2.length == 1) || (temp2.tolowercase == "the")) {
		alert("Sorry, your search request is too general.");
		document.tune.term.focus();
		return false;
		}
	return true;
}
