// JavaScript Document
/* <![CDATA[ */
var http = getHTTPObject();
var default_url = "/action/";
var xmlDoc;

var right_now=new Date();
var the_year=right_now.getFullYear();
var the_month=(right_now.getMonth() + 1);

var docent_blocked = null;
var self_blocked = null;

function buildArray(){
	docent_blocked = new Array();
	for(var i=0; i < 5; i++){
		var year = (parseInt(the_year) + i);
		docent_blocked[year] = new Array();
		for(var c=1; c<=12; c++){
			docent_blocked[year][c] = new Array(31);	
		}
	}
	return docent_blocked;
}

function fillArray(){
	
}

function getHTTPObject() {
	var xmlhttp;
	try {
		xmlhttp = new ActiveXObject('Msxml2.XMLHTTP');
	} catch (e) {
		try {
			xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
		} catch (E) {
			xmlhttp = false;
		}
	}
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		try {
			xmlhttp = new XMLHttpRequest();
		} catch (e) {
			xmlhttp = false;
		}
	}
	return xmlhttp;
}

function logon(username, password){
	var url = default_url + "login.php";
	var params = "username=" + username + "&password=" + password + "&dynamic=1";	
	if((http.readyState == 0) || (http.readyState == 4)){			
		http.open("POST", url, true); 
		http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		http.setRequestHeader("Content-length", params.length);
		http.setRequestHeader("Connection", "close");		
		http.onreadystatechange = handleHttpLoginLookup;
		http.send(params);
	}
}

function logout(){
	var url = default_url + "logout.php";
	url = url + "?dynamic=1&sid=" + Math.random();		
	if((http.readyState == 0) || (http.readyState == 4)){			
		http.open("GET", url, true); 
		http.onreadystatechange = handleHttpLoginLookup;
		http.send(null);
	}
}

function getInviteForm(next, eventID, classID, object, ev){
	var url = "/functions/callback.php";
	url = url + "?page=inviteForm&next=" + next + "&event=" + eventID + "&class=" + classID;
	url = url + "&sid=" + Math.random();	
	displayInvite(object, ev);
	if((http.readyState == 0) || (http.readyState == 4)){			
		http.open("GET", url, true); 
		http.onreadystatechange = function(){
			if (http.readyState == 4) {			
				if ((http.status == 200)||(http.status == 0)) { 
				
				$("#popbody").html("<h3 id=\"headerInvite\" class=\"left\">Send An Invite</h3><a href=\"\" id=\"headerClose\" class=\"right\" >Close</a><div class=\"leftanchor\"></div>" + http.responseText);
				$("#popbody").removeClass('facts');
				$("#popbody").addClass('invite');
				
				$("#headerClose").click ( function(){
					hideHelp();
					return false;
				});
				}
			}
		}
		http.send(null);
	}
}

function handleHttpLoginLookup(){	
	if (http.readyState == 4) {			
		if ((http.status == 200)||(http.status == 0)) { 	
			var response = http.responseText;
			var loginBox = document.getElementById('loginModule');
			loginBox.innerHTML = response;
		}			
	}
}

function getDayFromString(stringVal){
	var cur_date = new Date(stringVal);
	var cur_day = parseInt(cur_date.getDay());
	if(cur_day == 6 || cur_day == 0)
		document.getElementById('child_price').value=0;
	else
		document.getElementById('child_price').value=4;
	calculateGeneralAdmission();
}

function calculateGeneralAdmission(){
	var childPrice = parseFloat(document.getElementById('child_price').value);
	var teenPrice = parseFloat(document.getElementById('teen_price').value);
	var adultPrice = parseFloat(document.getElementById('adult_price').value);
	var totalChild = parseFloat(document.getElementById('tot_child').value);
	var totalTeen = parseFloat(document.getElementById('tot_teen').value);
	var totalAdult = parseFloat(document.getElementById('tot_adult').value);
	var target = document.getElementById('total_price');	
	target.innerHTML = ((childPrice * totalChild) + (adultPrice * totalAdult) + (teenPrice * totalTeen)).toFixed(2);	
}

function checkDate(dateObject){
	var d = dateObject.getDay()
	if(d == 0 || d == 6)
		return true;
	else
		return false;
}

function hideWends(){
	var targetDate = document.getElementById('f_date_a').value;	
	var targetDateObject = new Date(targetDate);
	var d = targetDateObject.getDay();
	if(d == 3){
		document.getElementById('optionalChoice').style.display = 'none';
	} else
		document.getElementById('optionalChoice').style.display = 'inline';
	return true;
}

function ccCopy(){
	document.getElementById('cc_address').value = document.getElementById('source_address').value;
	document.getElementById('cc_suite').value = document.getElementById('source_suite').value;
	document.getElementById('cc_city').value = document.getElementById('source_city').value;
	document.getElementById('cc_state').value = document.getElementById('source_state').value;
	document.getElementById('cc_zip').value = document.getElementById('source_zip').value;
	document.getElementById('cc_phone').value = document.getElementById('source_phone').value;
	document.getElementById('cc_email').value = document.getElementById('source_email').value;
}

/* ]]> */// JavaScript Document