function clearText(thefield){
	if (thefield.defaultValue==thefield.value)
//	thefield.style.color = "black"
	thefield.value = ""
}



function validateOnSubmit() {
	searchfor = document.search.findthis.value
	
	if(searchfor == "" || searchfor == null || !isNaN(searchfor) || searchfor.charAt(0) == ' ' || searchfor == "Search here" ){
		return false;
	}

}

function validateComment() {
					
	var errMsg = ""; 	// variable to hold the error message
	var errs = 0;			// variable to count errors
					
	var emailPattern = /[a-zA-Z0-9._%+-].@[a-zA-Z0-9._%+-]+\.[a-zA-Z]{2,4}$/ ;
	var emptyString = /^\s*$/ ;
		
	document.getElementById("msg").firstChild.nodeValue = " ";
	
			
	if(emptyString.test(document.comment.fromemail.value)){
		errs += 1;
		errMsg += "Please add your emial address<br/>";
	}else{
		if(!emailPattern.test(document.comment.fromemail.value)){
			errs += 1;	// if the email address does not match the regular expression increment the error count
			errMsg += "Please check your email address<br/>";
		}
	}
			
			
	if(emptyString.test(document.comment.name.value)){
		errs += 1;
		errMsg += "Please enter your name<br/>";
	}
	
	if(emptyString.test(document.comment.comment.value)){
		errs += 1;
		errMsg += "Please enter your comment<br/>";
	}
	
				
	if(errs>0){
		var elem = document.getElementById("msg");
		elem.innerHTML = errMsg;
		document.getElementById("errorpanel").style.background = "red";
		
		return false;
	}
}

function validateEmailArticle() {
					
	var errMsg = ""; 	// variable to hold the error message
	var errs = 0;			// variable to count errors
					
	var emailPattern = /[a-zA-Z0-9._%+-].@[a-zA-Z0-9._%+-]+\.[a-zA-Z]{2,4}$/ ;
	var emptyString = /^\s*$/ ;
		
	document.getElementById("msg").firstChild.nodeValue = " ";
	
	if(emptyString.test(document.emailanarticle.toemail.value)){
		errs += 1;
		errMsg += "Please complete the 'To' email<br/>";
	}else{
		if(!emailPattern.test(document.emailanarticle.toemail.value)){
			errs += 1;	// if the email address does not match the regular expression increment the error count				
			errMsg += "Please check the 'To' email address<br/>";
		}
	}
			
	if(emptyString.test(document.emailanarticle.fromemail.value)){
		errs += 1;
		errMsg += "Please add your emial address<br/>";
	}else{
		if(!emailPattern.test(document.emailanarticle.fromemail.value)){
			errs += 1;	// if the email address does not match the regular expression increment the error count
			errMsg += "Please check your email address<br/>";
		}
	}
			
			
	if(emptyString.test(document.emailanarticle.name.value)){
		errs += 1;
		errMsg += "Please enter your name<br/>";
	}
				
	if(errs>0){
		var elem = document.getElementById("msg");
		elem.innerHTML = errMsg;
		document.getElementById("errorpanel").style.background = "red";
		
		return false;
	}
}




function returnObjById( id ) 
{ 
    if (document.getElementById) 
        var returnVar = document.getElementById(id); 
    else if (document.all) 
        var returnVar = document.all[id]; 
    else if (document.layers) 
        var returnVar = document.layers[id]; 

	//alert(returnVar.id);

    return returnVar; 
}


var d=document;
function o(id){
    return d.getElementById?d.getElementById(id):(d.all?d.all[id]:(d.layers?d.layers[id]:null));
}




function holdthis(id){
	eleid = returnObjById(id);
	alert(eleid);
	
	// use setInterval() to maintain focus
	setInterval('holdmenu(eleid)', 500);
	//alert(eleid);
	
	// use setTimeout to call clearInterval() to stop the setInterval() event
	setTimeout('releasemenu(eleid)', 500);
	//alert('timeout called')
	//setTimeout("alert('1 seconds!')",1000);
	

}
function holdmenu(id){
	// focus menu item
	//document.getElementById(eleid).focus();
	eleid.focus();
	//alert('holding '.eleid);
	
}
function releasemenu(id){
	eleid.blur()
	//returnObjById(id).focus()
}

function SignUpValidateOnSubmit() {
	
	var errMsg = ""; 	// variable to hold the error message
	var errs = 0;		// variable to count errors
	
	// email address pattern
	var emailPattern = /[a-z0-9._%+-].@[a-z0-9._%+-]+\.[a-z]{2,4}$/ ;

	var emptyString = /^\s*$/ ;
	
	if(emptyString.test(document.signup.emailaddr.value)){			errs += 1;	
		// if the email address does not match the regular expression increment the error count
		//var elem = document.getElementById("email");
		//elem.firstChild.nodeValue = "Required field";
	}else{
		if(!emailPattern.test(document.signup.emailaddr.value)){
			errs += 1;	// if the email address does not match the regular expression increment the error count
			//errMsg += "Please check the email address \n";	// add specific error message to the error variable
			//var elem = document.getElementById("email");
			//elem.firstChild.nodeValue = "Check email address";
			//document.getElementById("email").style.background = "red";
			//document.getElementById("email").style.color = "white";
		}
	}
		
	if(errs>0){
		//alert(errMsg);
		return false;
	}
};

function tabSwitch_2(active, number, tab_prefix, content_prefix) {  
      
    for (var i=65; i < number+1; i++) {  
      document.getElementById(content_prefix+i).style.display = 'none';  
      document.getElementById(tab_prefix+i).className = '';  
    }  
    document.getElementById(content_prefix+active).style.display = 'block';  
    document.getElementById(tab_prefix+active).className = 'active';      
      
}
