//<![CDATA[
window.addEvent('domready', function() {

	
	/* -------------------- ADD EVENT LISTNERS ------------------------*/
	
	/// --------- NAV ELEMENTS
	
	$('lHome').addEvent('click', function(e) {
		e = new Event(e).stop();
		var url = "home.php";
	 	get_Page('m_Text',url);
	});
	
	$('lServices').addEvent('click', function(e) {
		e = new Event(e).stop();
		var url = "services.php";
	 	get_Page('m_Text',url);
	});

	$('lClient').addEvent('click', function(e) {											
		e = new Event(e).stop();
		var url = "clientinfo.php";
	 	new Ajax(url, {
			method: 'POST',
			update: $('m_Text'),
			onComplete: function() {
				//Init_Clients();
			}			
		}).request();
	});

	$('lBio').addEvent('click', function(e) {
		e = new Event(e).stop();
		var url = "bio.php";
	 	get_Page('m_Text',url);
	});

	$('lReferences').addEvent('click', function(e) {
		e = new Event(e).stop();
		var url = "references.php";
	 	get_Page('m_Text',url);
	});

	$('lContact').addEvent('click', function(e) {											
		e = new Event(e).stop();
		var url = "contact.php";
	 	new Ajax(url, {
			method: 'POST',
			update: $('m_Text'),
			onComplete: function() {
				Init_Contact();
			}			
		}).request();
	});
	
	/// --------- OTHER ELEMENTS
	
	$('get_Daily').addEvent('click', function(e) {
		e = new Event(e).stop();
		var url = "newz/getNewz.php";
	 	get_Page('m_Text',url);
	});


	


});





function displaylContact() {
		var url = "contact.php";
	 	new Ajax(url, {
			method: 'GET',
			update: $('m_Text'),
			onComplete: function() {
				Init_Contact();
			}			
		}).request();	
		return false;

}

function Init_Contact() {
	
	
	$('ContactInfo').addEvent('submit', function(e) {
		/**
		 * Prevent the submit event
		*/
		
		new Event(e).stop();
	 
		/**
		 * This empties the log and shows the spinning indicator
		 */
		//var log = $('m_Text').empty().addClass('ajax-loading');
	 	//alert(log);
		/**
		 * send takes care of encoding and returns the Ajax instance.
		 * onComplete removes the spinner from the log.
		 */
		this.send({
			update: $('m_Text'),
			method: 'POST',
			onComplete: function() {
				//log.removeClass('ajax-loading');
			}
		});
	});
	


}

function get_Page(id,url) {
	//alert("GET Page:" + url + "   id = " + id );

		new Ajax(url, {
			method: 'get',
			update: $(id)
		}).request();

}

function get_Newz(id) {
	
	var option = id.options[id.selectedIndex].value;
		$('f_GetNewz').send({
			update: $('m_Text')			
			});
	//alert("Select: " + option + "   " + $('f_GetNewz'));	
	document.f_GetNewz.id.selectedIndex = 0;


}


function Init_Clients() {
	
		var Site = {
	
				accordion: function(){
				
				var list = $$('#accordion li div.collapse');
				var headings = $$('#accordion li h3');
				var collapsibles = new Array();
				var spans = new Array();
				
				headings.each( function(heading, i) {

					var collapsible = new Fx.Slide(list[i], { 
						duration: 500, 
						transition: Fx.Transitions.quadIn
					});
					
					collapsibles[i] = collapsible;
					spans[i] = $E('span', heading);
					
					heading.onclick = function(e){
						var span = $E('span', heading);

						if(span){
							var newHTML = span.innerHTML == '+' ? '&deg;' : '+';
							span.setHTML(newHTML);
						}
						
						for(var j = 0; j < collapsibles.length; j++){
							if(j!=i) {
								collapsibles[j].slideOut();
								if(spans[j]) spans[j].setHTML('+');
							}
						}
						
						collapsible.toggle();
						
						return false;
					}
					
					collapsible.hide();
					
				});
			}
		};
		
		Site.accordion();

}

function NewWindow(url) {
	var width = window.getWidth() * .8;
	var height = window.getHeight() * .8;
	if (height<580) {
		 height = 580;
		 width = 780;
	}
	var tmp_x = center_Cords(width,'x');
	var tmp_y = center_Cords(height,'y');
	window.open(url,'_blank','status=yes,top=' + tmp_y + ',left=' + tmp_x + ',width=' + width + ',height=' + height );
}

function center_Cords(tmp_dim,type) {
	
	
	if (document.body && typeof(document.body.offsetHeight) == 'number')
		{
			 var cHeight = document.body.offsetHeight;
			 var cWidth = document.body.offsetWidth;
		}
		else if (typeof(window.innerHeight) == 'number')
		{
			 var cHeight = window.innerHeight;
			 var cWidth = window.innerWidth;
		}
		else
		{
			 var cHeight = 500;	
			 var cWidth = 800;
		}		

	
	
	
	if (type == 'x') {
		
		var	pass = ((cWidth-tmp_dim)/2)
		return pass
		
	} else if (type == 'y') {
		
		var	pass = ((cHeight-tmp_dim)/2)
		return pass
		
	}
										 
}


//]]>	