function getemails() {
popup_page = window.open("emails.php", "popup" , "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,copyhistory=0,width=371,height=310");
}
function popupWin(firstname,surname) {
popupWin = window.open("Some Required Fields Were not Filled in", "Enlarge" , "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,copyhistory=0,width=256,height=170");
popupWin.document.open();
popupWin.document.write("<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\"><title>Some Required Fields Were not Filled in</title><link href=\"css/calibre.css\" rel=\"stylesheet\" type=\"text/css\">");
popupWin.document.write("</head><body><table width=\"256\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td width=\"256\" class=\"bodyquotelarge\"><p>The Following Fields are required: <br><br><span class=\"bodygreyhighred\">");
popupWin.document.write(firstname);
popupWin.document.write("<br>");
popupWin.document.write(surname);
popupWin.document.write("<p><a href=\"javascript:window.close()\" class=\"bodyquote\">close</a></p></td></tr></table></body></html>");
popupWin.document.close();
return correct;
}

function register_check() 
{
var correct = true
var a = '';
var b = '';
var c = '';
var d = '';
var e = '';
var f = '';
var email = '';
var checks = '';
var fieldsList = "\n";
if (document.Register.Password.value.length < 6) {a = 'Password needs to be more than 6 chars';correct = false;}
if (document.Register.Password.value != document.Register.retype.value) {b = 'Passwords don\'t Match';correct = false;}
if (document.Register.First_name.value.length == 0) {c = 'First Name';correct = false;}
if (document.Register.Last_name.value.length == 0) {d = 'Last Name';correct = false;}
if (document.Register.Company.value.length == 0) {e = 'Company';correct = false;}
if (document.Register.Country.options[document.Register.Country.selectedIndex].value == "ps") {f = 'Country';correct = false;}

email = checkEmail(document.Register.Email.value, email);

if (a != ''){fieldsList = fieldsList + a + "\n";} 
if (b != ''){fieldsList = fieldsList + b + "\n";} 
if (c != ''){fieldsList = fieldsList + c + "\n";} 
if (d != ''){fieldsList = fieldsList + d + "\n";} 
if (e != ''){fieldsList = fieldsList + e + "\n";}
if (f != ''){fieldsList = fieldsList + f + "\n";}
if (email != ''){fieldsList = fieldsList + email + "\n";}

if (correct != true){alert("The Following Fields are Required:\n " + fieldsList + "\nPlease Fill in and Re-Submit");}
return correct;
}


function news_check() 
{
var correct = true
var title = '';
var des = '';
var year = '';
var fieldsList = "\n";
if (document.Add_News.title.value.length == 0) {title = 'Title';correct = false;}
if (document.Add_News.des.value.length < 25) {des = 'Description (25-800 chars)';correct = false;}
if (document.Add_News.Year.value.length == 0) {year = 'Year';correct = false;}
if (title != ''){fieldsList = fieldsList + title + "\n";} 
if (des != ''){fieldsList = fieldsList + des + "\n";} 
if (year != ''){fieldsList = fieldsList + year + "\n";} 

if (correct != true){
alert("The Following Fields are Required:\n " + fieldsList + "\n \n Please Fill in and Re-Submit");
}
return correct;
}

function product_check() 
{
var correct = true
var a = '';
var b = '';
var c = '';
var d = '';
var e = '';
var checks = '';
var fieldsList = "\n";
if (document.Add_Product.a.value.length == 0) {a = 'Product Name';correct = false;}
if ((document.Add_Product.b.options[document.Add_Product.b.selectedIndex].value == 0)&&(document.Add_Product.otherb.value.length == 0)) {b = 'Section';correct = false;}
if ((document.Add_Product.c.options[document.Add_Product.c.selectedIndex].value == 0)&&(document.Add_Product.otherc.value.length == 0)) {c = 'Type';correct = false;}
if (document.Add_Product.d.value.length == 0) {d = 'Link';correct = false;}
if (document.Add_Product.e.value.length == 0) {e = 'Keywords';correct = false;}


if (a != ''){fieldsList = fieldsList + a + "\n";} 
if (b != ''){fieldsList = fieldsList + b + "\n";} 
if (c != ''){fieldsList = fieldsList + c + "\n";} 
if (d != ''){fieldsList = fieldsList + d + "\n";} 
if (e != ''){fieldsList = fieldsList + e + "\n";}

if (correct != true){alert("The Following Fields are Required:\n " + fieldsList + "\nPlease Fill in and Re-Submit");}
return correct;
}

function formChecker() 
{
var correct = true
var firstname = '';
var surname = '';
var country = '';
var email = '';
var EmailCorrect = false;
var fieldsList = "\n";
if (document.contactForm.FirstName.value.length == 0) {firstname = 'Firstname';correct = false;}
if (document.contactForm.Surname.value.length == 0) {surname = 'Surname';correct = false;}
if (document.contactForm.Country.options[document.contactForm.Country.selectedIndex].value == 'ps') {country = 'Country';correct = false;}


var EmailCorrect = false
for (var i = 0; i <= document.contactForm.Email.value.length; i++)
{
 if (document.contactForm.Email.value.charAt(i) == "@") {
 EmailCorrect = true;
 var marker = i;
 }

}
for (var j = marker; j <= document.contactForm.Email.value.length; j++)
{
 if (document.contactForm.Email.value.charAt(j) != ".") {
 EmailCorrect = false
 } else {
 EmailCorrect = true
 j = document.contactForm.Email.value.length;
 }
 }
 
var EMLength = document.contactForm.Email.value.length
if (EmailCorrect == false){email = 'Valid Email Address'; correct= false}


if (firstname != ''){
fieldsList = fieldsList + firstname + "\n";
} if (surname != ''){
fieldsList = fieldsList + surname + "\n";
} if (email != ''){
fieldsList = fieldsList + email + "\n";
} if (country != ''){
fieldsList = fieldsList + country + "\n";
} 

if (correct != true){
alert("The Following Fields are Required:\n " + fieldsList + "\n \n Please Fill in and Re-Submit");
}
return correct;
}
function areyousure(){
correct = true
if (confirm("Are you sure that you want to remove this?") == true) {return correct;} else {correct = false;}
return correct;
}

function areyousurechange(){
correct = true
if (confirm("Are you sure that you want to change this?") == true) {return correct;} else {correct = false;}
return correct;
}

function file_upload(){
var correct = true
var a = '';
var b = '';
var fieldsList = "\n";
if (document.form1.des.value.length < 20) {a = 'Description (20 - 115)';correct = false;}
if ((document.form1.theFile.value.length == 0) && (document.form1.thelink.value.length == 0)) {b = 'File to be uploaded';correct = false;}
if (a != ''){fieldsList = fieldsList + a + "\n";} 
if (b != ''){fieldsList = fieldsList + b + "\n";} 

if (correct != true){alert("The Following Fields are Required:\n " + fieldsList + "\nPlease Fill in and Re-Submit");}
if (correct == true){
if (confirm("The file will now be uploaded to the server, are you sure all information is correct") == true) {return correct;} else {correct = false;}
}
return correct;
}

function checkEmail(form, email)
{
var EmailCorrect = false
for (var i = 0; i <= form.length; i++)
{
 if (form.charAt(i) == "@") {
 EmailCorrect = true;
 var marker = i;
 }

}
for (var j = marker; j <= form.length; j++)
{
 if (form.charAt(j) != ".") {
 EmailCorrect = false
 } else {
 EmailCorrect = true
 j = form.length;
 }
 }
 
var EMLength = form.length
if (EmailCorrect == false){email = 'Valid Email Address'; correct= false}
return email;}