// onload manager
onloadFunctions = new Array();
onload = function() {
	for(i=0; i < onloadFunctions.length; i++) {
		onloadFunctions[i]();
	}
}

function onloadAdd(func) {
	onloadFunctions[(onloadFunctions.length++)] = func;
}

// input placeholders:
onloadAdd(function() {
	inputList = document.getElementsByTagName("INPUT");
	for(m=0; m < inputList.length; m++) {
		input = inputList[m];
		if(input.type == "text" && input.title) {
			input.classBackup = input.className;
			if(input.value == input.title) {
				input.className = input.classBackup+" blurred";
			}
			input.onfocus = function() {
				if(this.value == this.title) {
					this.value = "";
					this.className = this.classBackup
				}
			}
			input.onblur = function() {
				if(this.value == "") {
					this.value = this.title;
					this.className = this.classBackup+" blurred";
				}
			}
			input.onblur()
		}
	}
});
onloadAdd(function() {
	// navbar ie6
	var links = document.getElementById("navigation").getElementsByTagName("div");
	for( var linky in links ) {
		links[linky].onmouseover = function() {
			var div = this.getElementsByTagName("div")[0];
			if(div) {
				div.style.display = "block";
			}
		}
		links[linky].onmouseout = function() {
			var div = this.getElementsByTagName("div")[0];
			if(div) {
				div.style.display = "none";
			}
		}
	}
	// sitebridge ie6
	document.getElementById("sitebridge").getElementsByTagName("span")[0].onmouseover = function() {
		this.parentNode.getElementsByTagName("ul")[0].style.display = "block";
	};
	document.getElementById("sitebridge").getElementsByTagName("span")[0].onmouseout = function() {
		this.parentNode.getElementsByTagName("ul")[0].style.display = "none";
	};
});
function checkState(state) {
	if(state=="vic") {
		if(confirm("Victoria has its own Australia Day Website, so we don't accept events from Victoria. \nWould you like to be taken to Victoria's Australia Day site now?")) {
			window.location = "http://www.australiaday.vic.gov.au/home.asp"
		}
	}
	if(state=="nsw") {
		if(confirm("New South Wales has its own Australia Day Website, so we don't accept New South Wales events. \nWould you like to be taken to New South Wales' Australia Day site now?")) {
			window.location = "http://www.australiaday.com.au/"
		}
	}
}
function switchTab(id) {
	createCookie("tabType",id,1);
	if(id == 1) {
		document.getElementById("regionalPane").style.display = "block";
		document.getElementById("metroPane").style.display = "none";
		document.getElementById("tabMetro").className = "";
		document.getElementById("tabRegional").className = "selected";
	} else {
		document.getElementById("regionalPane").style.display = "none";
		document.getElementById("metroPane").style.display = "block";
		document.getElementById("tabRegional").className = "";
		document.getElementById("tabMetro").className = "selected";
	}
	onload();
	return false;
}
function emailFriend() {
	window.location = "/email/?href="+window.location
}
var min=8;
var max=18;
function increaseFontSize() {
   var p = document.getElementById("body").getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=max) {
         s += 1;
      }
      p[i].style.fontSize = s+"px"
   }
}
function decreaseFontSize() {
   var p = document.getElementById("body").getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=min) {
         s -= 1;
      }
      p[i].style.fontSize = s+"px"
   }   
}
function checkTimeType(dateField) {
	var val = document.getElementsByName(dateField+"TimeType")[0].selectedIndex
	if(val) {
		document.getElementById(dateField+"Time").style.display = "inline"
	} else {
		document.getElementById(dateField+"Time").style.display = "none"
	}
}
function launchRocky() {
	window.open("http://www.australiaday.org.au/games/rocky_the_cocky.html","rocky","width=355,height=650");
}
function launchMemory() {
	window.open("http://www.australiaday.org.au/games/memorygame.html","memory","width=746,height=535");
}
function createCookie(name, value, days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}



var slideshow = {
	"data" : [],
	"currentIndex" : 0,
	"timer" : null,
	"panel" : "#mediapanel",
	"interval" : 5200,
	"fadeSpeed" : "slow",
	"init" : function(data) {
		slideshow.data = data;
		for(var m in slideshow.data) {
			$("<img>").attr("src",slideshow.data[m]);
		}
		slideshow.panel = $(slideshow.panel).empty().append("<img />");
		slideshow.panel.children("img").attr("src",slideshow.data[0]);
		$(window).load(slideshow.go);
	},
	"next" : function() {
		slideshow.timer = setTimeout(slideshow.next,slideshow.interval);
		slideshow.currentIndex = slideshow.currentIndex+1;
		if(slideshow.currentIndex >= slideshow.data.length) slideshow.currentIndex = 0;
		slideshow.panel.children("div").remove();
		var img = slideshow.panel.append("<div style=\"position: absolute; left: 0px; top: 0px;\" ><img /></div>").find("div img");
		img.hide().attr("src",slideshow.data[slideshow.currentIndex]).fadeIn(slideshow.fadeSpeed,function() {
			slideshow.panel.children("img").attr("src",slideshow.data[slideshow.currentIndex]);
			slideshow.panel.children("div").remove();
		});
	},
	"go" : function() {
		slideshow.timer = setTimeout(slideshow.next,slideshow.interval);
	}
};
var newsletter = {
	
}