window.onload = loadJobs;
var xmlDoc;
		   var xslt;
           var xsldoc;
           
function loadJobs(fileName)
{
//alert("hi");
if (document.implementation && document.implementation.createDocument)
 {
		xmlDoc = document.implementation.createDocument("", "", null);
		xmlDoc.load(fileName);
		
	}
    // MSIE uses ActiveX
	else if (window.ActiveXObject)
	 {
		xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0");
		xmlDoc.async = "false";
		xmlDoc.load(fileName);
	} 


}

function loadXSLTs(fileName)
{
//WScript.Echo("You are here");
if (document.implementation && document.implementation.createDocument)
 {
		xsldoc = document.implementation.createDocument("", "", null);
		xslt= document.implementation.createDocument("", "", null);
		//xmlDoc.load(fileName);
		
	}
    // MSIE uses ActiveX
	else if (window.ActiveXObject)
	 {
		xslt= new ActiveXObject("Msxml2.XSLTemplate.3.0");
		xsldoc = new ActiveXObject("Msxml2.FreeThreadedDOMDocument.3.0");
	} 
	       xsldoc.async = false;
           xsldoc.load("job.xslt");
}

function showTable()
{
alert("showTable")
document.write("<table border=0>");
	var x=xmlDoc.getElementsByTagName("jobs");
for (var i=0;i<x.length;i++)
{ 
document.write("<tr>");
document.write("<td>");
document.write(
x[i].getElementsByTagName("Descripiton")[0].childNodes[0].nodeValue);
document.write("</td>");

document.write("<td>");
document.write(
x[i].getElementsByTagName("Experiance")[0].childNodes[0].nodeValue);
document.write("</td>");
document.write("</tr>");
}
document.write("</table>");

}
	


function display()
{
alert("display");
Description=
(x[i].getElementsByTagName("Descripiton")[0].childNodes[0].nodeValue);
year=
(x[i].getElementsByTagName("Experiance")[0].childNodes[0].nodeValue);

xmlDoc.getElementById("show").innerHTML=txt;
}
	
function next()
{
alert("Next");
if (i<x.length)
  {
  i++;
  display();
  }
}

function previous()
{
alert("previous");
if (i>0)
  {
  i--;
  display();
  }
} 

function getFirstChild(inode)
{
  x = inode.firstChild;
 // alert("Node Type:" + x.nodeType);
  
  while(x.nodeType != 1)
  {
     x = x.nextSibling;
  }
  return x;
}

function getNextSibling(iNode)
{
   x = iNode.nextSibling;
   document.getElementById("ShowmeJobs").innerHTML+=x.tagName+" = "+ x.childNodes[0].nodeValue +"<br />";
   while(x.nodeType != 1)
   {
      x = iNode.nextSibling;
   document.getElementById("ShowmeJobs").innerHTML+=x.tagName+" = "+ x.childNodes[0].nodeValue +"<br />";
   }
}

function searchJobs(JobDescription)
	{
	//alert("hihi");
	  var NodetoFind;
	  var JobInfo;
	  var jb;
	  var i;
	  var res;
	  var firstNode;
	  var j;
	  var mynode;
	  var xsl;      
	  var ex;
	   var xslproc;
	   var resultDocument;
       if(!xmlDoc)
	       {
	       loadJobs("Careers.xml");
	       }		  
		   //var xslt = new ActiveXObject("Msxml2.XSLTemplate.3.0");
           //var xsldoc = new ActiveXObject("Msxml2.FreeThreadedDOMDocument.3.0");
          // xsldoc.async = false;
           //xsldoc.load("job.xslt");
	
   if((!xslt) || (!xsldoc)) 
   {
      loadXSLTs("job.xslt");
   }
  document.getElementById("ShowmeJobs").innerHTML = ""; 
 if (document.implementation && document.implementation.createDocument)
 {
   xslproc=new XSLTProcessor();
 xslproc.importStylesheet(xsldoc);
 
  xslproc.setParameter(null,"jobId",JobDescription);
 resultDocument2 = xslproc.transformToFragment(xmlDoc,document);

  document.getElementById("ShowmeJobs").appendChild(resultDocument2);
 }
 else
 {
  if (xmlDoc.parseError.errorCode != 0) {
      var myErr = xmlDoc.parseError;
      WScript.Echo("You have error " + myErr.reason);
   } else {
		  
           xslt.stylesheet = xsldoc;	
			xslproc =  xslt.createProcessor();
			 xslproc.input =xmlDoc;	
             xslproc.addParameter("jobId",JobDescription);
            xslproc.transform();
			document.getElementById("ShowmeJobs").innerHTML = xslproc.output;
			  }
}
}
	
	
	
