Fx.Font = new Class({
	initialize: function(elements, sid, gid, growsize){
		this.growsize = (growsize) ? growsize : 2;
		this.elements = [];
 		elements.each(function(el){
			this.elements.push([el,el.getStyle('font-size').toInt()]);
		},this);
		var stored=Cookie.get('fontsize');
		if (stored=='large')
		{
			this.grow();
		}
		$(gid).onclick = function(){this.grow()}.bind(this);
		$(sid).onclick = function(){this.shrink()}.bind(this);
	},
	grow: function(){
		this.elements.each(function(el){
			if(el[0].getStyle('font-size').toInt() == el[1])
				el[0].effect('font-size',{duration:300,unit:'px'}).custom(el[1],el[1]+this.growsize);
		},this);
		Cookie.remove('fontsize',{path:'/',duration:7,domain:'alp.org.au'});
		Cookie.set('fontsize','large',{path:'/',duration:7,domain:'alp.org.au'});
	},
	shrink: function(){
		this.elements.each(function(el){
			if(el[0].getStyle('font-size').toInt() == el[1]+this.growsize)
				el[0].effect('font-size',{duration:300,unit:'px'}).custom(el[1]+this.growsize, el[1]);
		},this);
		Cookie.remove('fontsize',{path:'/',duration:7,domain:'alp.org.au'});
		Cookie.set('fontsize','small',{path:'/',duration:7,domain:'alp.org.au'});
	}
});
StyleSheetSwitch = new Class({
	initialize: function(){
		if (document.URL.indexOf('?print') > 0)
		{
			this.setActiveStyleSheet('print');
			window.print(); 
		}
		else
		{
			this.cookie = Cookie.get("style");
			this.title = this.cookie ? this.cookie : this.getPreferredStyleSheet();
			this.setActiveStyleSheet(this.title);
		}
		window.addEvent('unload',function (){this.saveStyleSheet()}.bind(this));
	},
	setActiveStyleSheet: function(title) 
	{
		var a;
		for(var i=0; (a = document.getElementsByTagName("link")[i]); i++)
		{
			if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title"))
			{
			  a.disabled = true;
			  if(a.getAttribute("title") == title) a.disabled = false;
			}
		}
	},
	getActiveStyleSheet: function ()
	{
		var a;
		for(var i=0; (a = document.getElementsByTagName("link")[i]); i++)
		{
			if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
		}
		return null;
	},
	getPreferredStyleSheet: function ()
	{
		var a;
		for(var i=0; (a = document.getElementsByTagName("link")[i]); i++)
		{
		if(a.getAttribute("rel").indexOf("style") != -1
		   && a.getAttribute("rel").indexOf("alt") == -1
		   && a.getAttribute("title")
		   ) return a.getAttribute("title");
		}
		return null;
	},
	saveStyleSheet: function ()
	{
		var title = this.getActiveStyleSheet();
		Cookie.remove("style",{path:'/',duration:7});
		Cookie.set("style", title,{path:'/',duration:7});
	}
});
function setMode(mode)
{
	Cookie.remove('mode',{path:'/',duration:7,domain:'alp.org.au'});
	Cookie.set('mode',mode,{path:'/',duration:7,domain:'alp.org.au'});
}
function resizeLHS()
{
	var height=$E('div#col-right .wrap').offsetHeight;
	if($('col-left').offsetHeight<height) $('col-left').style.height=height+'px';
}
function popup(url,width,height)
{
	var left = 0; 
	var top = 0;
	if(width==null)
	{
		var width=640;
	}
	if(height==null)
	{
		var height=480;
	}
	
	if (typeof( window.innerWidth ) == 'number') {
	// non-IE...
		left = (window.innerWidth-width)/2;
		top = (window.innerHeight-height)/2;
	} else if (document.documentElement && 
			  ( document.documentElement.clientWidth || document.documentElement.clientHeight )) {
	// IE 6+ in 'standards compliant mode'...
		left = (document.documentElement.clientWidth - width) / 2;
		top = (document.documentElement.clientHeight - width) / 2;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    // IE 4 compatible...
		left = (document.body.clientWidth - width) / 2;
		top = (document.body.clientHeight - width) / 2;
	}

	eval("var pup = window.open('"+url+"', 'pupwin', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width="+width+",height="+height+",left = "+left+",top = "+top+"');");
}
function toggle_enews(input,type)
{
	if(type=='focus')
	{
		if(input.value=='your@email')
		{
			input.value='';
		}
	}
	else
	{
		if(input.value=='')
		{
			input.value='your@email';
		}
	}
}
function toggle_search(input,type)
{
	if(type=='focus')
	{
		if(input.value=='Site Search')
		{
			input.value='';
		}
	}
	else
	{
		if(input.value=='')
		{
			input.value='Site Search';
		}
	}
}
function addbookmark(title,url)
{
	if (window.sidebar)
	{
		window.sidebar.addPanel(title, url,"");
	} 
	else if(document.all)
	{
		window.external.AddFavorite( url, title);
	}
	else if(window.opera && window.print)
	{
		return true;
	}
}
function printPage() {
	window.open(document.URL + "?print",'printwin','width=750,height=500,scrollbars=yes,resizable=yes');
}
