function createObject() {
	var request_type;
	
	try{
		// Opera 8.0+, Firefox, Safari
		request_type = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			request_type = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				request_type = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your current browser of choice does not support the technologies required for online registration. Please use another browser.");
				return false;
			}
		}
	}

	return request_type;
}


function bookmarksite(){

	var title = ":: Kids For The Nations Summer Day Camp ::";
	var url = "http://www.kidsforthenations.com/";

	if (window.sidebar) {// firefox

		window.sidebar.addPanel(title, url, "");

	} else if(window.opera && window.print) { // opera
		var elem = document.createElement('a');
		elem.setAttribute('href',url);
		elem.setAttribute('title',title);
		elem.setAttribute('rel','sidebar');
		elem.click();

	} else if(document.all) { // ie

		window.external.AddFavorite(url, title);

	} else {
		
		alert('This does not work for your browser. Please manually add a book mark.');			
		
	}
}

var httpMakeContact = createObject();

function contactForm() {
	
	//Form Validation First
	if(document.getElementById('contactName').value=="") {
	
		alert('Please fill in your name.');
		document.getElementById('contactName').focus();
	
	} else if(document.getElementById('contactEmail').value=="") {
		
		alert('Please fill in your e-mail address.');
		document.getElementById('contactEmail').focus();
		
	} else if(document.getElementById('contactText').value=="") {
		
		alert('Please fill in some comments.');
		document.getElementById('contactText').focus();
		
	} else { //If all okay, send email
	
		nocache = Math.random();
		
		showProcessing();

		//Let's get the data from the form
		var contactName=encodeURI(document.getElementById('contactName').value);
		var contactEmail=encodeURI(document.getElementById('contactEmail').value);
		var contactText=encodeURI(document.getElementById('contactText').value);

		httpMakeContact.open('get', 'contactUsEmail.php?contactName='+contactName+'&contactEmail='+contactEmail+'&contactText='+contactText+'&nocache='+nocache);
		httpMakeContact.onreadystatechange = function processContactReply() {
			
			if(httpMakeContact.readyState == 4){
				var response = httpMakeContact.responseText;
				contactCompleted();
			}
			
		};
		httpMakeContact.send(null);

		
	
	}
	
}

function showProcessing() {
	
	document.getElementById('contactProcessing').style.display='block';
	document.getElementById('contactProcessing').style.visibility='visible';
	
	
}

function hideProcessing() {
	
	document.getElementById('contactProcessing').style.display='none';
	document.getElementById('contactProcessing').style.visibility='hidden';
	
	
}

function contactCompleted() {
	
	hideProcessing();
	document.getElementById('contactContainer').innerHTML='<div style="height: 100%; width: 100%;"><table cellpadding="0" cellspacing="0" width="100%" style="height: 100%;"><tr><td align="center" valign="middle"><table cellspacing="0" cellpadding="0" align="center"><tr><td align="center" style="color: #FFFFFF; font-weight: bold; font-size: 16px;">Thank you for contacting us!</td></tr></table></td></tr></table></div>';

}


