$(function(){
	// Accordion
	$("#accordion").accordion({ header: "h3" });
	// Tabs
	$('#tabs').tabs();
	// Dialog			
$('.error').hide();
$('#dialog_logout').dialog({
		autoOpen: false,
		width: 400,
		height:175,
		resizable: false,
		buttons: {
			"Ok": function() { 
			$.ajax({
   type: "GET",
   url: "fn_logout.cfm",
   data: "logout",
   success: function(msg){
 
		   $('#dialog_logout').dialog("close"); 
		   window.location.href ="index.cfm?logout";
		

   }
 });
				
			}, 
			"Cancel": function() { 
				$(this).dialog("close"); 
			} 
		}
	});
$('#dialog_login_error').dialog({
		autoOpen: false,
		width: 400,
		height:240,
		resizable: false,
		buttons: {
			"Ok": function() { 
				$(this).dialog("close"); 
			}
		}
	});
			
$('#dialog_login').dialog({
		autoOpen: false,
		width: 400,
		height:220,
		resizable: false,
		buttons: {
			"Ok": function() { 
var email = $("input#email").val();
if (email == "") {
$('#email').css({backgroundColor:"#FF0000"});
	return false;
    }
var password = $("input#password").val();
if (password == "") {
	$('#password').css({backgroundColor:"#FF0000"});
      return false;
    }
	
var dataString = 'email='+ email + '&password=' + password;
$.ajax({
   type: "POST",
   url: "fn_login.cfm",
   data: dataString,
   success: function(msg){
	    if(msg=='yes') {	   
		   $('#dialog_login').dialog("close"); 
		   window.location.href ="wholesaleorders.cfm";
		}
		else {
			
$('#dialog_login_error').dialog("open"); 
			}

   }
 });



			}, 
			"Cancel": function() { 
				$(this).dialog("close"); 
			} 
		}
	});
	// Dialog Link
	$('#dialog_link').click(function(){
		$('#dialog').dialog('open');
		return false;
	});
	// Datepicker
	$('#datepicker').datepicker({
		inline: true
	});
	// Slider
	$('#slider').slider({
		range: true,
		values: [17, 67]
	});
	// Progressbar
	$("#progressbar").progressbar({
		value: 20 
	});
	//hover states on the static widgets
	$('#dialog_link, ul#icons li').hover(
		function() { $(this).addClass('ui-state-hover'); }, 
		function() { $(this).removeClass('ui-state-hover'); }
	);
});