﻿
/*
     Ajax
*/
     //Where are the ajax getter and setter asp files located?
     var ajax_source_url = 'http://technical.nycor.net/ajax/';
     var http_request = false;
     var waiting_html_str = '<p>&nbsp;</p><p><img src="/images/spinner.gif" height="24" width="24" /> <strong>Sending and Receiving Data...</strong></p>';

//----------------------------------------------------
//   getJobsByDiscipline
     function getJobsByDiscipline(data_str)
     {
          var page_section                                  =    'job-listing-container';
          var url                                           =    ajax_source_url + 'getJobListingsByDiscipline.asp';
          var poststr                                       =    "disciplines="   + encodeURI(data_str)

          postData(url, poststr, page_section);
          document.getElementById(page_section).innerHTML   =    waiting_html_str;
     }


//----------------------------------------------------
//   getQuickLinksByCompanyId
     function getQuickLinksByCompanyId(company_id)
     {
          var page_section                                  =    'quick-links-container';
          var url                                           =    ajax_source_url + 'getQuickLinksByCompanyId.asp';
          var poststr                                       =    "company_id="   + encodeURI(company_id)

          postData(url, poststr, page_section);
          document.getElementById(page_section).innerHTML   =    waiting_html_str;
     }

//---------------------------------------------------
     function postData(url, parameters, return_section) {
          http_request = false;
          if (window.XMLHttpRequest)
          {
               // Mozilla, Safari,...
               http_request = new XMLHttpRequest();
               if (http_request.overrideMimeType) {
         	          // set type accordingly to anticipated content type
                    //http_request.overrideMimeType('text/xml');
                    http_request.overrideMimeType('text/html');
               }
          } else if (window.ActiveXObject){
               // IE
               try {
                    http_request = new ActiveXObject("Msxml2.XMLHTTP");
               } catch (e) {
                    try {
                         http_request = new ActiveXObject("Microsoft.XMLHTTP");
               } catch (e) {}
          }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }

      http_request.onreadystatechange=function()
          {
               if(http_request.readyState==4)
               {
                   document.getElementById(return_section).innerHTML = http_request.responseText;
               } else {
                    document.getElementById(return_section).innerHTML= '<i style="color:#ff0000"></i>';

               }
          }
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
   }


     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;
     }

//---------------------------------------------------

