<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
							  xmlns:msxsl="urn:schemas-microsoft-com:xslt"
                			  xmlns:user="http://www.usa800.net">
	
	<xsl:output method="xml" indent="yes"/>
	<msxsl:script language="javascript" implements-prefix="user">
  	<![CDATA[

	// Accepts string of delimited data and requested question, returns associated answer
	  	
	    function getAnswer(thisString,whatQuestion)
		{
		
		var singleQuestion = "";
	    var singleAnswer = "";
		var singleQuestionArray = "";
        var singleQandA = myReplace(thisString,'; ',';');
		singleQandA = singleQandA.split(';');
		
		for (var i=0; i<singleQandA.length; i++)
		{   
		   singleQuestionArray = singleQandA[i].split('-');
		   if (singleQuestionArray.length > 1)
		   {
		       singleQuestion = singleQuestionArray[0];
		   	   if (singleQuestion == whatQuestion)
			   {
			        singleAnswer = singleQuestionArray[1];
					break;
			   }
		   }   
		}  		
	   	return singleAnswer;
	   	}
      
	  // Accepts string of delimited data and requested question, returns associated answer in elements for xml
	  	
	    function getAnswerInXml(thisString)
		{
		var singleQuestion = "";
	    var singleAnswer = "";
		var singleQuestionArray = "";
        var singleQandA = myReplace(thisString,'; ',';');
		singleQandA = singleQandA.split(';');
		var xmlResults = "";
		  
		 for (var i=0; i<singleQandA.length; i++)
		 {   
		   singleQuestionArray = singleQandA[i].split('-');
		   if (singleQuestionArray.length > 1)
		   {
		       singleQuestion = singleQuestionArray[0];
			   singleAnswer = singleQuestionArray[1];
			   xmlResults += "<IDResponse QuestionID=\"" + singleQuestion + "\" AnswerID=\"" + singleAnswer + "\"/>" 
		   }   
		 }  		
	   	 return xmlResults;
       	}
	
	  
        // function to create xml datatype
      	var xml = new ActiveXObject("MSXML2.DOMDocument.4.0");
   		xml.async=false;
   		function create_nodelist(myString)
   		{
     		if(xml)
			{
      		 if(xml.loadXML(myString))
			 {
         	 var x = xml.documentElement;
         		if(x)
				return x.selectNodes("/");
         		else
				return x;
        	 }
        	else
				return xml.documentElement;
     	    }
     		else
         		return 0;
      	}

		//receives string, sends to create nodes xml, sends to create xml datatype, returns xml node
    	function makeXml(myString)
		{
		    var myXml = getAnswerInXml(myString);
      		return create_nodelist(myXml);
     	}
	  		
  	]]>

	</msxsl:script>
	   <xsl:template match="/">

	       <xsl:variable name="edQuestions" select="string(//variable[@name='lookupCourse'])"/>
           <xsl:variable name="genQuestions" select="string(//variable[@name='lookupGeneral'])"/>

		   <EducationConnectionLeads>
		       <LeadSubjectSelections>
				    <Selection>
					   <xsl:attribute name="InterestAreaID">
					   <xsl:value-of select="user:getAnswer($edQuestions,'area of interest')"/>
					   </xsl:attribute>

					   <xsl:attribute name="SubjectCategoryID">
					   <xsl:value-of select="user:getAnswer($edQuestions,'course')"/>
					   </xsl:attribute>
					</Selection>
				 </LeadSubjectSelections>
				 <LeadSurvey>
				       <xsl:value-of select="user:makeXml($genQuestions)"/>
				 </LeadSurvey>
		   </EducationConnectionLeads>
	   </xsl:template>
    </xsl:stylesheet><!-- Stylus Studio meta-information - (c) 2004-2006. Progress Software Corporation. All rights reserved.
<metaInformation>
<scenarios ><scenario default="yes" name="Scenario1" userelativepaths="yes" externalpreview="no" url="edConnectCallXml.xml" htmlbaseurl="" outputurl="" processortype="internal" useresolver="yes" profilemode="0" profiledepth="" profilelength="" urlprofilexml="" commandline="" additionalpath="" additionalclasspath="" postprocessortype="none" postprocesscommandline="" postprocessadditionalpath="" postprocessgeneratedext="" validateoutput="no" validator="internal" customvalidator=""/></scenarios><MapperMetaTag><MapperInfo srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no" ><SourceSchema srcSchemaPath="edConnectCallXml.xml" srcSchemaRoot="call_data" AssociatedInstance="" loaderFunction="document" loaderFunctionUsesURI="no"/></MapperInfo><MapperBlockPosition><template match="/"></template></MapperBlockPosition><TemplateContext></TemplateContext><MapperFilter side="source"></MapperFilter></MapperMetaTag>
</metaInformation>
-->