function Cookie(name){ this.$name = name; var allcookies = document.cookie; if(allcookies == "") return; var cookies = allcookies.split(';'); var cookie = null; for(var i = 0; i<cookies.length; i++){ if(cookies[i].substring(0, name.length+1) == (name + "=")){ cookie = cookies[i]; break;}
}
if(cookie == null) return; var cookieval = cookie.substring(name.length+1); var a = cookieval.split("&"); for(var i = 0; i<a.length; i++)
a[i] = a[i].split(":"); for(var i=0; i<a.length; i++){ this[a[i][0]] = decodeURIComponent(a[i][1]);}
}
Cookie.prototype.store = function(daysToLive, path, domain, secure){ var cookieval = ""; for(var prop in this){ if((prop.charAt(0)=='$') || ((typeof this[prop])=='function'))
continue; if(cookieval != "") cookieval += '&'; cookieval += prop + ':' + encodeURIComponent(this[prop]);}
var cookie = this.$name + '=' + cookieval; if(daysToLive || daysToLive == 0){ cookie += "; max-age=" + (daysToLive*24*60*60);}
if(path) cookie += "; path=" + path
if(domain) cookie += "; domain=" + domain; if(secure) cookie += "; secure"; document.cookie = cookie;}
Cookie.prototype.remove = function(path, domain, secure){ for(var prop in this){ if(prop.charAt(0) != '$' && typeof this[prop] != 'function')
delete this[prop];}
this.store(0, path, domain, secure);}


var Zoom = function(c){ this.size = [100, 140]; this.defaultIdx = 0; this.selectedIdx = 0; this.container = c; this.cookie = new this.Cookie("fontsize"); if(this.cookie.sizeIdx){ this.selectedIdx = this.cookie.sizeIdx; this.change();}
}
Zoom.prototype.up = function(){ if(this.selectedIdx==this.size.length-1) return; this.selectedIdx++; this.change();}
Zoom.prototype.down = function(){ if(this.selectedIdx==0) return; this.selectedIdx--; this.change();}
Zoom.prototype.resetZoom = function(){ this.selectedIdx = this.defaultIdx; this.change();}
Zoom.prototype.change = function(){ this.cookie.sizeIdx = this.selectedIdx; this.cookie.store(null, "/"); document.getElementById(this.container).style.fontSize = this.size[this.selectedIdx]+"%";}
Zoom.prototype.Cookie = Cookie;

$(document).ready(function(){
	var btS = $("#zoomSmall");
	if(!!btS){
		var btL = $("#zoomLarge");
		
		var cookie = new Cookie("fontsize");
		if(cookie.sizeIdx==0) $(btS).addClass("selected");
		else if(cookie.sizeIdx==1) $(btL).addClass("selected");
		else $(btS).addClass("selected");
		
		var zoom = new Zoom('container');
		$(btS).click(function(){$(btS).addClass("selected");$(btL).removeClass("selected"); zoom.resetZoom();});
		$(btL).click(function(){$(btS).removeClass("selected");$(btL).addClass("selected"); zoom.up();});
	}
	
	//set rollover
	var preLoad = new Array();
	$('img.rollover,input.rollover').not("[@src*='_on.']").each(function(){
		var imgSrc = this.src;
		var imgOver = imgSrc.replace(/\.(gif|jpg|png)/,'_on.$1');
		preLoad.push(new Image());
		preLoad[preLoad.length-1].src = imgOver;
		$(this).hover(
			function (){this.src = imgOver;},
			function (){this.src = imgSrc;}
		);
	});
	$(".nav img").each(function(idx, obj){
		IEPNGFIX.hover(obj, obj.src.replace(/.png/,"_on.png"));
	});
	$(".nav_new img").each(function(idx, obj){
		IEPNGFIX.hover(obj, obj.src.replace(/.png/,"_on.png"));
	});
	$(".nav_db img").each(function(idx, obj){
		IEPNGFIX.hover(obj, obj.src.replace(/.png/,"_on.png"));
	});
	$(".nav_db_under img").each(function(idx, obj){
		IEPNGFIX.hover(obj, obj.src.replace(/.png/,"_on.png"));
	});
	$(".nav a").each(function(idx, obj){
		$(obj).click(function(){
			if(opener){
				opener.location.href=obj.href;
				opener.focus();
			}
			else open(obj.href);
			return false;
		});
	});
	
});
