function callMail(n,domain,displayText) {
var txt;
if(displayText=="") {
txt = n+"&#64;"+domain;
} else {
txt = displayText;
}
var str = "<a href=\"mailto:"+n+"&#64;"+domain+"\">"+txt+"</a>"; 
document.write(str); 
} 

function checkContactForm(f) {
var err = "";
var pattern=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;

if(f.names.value=="") {
err = "* Please enter your name\n"
}

if(f.mail.value=="") {
err = err + "* Please enter your e mail address\n";
} else {
if (pattern.test(f.mail.value)){
} else {         
err = err + "* The e mail address you supplied appears to be invalid\n" 
} 
}

if (f.detail.value=="") {
err = err + "* Please enter a message"
}

if(err!="") {
alert("Sorry, there were some errors in your submission, please correct and try again. The actual errors were;\n\n"+err);
return false;
}
}

function gotoURL(ur) {
self.location.href=ur;
}

function deleteItem(ur) {
if(confirm("Confirm you want to delete this item?")) {
gotoURL(ur);
} else {
return false;
}
}

function deleteUserPage(ur) {
if(confirm("Are you sure you want to delete this item. As this is a main menu item, you will also be deleting any child pages attached to this menu with the associated loss of data?")) {
gotoURL(ur);
} else {
return false;
}
}

function SetTotal(ele, tot, descr) {
var obj = document.getElementById(ele);
var hid = document.forms['pp'].amount;
var des = document.forms['pp'].item_name;
if(obj) {
obj.innerHTML = tot;
hid.value = tot;
des.value = descr;
}
}

function SendToPaypal() {
if(document.forms['pp'].amount.value>0) {
document.forms['pp'].submit();
} else {
alert("You must select a payment option before attempting to pay");
}
}


function updateItem(n,d,baseloc,u) {
var cn = document.getElementById(n).value;
var cd = document.getElementById(d).value;
var p = baseloc+"&cname="+cn+"&cdesc="+cd+"&u="+u;
gotoURL(p);
}

function addPhotoCat(n,d,baseloc) {
var cn = document.getElementById(n).value;
var cd = document.getElementById(d).value;
var p = baseloc+"&cname="+cn+"&cdesc="+cd+"&a=new";
gotoURL(p);
}

function addCourseType(o,n,c,baseloc) {
var co = document.getElementById(o).value;
var cn = document.getElementById(n).value;
var cc = document.getElementById(c).value;
var p = baseloc+"&corder="+co+"&cname="+cn+"&ccol="+cc+"&add=new";
gotoURL(p);
}

function addCourse(n,t,o,baseloc) {
var cn = document.getElementById(n).value;
var ct = document.getElementById(t).value;
var co = document.getElementById(o).value;
var p = baseloc+"&cname="+cn+"&ctype="+ct+"&corder="+co+"&add=new";
gotoURL(p);
}

function addClubPage(n,baseloc) {
var cn = document.getElementById(n).value;
var p = baseloc+"&title="+cn+"&a=new";
gotoURL(p);
}

function addUserPage(menutitle, pagetitle, parent, table,baseloc) {
var ct = document.getElementById(menutitle).value;
var cp = document.getElementById(pagetitle).value;
var par = document.getElementById(parent).value;
var p = baseloc+"&menutitle="+ct+"&pagetitle="+cp+"&parent="+par+"&t="+table+"&a=new";
gotoURL(p);
}

function addSaleCat(n,baseloc) {
var cn = document.getElementById(n).value;
var p = baseloc+"&cname="+cn+"&a=new";
gotoURL(p);
}

function updateSaleItem(n,baseloc,u) {
var cn = document.getElementById(n).value;
var p = baseloc+"&cname="+cn+"&u="+u;
gotoURL(p);
}

function vp(pid, w,h,type) {
var windowName="photo";
var url=""
if(type==0) { 
url = "viewimage.php?pid="+pid+"&t=0";
} else { 
url = "viewitem.php?pid="+pid+"&t=1";
}
y = (screen.availHeight - h)/2;
x = (screen.availWidth - w)/2;
y = 50;
win = window.open(url,windowName,"location=no,status=no,scrollbars=no,width="+w+",height="+h+",screenX="+x+",screenY="+y+",top="+y+",left="+x);
}

function vi(pid, w,h) {
var windowName="item";
var url=""
url = "viewitem.php?pid="+pid
y = (screen.availHeight - h)/2;
x = (screen.availWidth - w)/2;
y = 50;
win = window.open(url,windowName,"location=no,status=no,scrollbars=no,width="+w+",height="+h+",screenX="+x+",screenY="+y+",top="+y+",left="+x);
}

function changeOpac(obj, opac){
if (navigator.appName.indexOf("Netscape")!=-1&&parseInt(navigator.appVersion)>=5) {
obj.style.MozOpacity=opac/100;
} else if (navigator.appName.indexOf("Microsoft")!=-1&&parseInt(navigator.appVersion)>=4) {
obj.filters.alpha.opacity=opac;
}
}