// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

function replyToPostOnPage(post,topic,name) {
	if (postbox = document.getElementById('post_html_content')) {
		newpost = document.getElementById('post_html_content').value;
		newpost = 'In reply to "'+name+'":/topics/show/'+topic+'?post='+post+' : \r\r' +newpost
		postbox.value = newpost; 
		postbox.focus();
	}
	else {
		document.location = '/topics/show/'+topic+'?page=last&reply_to='+post+'#post_new'
	}
}

function appendToPost(append) {
	if (postbox = document.getElementById('post_html_content')) {
		newpost = document.getElementById('post_html_content').value;
		newpost = newpost+append;
		postbox.value = newpost; 
		postbox.focus();
	}
}

//------------------------------------------------------------------------------------------------------------------
function addClassNames() {
	// puts class names on all input form elements (for IE6 which can't handle input[type=text] etc.)
	var inputs = document.getElementsByTagName('input');
	for (i=0;i<inputs.length;i++) {
		if (inputs[i].type.toLowerCase() != 'hidden') {
			e = inputs[i]
			//code to change and replace strings
			var ec = ' ' + e.className.replace(/^\s*|\s*$/g,'') + ' ';
			var nc = ec;
			t = e.type.toLowerCase()
			//check if not already there
			if (ec.indexOf(' '+t+' ') == -1) {
				//not found, add it
				nc = ec + t;
			}
			//return the changed text!
			e.className = nc.replace(/^\s*|\s*$/g,''); //trimmed whitespace
		}
	}
}