// JavaScript Document

<!-- Begin
function open_win_size(url, name, width, height){
 var newwin
 var top 
 var left 
 top = (screen.height) ? (screen.height-height)/2 : 0;
 left = (screen.width) ? (screen.width-width)/2 : 0;
 newwin = window.open(url,name,"width="+width+",height="+height+",top="+top+",left="+left+", status=yes, scrollbars=yes, toolbar=no,resizable=no");
 newwin.focus();
 return;
//<A href="#" onClick='return window.open("demo/trial/UI-Viewer.asp?TryID=4","","status=yes, scrollbars=yes, toolbar=no,resizable=yes");'> 
}

// displays a mailto link for the persons email address passed in to the function
function ShowEmail(Email, Name)
{
	document.write('<a class="acontent" href="mailto:' + Email + '@hamptonbaptistchurch.org.au">' + Name + '</a>');
}

function open_win(url){
 var newwin
 newwin = window.open(url,"","status=yes, scrollbars=yes, toolbar=no,resizable=yes");
 newwin.focus();
 return;
//<A href="#" onClick='return window.open("demo/trial/UI-Viewer.asp?TryID=4","","status=yes, scrollbars=yes, toolbar=no,resizable=yes");'> 
}

function open_load(url, name, width, height, winObj)
{
  var newwin; // this will hold our opened window

  // first check to see if the window already exists
  if (winObj != null) {
    
    // the window has already been created, but did the user close it?
    // if so, then reopen it. Otherwise make it the active window.
    if (!winObj.closed) {
      winObj.focus();
      return winObj;
    }
    // otherwise fall through to the code below to re-open the window
  }
  if (winObj == null ) {
     // if we get here, then the window hasn't been created yet, or it
     // was closed by the user.
      newwin = window.open(url,name,"width="+width+",height="+height+", status=yes, scrollbars=yes, toolbar=no,resizable=no");
      return;
  }
}

/*	====================================================================== */
/*	Display provided URL in a popup window
/*	====================================================================== */

function OpenInPopup(sURL, sWindowName, sOptions)
{
	//alert(sOptions);
	
	// create a new browser window (unless this named window already exists)
	var hWin = window.open(sURL, sWindowName, sOptions);

	// bring the new window to the front (give it focus)
	hWin.focus();
}

/*	====================================================================== */

function printpage() {
window.print();  
}

function go_quicklink_url(form_quicklink) {
   // alert("Chiz: go_quicklink_url()");
   var url = document.form_quicklink.page.options[document.form_quicklink.page.selectedIndex].value;
   // alert(url);
   window.location.href = url;
}

function go_mainlink_url(form_mainlinks) {
   // alert("Chiz: go_mainlink_url");
   var url = document.form_mainlinks.HomepageDropdown.options[document.form_mainlinks.HomepageDropdown.selectedIndex].value;
   // alert(url);
   window.location.href = url;
}

function do_date() {
 document.write(showDate());
} 

// Rollover

/****fuction display date sart here *******/
//Date in Java Script .. Cameron Gregory  http://www.bloke.com/
// http://www.bloke.com/javascript/Date/
// change and modify this if you like, but leave these
// 4 comment lines in tact and unchanged.


function longMonthArray() {
     this[0] = "January";     this[1] = "February";     this[2] = "March";
     this[3] = "April";     this[4] = "May";     this[5] = "June";
     this[6] = "July";     this[7] = "August";     this[8] = "September";
     this[9] = "October";     this[10] = "November";     this[11] = "December";
        return (this);
}


function shortMonthArray() {
     this[0] = "Jan";     this[1] = "Feb";     this[2] = "Mar";
     this[3] = "Apr";     this[4] = "May";     this[5] = "Jun";
     this[6] = "Jul";     this[7] = "Aug";     this[8] = "Sep";
     this[9] = "Oct";     this[10] = "Nov";     this[11] = "Dec";
        return (this);
}


function longDayArray() {
     this[0] = "Sunday";     this[1] = "Monday";     this[2] = "Tuesday";
     this[3] = "Wednesday";     this[4] = "Thursday";     this[5] = "Friday";
     this[6] = "Saturday";
        return (this);
}


function shortDayArray() {
     this[0] = "Sun"; this[1] = "Mon"; this[2] = "Tue"; this[3] = "Wed";
     this[4] = "Thu"; this[5] = "Fri"; this[6] = "Sat";
        return (this);
}


function getShortYear(year)
{
shortyear =  year%100;
     if (shortyear < 10) shortyear = "0"+shortyear;
     return shortyear
}


function getLongYear(year)
{
  if (year > 1900) return year
  return year+1900;
}


function writeDateLong(format)
{
   shortDays = new shortDayArray();
   longDays = new longDayArray();
   shortMonths = new shortMonthArray();
   longMonths = new longMonthArray();
   d = new Date();
   day = d.getDate();
   month = d.getMonth();
     year = d.getYear();
   if (format == 0)
     str = shortDays[d.getDay()] + " " + shortMonths[month] +". " + day + ", "+getLongYear(year);
  else if (format == 1)
     str = shortDays[d.getDay()] + " " + longMonths[month] + " " + day + ", "+getLongYear(year);
  else if (format == 2)
     str = longDays[d.getDay()] + " " + longMonths[month] + " " + day + ", "+getLongYear(year);
  else if (format == 3)
     str = longMonths[month] + " " + day + ", "+getLongYear(year);
   else if (format == 4)
     str = shortDays[d.getDay()] + " " + day + " " + shortMonths[month] +". " +getLongYear(year);
  else if (format == 5)
     str = shortDays[d.getDay()] + " " + day + " " + longMonths[month] + " " +getLongYear(year);
  else if (format == 6)
     str = longDays[d.getDay()] + " " + day + " " + longMonths[month] + " " + getLongYear(year);
  else if (format == 7)
     str = day + " " + longMonths[month] + ", "+getLongYear(year);
  else {
     month++;
     shortyear = getShortYear(year);
     if (format == 8)
       str = month + "/" + day + "/" + shortyear;
     else if (format == 9)
       str = month + "/" + day + "/" + getLongYear(year);
     else if (format == 10)
       str = day + "/" + month + "/" + shortyear;
     else if (format == 11)
       str = day + "/" + month + "/" + getLongYear(year);
     else if (format == 12)
       str = shortyear + "/" + month + "/" + day;
     else if (format == 13)
       str = shortyear + "/" + month + "/" + day;
     else {
        if (day < 10) day = "0"+day
        if (month < 10) month = "0"+month
        if (format == 14)
          str = month + "/" + day + "/" + shortyear;
        else if (format == 15)
          str = month + "/" + day + "/" + getLongYear(year);
        else if (format == 16)
          str = day + "/" + month + "/" + shortyear;
        else if (format == 17)
          str = day + "/" + month + "/" + getLongYear(year);
        else if (format == 18)
          str = shortyear + "/" + month + "/" + day;
        else if (format == 19)
          str = shortyear + "/" + month + "/" + day;
        }
     }
  document.writeln(str);
}


function writeDate()
{
   writeDateLong(0);
}


function writeTimeLong(format)
{
   d = new Date();
   hour=d.getHours();
   min=d.getMinutes();
   sec=d.getSeconds();
   if (hour < 10) hour = "0"+hour;
   if (min < 10) min = "0"+min;
   if (sec < 10) sec = "0"+sec;
   if (format == 0)
      str = hour+":"+min+":"+sec;
   else if (format == 1)
      str = hour+":"+min;
   document.writeln(str);
}


function writeTime()
{
   writeTimeLong(0);
}



//check search form function to ensure search form has an entry in it.
function CheckSearchForm()
  {

	//Perform a replace on spaces to ensure they haven't just entered nothing  
  	var strSearchTerm = document.SearchForm.SearchKey.value;  	
  	var re = / /g;
	var strSearchTerm = strSearchTerm.replace(re,"");
  
	if( strSearchTerm == '' )
	  { 	
	  	alert('Please enter a search term.');
	  	document.SearchForm.SearchKey.value = '';
		document.SearchForm.SearchKey.focus();
		return false;
	  }
	//Form filled in, save those variables and process form

	return true;
  }

function isEmail(str) {
  // are regular expressions supported?
  var supported = 0;
  if (window.RegExp) {
	var tempStr = "a";
	var tempReg = new RegExp(tempStr);
	if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported)
	return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
}





/******************** fuction for text auto text scrolling**************************/
// begin absolutely positioned autoscroll area object scripts
/*
Extension developed by David G. Miles (www.z3roadster.net/dreamweaver)
Original Scrollable Area code developed by Thomas Brattli (www.bratta.com)
To add more shock to your site, visit www.DHTML Shock.com
*/

function verifyCompatibleBrowser(){
	this.ver=navigator.appVersion
	this.dom=document.getElementById?1:0
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
	this.ie4=(document.all && !this.dom)?1:0;
	this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5)
	return this
}
bw=new verifyCompatibleBrowser()
lstart=120
loop=true
var speed=100;
//var speed2= 50;
var speed_up = false; //add for swicth speed when mouseOver, mouseOut
pr_step=1.5
function ConstructObject(obj,nest){
    nest=(!nest) ? '':'document.'+nest+'.'
	this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0;
  	this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0;
	this.scrollHeight=bw.ns4?this.css.document.height:this.el.offsetHeight
	this.newsScroll=newsScroll;
	this.moveIt=b_moveIt; this.x; this.y;
    this.obj = obj + "Object"
    eval(this.obj + "=this")
    return this
}
function b_moveIt(x,y){
	this.x=x;this.y=y
	this.css.left=this.x
	this.css.top=this.y
}
//Makes the object scroll up
function newsScroll(speed){
	if(this.y>-this.scrollHeight){
	   if (speed_up == true){
		  //add increase pr_step to speed up the text
		  this.moveIt(0,this.y-10)
		  setTimeout(this.obj+".newsScroll("+speed+")",speed);
		}
		else  if (speed_up == false){		  
		  this.moveIt(0,this.y-pr_step)
		  setTimeout(this.obj+".newsScroll("+speed+")",speed);
		}
					
	}else if(loop) {
		this.moveIt(0,lstart)
		eval(this.obj+".newsScroll("+speed+")")
	  }
}
// add function for change speed when mouseOveror mouseOut
function speed_on (on) {
   if(on == 1) { 
    speed_up = true;
	return speed_up;
   }  
    else if(on == 0){
    speed_up = false;
	//alert(speed);
	return speed_up;  
	}
}

//Makes the object
function InitialiseAutoScrollArea(){
	objContainer=new ConstructObject('divASContainer')
	objContent=new ConstructObject('divASContent','divASContainer')
	objContent.moveIt(0,lstart)
	objContainer.css.visibility='visible'
	objContent.newsScroll(speed)
}
// end absolutely positioned scrollable area object scripts


// End -->
