//Coloured mouseovers on left navs
function hlOn(id,nobg) {
	if(nobg != 1) {
		id.className='nav-itemh';
	}
	id.style.cursor='hand';
	id.children.tags("A")[0].style.color='white'; 
        var html = id.innerHTML;
        if(html.match(/href="([^"]+)"/)) {
                var url = RegExp.$1;
                window.status = url;
        }

}

//Coloured mouseovers on left navs
function hlOff(id,nobg){
	if(nobg != 1) {
		id.className='nav-item';
		id.children.tags("A")[0].className='navlnk';
	}
	id.children.tags("A")[0].style.color='';
	window.status = '';
}
function hlshopOn(id,nobg) {
	if(nobg != 1) {
		id.className='shop-itemh';
	}
	id.style.cursor='hand';
	id.children.tags("A")[0].style.color='white'; 
        var html = id.innerHTML;
        if(html.match(/href="([^"]+)"/)) {
                var url = RegExp.$1;
                window.status = url;
        }

}

//Coloured mouseovers on left navs
function hlshopOff(id,nobg){
	if(nobg != 1) {
		id.className='shop-item';
		id.children.tags("A")[0].className='shoplnk';
	}
	id.children.tags("A")[0].style.color='';
	window.status = '';
}

//Coloured mouseovers on navs
function jump(id) {
	var html = id.innerHTML;
	if(html.match(/href="([^"]+)"/)) {
		var url = RegExp.$1;
		window.location.href = url;
	}
}
function popopen(m,n) {
	var win=window.open(m,n,'width=548,height=486,menubar=0,scrollbars=1,leftmargin=0,topmargin=0');
}

function email2friend()	{
	var emailurl=this.location;
	var path = "/_mail2friend.html?path="+emailurl;
	var win = window.open(path,'email2friend','width=280,height=450,menubar=0,scrollbars=0');
	
}
function bookmark()	{
	var url=this.location;
	//var description="Welcome To InterForum";
	var netscape="Netscape User's hit CTRL+D to add a bookmark to this site."
	if (navigator.appName=='Microsoft Internet Explorer')	{
		window.external.AddFavorite(url);
	}
	else if (navigator.appName=='Netscape')	{
		alert(netscape);
	}
}

function linkit(m){
	var shopitem = "/onlineshop/";
	var matchs = /\/([^/]*)(.*)(.)/;
	var results = m.match(matchs);
	if(results[1] == 'onlineshop'){
		if(results[3] == '/'){
			this.location="/onlineshop/index.php?dir=."+results[2]+results[3];
		}
		else{
			this.location="/onlineshop/info.php?page=."+results[2]+results[3];
		}
	}
	else{
		this.location="/"+results[1]+results[2]+results[3];
	}
}
//used for required fields in forms
var required=new Array();
var validate=new Array();
function required_fields(){
	var fm = document.questionaire;
	var err="";
	if(validate.length!=0){
	 	for(var i=0;i<validate.length;i++){
			var name = validate[i];
	 		var test="";
				test = fm[name].value;
			err += validate_email(test);
		}
	}
 	for(var i=0;i<required.length;i++){
		var name = required[i];
 		var test="";
		if(fm[name].length){	//check radio and checkboxes
			for(j=0;j<fm[name].length;j++){
				if(fm[name][j].checked){ if(fm[name][j].value){test="1";};}
				if(fm[name][j].selected){if(fm[name][j].value){test="1";};}
			}
		}
		else{
			test = fm[name].value;
		}
		if(test==''){
  			var newname = name.replace(/^Q(\d*)-/,'');
			err +=newname+'\n';
		}
 	}
	if(err !=""){	var msg = "you have not filled in:\n"+err;		alert(msg);	}
	else{	fm.submit();	}
}

function validate_email(test){
	var err='';
	var email = /(\w+)\@(\S+)\.(\S+)/;
	var emailvalidate = test.match(email);
	if(!emailvalidate)	{
		err+='a valid Email address\n';
	}
	return err;
}