//CLEAR FIELDfunction clearIt(field) {
if (field.value == "Email Address" || field.value == "Password" || field.value == "Zip Code" || field.value == "xxx-xxx-xxxx" || field.value == "http://") {field.value="";
}}

//AJAX
function Inint_AJAX() {try { return new ActiveXObject("Msxml2.XMLHTTP");  } catch(e) {} //IEtry { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {} //IEtry { return new XMLHttpRequest();          } catch(e) {} //Native Javascriptalert("Your browser does not support HTTP Request");return null;};


function Comment_Validate(form) {var req = Inint_AJAX();
var thecomment = form.comment.value;
req.onreadystatechange = function () { if (req.readyState==4) {      if (req.status==200) {
	var response = req.responseText;
	if (response == 'No Errors') {
	Comment_Process(form);
	} else {
	document.getElementById('errormsg').innerHTML=response; //return value;
	}      } }};
var fields = "comment="+thecomment;req.open("POST", "process_commentvalidate.php", true);req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");req.send(fields);};


function Comment_Process(form) {var req = Inint_AJAX();
var thecomment = form.comment.value;
var theuserid = form.userid.value;
var thetopicid = form.topicid.value;
var thecommentid = form.commentid.value;
req.onreadystatechange = function () { if (req.readyState==4) {      if (req.status==200) {
	var response = req.responseText;
	document.getElementById('thecomment').innerHTML=response; //return value;      } }};

var fields = "comment="+thecomment+"&userid="+theuserid+"&topicid="+thetopicid+"&commentid="+thecommentid;req.open("POST", "process_comment.php", true);req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");req.send(fields);};

//TEXT EDITING
function addCode(form, Action) {var AddTxt="";var txt="";
if(Action==1)  {  txt=prompt("Text to be bolded","Text");     if(txt!=null) {    AddTxt="<b>"+txt+"</b>";        }
}

if(Action==2)  {  txt=prompt("Text to be italicized","Text");     if(txt!=null) {    AddTxt="<i>"+txt+"</i>";        }
}

if(Action==3)  {  txt=prompt("URL for the link.","http://");     if(txt!=null) {    AddTxt='<a href="'+txt+'" target="_blank">';            txt=prompt("Text to be shown for the link","Text");              AddTxt+=txt+"</a>"; }
}
form.value+=AddTxt;}


$(document).ready(function() {
	// MENU ROLLOVER //
		// Preload all rollovers
		$("#menu img").each(function() {
			// Set the original src
			rollsrc = $(this).attr("src");
			if (!rollsrc.match(/_space/)) {
			rollON = rollsrc.replace(/.jpg$/ig,"_on.jpg");
			$("<img>").attr("src", rollON);
		}
		});
		
		// Navigation rollovers
		$("#menu a").mouseover(function(){
			imgsrc = $(this).children("img").attr("src");
			matches = imgsrc.match(/_on/);
			
			// don't do the rollover if state is already ON
			if (!matches) {
			imgsrcON = imgsrc.replace(/.jpg$/ig,"_on.jpg"); // strip off extension
			$(this).children("img").attr("src", imgsrcON);
			}
			
		});
		$("#menu a").mouseout(function(){
			$(this).children("img").attr("src", imgsrc);
		});

	// SUB MENU //
	$('#menu li').hover(function () {  
       		//show its submenu  
            	$('ul', this).slideDown(200).show(function(){
		});
		return false;
  	
        	},   
        	function () {  
            	//hide its submenu  
		$('ul', this).hide();  
            	// problem in ie7 $('ul', this).slideUp(200);  
        	}  
   		);   
		
	
	});

