function applyJob(url,job_id){
	if(!confirm("Do you want to apply this Job?")){
		return false;
	}
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		 alert ("Browser does not support HTTP Request");
		 return;
	 }
	var resume = document.getElementsByName('resume');
	var resume_id = 0;
	for(var i=0; i<resume.length; i++){
		if(resume[i].checked){
			resume_id = resume[i].value;
		}
	}
	if(resume_id==0){
		alert("Resume cannot be left blank");
		return false;
	}
	var comment = document.getElementById('comment');
	var job_title = document.getElementById('job_title');
	var company_name = document.getElementById('company_name');
	var url=url+"/apply_job_action.php";
	url=url+"?job_id="+job_id;
	url=url+"&resume_id="+resume_id;
	url=url+"&comment="+comment.value;
	url=url+"&job_title="+job_title.value;
	url=url+"&company_name="+company_name.value;
	url=url+"&dummy="+new Date().getTime();
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 	
			document.getElementById("divApply").innerHTML = xmlHttp.responseText;
		 } 
	};
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function sendEmail(url,job_id){
	var email = document.getElementById('email');
	var email_content = document.getElementById('email_content');
	if(email.value==""){
		alert ("Email cannot be left blank");
		email.focus();
		return false;
	}
	if(email_content.value==""){
		alert ("Email Content cannot be left blank");
		email_content.focus();
		return false;
	}
	if(!confirm("Do you want to Send this Job to Friend?")){
		return false;
	}
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		 alert ("Browser does not support HTTP Request");
		 return;
	 }
	
	var url=url+"/email_friend_action.php";
	url=url+"?job_id="+job_id;
	url=url+"&email="+email.value;
	url=url+"&email_content="+email_content.value;
	url=url+"&dummy="+new Date().getTime();
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 	
			document.getElementById("divApply").innerHTML = xmlHttp.responseText;
		 } 
	};
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function change_status(ctr,url,job_apply_id,status){
	if (xmlHttp==null){
		 alert ("Browser does not support HTTP Request");
		 return;
	 }
	
	var url=url+"/jobs_apply_change_status.php";
	url=url+"?job_apply_id="+job_apply_id;
	url=url+"&status="+status;
	url=url+"&dummy="+new Date().getTime();
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 	
			this.innerHTML = xmlHttp.responseText;
			if(status=="P"){
				//this.innerHTML = "";
			}else if(status=="A"){
			
			}else if(status=="R"){
			
			}
		 } 
	};
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function change_status_action(ctr,url,job_apply_id,status){
	if (xmlHttp==null){
		 alert ("Browser does not support HTTP Request");
		 return;
	 }
	
	var url=url+"/jobs_apply_change_status.php";
	url=url+"?job_apply_id="+job_apply_id;
	url=url+"&status="+status;
	url=url+"&dummy="+new Date().getTime();
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 	
			this.innerHTML = xmlHttp.responseText;
			if(status=="P"){
				//this.innerHTML = "";
			}else if(status=="A"){
			
			}else if(status=="R"){
			
			}
		 } 
	};
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function GetXmlHttpObject(){
	var xmlHttp=null;
	try{
		 // Firefox, Opera 8.0+, Safari
		 xmlHttp=new XMLHttpRequest();
	 }catch (e){
		 //Internet Explorer
		 try{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		  }catch (e){
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		  }
	 }
	return xmlHttp;
} 