/***************
Querious Designs
***************/

var months = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
var today = new Date();
var dt = today.getDate();
var dy = today.getDay();
var year = (document.cookie != "" && getCookie('whichyear') != null) ? getCookie('whichyear') : today.getFullYear();
var monthlen = new Array(31,checkLeapYear(year),31,30,31,30,31,31,30,31,30,31);
var chilly;

function checkLeapYear(year) {
	// 1.Years divisible by four are leap years, unless...
	// 2.Years also divisible by 100 are not leap years, except...
	// 3.Years divisible by 400 are leap years.
	if ( ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0) ) {
		return("29");
	} else {
		return("28");
	}
}

//open window
function open_window(url,width, height, resize, scroll) {
	chilly = window.open(url,"chilly", "width=" + width + ",height=" + height + ",resizable=" + resize + ",scrollbars=" + scroll + "");
	chilly.focus();
}

//Global Reminder - Day Object
function day_obj (date, color, text, href) {
	this.title = "day_"+ date;
	this.href = href;
	
	this.color = color;
	this.color_array = new Array(color);
	
	this.text = text;
	this.text_array = new Array(text);
	
	return(this);
}

//determines if Annual Reminders exist for particular month
function checkAnnuals(monthCheck) {
	return (eval("window."+monthCheck+"_EVENTS")) ? true : false;
}

//if necessary, append Annual Reminders to existing global array
function addAnnuals(monthAdd,monthArray,checked) {
	if(checked) {
		if(monthArray != "") {
			monthArray = monthArray.concat(eval("window."+monthAdd+"_EVENTS"));
		} else {
			monthArray = eval("window."+monthAdd+"_EVENTS");
		}
	}
	
	return monthArray;
}

//if the reminder is a long string without spaces, add break after every 20 characters
function adjustLength(rstring) {
	var new_text = "";
	if(rstring.length > 25 && rstring.indexOf(" ") < 0) {
		for(var x = 0; x <= rstring.length; x++) {
			if(x != 0 && (x % 20) == 0) {
				new_text += "<br>" + rstring.substring(x,x+1);
			} else {
				new_text += rstring.substring(x,x+1);
			}
		}
	} else {
		new_text = rstring;
	}
	return new_text;
}

//check admin cookie
function getAllowance() {
	var allowed = "";
	
	if(adminOnly) {
		if(document.cookie != "") {
			var anAdmin = getCookie('cookieAdmin');
			allowed = (anAdmin != null) ? true : false;
		}
	} else {
		allowed = true;
	}
	return allowed;
}

//netscape resize
OrigWidth  = window.innerWidth;
OrigHeight = window.innerHeight;
	
window.onresize = function (){
    if (window.innerWidth == OrigWidth && window.innerHeight == OrigHeight) return;
    window.location.reload();
}