  function WinOpen(URL, newin, winparameters){
     var newwin=open(URL,newin,winparameters);
  }

function redir(href) {
   location.href=href;
}

function redir_confirm(href) {
var msg ="COPYRIGHT AGREEMENT\n";
    msg+="I agree not to publish or use this material\n";
    msg+="  without the express permission of St Heliers School";

   if (confirm(msg)){
   location.href=href;
   } 
}

  function checkDelete(n, ref){
	if(n > 0) {
		 alert("Sorry, you can't delete that item when others are linked to it. \n Try unlinking instead.");
        	 return(false);
	} else {
                 var msg = "Do you wish to delete this item";
                 if (confirm(msg)) {
          	  location.href=ref;
	       } 
       }
  }

  function Check() {
     if (document.forms.stringsearch) {
           if  (document.forms.stringsearch.sword.value=="" && document.forms.searchform.sword.value == ""){ 
               alert ("You need to provide a primary search string.");
               return (false);
           }   
             return (true);

     } else if (document.forms.searchform.sword.value == ""){ 
                alert ("You need to provide a primary search string.");
                return (false);
     }   
            return (true);  
 }

function nameSet(winname) {
    window.name=winname;
}

function confirmDelete(ref){
var msg = "CONFIRM DELETE ?";
   if (confirm(msg))
      location.href=ref;
}

function confirmDrop(ref){
   var msg = "CONFIRM REMOVAL ?";
     if (confirm(msg))
        location.href=ref;
   }

function checkForm(f) {
  var msg;
  var empty_fields = "";
  var errors = "";
  var errornumber = 0 ;
for (var i=0; i < f.length; i++)
 {
    var e = f.elements[i];

       if ((e.type == "text") || (e.type == "textarea") ) {
            //first check if the field is empty
          if ((e.value == null) || (e.value == "")) {
              empty_fields += "\n             " + e.name;
              errornumber++;
              continue;
          }
       } 

       if ((e.type == "select-one")) {
          if (e.value == "") {
              empty_fields += "\n             " + e.name;
              errornumber++;
              continue;
          }
       }  
  }
    msg  = "____________________________________________________\n\n";
    msg += "The form was not submitted because of the following error(s). \n";
    msg += "Please correct the " + errornumber + " error(s) and re-submit.\n";
    msg += "____________________________________________________\n\n";

    if (errornumber > 0){
       msg += "- The following required fields are empty:"
            + empty_fields + "\n";
       alert (msg);
       return (false);
    } else {
      return (true);
    }
}



function reloadPage(init) { 
	if (init==true) with (navigator) {
		if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    		document.pgW=innerWidth; document.pgH=innerHeight; onresize=reloadPage;
	 	}
	}	else if (innerWidth!=document.pgW || innerHeight!=document.pgH)
		location.reload();
}



// Function to 'activate' images.
function imgOver(imgName) {
	if (document.images) {
	    document[imgName].src = eval(imgName + "over.src");
	}
}
// Function to 'deactivate' images.
function imgOff(imgName) {
	if (document.images) {
	    document[imgName].src = eval(imgName + "off.src");
	}
}

