﻿function displayjob(xml) {
	     var html="";
		 if(typeof xml == "string"){
			if( window.DOMParser ){
        	   xml = (new DOMParser()).parseFromString(xml, 'text/xml');
           }else if( window.ActiveXObject && window.GetObject ) {
        	   var dom = new ActiveXObject( 'Microsoft.XMLDOM' );
               dom.loadXML( xml );
               xml = dom;
           }
		 }
		 var jobhtml='<div class="border_l_r yellow_th"><div class="floatLeft width_80 pLeft_20 col_fff">Date Posted</div><div class="floatLeft width_106 pLeft_10 col_fff">Work Location</div><div class="floatLeft width_148 pLeft_60 col_fff">Position</div><div class="floatLeft pLeft_20 col_fff">Job Function</div></div>';
		 var recordcount = $(xml).find('recordCount').text();
		 if (recordcount== "0")
		 {
			html="There are no positions currently available in this field within the company. Please try another search or check back later. " ;
		 }
		 else
		 {
			   $(xml).find('searchResult').each(function(){   
					var linkurl="";
					var $obj = $(this); 									 
					var index = $obj.attr("index");
					var jobdate = $obj.find('datePosted').text();
					var worklocation = $obj.find('workLocation').text();
					var position = $obj.find('position').text();
					var jobfunction = $obj.find('jobFunction').text();
					var guid = $obj.find('guid').text();
					var temlink=$obj.find('url').text();
					var param =$obj.find('url').attr("parameterName");
					var target =$obj.find('url').attr("action");
					var para=param+"="+guid;
					linkurl=temlink+"?"+para;
					if ( index%2 ==0)
					{
						jobhtml+='<div class="border_l_r p_t_b_5 tr_item_lastnews_grey"><div class="floatLeft width_100 pLeft_10">'+ jobdate+'</div><div class="floatLeft width_106 pLeft_10">'+worklocation+'</div><div class="floatLeft width_208 pLeft_10"><a href="'+linkurl+'" target="'+target+'">'+position+'</a></div><div class="floatLeft width_121 pLeft_10">'+jobfunction+'</div><div class="clear"></div></div>';
					}
					else
					{
							jobhtml+='<div class="border_l_r p_t_b_5"><div class="floatLeft width_100 pLeft_10">'+ jobdate+'</div><div class="floatLeft width_106 pLeft_10">'+worklocation+'</div><div class="floatLeft width_208 pLeft_10"><a href="'+linkurl+'" target="'+target+'">'+position+'</a></div><div class="floatLeft width_121 pLeft_10">'+jobfunction+'</div><div class="clear"></div></div>';
						
					}
														 														
				});
			 html=jobhtml;
		 }
		  $('#jobresult').append($(html));
}
		
