imgout 		= new Image(9,9);
imgin 		= new Image(9,9);
imgout.src	= "/images/buttons/newtopic-plus.gif";
imgin.src	= "/images/buttons/newtopic-minus.gif";

function filter(imagename,objectsrc){
	if (document.images){
		document.images[imagename].src=eval(objectsrc+".src");
	}
}

function shoh(id) {
	if (document.getElementById(id).style.display == "none"){
		filter(("newtopic"),'imgin');	
	} else {	
		filter(("newtopic"),'imgout');	
	}
}


//FORUM ROLLOVER
function forumrollover(){
	var x=document.getElementsByTagName("div");
	for (var i=0;i<x.length;i++)
  	{
	if (x[i].id.indexOf("forumrow")>-1){
		var element = document.getElementById(x[i].id);
		element.onmouseover = rollover;
		element.onmouseout  = rollout;
		element.onclick = clickme;
	}
  	}
}

//FORUM ROLLOVER
function clickme(){
	var messageid = this.id.replace('forumrow','');
	var linkid = 'link' + messageid
	var thelink = document.getElementById(linkid).href;
	window.location.href = thelink;
}

//FORUM ROLLOVER
function rollover(){
	this.style.backgroundColor='#eeeeee';
	this.style.cursor = 'pointer';
}

//FORUM ROLLOVER
function rollout(){
	this.style.backgroundColor='white';
}

//FORUM 
function post(formname,color1,color2) {
	var keepgoing = true;
	if (isFilled(document.postmessage.topic) == false){ 	
		document.getElementById('topicform').style.background = color1;
		document.postmessage.topic.focus();
		keepgoing = false; 
		} 
	else {document.getElementById('topicform').style.background = color2;
	 }
	if (isFilled(document.postmessage.message) == false){ 	
		document.getElementById('messageform').style.background = color1; 
		if (keepgoing == true) { document.postmessage.message.focus();}
		keepgoing = false;
	} 
	else {document.getElementById('messageform').style.background = color2; 
	}
	if (keepgoing == true) {
		document.getElementById("postbutton").innerHTML = "Please wait...";
		document.forms[formname].submit();
		alert('got here');
		//AJAX POST
		//new Ajax.Request('/ajax/postmessage.asp', {
		//method: "post", 
		//contentType: "multipart/form-data",
		//parameters: Form.serialize(document.forms[formname]),
		
		//onSuccess: function(transport) { 	
		//	alert(transport)
			//LOG IN EXISTS?
			//	document.location.reload()
			//} 
			//}//-request arguments
			//);// new ajax request		
	} 
}

//requestHeaders: 'Content-type', 'application/x-www-form-urlencoded',
		//
		
		
//FORUM
function postmessage(formname,color1,color2) {
	if(validateform(formname,color1,color2)){
	    document.getElementById('postmessageindicator').style.display = "block"; 
		document.forms[formname].submit();
	} 
}

function logoff(){
		//AJAX POST
		new Ajax.Request('sc_logout.aspx', {
		method: "get",
		onSuccess: function(transport,formname) { 	
				document.location.reload()
			}
			//-onSuccess
			}//-request arguments
			);// new ajax request		
}



//ROLLOVER
function setupRollover(thisImage) {
	var a = thisImage.src.split("/");
	var a_length = a.length-1;
	aa = a[a_length];
	thisImage.outImage = new Image();
	thisImage.outImage.src = thisImage.src;
	thisImage.onmouseout = rollOut;
	thisImage.overImage = new Image();
	thisImage.overImage.src = "/images/nav/on/" + aa ;
	thisImage.onmouseover = rollOver;	
}

//ROLLOVER
function rolloverInit(){
	for (var i=0; i<document.images.length; i++) {
		if (document.images[i].getAttribute('name') == "rollover") {			
			setupRollover(document.images[i]);
		}
	}
}

//ROLLOVER
function rollOver() {
	this.src = this.overImage.src;
}

//ROLLOVER
function rollOut() {
	this.src = this.outImage.src;
}

window.onload = masterloader;

function masterloader(){
	rolloverInit();
	forumrollover();
}

//VALIDATION
function validEmail(email) {
			var re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
			return re.test(email); 
		}
		
//VALIDATION
function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
		
//VALIDATION
function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}
		
//VALIDATION
function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}
		
//VALIDATION
function isFilled(elm) {
	//alert(elm.type);
	//Last Updated by Sol - 6/14/07
	switch(elm.type){
	case "text":
		if (trim(elm.value) == "" || elm.value == null){
		return false;}
		else {return true;}
		break;
	case "password":
		if (trim(elm.value) == "" || elm.value == null){
		return false;}
		else {return true;}
		break;
	case "textarea":
		if (trim(elm.value) == "" || elm.value == null){
		return false;}
		else {return true;}
		break;
	case "select-one":
		var myindex=elm.selectedIndex;
		if (myindex==0){
		return false;}
		else {return true;}
		break;
	}
}

//VALIDATION
function validateform(formname,color1,color2){
	//last updated on 9/27/07
	//index of is mo betta
	var x = document.forms[formname];
	var allgood = true;
	for (var i=0;i<x.length;i++){
		if (x.elements[i].className.indexOf('required')>-1) {
		 	var thisformname = x.elements[i].name;
			var thisformid = x.elements[i].id;
			if (!isFilled(x.elements[i])) {
				document.getElementById(thisformid).style.background = color1;
				allgood = false;
				} else {
				  document.getElementById(thisformid).style.background = color2; 
				}
			}
		}
		if (allgood) {
			return true;
			} else {
			return false;
			}
	}


function logina(formname,validateid,color1,color2) {
	//VALIDATE REQUIRED
	if(validateform(formname,color1,color2)){
		//AJAX POST
		new Ajax.Request('/ajax/login.asp', {
		method: "post",
		parameters: Form.serialize(document.forms[formname]),
		onSuccess: function(transport,formname) { 	
			//LOG IN EXISTS?
			if (transport.responseText=='true'){
				//document.forms.formname.submit();
				document.getElementById(validateid).innerHTML = 'You are now logged in!';
				document.location.reload();
			} else {
				document.getElementById(validateid).innerHTML = 'Invalid Log In';
				if (document.getElementById(validateid).style.display == "none"){
					Effect.Appear(validateid,'blind');
				} else {
					Effect.Shake(validateid);
					}
				}
			}//-onSuccess
			}//-request arguments
			);// new ajax request		
	} else {
			//FILL IN THE REQUIRED FIELDS
			if (document.getElementById(validateid).style.display == "none"){
				document.getElementById(validateid).innerHTML = 'Please fill in required fields';
					Effect.Appear(validateid,'blind');
					} else {
					Effect.Shake(validateid);
					}
	}
}

function loginb(formname,validateid,color1,color2) {
	//VALIDATE REQUIRED
	if(validateform(formname,color1,color2)){
		//AJAX POST
		new Ajax.Request('sc_login.aspx', {
		method: "post",
		parameters: Form.serialize(document.forms[formname]),
		onSuccess: function(transport,formname) { 	
			//LOG IN EXISTS?
			if (transport.responseText=='true'){
				//document.forms.formname.submit();
				document.getElementById(validateid).innerHTML = '';
				document.location.reload()
			} else {
				document.getElementById(validateid).innerHTML = 'Invalid Log In';
				if (document.getElementById(validateid).style.display == "none"){
					Effect.Appear(validateid,'blind');
				} else {
					Effect.Shake(validateid);
					}
				}
			}//-onSuccess
			}//-request arguments
			);// new ajax request		
	} else {
			//FILL IN THE REQUIRED FIELDS
			if (document.getElementById(validateid).style.display == "none"){
				document.getElementById(validateid).innerHTML = 'Please fill in required fields';
					Effect.Appear(validateid,'blind');
					} else {
					Effect.Shake(validateid);
					}
	}
}

	
function contactus(formname,validateid) {
	//VALIDATE REQUIRED
	if(validateform(formname)){				
	
		//EMAIL IS VALID?
		var email = document.getElementById("email").value;
		if(!validEmail(email)){
			document.getElementById("email").style.background = "red"; 
			document.getElementById(validateid).innerHTML = '<span style="color:red; ">Invalid Email</span><br />';
			if (document.getElementById(validateid).style.display == "none"){
					Effect.Appear(validateid,'blind');
					} else {
					Effect.Shake(validateid);
					}
			} else {
			document.getElementById('validatemessage').style.display = "none";
			document.getElementById('indicator').style.display = "block";
			
			//AJAX POST
			new Ajax.Request('/ajax/contactform.asp', {
			method: "post",
			parameters: Form.serialize(document.forms[formname]),
			onComplete: function(transport) { 
			document.getElementById('submitform').innerHTML = '';
			document.getElementById(validateid).innerHTML = transport.responseText;
			
			Effect.Appear(validateid,'blind');
			
			}//-onSuccess
			}//-request arguments
			);// new ajax request	
			}
	}
}

function validEmail(email) {
	var re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
	return re.test(email); 
}

