// Main javascript functions


// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


// GENERIC POP UP WINDOW FOR IMAGES ------------------------------------------ 

   function popPic (name, w, h) {
          var snugas = window.open ('','','width='+w+',height='+h);
          var d = snugas.document;
          d.write('<html><body leftmargin="0" topmargin="0"><img src="'+name+'">');
          d.write('</body></html>');
          d.close();    
          }

// GENERIC POP UP WINDOW FOR IMAGES END ---------------------------------------

// POP UP WINDOW FOR MARINE TRACK --------------------------------------------- 

   function popMarineTrack (w, h) {
          var snugas = window.open ('','','width='+w+',height='+h);
          var d = snugas.document;
          d.write("<script language='javascript'> \n");
	  d.write("location.replace('http://system.marinetrack.com/scope/view/embed/l2m.asp'); \n")
         // d.write("location.replace('http://www.marinetrack.com/eventviewer/?vessel=04982007'); \n");
          d.write("</script>");
          d.close();    
          }
          
          



// POP UP WINDOW FOR MARINE TRACK END -----------------------------------------


// GENERIC FUNCTION TO CHECK A STRING IS NUMERIC ------------------------------

   // check a string is numeric
   
   function chkNumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789.";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }
   
// GENERIC FUNCTION TO CHECK A STRING IS NUMERIC END --------------------------



/*

###############################################################################

    ################  START OF VALIDATE SENDING EMAIL FORM #################

###############################################################################

*/
     
   
   // check email address supplied by user when sending mail 
   
   function checkEmail(form){
   
   if(form.email.value == ""){
      
      alert("Please enter you email address!");
   
      form.email.focus();
      return false;
      } else {
     
      
       var mailCheck = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
              
       if(!mailCheck.test(form.email.value)){
       
          alert("The email address you entered is invalid!");
       
          form.email.focus();
          return false;
       
        } else {
       
          return true;
         
          }
     
      }
        
  }
  
/*

###############################################################################

    #################  END OF VALIDATE SENDING EMAIL FORM #################

###############################################################################

*/

// GET THE CLIENT DATE AND RETURN IT 

function clientDate(){

  var d = new Date();

  var t_date = d.getDate();      // Returns the day of the month
  var t_mon = d.getMonth();      // Returns the month as a digit
  var t_year = d.getFullYear();  // Returns 4 digit year
  var t_hour = d.getHours();     // Returns hours
  var t_min = d.getMinutes();    // Returns minutes
  // var t_sec = d.getSeconds();    // Returns seocnds
  // var t_mil = d.getMilliseconds;  // Returns Milliseconds

  var fullDate = t_year . t_mon . t_date . t_hour . t_min;

  return fullDate;

}

/*

###############################################################################

    #################  START OF COUNT DOWN TIMER #################

###############################################################################

*/  

today  = new Date();
todayEpoch  = today.getTime();

target = new Date("05 July, 2008"); 
targetEpoch = target.getTime();

daysLeft = Math.floor(((targetEpoch - todayEpoch) / (60*60*24)) / 1000);

/*

###############################################################################

    #################  END OF COUNT DOWN TIMER #################

###############################################################################

*/ 