
function loadApply(id){

							
		// load the contact form using ajax
		$.get("apply.php",{action:'main',adversisement_Id:id},function(data){
			// create a modal dialog with the data
			$(data).modal({
				closeHTML: "<a href='#' title='Close' class='modal-close'>Close</a>",
				position: ["15%",],
				overlayId: 'contact-overlay',
				containerId: 'contact-container',
				onOpen: contact.open,
				onShow: contact.show,
				onClose: contact.close
			});
		});
	}
	

function loadApply2(id){

		top.location='http://www.lanka-jobs.com/apply_job.php?id='+id;					
		// load the contact form using ajax

}	

function loadApply3(id){

							
		// load the contact form using ajax
		$.get("../../apply.php",{action:'client',adversisement_Id:id},function(data){
			// create a modal dialog with the data
			$(data).modal({
				closeHTML: "<a href='#' title='Close' class='modal-close'>Close</a>",
				position: ["15%",],
				overlayId: 'contact-overlay',
				containerId: 'contact-container',
				onOpen: contact.open,
				onShow: contact.show,
				onClose: contact.close
			});
		});
	}
	

function loadApply4(id){

		top.location='../../apply_job.php?id='+id;					
		// load the contact form using ajax

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


	// preload images
	var img = ['cancel.png', 'form_bottom.gif', 'form_top.gif', 'loading.gif', 'send.png'];
	$(img).each(function () {
		var i = new Image();
		i.src = '_images/apply/' + this;
	});
});

var contact = {
	message: null,
	open: function (dialog) {
		// add padding to the buttons in firefox/mozilla
		if ($.browser.mozilla) {
			$('#contact-container .contact-button').css({
				'padding-bottom': '2px'
			});
		}
		// input field font size
		if ($.browser.safari) {
			$('#contact-container .contact-input').css({
				'font-size': '.9em'
			});
		}

		// dynamically determine height
		//var testIE = /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent);
		
		var userAgent="";
		var isFirefox = ( userAgent != null && userAgent.indexOf( "Firefox/" ) != -1 );

		if(isFirefox)
			var h = '';
		else	
			var h =600;
		if ($('#contact-subject').length) {
			h += 26;
		}
		if ($('#contact-cc').length) {
			h += 22;
		}

		var title = $('#contact-container .contact-title').html();
		$('#contact-container .contact-title').html('Loading...');
		dialog.overlay.fadeIn(200, function () {
			dialog.container.fadeIn(200, function () {
				dialog.data.fadeIn(200, function () {
					$('#contact-container .contact-content').animate({
						height: h
					}, function () {
						$('#contact-container .contact-title').html(title);
						$('#contact-container form').fadeIn(200, function () {
							$('#contact-container #contact-name').focus();

							$('#contact-container .contact-cc').click(function () {
								var cc = $('#contact-container #contact-cc');
								cc.is(':checked') ? cc.attr('checked', '') : cc.attr('checked', 'checked');
							});

							// fix png's for IE 6
							if ($.browser.msie && $.browser.version < 7) {
								$('#contact-container .contact-button').each(function () {
									if ($(this).css('backgroundImage').match(/^url[("']+(.*\.png)[)"']+$/i)) {
										var src = RegExp.$1;
										$(this).css({
											backgroundImage: 'none',
											filter: 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="' +  src + '", sizingMethod="crop")'   
										});
									}
								});
							}
						});
					});
				});
			});
		});
	},
	show: function (dialog) {
		
		
	},
	close: function (dialog) {
		$('#contact-container .contact-message').fadeOut();
		$('#contact-container .contact-title').html('Goodbye...');
		$('#contact-container form').fadeOut(200);
		$('#contact-container .contact-content').animate({
			height: 40
		}, function () {
			dialog.data.fadeOut(200, function () {
				dialog.container.fadeOut(200, function () {
					dialog.overlay.fadeOut(200, function () {
						$.modal.close();
					});
				});
			});
		});
	},
	error: function (xhr) {
		alert(xhr.statusText);
	},

	showError: function () {
		$('#contact-container .contact-message')
			.html($('<div class="contact-error"></div>').append(contact.message))
			.fadeIn(200);
	}
};



// later 

function applyJob(id){


var dataURL = 'id=' + id + '&type=check';

	$.ajax({
	   type: "POST",
	   url: "ajax-blocks/applyjob.php",
	   data: dataURL,
	   success: function(msg){
  		
		if(msg=="50"){
			
			$(".job_alert_msg").hide("fast", function(){
					$(".job_alert_msg").html('<div class="messageBox_125">In order to apply for vacancies, you need to create your CV. Please click <a href="jobs_resume_personal_info.php">here</a> to create one. Thank you.</div>').fadeIn("slow");
				})
			
		}else if(msg=="100"){
		
		
			$.ajax({
			   type: "POST",
			   url: "ajax-blocks/apply-job-form.php",
			   data: dataURL,
			   success: function(msg){
		   
					$(".ajax_apply_via_email").html(msg);
		   
			   }
			 });
			 
	 
		}else if(msg=="200"){
		
			$(".job_alert_msg").hide("fast", function(){
					$(".job_alert_msg").html('<div class="messageBox_126">you have already applied for this post. Please continue searching for an opening, which best suits you.</div>').fadeIn("slow");
				})
			
		}else if(msg=="300"){
		
			window.location = "user-login.php";
		
		}

	   }
	 });

}


function applyJob_applyNow(id){

var userMessage = document.getElementById("userMessage").value;

var dataURL = 'id=' + id + '&type=apply&userMessage=' + userMessage;

			$.ajax({
			   type: "POST",
			   url: "ajax-blocks/applyjob.php",
			   data: dataURL,
			   success: function(msg){
		   //alert(msg);
					//$(".ajax_apply_via_email").html(msg);
				
			//if(msg==100){
			
			$(".ajax_apply_via_email").hide("fast", function(){
					$(".ajax_apply_via_email").html('<div class="messageBox_127">you have successfully applied for the opening. Please check your profile and email for a favourable reply. Good luck!!!</div>').fadeIn("slow");
				})
			
			}
					
		   
			   //}
			   
			 });

}





