﻿//Specify Date Range for Scroller display to be active
var startDate = new Date (2011,11,18)		//THIS DATE IS THE FIRST DAY THE NOTICE WILL APPEAR - YYYY,MM,DD
var endDate = new Date (2011,11,27)		//THIS DATE IS THE LAST DAY THE NOTICE WILL APPEAR - YYYY,MM,DD

	//Specify Typing Scroller contents
	var line=new Array()
	line[1]="Community Barbeque - Sunday 27th November 2011, 5:30pm"  //line[1] will remain on screen after scrollers
	line[2]="...... at the Showgrounds Hall, Waimate North."
	line[3]="<<<<<< Click on 'Notice' button for more details."

//	line[1]="Kiwi Monitoring - contact Phillip Saunders 09 4059249 or Daryl Way 09 4059981"  //line[1] will remain on screen after scrollers
//	line[2]="...... Help protect our local kiwi population,"
//	line[3]="...... volunteers required for programme starting May 20th."
//	line[4]="<<<<<< Click on 'Notice' button for more details."
//		use the following for Kiwi Monitoring notice sizing
//		MyWindow = window.open('Notice_popup.htm', 'myNotice', 
//			'status=0, toolbar=0, location=0, menubar=0, directories=0, resizable=0, left=100, top=100, height=480, width=600')

//	line[1]="Biodiversity of Northland Seminar Feedback Form"
//	line[2]="<<<<<< Click on 'Notice' button for more details."

//	line[1]="Kiwi Monitoring - contact Phillip Saunders 09 405 9249"  //line[1] will remain on screen after scrollers
//	line[2]="...... Help protect our local kiwi population,"
//	line[3]="...... volunteers required for programme starting late May."

//	line[1]="Community BBQ & Last Annual Tree Auction - Sunday 16th May, 5:00pm"  //line[1] will remain on screen after scrollers
//	line[2]="...... at the Showgrounds Hall, Waimate North."
//	line[3]="<<<<<< Click on 'Notice' button for more details."
//		use the following for Community BBQ & Annual Tree Auction notice sizing
//		MyWindow = window.open('Notice_popup.htm', 'myNotice', 
//			'status=0, toolbar=0, location=0, menubar=0, directories=0, resizable=0, left=100, top=100, height=600, width=600')

//	line[1]="Community Barbeque - Sunday 27th November 2011, 5:30pm"  //line[1] will remain on screen after scrollers
//	line[2]="...... at the Showgrounds Hall, Waimate North."
//	line[3]="<<<<<< Click on 'Notice' button for more details."
//		use the following for Community BBQ notice sizing
//		MyWindow = window.open('Notice_popup.htm', 'myNotice', 
//			'status=0, toolbar=0, location=0, menubar=0, directories=0, resizable=0, left=100, top=100, height=320, width=600')

//	line[1]="Bay of Islands Show - Saturday 12th November 2011"  //line[1] will remain on screen after scrollers
//	line[2]="...... visit us at the Waimate North Showgrounds"

//	line[1]="Annual General Meeting - Monday 15th September, 7:30pm"  //line[1] will remain on screen after scrollers
//	line[2]="...... at the Sunday School Building, Waimate North."
//	line[3]="<<<<<< Click on 'Notice' button for more details."
//		use the following for AGM notice sizing
//		MyWindow = window.open('Notice_popup.htm', 'myNotice', 
//			'status=0, toolbar=0, location=0, menubar=0, directories=0, resizable=0, left=100, top=100, height=300, width=500')

	var leader="Notice:"
	var popuppage=1;  // is there a popup for more detailed notice?  0 for no, 1 for yes.



	var ts_fontsize="16px"  //Specify font size for scoller
	var tscroller_color='#0000FF'  //Colour for scroller text - BLUE
	var tscroller_bgColor='#CCFFCC'  //Background colour for scroller text
	
	var maxcounter=1  // Number of times to show the scroller notice

	//Specify Fading Scroller contents
	var maxsteps=40; // number of steps to take to change from start color to endcolor
	var stepdelay=40; // time in miliseconds of a single step
	//**Note: maxsteps*stepdelay will be total time in miliseconds of fading effect
	var startcolor= new Array(255,255,255); // start color (red, green, blue)
	var endcolor=new Array(0,0,255); // end color (red, green, blue) - BLUE

	var fcontent=line[1];

	var fadelinks=1;  //should links inside scroller content also fade like text? 0 for no, 1 for yes.

//--------Should be no need to edit below this line------------------------------------------------

//Date Range variables

var today = new Date()		//Today's date to compare
startDate.setMonth(startDate.getMonth()-1)	//adjust month for storage (0-11)
endDate.setMonth(endDate.getMonth()-1)	//adjust month for storage (0-11)
var currentDate = new Date (today.getFullYear(),today.getMonth(),today.getDate())      //GET CURRENT DATE - YYYY,MM,DD

//Typing Scroller variables, etc.

	var longestmessage=1
	for (i=2;i<line.length;i++){
	if (line[i].length>line[longestmessage].length)
		longestmessage=i
	}

	//Auto set scroller width
	var tscroller_width=line[longestmessage].length+5
	var leader_width=leader.length
	var fullmessage_width=tscroller_width+leader_width

	lines=line.length-1 //--Number of lines

	temp=""
	nextchar=-1;
	nextline=1;
	scrollcounter=1;

//Fading Scroller variables, etc.
	
	var ie4=document.all&&!document.getElementById;
	var DOM2=document.getElementById;

//Compare for valid date range and set up scroller field

	function comparedate(){
		if (currentDate >= startDate && currentDate <= endDate){
			//if IE 4+ or NS6
			if (document.all||document.getElementById){
				document.write('<form name="bannerform">')
				document.write('<div style="position:relative; width='+fullmessage_width+'">')
				if (popuppage==0){
					document.write('<input type="text" name="leader" size="5" value='+leader+'')
					document.write('  style="background-color: #C0C0C0; color: black; text-align:center; font-family: arial; font-size: '+ts_fontsize+'; font-weight:bold">')
				}
				else {
					document.write('<input type="button" name="leader" id="leader" size="5" value='+leader+' onclick="OpenPopUpWindow()"')
					document.write('  style="background-color: red; color: white; text-align:center; font-family: arial; font-size: '+ts_fontsize+'; font-weight:bold">')
				}
				document.write('<input type="text" name="banner" id="banner" size="'+tscroller_width+'"')
				document.write('  style="background-color: '+tscroller_bgColor+'; color: '+tscroller_color+'; font-family: arial; font-size: '+ts_fontsize+'; font-weight:bold; padding-left: 2em"></div>')
				document.write('</form>')
				document.write('<hr />')
				animate()}
		return}
	}
	function OpenPopUpWindow(){
		MyWindow = window.open('Notice_popup.htm', 'myNotice', 
			'status=0, toolbar=0, location=0, menubar=0, directories=0, resizable=0, left=100, top=100, height=320, width=500')
	}
	
	/*
	Typing Scroller
	Submitted by bengaliboy00@hotmail.com (hp: http://www.angelfire.com/nt/bengaliboy/)
	With modifications by Dynamicdrive.com
	For full source code, usage terms, and 100s more scripts, visit http://dynamicdrive.com
	*/

	function animate(){
		if (temp==line[nextline] & temp.length==line[nextline].length & nextline!=lines){
			nextline++;
			nextchar=-1;
			document.bannerform.banner.value=temp;
			temp="";
			setTimeout("nextstep()",1000)}
		else if (nextline==lines & temp==line[nextline] & temp.length==line[nextline].length){  
				if (scrollcounter==maxcounter){
					setTimeout("changecontent()",1000)  // drop out of Scroller loop and go to Fader
					return}
				else {
					nextline=1;
					nextchar=-1;
					scrollcounter++}
					document.bannerform.banner.value=temp;
					temp="";
					setTimeout("nextstep()",1000)}
			else{
				nextstep()}
		}

	function nextstep(){
		nextchar++;
		temp+=line[nextline].charAt(nextchar);
		document.bannerform.banner.value=temp
		setTimeout("animate()",50)}

	/***********************************************
	* Fading Scroller- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
	* This notice MUST stay intact for legal use
	* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
	***********************************************/

	/*Rafael Raposo edited function*/
	//function to change content
	function changecontent(){ 
	  if (DOM2){
	    document.getElementById("banner").style.color="rgb("+startcolor[0]+", "+startcolor[1]+", "+startcolor[2]+")"
	    document.bannerform.banner.value=fcontent;
	    if (fadelinks)
	      linkcolorchange(1);
	    colorfade(1, 15);
	  }
	  else if (ie4)
	    document.bannerform.banner.value=fcontent;
	}
	
	// colorfade() partially by Marcio Galli for Netscape Communications.  ////////////
	// Modified by Dynamicdrive.com
	
	function linkcolorchange(step){
	  var obj=document.getElementById("banner").getElementsByTagName("A");
	  if (obj.length>0){
	    for (i=0;i<obj.length;i++)
	      obj[i].style.color=getstepcolor(step);
	  }
	}
	
	/*Rafael Raposo edited function*/
	var fadecounter;
	function colorfade(step) {
	  if(step<=maxsteps) {	
	    document.getElementById("banner").style.color=getstepcolor(step);
	    if (fadelinks)
	      linkcolorchange(step);
	    step++;
	    fadecounter=setTimeout("colorfade("+step+")",stepdelay);}
	   else{
	    clearTimeout(fadecounter);
	    document.getElementById("banner").style.color="rgb("+endcolor[0]+", "+endcolor[1]+", "+endcolor[2]+")";
	  }   
	}
	
	/*Rafael Raposo's new function*/
	function getstepcolor(step) {
	  var diff
	  var newcolor=new Array(3);
	  for(var i=0;i<3;i++) {
	    diff = (startcolor[i]-endcolor[i]);
	    if(diff > 0) {
	      newcolor[i] = startcolor[i]-(Math.round((diff/maxsteps))*step);}
	    else {
	      newcolor[i] = startcolor[i]+(Math.round((Math.abs(diff)/maxsteps))*step);
	    }
	  }
	  return ("rgb(" + newcolor[0] + ", " + newcolor[1] + ", " + newcolor[2] + ")");
	}
