
		( function($) {
			$(document).ready(function(){

				// Go to top of the page before loading modal window
				$(document).bind('cbox_open', function(){
					$("html, body").animate({ scrollTop: 0 }, "slow");
				});

				// Wire up close button
				$(".close_btn").live('click', function(){
					 $.fn.colorbox.close();
				});

				// Click here to upload resume modal
			//	$('.loginform').colorbox();

				$('.loginform').each(function() {
			    	 $(this).colorbox({
			    	     href: $(this).attr("href")
			    	 });
		    	  });

				// Click here to load login form modal when clicked from button

				 $(".loginform1").colorbox();

				// Click here to open signup form modal from another modal

				$(".signup").live('click', function(){
					 $.fn.colorbox({
							transition: 'elastic',
							speed: 350
						});
				});

				// Click here to open signup form modal from a normal page
				$(".signup1").colorbox();

				/*
				$( '.loginform' ).live('click', function(e){
			        e.preventDefault();
			        $(this).colorbox();
			    });
			    */

				//Loading Modal Boxes on Login Form Page

		        //Loads Forgot password page from Login form page
		        $(".forgotpasswordbox").live('click', function(){
					 $.fn.colorbox();
				});



		        $('#loginformsubmit').live('submit', function(e){

		    	    e.preventDefault();

		    	    $(this).ajaxSubmit({
		    	    	dataType:  'json',
		    	        success: function(response) {

		    	            if(response.status == true)
		    	            {
		    	            	$.colorbox({href: "http://" + document.location.hostname + "/jobs/login_jobs_applied_check.php"});
		    	            }
		    	            else
		    	            {
		    	            	$(".userlogin .message").remove();

		    	            	$.map(response.errors, function(key, value) {
		    	            		message = "<div class='message'>" + key + "</div>";
		    	            		field = value.split('_')[0];
		    	            		$("input[name=" + field + "]").addClass("error");
		    	            		$("input[name=" + field + "]").after(message);
		    	            	});

		    	            	$.colorbox.resize();
		    	            }
		    	        },
		    	        error: function(data) {
		    	            alert("An error has occurred while submitting your request.");
		    	        }
		    	    })

		    	    return false;
		    	});

				//End Loading Modal Boxes on Login Form Page


			   function getField(value)
			   {
				   return value.split('_')[0];
			   }


				//Loading Modal Boxes on Register Candidate Profile Page

		       $('#SignupForm').live('submit', function(e){

		    	    e.preventDefault();

		    	    $(this).ajaxSubmit({
		    	    	dataType:  'json',
		    	        success: function(response) {

		    	            if(response.status == true)
		    	            {
		    	            	$.colorbox({href: "http://" + document.location.hostname + "/jobs/loginform.php?status=newuser"});
		    	            }
		    	            else
		    	            {
		    	            	$(".register-steps .message").remove();
		    	            	$(".register-steps .message1").remove();

		    	            	$.map(response.errors, function(key, value) {
		    	            		message = "<div class='message'>" + key + "</div>";
		    	            		field = value.split('_')[0];
		    	            		$("input[name=" + field + "]").addClass("error");
		    	            		$("input[name=" + field + "]").after(message);
		    	            		$("select[name=" + field + "]").addClass("error");
		    	            		$("select[name=" + field + "]").after(message);
		    	            		$(".jobtype1").addClass("error");
		    	            		$(".jobtype1").after(message);
		    	            	});

		    	            	$.colorbox.resize();
		    	            }
		    	        },
		    	        error: function(data) {
		    	            alert("An error has occurred while submitting your request.");
		    	        }
		    	    })

		    	    return false;
		    	});

				//End Loading Modal Boxes on Register Candidate Profile Page

				//Loading Modal Boxes on Candidate Profile Page

		       $(".editprofile").live('click', function(){
					 $.fn.colorbox();
				});


		       $(".logout").live('click', function(){
					 $.fn.colorbox();
				});


			   //End Loading Modal Boxes on Candidate Profile Page

		     // Loads User Profile Modal Box

		       $(".viewuserprofile").live('click', function(){
					 $.fn.colorbox();
				});

			   //Loading Modal Boxes on Edit Candidate Profile Page

		       $('#editprofileform').live('submit', function(e){

		    	    e.preventDefault();

		    	    $(this).ajaxSubmit({
		    	    	dataType:  'json',
		    	        success: function(response) {

		    	            if(response.status == true)
		    	            {
		    	            	$.colorbox({href: "http://" + document.location.hostname + "/jobs/candidateprofile.php"});
		    	            }
		    	            else
		    	            {
		    	            	$(".editprofile-box .grid .infields .message").remove();

		    	            	$.map(response.errors, function(key, value) {
		    	            		message = "<div class='message'>" + key + "</div>";
		    	            		field = value.split('_')[0];
		    	            		$("input[name=" + field + "]").addClass("error");
		    	            		$("input[name=" + field + "]").after(message);
		    	            		$("select[name=" + field + "]").addClass("error");
		    	            		$("select[name=" + field + "]").after(message);
		    	            	}) ;

		    	            	$.colorbox.resize();
		    	            }
		    	        },
		    	        error: function(data) {
		    	            alert("An error has occurred while submitting your request.");
		    	        }
		    	    })

		    	    return false;
		    	});


		       $(".cancel").live('click', function(){
					 $.fn.colorbox();
				});

				//End Loading Modal Boxes on Edit Candidate Profile Page


		       //Loading Job Applied List in Candidate Profile and Edit Candidate Profile Modal Boxes
		       $(".jobs_applied_list").live('click', function(){
					 $.fn.colorbox({
			    	     href: $(this).attr("href")
			    	 });
				});



		     //Loading pagination in candidate_jobs_applied_list

		       $(".jobsapplied_pagination").live('click', function(){
					 $.fn.colorbox({
			    	     href: $(this).attr("href")
			    	 });
				});

		       $(".previousjobsapplied").live('click', function(){
					 $.fn.colorbox({
			    	     href: $(this).attr("href")
			    	 });
				});

		       $(".nextjobsapplied").live('click', function(){
					 $.fn.colorbox({
			    	     href: $(this).attr("href")
			    	 });
				});


		       //Apply Jobs using Post method in Jobs and Search Pages
		       $('#applyjobs').live('submit', function(e){

		    	    e.preventDefault();

		    	    $(this).ajaxSubmit({

		    	        success: function(html){
                            $.colorbox({html:html, open:true});
		    	        },
		    	        error: function(data) {
		    	            alert("An error has occurred while submitting your request.");
		    	        }
		    	    });

		       });

		       //Apply to jobs from job details modal box

		       $(".applynow_btn").live('click', function(){
					 $.fn.colorbox();
				});

		     //Loading Job Details Modal Box from Jobslist
		       $(".jobdetails").colorbox();

		     //Loading Job Details Modal Box from Applied jobs List
		       $(".appliedjobdetails").live('click', function(){
					 $.fn.colorbox();
				});

		       //Loading Post job Modal Box

		       $(".post-your-job").colorbox();

		       //Loading Modal Boxes after job posting is submitted

		       $('#jobposting').live('submit', function(e){

		    	    e.preventDefault();

		    	    $(this).ajaxSubmit({
		    	    	dataType:  'json',
		    	        success: function(response) {

		    	            if(response.status == true)
		    	            {
		    	            	$.colorbox({href:"http://" + document.location.hostname + "/jobs/thankyou-jobposting.php"});
		    	            }
		    	            else
		    	            {
		    	            	$(".posturjob .grid .message").remove();

		    	            	$.map(response.errors, function(key, value) {
		    	            		message = "<div class='message'>" + key + "</div>";
		    	            		field = value.split('_')[0];
		    	            		$("input[name=" + field + "]").addClass("error");
		    	            		$("input[name=" + field + "]").after(message);
		    	            		$("select[name=" + field + "]").addClass("error");
		    	            		$("select[name=" + field + "]").after(message);
		    	            		$("textarea[name=" + field + "]").addClass("error");
		    	            		$("textarea[name=" + field + "]").after(message);
		    	            	}) ;

		    	            	$.colorbox.resize();
		    	            }
		    	        },
		    	        error: function(data) {
		    	            alert("An error has occurred while submitting your request.");
		    	        }
		    	    })

		    	    return false;
		    	});

		     //Loading back Post job Modal Box

		       $(".postjobs").live('click', function(){
					 $.fn.colorbox();
				});


		       //Loading Modal Boxes after job posting is submitted

		       $('#forgot-password-form').live('submit', function(e){

		    	    e.preventDefault();

		    	    $(this).ajaxSubmit({
		    	    	dataType:  'json',
		    	        success: function(response) {

		    	            if(response.status == true)
		    	            {
		    	            	$.colorbox({href:"http://" + document.location.hostname + "/jobs/forgotpassword-confirmation.php"});
		    	            }
		    	            else
		    	            {
		    	            	$("#forgotpassword-box .inp .message").remove();

		    	            	$.map(response.errors, function(key, value) {
		    	            		message = "<div class='message'>" + key + "</div>";
		    	            		field = value.split('_')[0];
		    	            		$("input[name=" + field + "]").addClass("error");
		    	            		$("input[name=" + field + "]").after(message);
		    	            	}) ;

		    	            	$.colorbox.resize();
		    	            }
		    	        },
		    	        error: function(data) {
		    	            alert("An error has occurred while submitting your request.");
		    	        }
		    	    })

		    	    return false;
		    	});


		   });
		}) ( jQuery );

