// JavaScript Document

var req;
var node;
var divID;
var next=0;
if (window.XMLHttpRequest) 
{
	
	req = new XMLHttpRequest();
	
} 
else if (window.ActiveXObject) 
{

	req = new ActiveXObject("Microsoft.XMLHTTP");
	
}	
function showTab(divId)
{
	var divObj = document.getElementById(divId);
	divObj.style.visibility = "visible";
	divObj.style.display = "block";
}
function hideTab(divId)
{
	var divObj = document.getElementById(divId);
	divObj.style.visibility = "hidden";
	divObj.style.display = "none";
}
// JavaScript Document

function showDiv(divId)
{
	var divObj = document.getElementById(divId);
	divObj.style.visibility = "visible";
	divObj.style.display = "block";
}
function hideDiv(divId)
{
	
	var divObj = document.getElementById(divId);
	divObj.style.visibility = "hidden";
	divObj.style.display = "none";
}

function showDiv(divId)
{
	var divObj = document.getElementById(divId);
	divObj.style.visibility = "visible";
	divObj.style.display = "block";
}


function sendToFriend(jobId)
{
window.open("/candidate/faces/jsp/sendToFriend.jsp?jobId="+jobId,
	"mywindow","location=0,status=0,scrollbars=0,width=365,height=250,top=100,left=100");
}

/* 02/04/2009 - Nasir - Change Password Starts*/
 function updatePassword(){
	  var oldPassword= trim(document.getElementById('oldPassword').value);
	  var newPassword=trim(document.getElementById('newPassword').value);
	  var confirmPassword=trim(document.getElementById('confirmPassword').value);

	  if(oldPassword==''){
		  alert("Please enter old password");
		  document.getElementById('oldPassword').focus();
		  return;
	  }

	if(checkSpace(oldPassword)){
		  alert("Spaces are not allowed. Please re enter password");
		  document.getElementById('oldPassword').focus();
		  return;
	}
	
	  if(newPassword==''){
		  alert("Please enter New password");
		   document.getElementById('newPassword').focus();
		  return;
	  }
		
	if(checkSpace(newPassword)){
		  alert("Spaces are not allowed. Please re enter New password");
		  document.getElementById('newPassword').focus();
		  return;
	}
	 
	  if(confirmPassword==''){
		  alert("Please enter Confirm password");
		   document.getElementById('confirmPassword').focus();
		  return;
	  }


		   
		/*    if((oldPassword.length<5)||(oldPassword.length>=20)){
		  
		   alert("Old Password should be more than 5 characters and less than 20 characters");
		   document.getElementById('oldPassword').focus();
		   return false
		 }*/

		 if((newPassword.length<5)||(newPassword.length>20)){
		  
		   alert("New Password should be more than 5 characters and less than 20 characters");
		   document.getElementById('newPassword').focus();
		   return false
		 }

		 if((confirmPassword.length<5)||(confirmPassword.length>20)){
		  
		   alert("Confirm Password should be more than 5 characters and less than 20 characters");
		   document.getElementById('confirmPassword').focus();
		   return false
		 }

	if(newPassword!=confirmPassword){
			  alert("New password and confirm new password do not match.");
			   document.getElementById('confirmPassword').focus();
			  return;
		  }


		var pathname = window.location.pathname;	
		var contextPath = pathname.substring( 0, pathname.indexOf("/faces") );
		var url = contextPath + "/faces/UpdatePasswordServlet?";
		url+="&oldPassword="+oldPassword;
		url+="&newPassword="+newPassword;
		

			if (req != null) {
					req.open("POST", url, true);
					req.onreadystatechange = updatePasswordResponse;
					req.send(null);
				}  


  }

  function updatePasswordResponse(){
	  if (req.readyState == 4)
		{		
		//process only if OK
           if (req.status == 200)	
			   {
					if(req.responseText==null) 
						{ 
							alert("Invalid Response");
						}
					else 
						{			
						var resp=trim(req.responseText);	
						if(resp == "update_fail"){
								
							var span = "<span>Invalid old password.Please enter correct password </span>";
							    document.getElementById('passwordMessage').innerHTML = span;
								document.getElementById('passwordMessage').style.visibility="visible";
								document.getElementById('passwordMessage').style.display="block";
								
					
						}
						else if(resp=="update_success")
							{
							window.location.href="myDashBoard.jsp?passwordMessage=updated";
					
							}	
							 else{
								 	var span = "<span>Invalid Session</span>";
								document.getElementById('passwordMessage').innerHTML = span;
								document.getElementById('passwordMessage').style.visibility="visible";
								document.getElementById('passwordMessage').style.display="block";
								
							 }
						}
				}
		 }
  }
  
 /*Change Password Ends*/
 
 
 function checkSpace(value){ 
  var regExp=/[\s]/;	
  if(value!=""){	
	if(!regExp.test(value))
	 {		
		return false;
	 }
  }
	 return true;
 } 

  function trim(s) {
   var temp = s;
   return temp.replace(/^\s+/,'').replace(/\s+$/,'');
}

function navigateToDashboard(){
	window.location.href="Dashboard.jsp";
}

function saveAlternateMail(){
 var alternateEmail= trim(document.getElementById('alternateEmail').value);
  if(alternateEmail==''){
		  alert("Please enter Email Id");
		  document.getElementById('alternateEmail').focus();
		  return;
	  }
	if(!validateEmail('alternateEmail')){
		alert("Enter a valid Email Id");
		 document.getElementById('alternateEmail').focus();
		return ;
	}
	
		var pathname = window.location.pathname;	
		var contextPath = pathname.substring( 0, pathname.indexOf("/faces") );
		var url = contextPath + "/faces/SaveAlternateEmailServlet?";
		url+="&alternateEmail="+alternateEmail;	

			if (req != null) {
					req.open("POST", url, true);
					req.onreadystatechange = saveAlternateEmailResponse;
					req.send(null);
				}  
	
	
	  
}

function resendMail(alternateEmail){
	

	var pathname = window.location.pathname;	
	
		var contextPath = pathname.substring( 0, pathname.indexOf("/faces") );
		var url = contextPath + "/faces/ResendMailForAlternateEmailServlet?";
		
		url+="&alternateEmail="+alternateEmail;	

			if (req != null) {
					req.open("POST", url, true);
					req.onreadystatechange = alternateEmailResponse;
					req.send(null);
				}  
	
	
	  
}



function saveAlternateEmailResponse(){
if (req.readyState == 4)
		{		
		//process only if OK
           if (req.status == 200)	
			   {
					if(req.responseText==null) 
						{ 
							alert("Invalid Response");
						}
					else 
						{			
						var resp=trim(req.responseText);
						
							if(resp == "save_fail"){
									
								 document.getElementById('duplicateMailMessage').style.visibility = "visible";
								 document.getElementById('duplicateMailMessage').style.display="block";
								 document.getElementById('duplicateMailMessage').innerHTML="Sorry! There was an error in the request,Please try again.";
								
							}
							
							 else if(resp=="mail_exists"){

								 document.getElementById('duplicateMailMessage').style.visibility = "visible";
								 document.getElementById('duplicateMailMessage').style.display="block";
								 document.getElementById('duplicateMailMessage').innerHTML="This Email Id already exists.Please enter a different mail Id";
							 }
							
							 else
								{
								window.location.href="manageAlternativeEmailID.jsp?alternateMail="+resp;
						
								}	
						}
				}
		 }
}



function alternateEmailResponse(){
	
if (req.readyState == 4)
		{		
		//process only if OK
           if (req.status == 200)	
			   {
					if(req.responseText==null) 
						{ 
							alert("Invalid Response");
						}
					else 
						{			
						var resp=trim(req.responseText);
													
							   if(resp=="mail_sent"){

								 document.getElementById('mailMessage').style.visibility = "visible";
								 document.getElementById('mailMessage').style.display="block";
								 document.getElementById('mailMessage').innerHTML="Email activation mail sent. Please check your email account.";
							 }
							 
							 else if(resp=="mailError"){

								 document.getElementById('mailMessage').style.visibility = "visible";
								 document.getElementById('mailMessage').style.display="block";
								 document.getElementById('mailMessage').innerHTML="Mail could not sent due to system error.";
							 }
							
						}
				}
		 }
}


  function validateEmail(id)
	{
	  var value = document.getElementById(id).value;
	  var regExp=/^[-a-z0-9\._]+@(?:[-a-z0-9]+\.){1,32}[a-z]+$/i;	
	  if(value!=""){	
		if(!regExp.test(value))
		 {		
			return false;
		 }
	  }
		 return true;
	}


 function showAltMailId(altMailsXml,alternateMail){
	var XmlObj = xmlStringToXmlDoc(altMailsXml);
	var keyWordList=XmlObj.getElementsByTagName('Emails');
	 var color = 0;
	var out = '<table width="100%" border="0" cellspacing="0" cellpadding="0">';
		  out+= '<tr>';
		  out+= '	<td width="40%" class="tableheader">Alternate Email ID </td>';
		  out+= '	<td width="40%" class="tableheader">Created Date</td>';
		  out+= '	<td width="20%" class="tableheader" >Confirmed</td>';
		  out+= '	</tr>';
		 
						if(keyWordList.length>0){
					for(i=0; i<keyWordList[0].childNodes.length; i++)
							{
										
									var email=keyWordList[0].childNodes[i].getAttribute("email");
									var createDate=keyWordList[0].childNodes[i].getAttribute("createDate");
									var onlyDate =createDate;
									var isConfirmed=keyWordList[0].childNodes[i].getAttribute("Confirmed");
									

									if(color == 0){
										out+= '<tr>';
										out+= '<td class="tablerow1">'+email+'</td>';
										out+= '<td class="tablerow1">'+onlyDate+'</td>';
										if(isConfirmed=="Yes")
										{

										out+= '<td class="tablerow1" >'+isConfirmed+'</td>';
										}else if(isConfirmed=="No")
										{
										out+= '<td class="tablerow1" >'+isConfirmed+'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=javascript:void(0); onclick=resendMail("'+email+'"); class=advancedsearch strong>Resend Mail</a></td>';
										}
										out+= '</tr>';
										color=1;
									}
									else{
										out+= '<tr>';
										out+= '<td class="tablerow2">'+email+'</td>';
										out+= '<td class="tablerow2">'+onlyDate+'</td>';
										if(isConfirmed=="Yes")
										{
										out+= '<td class="tablerow2" >'+isConfirmed+'</td>';
										}else if(isConfirmed=="No")
										{
										out+= '<td class="tablerow2" align="" >'+isConfirmed+'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=javascript:void(0); onclick=resendMail("'+email+'"); class=advancedsearch strong>Resend Mail</a></td>';
										}
										out+= '</tr>';
										color=0;
									}
							}
							out+= '</table>';
							document.getElementById('altMailsDiv').innerHTML= out;
							
						}

			

			if(alternateMail !="null"){
		var span = "<span>Email Id '"+alternateMail+"' successfully created. Check your mail to confirm the newly created mail id.</span>";
		document.getElementById('mailMessage').style.visibility="visible";
		document.getElementById('mailMessage').style.display="block";
		document.getElementById('mailMessage').innerHTML = span;
}

 }

function showWalkinDetails(walkinList){

var XmlObj = xmlStringToXmlDoc(walkinList);
 node=XmlObj.getElementsByTagName('WalkinList');
 if(node.length>0){
	var  out= getWalkinTableContent(0);
	document.getElementById('WalkInDetails').innerHTML= out;
 }
 else{
	 document.getElementById('walkinTD').style.display="none";
     document.getElementById('walkinTD').style.visibility="hidden";
 }

}


 function xmlStringToXmlDoc(result)
   {
		var xmlDoc;
		   if(document.implementation && document.implementation.createDocument) 
			   {
				//Mozilla
				var domParser = new DOMParser();
				xmlDoc = domParser.parseFromString(result, "text/xml");
			  } 
			else if (window.ActiveXObject)
				{
				 //IE
				 xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
				 xmlDoc.async="false";
				  xmlDoc.loadXML(result);
				}
			  return xmlDoc;
  }
  
  function incNext(){
	  if(next < node[0].childNodes.length-1){
	  next++ ;	
	  }
	var  out= getWalkinTableContent(next);
	document.getElementById('WalkInDetails').innerHTML= out;
  }

    
  function decNext(){
	    if(next >0 ){
	    next-- ;		
		}
	var  out= getWalkinTableContent(next);
	document.getElementById('WalkInDetails').innerHTML= out;
  }


  function getWalkinTableContent(count){
			var nodeLength =node[0].childNodes.length;

	  		var out = ' <table width="100%" border="0" cellspacing="0" cellpadding="4" class="bluebg">';
		 out+=	 '<tr>';
         out+=    '<td>&nbsp;</td>';
         out+=   '<td align="right"><a href="javascript:hideDiv(\'WalkInDetails\');" class="textblue">Close</a></td>';
         out+=   '</tr>';	
		
									var locatin=null;
									var walkenddate=null;
									if(node[0].childNodes[count].getAttribute("location")!=null){
										locatin = node[0].childNodes[count].getAttribute("location");
									}
									if(node[0].childNodes[count].getAttribute("walkenddate")!=null){
									 walkenddate=node[0].childNodes[count].getAttribute("walkenddate").substring(0,10);
									}

									var walkstartdate=null;
									if(node[0].childNodes[count].getAttribute("walkstartdate")!=null){
									  walkstartdate= node[0].childNodes[count].getAttribute("walkstartdate").substring(0,10);
									}

									var address=null; 
									if(node[0].childNodes[count].getAttribute("address")!=null){
									address = node[0].childNodes[count].getAttribute("address");
									//replace ` character to get original string
									address=address.replace("`","'");
									}
									//	alert(walkstartdate)
									if(locatin==null)
										locatin="";
									if(walkenddate==null)
										walkenddate="";
									if(walkstartdate==null)
										walkstartdate="";
									if(address==null)
										address="";

									      out+=   '<tr>';
                                          out+=   '    <td class="strong">Date :</td>';
                                          out+=   '    <td>'+walkstartdate;
										  if(walkstartdate !="" && walkenddate !=""){
										  out+=   '  to '+walkenddate+'</td>';
										  }else{
											out+=  walkenddate+'</td>';
										  }
                                          out+=   ' </tr>';
										  if(locatin!=""){
                                          out+=   ' <tr>';
                                          out+=   '      <td class="strong">Location :</td>';
                                          out+=   '     <td>'+locatin+'</td>';
                                          out+=   ' </tr>';
										  }
										  if(address!=''){
										  out+=   ' <tr>';
                                          out+=   '    <td class="strong" valign="top">Address :</td>';
                                          out+=   '     <td>'+address+'</td>';
                                          out+=   ' </tr>';
										  }
										
		 out+=   ' 	<tr>';

		out+="<td class='textblack strong' width='50%'>&nbsp;";
		if(nodeLength>1)
		out+="<a href=\"javascript:decNext()\"'><img src='../images/prev_bullet.gif' alt=''/></a>&nbsp;&nbsp;<a href=\"javascript:decNext()\" >Previous</a>";
		out+="</td>";
		out+="<td align='right'>";
		if(nodeLength>1)
		out+="<a href=\"javascript:incNext()\" class='textblack strong'>Next</a>&nbsp;&nbsp;<a href=\"javascript:incNext()\"><img src='../images/next_bullet.gif' alt=''/></a>";
		out+="</td>";

	    out+=   ' 	</tr>';

			out+= '</table>';
			  return out;
										  
  }
  
    function sendJobToFriend(){
		
		var friendMailId = document.getElementById("friendMailId").value;
		window.close();

	}
	
 

 function showJobPostings(responseVal){

	 var XmlObj = xmlStringToXmlDoc(responseVal);
	 var node=XmlObj.getElementsByTagName('JobPostingList');
	 var out='';
	  out+=   ' <table border="0" cellspacing="4" cellpadding="2" class="righttablewidth">';
		for(i=0; i<node[0].childNodes.length; i++)
				{										
				var positiontitle	=	node[0].childNodes[i].getAttribute("positiontitle");
				var recruitmentcompany	=	node[0].childNodes[i].getAttribute("recruitmentcompany");
				var jobdesc	=	node[0].childNodes[i].getAttribute("jobdesc");
				var advimagepath	=	node[0].childNodes[i].getAttribute("advimagepath");
				var publication	=	node[0].childNodes[i].getAttribute("publication");
				var publicationdate	=	node[0].childNodes[i].getAttribute("publicationdate");
				var edition	=	node[0].childNodes[i].getAttribute("edition");
				
				     out+=   '  <tr>';
				     out+=   ' 	<td width="1%" valign="top"><input name="" type="checkbox" value="" class="border0"></td>';
				     out+=   ' 	<td valign="top" width="10%"><a href="#"><img src="'+advimagepath+'" alt=""  height="150" width="150"/></a></td>';
				     out+=   ' 	<td valign="top"><table width="100%" border="0" cellspacing="2" cellpadding="0">';
                     out+=   '     <tr>';
                     out+=   '      <td height="94" valign="top"><p><strong>'+positiontitle+'</strong></p>';
					 out+=   ' 	<p>'+recruitmentcompany+'</p><br />';
					 out+=   ' 	<p>'+jobdesc+'...</p></td>';
                     out+=   '    </tr>';
                     out+=   '    <tr>';
                     out+=   '      <td class="bluebg"><table width="100%" border="0" cellspacing="0" cellpadding="2">';
					 out+=   ' 	  <tr>';
					 out+=   ' 		<td><table width="98%" border="0" cellspacing="2" cellpadding="2" align="center">';
					 out+=   ' 	  <tr>';
					 out+=   ' 	<td><img src="../images/search_icon.gif" alt=""></td>';
					 out+=   ' 		<td><a href="#" class="underlinedlink">Search Similar Jobs</a></td>';
					 out+=   ' 	<td><img src="../images/jobadviser_icon.gif" alt=""></td>';
					 out+=   ' 		<td><a href="#" class="underlinedlink">All jobs by this Advertiser</a></td>';
					 out+=   ' 		<td><img src="../images/searchjobs_icon.gif" alt=""></td>';
					 out+=   ' 		<td><a href="#" class="underlinedlink">All jobs in this Advertisement</a></td>';
					 out+=   ' 	  </tr>';
					 out+=   ' 	</table></td>';
					 out+=   ' 	  </tr>';
					 out+=   ' 	  <tr>';
					 out+=   ' 		<td class="blutext11content2_link">&nbsp;&nbsp;&nbsp;<em>Published Date : '+publicationdate+'('+publication+' - '+edition+')</em></td>';
					 out+=   ' 	  </tr>';
					 out+=   ' 	</table>';
					 out+=   ' 	</td>';
                     out+=   '  </tr>';
                     out+=   '  </table></td>';
				     out+=   '   </tr>';
				   	
				}
  out+=   ' </table>';	
  document.getElementById('resultDiv').innerHTML = out;

 }
 
function redirectToPage(pageName){
window.location.href =pageName;
}


function showPasswordMessage(passwordMessage)
{
	document.getElementById('passwordMessage').innerHTML="Your password has been successfully updated";
	document.getElementById('passwordMessage').style.display="block";
     document.getElementById('passwordMessage').style.visibility="visible";

}

var prevFilterName="";
function setAllFilterName(){
prevFilterName =document.getElementById('add:filterName').value;
}


//createSearchFilter validation.

function fnCheckValidation()
{
    var checkTitle =false;
    
	var currentFilterName = document.forms['add'].elements['add:filterName'].value;
		if(currentFilterName.length==0){
				alert('Please Enter Filter Name');	
				document.forms['add'].elements['add:filterName'].focus();
				return false;
		}			
	
		if(prevFilterName!=null && prevFilterName == currentFilterName){
		checkTitle =true;
		}
		
		if(! checkTitle){
			var allFilterTitle = document.getElementById("add:allFilterName").value;
			if(allFilterTitle && allFilterTitle !="" && allFilterTitle.indexOf(currentFilterName)!=-1){
				alert('Please enter unique filter name.')
				return false;
			}
		}
		
//	var coverLetterContent = document.forms['add'].elements['add:filterComment'].value;
	
		//if(coverLetterContent.length==0){
		//		alert('Please enter filter comment');	
		//		document.forms['add'].elements['add:filterComment'].focus();
		//		return false;
		//}
	
	return true;
}


 function resumeFormats(fileName,filePath,contextPath)
{
	location.href=contextPath+"/"+"fileDownloadServlet?fileName="+fileName+"&filePath="+filePath;

//renderData('resumeFormat','divDownload',contextPath,'&fileName='+fileName+'&filePath='+filePath,'fileDownloadServlet','','');
}

function saveJobSearch(jobId)
{
window.location.href = "myjobdescription.jsp?jobId="+jobId;
}

function applyJob(jobId)
{
window.location.href ="myApplication.jsp?jobId="+jobId;
	
}
function sendToPage(pageName,nav,formId){
//save search band navigation
	var saveSearchId =document.getElementById(formId+":saveSearchId").value;
	//alert(pageName+"?pageNavigation="+nav+"&"+"saveSearchId="+saveSearchId+"&saveSearch=Y")
window.location.href =pageName+"?pageNavigation="+nav+"&"+"saveSearchId="+saveSearchId+"&saveSearch=Y";

}

//search saved FIlter
function checkForTab(formId){
var saveSearch = document.getElementById(formId+":saveSearch").value;
var pageNavigation = document.getElementById(formId+":pageNavigation").value;
if(saveSearch && saveSearch!=null){
  	  if(formId =="frmSearch"){
		
		if(pageNavigation !="" && pageNavigation=="2"){
				 document.getElementById("2").style.display ="block";
				 document.getElementById("-2").style.display ="none";
				 document.getElementById("3").style.display ="none";
				 document.getElementById("3Search").style.display ="none";
				 setLocationValues(document.getElementById("frmSearch:locationListHidden").value);				
				 
		}else if(pageNavigation !="" && pageNavigation=="3"){
				document.getElementById("2").style.display ="none";
				document.getElementById("-2").style.display ="none";
				document.getElementById("-3").style.display ="none";

				document.getElementById("3Search").style.display ="block";
				document.getElementById("3").style.display ="block";
			setLocationValues(document.getElementById("frmSearch:locationListHidden").value);
		}else{
			document.getElementById("-2").style.display ="block";

			setLocationValues(document.getElementById("frmSearch:locationListHidden").value);

		}
			

    }else if(formId =="frmAdvert"){
		//search result page
		if(pageNavigation !="" && pageNavigation=="3"){
				
				document.getElementById("3").style.display ="block";
				document.getElementById("-3").style.display ="none";

				document.getElementById("2").style.display ="none";
				document.getElementById("3Search").style.display ="block";
		}else{
		
			document.getElementById("2").style.display ="block";
			document.getElementById("3Search").style.display ="none";
		
		}
    
    }

document.getElementById("showTabDiv").style.display ="block";
}
}
 
/*
*  Converts XML in String format to Dom format
*/
function parseStringResponse(result)
{
	var xmlDoc;
	if(document.implementation && document.implementation.createDocument) {
	//Mozilla
		var domParser = new DOMParser();
		xmlDoc = domParser.parseFromString(result, "text/xml");
	} else if (window.ActiveXObject){
	//IE
		xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.async="false";
		xmlDoc.loadXML(result);
	}
	return xmlDoc;
}
 function getTableHeaderForJobRecmendation(){
	_lTabelHeader = [{"title":"Position Title","width":"200","align":"left","toolTip":false,"toolTipText":"data","sortable":false,"sort_type":"Text",'display':true},
					 {"title":"Location","width":"200","align":"left","toolTip":true,"toolTipText":"data","sortable":true,"sort_type":"Text",'display':true},
				     {"title":"Company","width":"200","align":"left","toolTip":false,"toolTipText":"data","sortable":false,"sort_type":"Text",'display':true},
					 {"title":"Match","width":"120","align":"center","toolTip":false,"toolTipText":"data","sortable":true,"sort_type":"Text",'display':true},
					 {"title":"Date of Position","width":"160","align":"center","toolTip":false,"toolTipText":"data","sortable":false,"sort_type":"Text",'display':true}
					];
	return _lTabelHeader;

}

function jobRecommendation(){


_TableData = new Array();
 var xmlResponse = document.getElementById("dashbord:recommendList").value;
	var xmlObjDetail=parseStringResponse(xmlResponse);

	var  _lTabelHeader = getTableHeaderForJobRecmendation();
	
	var ctElem = xmlObjDetail.getElementsByTagName("JobRecomends");
	//alert("ct elem is >>>"+ctElem);
	var xmlElem = ctElem[0].getElementsByTagName("JobRecomend");
	
	var htmlStr="";
	successMessage='';

	var total = xmlElem.length;
	
	for(var x=0;x<total; x++) 
	{

		var pk = xmlElem[x].getAttribute("pkId");
		var positionTitle = xmlElem[x].getAttribute("positiontitle");
		var location = xmlElem[x].getAttribute("location");
		var company = xmlElem[x].getAttribute("company");
		var score = xmlElem[x].getAttribute("score");
		var issuedate = xmlElem[x].getAttribute("issuedate");
		var jobId = xmlElem[x].getAttribute("jobId")
		if(jobId == null){
		 title= positionTitle;
		}else{
			 title="<a href='myjobdescription.jsp?jobId="+jobId+"'>"+positionTitle+"</a>";
			
		}
			  		
		if(location=="null"){
		location='-';
		}
		if(company=="null"){
		company='-';
		}
		
		
		if(issuedate=="null"){
		issuedate='-';
		}
		
		
		 _rowData = new Array(title,location,company,'<img src='+score+'>',issuedate);
		_TableData[x] = _rowData

	}
		
		_TableFooter = new Array();
	
		var dataTable = new myTable("cantaner",_lTabelHeader,_TableData,_TableFooter,{'height':'20'});
}

var fromApplication =false;

 function getCompareJobSearch(jobId,application, divId){
	 
	fromApplication = application;
	divID=divId;
 var url = contextPath+"/faces/CompareJobServlet";
 var params ="jobId="+jobId+"&time="+new Date().getTime();
				
var suggestAjax = new myAjax(url, 'get', 'xml', {'params':params,'callBack':'showCompareResult'});
  
 }
function showCompareResult(xmlResponse )
{

	var belowCTC="-";
	var similarCTC="-";
	var aboveCTC ="-";
	var belowExp ="-";
	var similarExp ="-";
	var aboveExp="-";
	var company="-";
	
	var xmlSupplierObj = (xmlResponse);
	var responseElement = xmlSupplierObj.getElementsByTagName("Response");
		if(responseElement.length >0 ){
	var expElement = responseElement[0].getElementsByTagName("EXPERIENCE");
	if(expElement.length>0){
		if(expElement[0].getAttribute("less") && expElement[0].getAttribute("less").length>0)
		belowExp = expElement[0].getAttribute("less")+"%";
		if(expElement[0].getAttribute("more") && expElement[0].getAttribute("more").length>0)
		aboveExp = expElement[0].getAttribute("more")+"%";
		if(expElement[0].getAttribute("same") && expElement[0].getAttribute("same").length>0)
		similarExp = expElement[0].getAttribute("same")+"%";
	}

	var ctcElement = responseElement[0].getElementsByTagName("CTC");
	if(ctcElement.length>0){
		if(ctcElement[0].getAttribute("less") && ctcElement[0].getAttribute("less").length>0)
		belowCTC = ctcElement[0].getAttribute("less")+"%";
		if(ctcElement[0].getAttribute("more") && ctcElement[0].getAttribute("more").length>0)
		aboveCTC = ctcElement[0].getAttribute("more")+"%";
		if(ctcElement[0].getAttribute("same") && ctcElement[0].getAttribute("same").length>0)
		similarCTC = ctcElement[0].getAttribute("same")+"%";
	}
	var companyName = responseElement[0].getElementsByTagName("COMPANY_NAME");
	if(companyName.length>0){
		if(companyName[0].getAttribute("company") && companyName[0].getAttribute("company").length>0)
		company = companyName[0].getAttribute("company");
	}
		}
var html ="";
if(fromApplication){
	html = getHTMlForMyApplication(belowCTC,similarCTC,aboveCTC,belowExp,similarExp,aboveExp,company,divID);
	document.getElementById(divID).innerHTML =html;
	showDiv(divID);

}else{
	html = getHTMl(belowCTC,similarCTC,aboveCTC,belowExp,similarExp,aboveExp,company);
	document.getElementById("applyDetails").innerHTML =html;
    showDiv("applyDetails");

}
fromApplication = false;

}



function getHTMl(belowCTC,similarCTC,aboveCTC,belowExp,similarExp,aboveExp,company){

var html="";
html +="<TABLE cellSpacing='0' cellPadding='0'  border='0'>";
html +="<TBODY>";
html +="<TR>";
html +="<TD class='insidetab_topleft'></TD>";
html +="<TD class='insidetab_topcenterbg'></TD>";
html +="<TD class='insidetab_topright'></TD></TR>";
html +="<TR>";
html +="<TD class='insidetab_midleft'></TD>";
html +="<TD class='insidetab_midcenterbg'>";
html +="<TABLE cellSpacing='0' cellPadding='0' width='100%' border='0'>";
html +="<TBODY>";
html +="<TR>";
html +='<TD align="right"><a href="javascript:hideDiv(\'applyDetails\');" class="textblue">Close</A></TD></TR>';
html +="<TR>";
html +="<TD class='strong'>"+company+"</TD>";
html +="</TR>";
html +="<TR>";
html +="<TD class='strong'>Comparison with Other Applicants.</TD></TR>";
html +="<TR>";
html +="<TD>&nbsp;</TD></TR>";
html +="<TR>";
html +="<TD>";
html +="<TABLE cellSpacing='4' cellPadding='0' width='100%' border='0'>";
html +="<TBODY>";
html +="<TR>";
html +="<TD>&nbsp;</TD>";
html +="<TD class='strong'>Below</TD>";
html +="<TD class='strong'>Similar</TD>";
html +="<TD class='strong'>Above</TD></TR>";
html +="<TR>";
html +="<TD class='strong'>My CTC</TD>";
html +="<TD>"+aboveCTC+"</TD>";
html +="<TD>"+similarCTC+"</TD>";
html +="<TD>"+belowCTC+"</TD></TR>";
html +="<TR>";
html +="<TD class='strong'>My Exp.</TD>";
html +="<TD>"+aboveExp+"</TD>";
html +="<TD>"+similarExp+"</TD>";
html +="<TD>"+belowExp+"</TD></TR>";
html +="</TBODY></TABLE></TD></TR></TBODY></TABLE></TD>";
html +="<TD class='insidetab_midright'></TD></TR>";
html +="<TR>";
html +="<TD class=insidetab_botleft></TD>";
html +="<TD class='insidetab_botcenterbg'></TD>";
html +="<TD class='insidetab_botright'></TD></TR></TBODY></TABLE>";

return html;
}


function getHTMlForMyApplication(belowCTC,similarCTC,aboveCTC,belowExp,similarExp,aboveExp,company,divID){

var html="";
html +="<TABLE cellSpacing='0' cellPadding='0'  border='0'>";
html +="<TBODY>";
html +="<TR>";
html +="<TD></TD>";
html +="<TD></TD>";
html +="<TD></TD></TR>";
html +="<TR>";
html +="<TD></TD>";
html +="<TD>";
html +="<TABLE cellSpacing='0' cellPadding='0' width='100%' border='0'>";
html +="<TBODY>";
html +="<TR>";
html +='<TD align="right"><a href="javascript:hideDiv(\''+divID+'\');" class="textblue">Close</A></TD></TR>';
html +="<TR>";
html +="<TD class='strong'>"+company+"</TD>";
html +="</TR>";
html +="<TR>";
html +="<TD class='strong'>Comparison with Other Applicants.</TD></TR>";
html +="<TR>";
html +="<TD>&nbsp;</TD></TR>";
html +="<TR>";
html +="<TD>";
html +="<TABLE cellSpacing='4' cellPadding='0' width='100%' border='0'>";
html +="<TBODY>";
html +="<TR>";
html +="<TD>&nbsp;</TD>";
html +="<TD class='strong'>Below</TD>";
html +="<TD class='strong'>Similar</TD>";
html +="<TD class='strong'>Above</TD></TR>";
html +="<TR>";
html +="<TD class='strong'>My CTC</TD>";
html +="<TD>"+aboveCTC+"</TD>";
html +="<TD>"+similarCTC+"</TD>";
html +="<TD>"+belowCTC+"</TD></TR>";
html +="<TR>";
html +="<TD class='strong'>My Exp.</TD>";
html +="<TD>"+aboveExp+"</TD>";
html +="<TD>"+similarExp+"</TD>";
html +="<TD>"+belowExp+"</TD></TR>";
html +="</TBODY></TABLE></TD></TR></TBODY></TABLE></TD>";
html +="<TD></TD></TR>";
html +="<TR>";
html +="<TD></TD>";
html +="<TD></TD>";
html +="<TD></TD></TR></TBODY></TABLE>";    
return html;

}  

function openPopUpWindow(pageName)
{
window.open(pageName,"win2", 
	"width=350,height=350,scrollbars=yes,resizable=yes,menubar=no");
}

//Footer JS File Script Comes Here //


function footerBottom() {

            //alert("Hi..");

            var _height=document.body.scrollHeight;
            var _width=document.body.scrollWidth;
            var height = parseInt(_height);
            var width = parseInt(_width);

            //alert("Height --->> "+height);
            //alert("Width --->> "+width);
            //alert("Your resolution is "+screen.width+"x"+screen.height); 

            var footer=document.getElementById('footerClass');
            if (screen.height == 600 && height < 510 && footer!= null){
                        //alert("Inside 600");
                        footer.className='footerClass';
            } 

            else if (screen.height == 768 && height < 600 && footer!= null){
                        //alert("Inside else if 768");
                        footer.className='footerClass';
            }            

            else if (screen.height == 612 && height < 502 && footer!= null){
                        //alert("Inside else if 612");
                        footer.className='footerClass';
            }          

            else if (screen.height == 864 && height < 774 && footer!= null){
                        //alert("Inside else if 800");
                        footer.className='footerClass';
            } 

            else if (screen.height == 720 && height < 630 && footer!= null){
                        //alert("Inside else if 720");
                        footer.className='footerClass';
            }         

            else if (screen.height == 800 && height < 710 && footer!= null){
                        //alert("Inside else if 800");
                        footer.className='footerClass';
            }

			else if (screen.height == 960 && height < 870 && footer!= null){
                        //alert("Inside else if 960");
                        footer.className='footerClass';
            }

			else if (screen.height == 1024 && height < 934 && footer!= null){
                        //alert("Inside else if 1024");
                        footer.className='footerClass';
            }

            else if (footer!= null){
                       //alert("Inside else");
                        footer.className='';
            }

}            // writtn by Shiva end



var sX = 0; var sY = 0; var vX = 0; var vY = 0;
function UpdateCursorPosition(e){ sX = e.pageX; sY = e.pageY;}
function UpdateCursorPositionDocAll(e){ sX = event.clientX; sY = event.clientY;}
if(document.all) { document.onmousemove = UpdateCursorPositionDocAll; }
else { document.onmousemove = UpdateCursorPosition; }
function AssignPosition(d) {
if(self.pageYOffset) {
	vX = self.pageXOffset;
	vY = self.pageYOffset;
	}
else if(document.documentElement && document.documentElement.scrollTop) {
	vX = document.documentElement.scrollLeft;
	vY = document.documentElement.scrollTop;
	}
else if(document.body) {
	vX = document.body.scrollLeft;
	vY = document.body.scrollTop;
	}
if(document.all) {
	sX += vX; 
	sY += vY;
	}
d.style.left = (sX+0) + "px";
d.style.top = (sY+0) + "px";
}
function HideContent(d) {
if(d.length < 1) { return; }
document.getElementById(d).style.display = "none";
}
function ShowContent(d) {
if(d.length < 1) { return; }
var dd = document.getElementById(d);
AssignPosition(dd);
dd.style.display = "block";
}

 function checkSpaceOnKeyPress(Id,value){ 
  var regExp=/[\s]/;
 
  if(value==""){	
	if(!regExp.test(value))
	 {	
		alert("Spaces are not allowed. Please re enter password");
		document.getElementById(Id).focus();
		return false;
	 }
  }
	 return true;
 }
 

function setLocationValues(locVal){
	if(locVal!="" && locVal){
		selectLocValues('locId',locVal);
	}
}

function selectLocValues(listDivId,locVal){
	
	var listDivObj = document.getElementById(listDivId);
	var listObj = listDivObj.getElementsByTagName('input');
	for (var x=0;x<listObj.length ;x++ ){
		if (listObj[x].type != "checkbox") continue;
		var _id = listObj[x].id;
		var hiddenId =_id.substring(0,_id.indexOf(":cgSelected")) +":cgRfnum";
		var hiddenVal = document.getElementById(hiddenId).value;
		if(locVal.indexOf(hiddenVal)!=-1){
			var textId = _id.substring(0,_id.indexOf(":cgSelected")) +":cgName";		
			if(hiddenValue!="")
				hiddenValue+=",";
			hiddenValue+=document.getElementById(textId).innerHTML;
			listObj[x].checked =true;
			totalChecked =totalChecked+1;
			hiddenCounter++;
			if(checkedValue!=""){
			checkedValue =checkedValue+ ","+hiddenVal;
			}else{
			checkedValue =hiddenVal;
			}
		}
	}
	if(hiddenValue!="")
		document.getElementById("locationSelect").innerHTML = hiddenValue;
	else
		document.getElementById("locationSelect").innerHTML ="--Select--";

}

var sX = 0; var sY = 0; var vX = 0; var vY = 0;
function UpdateCursorPosition(e){ sX = e.pageX; sY = e.pageY;}
function UpdateCursorPositionDocAll(e){ sX = event.clientX; sY = event.clientY;}
if(document.all) { document.onmousemove = UpdateCursorPositionDocAll; }
else { document.onmousemove = UpdateCursorPosition; }
function AssignPosition(d) {
if(self.pageYOffset) {
	vX = self.pageXOffset;
	vY = self.pageYOffset;
	}
else if(document.documentElement && document.documentElement.scrollTop) {
	vX = document.documentElement.scrollLeft;
	vY = document.documentElement.scrollTop;
	}
else if(document.body) {
	vX = document.body.scrollLeft;
	vY = document.body.scrollTop;
	}
if(document.all) {
	sX += vX; 
	sY += vY;
	}
d.style.left = (sX+0) + "px";
d.style.top = (sY+0) + "px";
}
function HideContent(d) {
if(d.length < 1) { return; }
document.getElementById(d).style.display = "none";
}
function ShowContent(d) {
if(d.length < 1) { return; }
var dd = document.getElementById(d);
AssignPosition(dd);
dd.style.display = "block";
}

 function checkSpaceOnKeyPress(Id,value){ 
  var regExp=/[\s]/;
 
  if(value==""){	
	if(!regExp.test(value))
	 {	
		alert("Spaces are not allowed. Please re enter password");
		document.getElementById(Id).focus();
		return false;
	 }
  }
	 return true;
 }
 

//-------------------get object of given id based on given object container -----------------------
function obj$(i,d){
	var d = d || document;
	return d.getElementById(i);
}
//---------------- display object based on given object id --------------------------
function show$(i){
	var o;
	if(typeof(i)=="string") o = obj$(i); else if(typeof(i)=="object") o = i;
	if (o){
		o.style.display='block';
		o.style.visibility='visible';
	}
}
//--------------- hide object based on given object id---------------------------
function hide$(i){
	var o;
	if(typeof(i)=="string") o = obj$(i); else if(typeof(i)=="object") o = i;
	if (o){
		o.style.display='none';
		o.style.visibility='hidden';
	}
}
//--------------- toggle display based on given object id ---------------------------
function toggle$(i){
	var o;
	if(typeof(i)=="string") o = obj$(i);
	if(typeof(i)=="object") o = i;
	if (o){
		if(o.style.display.toLowerCase()=='none' || o.style.visibility.toLowerCase()=='hidden'){
			show$(i);
		} else {
			hide$(i);
		}
	}
}
//------------- set value in the given object id-----------------------------
function setValue$(i,v){
	if(typeof(i)=='string') if(obj$(i)) obj$(i).value=v;
	else if(typeof(i)=='object') i.value = v;
}
//---------------- get value of given object id--------------------------
function getValue$(i){
	if(typeof(i)=='string'){ 
		if(obj$(i)) return (obj$(i).value+"");
	}else if(typeof(i)=='object') return (i.value+"");
	return null;
}

//------------- set innerHTML in the given object id-----------------------------
function setInnerHTML$(i,v){
	if(typeof(i)=='string') 
		obj$(i).innerHTML= v; 
	else if(typeof(i)=='object') 
		i.innerHTML= v;
}
//---------------- get innerHTML of given object id--------------------------

function getInnerHTML$(i){
	if(typeof(i)=='string') 
		return obj$(i).innerHTML; 
	else if(typeof(i)=='object') 
		return i.innerHTML;
	return null;
}


// to get x,y position of an object
function getObjectPos$(obj){
	var pos = {x: obj.offsetLeft||0, y: obj.offsetTop||0};
	while(obj = obj.offsetParent) {
		pos.x += obj.offsetLeft||0;
		pos.y += obj.offsetTop||0;
	}
	return pos;
}
// to get size of the window
function getWindowSize$(){
	var size = {w:0,h:0};
	//IE
	if(!window.innerWidth){  ////strict mode
		if(!(document.documentElement.clientWidth == 0)){
			size.w = document.documentElement.clientWidth;
			size.h = document.documentElement.clientHeight;
		} else {  ////quirks mode
			size.w = document.body.clientWidth;
			size.h = document.body.clientHeight;
		}
	}else { //w3c
		size.w = window.innerWidth;
		size.h = window.innerHeight;
	}
	return size;
}

// to get object size
function getObjectSize$(e) {
	var size = {w:0, h:0};
	size.w = e.offsetWidth;
	size.h = e.offsetHeight;
	return size;
}

/*To Resize images*/
function ResizeImage()
{
  var maxheight = 150;
  var maxwidth = 150;
  var imgs = document.getElementsByTagName("img");
  for ( var p = 0; p < imgs.length; p++ )
  {
    if ( imgs[p].getAttribute("dir") == "adimage" )
    {
      var w = parseInt( imgs[p].width );
      var h = parseInt( imgs[p].height );
      if ( w > maxwidth )
      {
        h = ( maxwidth / w ) * h;
        w = maxwidth;
        imgs[p].height = h;
        imgs[p].width = w;
      }
      if ( h > maxheight )
      {
        imgs[p].width = ( maxheight / h ) * w;
        imgs[p].height = maxheight;
      }
    }
  }
}