window.defaultStatus="Caribbean Disaster Information Network [CARDIN]";

function statDisplay(message)
{
	window.status=message;
	return true;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


// Function    : Date()
//
// Description : Returns current Date.
//
// Author      : Okeno Palmer [Email: p.keno@excite.com]
//
// Version     : 1.0 using Javascript 1.2
/////////////////////////////////////////////////////////////////
function dateFormat()
{
	var date = new Date();
	var val = date.toString();
  	var ddmm = val.slice(0, 10);
  	var yy = val.slice((val.length - 5), val.length);
  	var str = ddmm + ", " + yy;

	return str.bold();
}

// Function    : openWin()
//
// Description : Opens a new browser window with features specified 
//
// Author      : Okeno Palmer [Email: p.keno@excite.com]
//
// Version     : 1.0 using Javascript 1.2
/////////////////////////////////////////////////////////////////
function openWin(url, winname, features)
{
	var newWin = window.open(url, winname, features);
	newWin.focus();
}



////////////////////////////////////////////////////////////////
// FORM VERIFICATION 
////////////////////////////////////////////////////////////////
// Check to see if a string contains whitespace characters
function isBlank(string)
{
   for(var i = 0; i < string.length; i++)
   {
      var ch = string.charAt(i);

      if((ch != ' ') && (ch != '\n') && (ch != '\t'))
         return false;
   }
   return true;
}


// Perform form verification
function verify(frm)
{
   var msg;
   var empty_fields = ""; 

   // Traverse form and check for empty fields
   for(var i = 0; i < frm.length; i++)
   {
      // Check if required field in form is empty
      if(!frm.elements[i].optional)
      {
         if((frm.elements[i].value == null) || (frm.elements[i].value == "") || isBlank(frm.elements[i].value))
            empty_fields += "\n " + frm.elements[i].name;
      }
	  
	  // Check if Character Limit is set
	  if(frm.elements[i].limit) {	 
	  	if(frm.elements[i].value.length > frm.elements[i].limit)
			empty_fields +="\n" + "There are " + frm.elements[i].value.length + " characters in the" + frm.elements[i].name +  " Field. Limit is " + frm.elements[i].limit;
		}
   }

   // If there are any empty required fields, display message and return false
   // to prevent form from being submitted.
   if(!empty_fields)
      return true;

   msg  = "_______________________________________________\n";
   msg += "\nForm was not submitted due to following errors:\n";
   msg += "Correct error(s) and re-submit form:\n";
   msg += "_______________________________________________\n";

   msg += "The following required fields are empty:\n";
   msg += empty_fields + "\n";
   
   if(empty_fields)
   {
      alert(msg);
      return false;
   }
}

/////////////////////////////////////
// End of FORM VERIFICATION
/////////////////////////////////////



