function button_as_link(div, change) {
	
	var ele = document.getElementById(div);
	
	if(change == "yes"){
		ele.style.color = "#00F";
	} else{
		ele.style.color = "#009";
	}
	
}

function confirmSubmit(){
	var agree=confirm("Are you sure you wish to continue? \n\n This cannot be undone.");
	if (agree)
		return true ;
	else
		return false ;
}

function wordCounter(textarea, counter, minimum, maximum) {
	var wordCount = document.getElementById(counter);
	var newWordCount = 0;
	
	//Remove line breaks from string
	var temp="";
	for(i=0; i<textarea.value.length; i++){
		temp = temp + textarea.value[i].replace("\n", " ");
	}
	
	//Loop through text and count number of words
	for(i=0; i<temp.length; i++){
		
		//If next character is a word increment word count
		if(temp[i] != " " && (temp[i-1] == " " || i == 0))
			newWordCount++;
		
		//Limit number of words
		if(newWordCount > maximum){
			textarea.value = textarea.value.substring(0, i);
			if(temp[i] == " ")
				textarea.value = textarea.value.substring(0, i-1);
		}
	}
		
	//Update number of words
	if(newWordCount < maximum)
		wordCount.innerHTML = newWordCount;
	else
		wordCount.innerHTML = maximum;
	
	//Update Inner HTML Color for newWordCount
	if(newWordCount < minimum)
		wordCount.style.color="#900";
	else
		wordCount.style.color="#009";
	
}

function KeyCheckTripApps(){
	
	var KeyID = event.keyCode;
	var temp1 = document.trip_app.keyvalues1.value;
	var temp2 = document.trip_app.keyvalues2.value;
	
	if(KeyID == '17')
		document.trip_app.keyvalues1.value = KeyID;
	else if(KeyID == '16')
		document.trip_app.keyvalues2.value = KeyID;
	
	if(temp1 == '17' && KeyID == '74'){
		document.trip_app.desired_page.focus();
	}
	
	if((KeyID == '37' || KeyID == '39' || KeyID == '76' || KeyID == '83') && temp1 == '17'){
		document.trip_app.keyvalues1.value = KeyID;
		document.trip_app.submit();
	}
}

function KeyReleaseTripApps(){
	
	var KeyID = event.keyCode;
	
	if(KeyID == '17')
		document.trip_app.keyvalues1.value = "";
	else if(KeyID == '16')
		document.trip_app.keyvalues2.value = "";
	
}

function KeyCheckBoardApps(){
	
	var KeyID = event.keyCode;
	var temp1 = document.board_app.keyvalues1.value;
	var temp2 = document.board_app.keyvalues2.value;
	
	if(KeyID == '17')
		document.board_app.keyvalues1.value = KeyID;
	else if(KeyID == '16')
		document.board_app.keyvalues2.value = KeyID;
	
	if(temp1 == '17' && KeyID == '74'){
		document.board_app.desired_page.focus();
	}
	
	if((KeyID == '37' || KeyID == '39' || KeyID == '76' || KeyID == '83') && temp1 == '17'){
		document.board_app.keyvalues1.value = KeyID;
		document.board_app.submit();
	}
}

function KeyReleaseBoardApps(){
	
	var KeyID = event.keyCode;
	
	if(KeyID == '17')
		document.board_app.keyvalues1.value = "";
	else if(KeyID == '16')
		document.board_app.keyvalues2.value = "";
	
}

function highlight_checkbox(checkbox_name, form_name, always_submit){
	if(checkbox_name.checked == true || always_submit == 'Yes')
		form_name.submit();
}

function select_checkbox(checkbox_info, checkbox_name, numb_divs){
	var link_section = document.getElementById(checkbox_name+'_title');
	
	//Update color of link and 'check' in checkbox
	if(link_section.style.color == 'rgb(102, 102, 102)'){
		checkbox_info.checked = true;
		link_section.style.color = '#009';
	} else{
		checkbox_info.checked = false;
		link_section.style.color = '#666';
	}
	
	//Loop through divs related to checkbox
	for(i=1; i<=numb_divs; i++){
		var div_name = document.getElementById(checkbox_name+'_'+i);
		if(div_name != null){
			if(link_section.style.color == 'rgb(102, 102, 102)')
				div_name.style.display="none";
			else
				div_name.style.display="block";
		}
	}
}