// JavaScript Document
$(document).ready(function(){
	// higlight the appropriate navigation tab
	var dl = document.location;
	var href = dl.href;
	
	/* 	
		jQuery Plugin: Cycle Lite *great* work guys.
		See: http://malsup.com/jquery/cycle/lite/
	*/
	$('#slider').cycle({
		fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
	});

	$('.navigation ul li a').each (function(e){
		var here = $(this).attr('href');
		if( href.indexOf( here) > 0 ){
			// alert(here);
			$(this).parent('li').addClass('selected');
		}
	});
	
	$('#name').click ( function(e){ 
		if ( this.value.toLowerCase() == 'usuario') {
			this.value = '';
		}
	});

	$('#pswd').focus ( function(e){
		$('#passwordbx').html('<input type="password" name="password" id="pswd" class="text" value="" />');
		$('#pswd').focus();
	});
	
	$('#contactSend').click ( function(e){
		// use AJAX to post the form and display the result.
		e.preventDefault();

		var emailarray = { 
			ip: $('#ip').val(), 
			httpref: $('#httpref').val(), 
			httpagent: $('#httpagent').val(), 
			attn: $('#attn').val(), 
			visitor: $('#visitor').val(), 
			visitormail: $('#visitormail').val(), 
			notes: $('#notes').val()					   	
		};
	
		$.post( "/mail.php", 
		   emailarray, 
		   function(data) {
			// split output to get the status of the mail.
			var status = data.split(';');
			//if (status[0] == '0') { $('#contactus').hide(); }
			$('#contactus').hide();
			$('#sendMailResponse').html(status[1]);
		});
	});
});