// Preload Images
img1 = new Image(16, 16);  
img1.src="/_images/spinner.gif";

img2 = new Image(220, 19);  
img2.src="/_images/ajax-loader.gif";

// When DOM is ready

$(document).ready(function(){

// Launch MODAL BOX if the Login Link is clicked
$("#login_link").click(function(){
$('#login_form').modal({onOpen: function (dialog) {
	dialog.overlay.fadeIn('slow', function () {
		dialog.data.hide();
		dialog.container.fadeIn('slow', function () {
			dialog.data.slideDown('slow');
		});
	});
}});


});

$("#Photo_Popup").click(function(){
	
	
	
	
$('#Photo_Box').modal({onOpen: function (dialog) {
	$('#simplemodal-container').css("width","400px");
$('#simplemodal-container').css("height","450px");
	dialog.overlay.fadeIn('slow', function () {
		dialog.data.hide();
		dialog.container.fadeIn('slow', function () {
			dialog.data.slideDown('slow');
		});
	});
}});


});








// When the form is submitted
$("#status > form").submit(function(){  

// Hide 'Submit' Button
$('#submit').hide();

// Show Gif Spinning Rotator
$('#ajax_loading').show();

// 'this' refers to the current submitted form  
var str = $(this).serialize();  

// -- Start AJAX Call --

$.ajax({  
    type: "POST",
    url: "do-login.asp",  // Send the login info to this page
    data: str,  
    success: function(msg){  
   
$("#status").ajaxComplete(function(event, request, settings){  
 
 // Show 'Submit' Button
$('#submit').show();

// Hide Gif Spinning Rotator
$('#ajax_loading').hide();  

 if(msg == 'OKCLIENT' || msg == 'OKCAND') // LOGIN OK?
 {  
 var login_response = '<div id="logged_in">' +
	 '<div style="width: 250px; float: left; margin-left: 10px;">' + 
	 '<div style="width: 40px; float: left;">' +
	 '<img style="margin: 10px 0px 10px 0px;" align="absmiddle" src="/_images/ajax-loader.gif">' +
	 '</div>' +
	 '<div style="margin: 10px 0px 0px 10px; float: right; width: 200px;">'+ 
	 "You are successfully logged in! <br /> Please wait while you're redirected...</div></div>";  

$('a.modalCloseImg').hide();  

$('#simplemodal-container').css("width","400px");
$('#simplemodal-container').css("height","150px");
 
 $(this).html(login_response); // Refers to 'status'

// After 3 seconds redirect the 
if(msg == 'OKCLIENT') // LOGIN OK?
 {  
setTimeout('go_to_client_page()', 2000); 
 }
 if(msg == 'OKCAND') // LOGIN OK?
 {  
setTimeout('go_to_cand_page()', 2000); 
 }
 }  
 else // ERROR?
 {  
 var login_response = msg;
 $('#login_response').html(login_response);
 }  
      
 });  
   
 }  
   
  });  
  
// -- End AJAX Call --

return false;

}); // end submit event

});

function go_to_client_page()
{
window.location = 'ClientHome.asp'; // Members Area
}

function go_to_cand_page()
{
window.location = 'CandidateHome.asp'; // Members Area
}



