// JavaScript Document

//Tab Click Control
function tabClick(selfRef) {
	id=selfRef.id;
	new_id=id+"_content";
	document.getElementById("tab_content_display").innerHTML=document.getElementById(new_id).innerHTML;
	return false;
}

//Check email format
function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   return false;
		}
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false;
		}
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
			return false;
		}
		if (str.indexOf(at,(lat+1))!=-1){
		return false;
		}
		if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
			return false;
		}
		
		if (str.indexOf(dot,(lat+2))==-1){
			return false;
		}
		if (str.indexOf(" ")!=-1){
			return false;
		}
	}
	
//validate Form
	function validateForm(contactForm){
			var theMessage = "Please fill all fields before submission:\n";
			var noErrors = theMessage;
			
		if(""==document.forms.contactForm.firstName.value){
			theMessage = theMessage + "First Name\n";
		}
		if(""==document.forms.contactForm.lastName.value){
			theMessage = theMessage + "Last Name\n";
		}
		if(""==document.forms.contactForm.phone.value){
			theMessage = theMessage + "Phone Number\n";
		}
		if(""==document.forms.contactForm.email.value){
			theMessage = theMessage + "Email Address\n";
		} else {
			if (echeck(document.forms.contactForm.email.value)==false){
					document.forms.contactForm.email.value="";
					theMessage = theMessage + "Valid Email Address";
				}
		}
		if (theMessage == noErrors) {
			
			return true;
				
				} else {
				
				var required = document.getElementById('required');
				//required.innerHTML = theMessage;
				alert(theMessage);
				return false;
				}
	}
//Remove Google Styles
  
  if(window.attachEvent)
    window.attachEvent("onload",setListeners);

  function setListeners(){
    inputList = document.getElementsByTagName("INPUT");
    for(i=0;i<inputList.length;i++){
      inputList[i].attachEvent("onpropertychange",restoreStyles);
      inputList[i].style.backgroundColor = "";
    }
    selectList = document.getElementsByTagName("SELECT");
    for(i=0;i<selectList.length;i++){
      selectList[i].attachEvent("onpropertychange",restoreStyles);
      selectList[i].style.backgroundColor = "";
    }
  }

  function restoreStyles(){
    if(event.srcElement.style.backgroundColor != "")
      event.srcElement.style.backgroundColor = "";
  }
  
// Date and Time Functions

function getCalendarDate()
{
   var months = new Array(13);
   months[0]  = "January";
   months[1]  = "February";
   months[2]  = "March";
   months[3]  = "April";
   months[4]  = "May";
   months[5]  = "June";
   months[6]  = "July";
   months[7]  = "August";
   months[8]  = "September";
   months[9]  = "October";
   months[10] = "November";
   months[11] = "December";
   var now         = new Date();
   var monthnumber = now.getMonth();
   var monthname   = months[monthnumber];
   var monthday    = now.getDate();
   var year        = now.getYear();
   if(year < 2000) { year = year + 1900; }
   var dateString = monthname +
                    ' ' +
                    monthday +
                    ', ' +
                    year;
   return dateString;
} // function getCalendarDate()

function getClockTime()
{
   var now    = new Date();
   var hour   = now.getHours();
   var minute = now.getMinutes();
   var second = now.getSeconds();
   var ap = "AM";
   if (hour   > 11) { ap = "PM";             }
   if (hour   > 12) { hour = hour - 12;      }
   if (hour   == 0) { hour = 12;             }
   if (hour   < 10) { hour   = "0" + hour;   }
   if (minute < 10) { minute = "0" + minute; }
   if (second < 10) { second = "0" + second; }
   var timeString = hour +
                    ':' +
                    minute +
                    ':' +
                    second +
                    " " +
                    ap;
   return timeString;
} // function getClockTime()

var calendarDate = getCalendarDate();
var clockTime = getClockTime();

  