function emailvalidation(entered, alertbox)
{
with (entered)
{
apos=value.indexOf("@");
dotpos=value.lastIndexOf(".");
lastpos=value.length-1;
if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2)
{if (alertbox) {alert(alertbox);} return false;}
else {return true;}
}
}

function valuevalidation(entered, min, max, alertbox, datatype)
{
with (entered)
{
checkvalue=parseFloat(value);
if (datatype)
{smalldatatype=datatype.toLowerCase();
if (smalldatatype.charAt(0)=="i") {checkvalue=parseInt(value)};
}
if ((parseFloat(min)==min && checkvalue<min) || (parseFloat(max)==max && checkvalue>max) || value!=checkvalue)
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}

function digitvalidation(entered, min, max, alertbox, datatype)
{
with (entered)
{
checkvalue=parseFloat(value);
if (datatype)
{smalldatatype=datatype.toLowerCase();
if (smalldatatype.charAt(0)=="i")
{checkvalue=parseInt(value); if (value.indexOf(".")!=-1) {checkvalue=checkvalue+1}};
}
if ((parseFloat(min)==min && value.length<min) || (parseFloat(max)==max && value.length>max) || value!=checkvalue)
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}

function emptyvalidation(entered, alertbox)
{
with (entered)
{
if (value==null || value=="")
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}


function formvalidation(thisform)
{
with (thisform)
{
if (emptyvalidation(name,"You cannot leave the NAME field blank")==false) {name.focus(); return false;};
if (emptyvalidation(username,"You must enter a DISPLAY NAME")==false) {username.focus(); return false;};
if (emailvalidation(email,"You must enter a valid email address")==false) {email.focus(); return false;};
if (emailvalidation(email2,"You must enter the same email address twice")==false) {email2.focus(); return false;};
if (emptyvalidation(heading,"You cannot leave the TITLE OF PHOTO field blank")==false) {heading.focus(); return false;};
if (emptyvalidation(uploaded,"You have not selected a file to upload")==false) {uploaded.focus(); return false;};
if (emptyvalidation(terms,"You must agree to the TERMS AND CONDITIONS")==false) {terms.focus(); return false;};
}
}


function form2validation(thisform)
{
with (thisform)
{
if (emptyvalidation(heading,"You cannot leave the TITLE OF PHOTO field blank")==false) {heading.focus(); return false;};
if (emptyvalidation(uploaded,"You have not selected a file to upload")==false) {uploaded.focus(); return false;};
if (emptyvalidation(terms,"You must agree to the TERMS AND CONDITIONS")==false) {terms.focus(); return false;};
}
}

function myopen(filename,windowname,properties) {
    mywindow = window.open(filename,windowname,properties);
}