// JavaScript Document


function campus_login_form()
    {
		
	
	
								
        //
        var  username=$("#username").val();
        var  password= $("#password").val();
		
		
		var url_data="username="+username+"&password="+password;
		
		//
		
		$("#msgbox").removeClass().addClass('messagebox').text('Validating....').fadeIn(1000);
		
        $.ajax( 
                { 
			
    type: "POST", 
    url: "validate.php", 
    data:url_data,
        beforeSend: function() {
                $("#sendingMessage").show();
                },
            success: function(data) 
			{
				
                 
							
						if(trim(data)=='yes') //if correct login detail
		           {
		  	$("#msgbox").fadeTo(200,0.1,function()  //start fading the messagebox
			{ 
			  //add message and change the class of the box and start fading
			  $(this).html('Logging in.....').addClass('messageboxok').fadeTo(900,1,
              function()
			  { 
			  	 //redirect to secure page
				 document.location='login.php';
			  });
			  
			});
						} //end of yes
						
				else
				  {
				
					$("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
                {
                  //add message and change the class of the box and start fading
                  $(this).html('Your username or password does match...').addClass('messageboxerror').fadeTo(900,1);
                });
  
					  
				  } //end of no
				
				//$('#targetDiv').html(data);
                
			}

         });    
		
		  return false;
		      
       
	
									
			
		
		
	} //end of human resource form





	function LTrim( value ) {
	
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
	
}

// Removes ending whitespaces
function RTrim( value ) {
	
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
	
}

// Removes leading and ending whitespaces
function trim( value ) {
	
	return LTrim(RTrim(value));
	
}



function hilite(elem)
{
	
	elem.style.background = '#FcC';

}

function lowlite(elem)
{
	elem.style.background = '#fff';
}



 //displaying the value
    function  dispaly_level(value)
  {
	

	    
			
		
        
		 if(value==0)
		   {
			alert("Select faculty");
			return false;
		   }
		
	    
		
		var url_data="value="+value;
		
		//
		
		
		   //calling the page via ajax
	
		
        $.ajax( 
                { 
			
    type: "POST", 
    url: "faculty.php", 
    data:url_data,
        beforeSend: function() {
        
                },
            success: function(data) 
			{
              
			 
			 
			 $('#level_div').html(data);
			 
			 //document.getElementById('display_vdc_div').innerHTML =data; 
                
			} //end of success 

         });    
		
						
	    
	  
  }//end of function



  function  dispaly_part(value,faculty)
  {
	

	  
			
		
        
		 if(value=='')
		   {
			alert("Select faculty");
			return false;
		   }
		
	 
		
		var url_data="value="+value+"&faculty="+faculty;
		
		//
		
		
		   //calling the page via ajax
	
		
        $.ajax( 
                { 
			
    type: "POST", 
    url: "part.php", 
    data:url_data,
        beforeSend: function() {
        
                },
            success: function(data) 
			{
              
			 
			 
			 $('#discipline_div').html(data);
			 
			 //document.getElementById('display_vdc_div').innerHTML =data; 
                
			} //end of success 

         });    
		
						
	    
	  
  }//end of function



  function  dispaly_discipline(value)
  {
	

	    
			
		
        
		 if(value=='')
		   {
			alert("Select faculty");
			return false;
		   }
		
	
		
		var url_data="value="+value;
		
		//
		
		
		   //calling the page via ajax
	
		
        $.ajax( 
                { 
			
    type: "POST", 
    url: "discipline.php", 
    data:url_data,
        beforeSend: function() {
        
                },
            success: function(data) 
			{
              
			 
			 
			 $('#discipline_div').html(data);
			 
			 //document.getElementById('display_vdc_div').innerHTML =data; 
                
			} //end of success 

         });    
		
						
	    
	  
  }//end of function
  
  
  
  
  
  //changing the password 
  
  
   function  change_password()
  {
	

	    
			
		  var  old_password=$("#old_password").val();
		  var new_password=$("#new_password").val();
        
		 if(old_password=='')
		   {
			alert("Enter Your Old Password.");
			return false;
		   }
		
	     if(new_password=='')
		   {
			alert("Enter Your New Password");
			return false;
		   }
		
		
		var url_data="old_password="+old_password+"&new_password="+new_password;
		
		//
		
		
		   //calling the page via ajax
	
		
        $.ajax( 
                { 
			
    type: "POST", 
    url: "change_password.php", 
    data:url_data,
        beforeSend: function() {
        
                },
            success: function(data) 
			{
              
			 
			 
			 $('#targetDiv').html(data);
			 
			 //document.getElementById('display_vdc_div').innerHTML =data; 
                
			} //end of success 

         });    
		
						
	    
	  
  }//end of function

