function openjob(url,id){
	windowW=600;
	windowH=400;
	
	screenW=screen.availWidth;
	screenH=screen.availHeight;
	
	posiL=(screenW-windowW);
	posiR=(screenH-windowH);
	
	url=url+"/jobs/view/?id="+id;
	//alert(posiL+' '+posiR);
	//window.open(url,'jobdesc','width='+windowW+',height='+windowH+',left='+posiL+',top='+posiR+',screenX='+posiL+',screenY='+posiR+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=no');
	//btnClose="<div><span onclick='this.win.close();'>Close</span></div>";
	var myAjax = new Ajax.Updater('div_js_job', url, {  method: 'post',postBody:'',onLoading:function(){$('loading').className="loading";}, onComplete: function(){
		$('loading').className="";
		var win = new Window({className: "mac_os_x", width:550, height:450, zIndex: 100,minimizable:true,maximizable:false,closable:true, resizable: false, title: "Job Description", showEffect:Effect.BlindDown, hideEffect: Effect.SwitchOff, draggable:true, wiredDrag: true}); 
		win.getContent().innerHTML= $('div_js_job').innerHTML;
		win.showCenter();
	}});
}

function applyjob(url,id){

	controlerCheck="/jobs/checkapply/?id="+id;
	controlerApply="/jobs/apply/?id="+id;

	var myAjax = new Ajax.Updater('div_js_job', url+controlerCheck, {  method: 'post',postBody:'',onLoading:function(){$('loading').className="loading";}, onComplete: function(){
		
		$('loading').className="";
		msg=$('div_js_job').innerHTML;
		if(msg=='false'){
			statusmsg="Please logging to apply for jobs.<br/>Click <a href="+url+"/applicant/login>Here</a> to login.";
			Dialog.alert(statusmsg,{windowParameters: {className: "alphacube", width:300,showEffectOptions: {duration:1}, height:100}, okLabel: "Cancel",ok:function(win) {return true;}, cancel:function(win) {return true;}});
			//You are required to be logged in inorder to apply jobs.
		}
		else if (msg=='applied'){
			Dialog.alert("You have already applied for this job.",{windowParameters: {className: "alphacube", width:300,showEffectOptions: {duration:1}, height:100}, okLabel: "OK",ok:function(win) {return true;}, cancel:function(win) {return true;}});
		}
		else{
			text_msg="<div id='edit_pro'><a href='"+url+"/applicant/edit'>Edit Profile</a></div><div>Are you sure you want to apply for this job?</div>";
			
			Dialog.confirm(text_msg,{windowParameters: {className: "alphacube", width:300,showEffectOptions: {duration:1}, height:100}, okLabel: "Yes",cancelLabel:"No",ok:function(win) {
				var myAjax = new Ajax.Updater('div_js_job', url+controlerApply, {  method: 'post',postBody:'',onLoading:function(){}, onComplete: function(){}});
				return true;
				
			}, cancel:function(win) {return true;}});
		}
	
	}});

}

function clear_search(){
	$('txtKey').value='';
	$('sltCategory').value='-1';
	$('sltAge').value='-1';
	$('sltIndustry').value='-1';
	$('sltExperience').value='-1';
	$('sltProvince').value='-1';
	$('sltDistrict').value='-1';
	$('txtSalary').value='';
	$('txtKey').focus();
}

function clear_app_search(){
	$('txtKey').value='';
	$('sltCategory').value='-1';
	$('sltAge').value='-1';
	$('sltIndustry').value='-1';
	$('sltExperience').value='-1';
	$('txtKey').focus();
	$('req_result').innerHTML='';
	$('lgdSearch').innerHTML='';
	$('div_search_main').style.visibility='hidden';
}

function job_search(url){
	//url=url+"/jobs/result/";
	key=$('txtKey').value;
	key = key.replace(/[\\]+/g, ""); 
	

	salary=$('txtSalary').value;
	salary = salary.replace(/[\\]+/g, ""); 
	//alert(salary);
	
	category=$('sltCategory').value;
	age=$('sltAge').value;
	industry=$('sltIndustry').value;
	experience=$('sltExperience').value;
	province=$('sltProvince').value;
	district=$('sltDistrict').value;
	
	url=url+"&key="+key;
	url=url+"&sal="+salary;
	url=url+"&cat="+category;
	url=url+"&age="+age;
	url=url+"&ind="+industry;
	url=url+"&exp="+experience;
	url=url+"&pro="+province;
	url=url+"&dis="+district;
	//http://portal.lk/jobbank/jobs/result/?key=java&sal=44000&cat=-1&age=-1&ind=-1&exp=-1&pro=-1&dis=-1
	//alert(url);
	
	var myAjax = new Ajax.Updater('req_result', url, {  method: 'post',postBody:'',onLoading:function(){$('loading').className="loading";}, onComplete: function(){$('loading').className="";$('lgdSearch').innerHTML='Results';}});
	
}


function applicant_search(url){
	$('div_search_main').style.visibility='visible';
	//url=url+"/jobs/result/";
	key=$('txtKey').value;
	key = key.replace(/[\\]+/g, ""); 
	
	category=$('sltCategory').value;
	age=$('sltAge').value;
	industry=$('sltIndustry').value;
	experience=$('sltExperience').value;

	
	url=url+"&key="+key;
	url=url+"&cat="+category;
	url=url+"&age="+age;
	url=url+"&ind="+industry;
	url=url+"&exp="+experience;
	//http://portal.lk/jobbank/jobs/result/?key=java&sal=44000&cat=-1&age=-1&ind=-1&exp=-1&pro=-1&dis=-1
	//alert(url);
	
	var myAjax = new Ajax.Updater('req_result', url, {  method: 'post',postBody:'',onLoading:function(){$('loading').className="loading";}, onComplete: function(){$('loading').className="";$('lgdSearch').innerHTML='Results';}});
	
}



function frm_submit(val){
	if((val!='')||(val!=null)){
		$(val).form.submit();
		//alert(val);
	}
}


function rmjob(url,id){
	url=url+"/employer/rmjobs/?id="+id;
	//alert(url);
	
	var text_msg="Are you sure you want to remove this job?";
	
	Dialog.confirm(text_msg,{windowParameters: {className: "alphacube", width:300,showEffectOptions: {duration:1}, height:100}, okLabel: "Yes",cancelLabel:"No",ok:function(win) {
			window.location.href=url;
				
			}, cancel:function(win) {return true;}
	});
	
}


function get_sub_cat(url,id){
	url=url+"/jobs/subcat/?cat="+id;
	//alert(url);
	var myAjax = new Ajax.Updater('td_sub_cat', url, {  method: 'post',postBody:'',onLoading:function(){}, onComplete: function(){}});
}
