/*
	JQuery AJAX functions
	Written by Simon Baxter
	Copyright 2011 Simbax.com Ltd
*/

$(document).ready(function(){ 
	
	$("form#signin_form").submit(function(){
		$.ajax({  
			type: "POST", 
			cache: false, 
			url: "ajax.php",  
			dataType: "text",
			data: ({
				'action':'login',
				'email': $('#email').val(),
				'password':$('#password').val()
			}),  
			success: function(result)
				{ 
					if(result === '1') {
						location.reload();
					} else {
						alert(result);
					}
				}  
		});
		return false;
	});
	
	
	
	// Create overlay and append to body:
    /*$('<div id="ajax_overlay"/>').css({
        position: 'fixed',
        top: 0,
        left: 0,
        width: '100%',
        height: $(window).height() + 'px',
        background: 'white url(/loading.gif) no-repeat center'
    }).hide().appendTo('body');*/
	
	
	//$("#c").change(function(e){
		
		/*$('html, body').animate({
			scrollTop: $("#suppliers_h1").offset().top
		}, 1000);*/
		
		// SHOW overlay
        //$('#suppliers').html('<img src="i/loading.gif" alt="Loading" />');
		
		/*$.ajax({  
			type: "POST", 
			cache: false, 
			url: "ajax.php",  
			dataType: "text",
			data: ({
				'action':'getsuppliers',
				'category': $('#c').val()
			}),  
			success: function(result)
				{ 
					$('#suppliers').html(result);
				} ,
			error: function()
				{
					$('#suppliers').html('tits');
				}
		});
		return false;
	});
	*/
	
	/*
		Change the input field style on focus.  Revert back on blur
	------------------------------------------------------------------------------------------------------*/
	$('.textfield').focus(function() {
		$(this).addClass("current_textfield");
	});
	$('.textfield').blur(function() {
		$(this).removeClass("current_textfield");
	});
	
	
	
});
