
function updatenote(recruiterid,persid)
{

  if (window.XMLHttpRequest)
  {
    // code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
  }
  else
  { 
    // code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }

  recruiterid = encodeURIComponent(recruiterid);
  persid = encodeURIComponent(persid);

  if(document.getElementById('textarea'+persid))
  {
   mynote = document.getElementById('textarea'+persid).value;
  } else {
   mynote = '';
  }
  mynote = encodeURIComponent(mynote);

  xmlhttp.open("GET","updatenote.php?recruiterid=" + recruiterid + '&persid=' + persid + '&note=' + mynote ,false);

    
  xmlhttp.send(null);

  //window.alert(xmlhttp.responseText);

}

// This function would be a replacement for updatenote()
function updatenote2(recruiterid,persid,type)
{

  if (window.XMLHttpRequest)
  {
    // code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
  }
  else
  {
    // code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }

  var recruiterid = encodeURIComponent(recruiterid);
  var persid = encodeURIComponent(persid);

  if(document.getElementById('textarea'+persid+'_'+type))
  {
   mynote = document.getElementById('textarea'+persid+'_'+type).value;
  } else {
   mynote = '';
  }

  var mynote = encodeURIComponent(mynote);
  var type = encodeURIComponent(type);

  var url = "updatenote.php?recruiterid=" + recruiterid + '&persid=' + persid + '&note=' + mynote+'&type=' + type;

  xmlhttp.open("GET", url ,false);

  xmlhttp.send(null);

  //window.alert(xmlhttp.responseText);

}

function updatebookmark(bookmarkid,folderid)
{

  if (window.XMLHttpRequest)
  {
    // code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
  }
  else
  { 
    // code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }

  bookmarkid = encodeURIComponent(bookmarkid);
  folderid = encodeURIComponent(folderid);

  xmlhttp.open("GET","updatebookmark.php?bookmarkid=" + bookmarkid + '&folderid=' + folderid,false);

    
  xmlhttp.send(null);

//  window.alert(xmlhttp.responseText);

}


function get_folder_list(recruiterid)
{
 
  if (window.XMLHttpRequest)
  {
    // code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
  }
  else
  { 
    // code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }

  recruiterid = encodeURIComponent(recruiterid);

  xmlhttp.open("GET","get_folder_list.php?recruiterid=" + recruiterid,false);

    
  xmlhttp.send(null);

  window.alert(xmlhttp.responseText);

}

function HideContent(d) 
{
  document.getElementById(d).style.display = "none";
}

function ShowContent(d) 
{
  document.getElementById(d).style.display = "block";
}

function ReverseDisplay(d) 
{
  if(document.getElementById(d).style.display == "none") 
  { 
    document.getElementById(d).style.display = "block"; 
  }
  else 
  { 
    document.getElementById(d).style.display = "none"; 
  }
  
  //document.getElementById('tabpreview').style.display = "none"; 
 
}

function ReverseDisplay3(d) 
{
  if(document.getElementById(d).style.display == "none") 
  { 
    document.getElementById(d).style.display = "block"; 
  }
  else 
  { 
    document.getElementById(d).style.display = "none"; 
  }
  
  document.getElementById('tabpreview').style.display = "none"; 
 
}

// do_not_send_email by default is not set so it would evaluate to false
function quickConnect(name,rip_fld_name,rip_fld_val,do_not_send_email)
{
 var mes = "Quick Connect lets you quickly and easily send a connection request to another community member."
 if(do_not_send_email)
 {
  mes += " After you click OK, the connection request will be placed into the system asking to create a connection.\n\n"
 } else {
  mes += " After you click OK, an e-mail will be sent asking to create a connection.\n\n"
 }
 mes += "Are you sure you want to send a quick connection request to " + name + "?"
 var rip_fld;
 if(confirm(mes))
 {
  var url;
  if('rrpiptoo2'===rip_fld_name)
  {
   rip_fld = 'rrpiptoo';
   url = "/makecontacte.php?kda=" + Math.round(Math.random(100000000)) // sent by jobseeker to recruiter
  } else if('rrpiptoo'===rip_fld_name) {
   rip_fld = 'rpiptoo';
   url = "/makecontacte.php?user=recruiter"; // sent by recruiter to jobseeker
  } else if('rrpiptoo3'===rip_fld_name) {
   rip_fld = 'rrpiptoo';
   url = "/makecontacte.php?user=recruiter"; // sent by recruiter to recruiter
  } else {
   rip_fld = 'rpiptoo';
   url = "/makecontacte.php"; // sent by jobseeker to jobseeker
  }
	var currTime=new Date();
  var param = 'sendmail=sendmail&method=quickconnect&' + rip_fld + '=' + encodeURIComponent(rip_fld_val) + '&custommessage=' + encodeURIComponent('') + '&time=' + currTime.getTime();
  
 		$.ajax({
				url:	url,
				data:	param,
				type:	'POST',
				cache: false,
				success:	function(data)
				{
					//alert(data);
					if(data=='1')
					{
						alert("You have exceeded your connection request for the day");
					}
					else if(data=='2')
					{
						alert("You have exceeded your 25 connection request for the month");
					}
					else
					{
						
          				refreshNotInterested();
          				alert('The connection request has been sent');
					}
				}
			});
	/*$.post(
         url,
         param,
         function(data){
          refreshNotInterested();
          alert('The connection request has been sent');
         }
        );*/
	 }
}

function quickConnectDisabled(name)
{
 mes = "Sorry, " + name + " has connection requests disabled.";
 alert(mes);
}

function sendMessageDisabled(name)
{
 mes = "Sorry, " + name + " does not wish to receive e-mail communications.";
 alert(mes);
}

refreshNotInterested = function()
{
 if(document.getElementById('popup_dialog_content'))
 {
  $.ajax({
   url: 'ajax_popup_dialog_content.php',
   async: true,
   success: function(data){
    $("#popup_dialog_content").html(data);
   }
  });
 } // end if(document.getElementById('popup_dialog_content'))
 if(document.getElementById('ymn_box_content'))
 {
  $.ajax({
   url: 'ajax_ymn_content.php',
   async: true,
   success: function(data){
    $("#ymn_box_content").html(data);
    ymn_links_bind();
   }
  });
 } // end if(document.getElementById('ymn_box_content'))
}

//sk: 13 Feb 2012: added the default argument to the function
function liveSearchEmpty(txt_search)
{
  if(true===ls_disable_ajax_loader)
  {
   return false;
  }

  if(!txt_search)
  {
   var txt_search = 'txt_search';
  }

  var result = true;
  if(document.getElementById(txt_search))
  {
   var temp = $('#' + txt_search).val();
   if(temp.length>=2 && 'i.e. Chris Smith or football Chicago or Amazon.com'!=temp)
   {
    result = false;
    ls_disable_ajax_loader = true;
   }
  }

  return result;
}
