<?xml version="1.0" encoding="utf-8"?>

<!-- This file must be saved in UTF8 encoding with proper UTF8 byte order mark -->

<xslt:stylesheet version="1.0" xmlns:xslt="http://www.w3.org/1999/XSL/Transform">
  <xslt:output method="html" version="1.0" encoding="utf-8"/>

  <!-- Helper functions for generating links, javascript and css declarations -->
  <xslt:include href="common.xslt"/>
  
  <xslt:template match="/">
    <xslt:text disable-output-escaping="yes">&lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;</xslt:text>
    <html>
      <head>
	  <meta name="msapplication-window" content="width=800;height=600"/>
        <script type="text/javascript">
          <xslt:call-template name="javascript"/>
        </script>
        <xslt:call-template name="buildCSS"/> 
      </head>
      <body minwidth="0" minheight="0" maxwidth="0" maxheight="0" debug="1" allcontacts="0">
		<table cellpadding="0" cellspacing="0" width="100%" class="maintable">
			<tr>
				<td valign="top">
					<table cellpadding="0" cellspacing="0">
						<xslt:call-template name="Company">
							<xslt:with-param name="Company" select="XSLT/Contact/Company"/>
							<xslt:with-param name="Department" select="XSLT/Contact/Department"/>
						</xslt:call-template>
						<xslt:call-template name="RemoteContactInformation">
							<xslt:with-param name="Businessstreet" select="XSLT/Contact/BusinessAddressStreet"/>
							<xslt:with-param name="Businesscity" select="concat(XSLT/Contact/BusinessAddressPostalCode, ' ', XSLT/Contact/BusinessAddressCity)"/>
							<xslt:with-param name="Businesscountry" select="concat(XSLT/Contact/BusinessAddressState, ' ', XSLT/Contact/BusinessAddressCountry)"/>
							<xslt:with-param name="Privatestreet" select="XSLT/Contact/PrivateAddressStreet"/>
							<xslt:with-param name="Privatecity" select="concat(XSLT/Contact/PrivateAddressPostalCode, ' ', XSLT/Contact/PrivateAddressCity)"/>
							<xslt:with-param name="Privatecountry" select="concat(XSLT/Contact/PrivateAddressState, ' ', XSLT/Contact/PrivateAddressCountry)"/>
						</xslt:call-template>
					</table>
				</td>
				<xslt:if test ="normalize-space(XSLT/General/PicturePresenceHeight) = '16' and XSLT/Contact/binarydata/jpegPhoto">
				  <td align="right">
					<span style="display:none;">PCE-2562</span>
					<xslt:element name="img">
					  <xslt:attribute name="src">RemoteContact!jpegPhoto</xslt:attribute>
					</xslt:element>
				  </td>
				</xslt:if>
			</tr>
			<xslt:if test="normalize-space(XSLT/Callparams/CallOutbound) = 0">
			<tr><td> <div id="ucid"> </div> </td></tr>
			<tr>
			<td>
				<div id="output" style="color:black"> 
					<script type="text/javascript">
						var output, ucid
						var strUid = new String
						var strParams = new String
						var objHTTP, strResult;
						strUid = '<xslt:value-of select="XSLT/Callparams/DataMap/globallyUniqueCallLinkageID"/>';
						ucid = document.getElementById("ucid");
						ucid.innerText = strUid;
						strParams = "ucid=" + strUid;
						output = document.getElementById("output");
						objHTTP = new ActiveXObject('Microsoft.XMLHTTP');
						objHTTP.open('GET',"http://172.31.129.108:1099/ebay/query.cgi?" + strParams,false);
						objHTTP.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
						objHTTP.send(); 
						strResult = objHTTP.responseText;
						output.innerHTML = strResult;
					</script>
				</div>
				</td>
			</tr>
			</xslt:if>
			
			<xslt:if test="normalize-space(XSLT/Callparams/CallOutbound) = 1">
			<tr><td> <div id="CaseNumber"> </div> </td></tr>
			<tr><td>
				<div id="output" style="color:black"> 
					<script type="text/javascript">
						var output, CaseNumber
						var strUid = new String
						var strParams = new String
						var objHTTP, strResult;
						strUid = '<xslt:value-of select="XSLT/Contact/CustomerID"/>';
						CaseNumber = document.getElementById("CaseNumber");
						CaseNumber.innerText = strUid;
						strParams = "CaseNumber=" + strUid;
						//alert (strUid);
						output = document.getElementById("output");
						objHTTP = new ActiveXObject('Microsoft.XMLHTTP');
						objHTTP.open('GET',"http://172.31.129.108:1099/ebay/outgoingcalls/query.cgi?" + strParams,false);
						objHTTP.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
						objHTTP.send(); 
						strResult = objHTTP.responseText;
						output.innerHTML = strResult;
					</script>
				</div>
			</td></tr>
			</xslt:if>
			
			<tr>
				<td>
				<script type="text/javascript"> 	
					</script>
				</td>
			</tr>
          <!-- Web link example -->
          <!--
            <xslt:if test="normalize-space(XSLT/Contact/WebPageURL) != ''">
              <tr><td>
              <xslt:call-template name="buildlink">
                <xslt:with-param name="linkadress" select="XSLT/Contact/WebPageURL"/>
                <xslt:with-param name="linktext" select="XSLT/Contact/WebPageURL"/>
                <xslt:with-param name="target">_blank</xslt:with-param>
              </xslt:call-template>
              </td></tr>
            </xslt:if>
          -->  

          <!-- Mail link example 1 -->
          <!--
            <xslt:if test="normalize-space(XSLT/Contact/EMail) != ''">
              <tr><td>
              <xslt:call-template name="buildmaillink">
                <xslt:with-param name="linktext" select="XSLT/Contact/EMail"/>
                <xslt:with-param name="recipient" select="XSLT/Contact/EMail"/>
                <xslt:with-param name="subject">Thank you for calling...</xslt:with-param>
              </xslt:call-template>
              </td></tr>
            </xslt:if>
          -->  

          <!--
          <tr><td>
          <xslt:call-template name="buildmaillink">
            <xslt:with-param name="linktext">Callback Email</xslt:with-param>
            <xslt:with-param name="recipient"></xslt:with-param>
            <xslt:with-param name="carboncopy"></xslt:with-param>
            <xslt:with-param name="blindcarboncopy"></xslt:with-param>
            <xslt:with-param name="subject" select="concat('Request for callback to ',XSLT/Contact/DisplayName)"/>
            <xslt:with-param name="encoding">ansi</xslt:with-param>
            <xslt:with-param name="body">
              <xslt:if test="normalize-space(XSLT/Contact/DisplayName) != ''">
                <xslt:value-of select="concat(XSLT/Contact/DisplayName, '\n')"/>
              </xslt:if>          
             <xslt:if test="normalize-space(XSLT/Contact/CurrentNumberSC) != ''">
                <xslt:value-of select="concat(XSLT/Contact/CurrentNumberSC, '\n')"/>
              </xslt:if>
              <xslt:if test="normalize-space(XSLT/Contact/BusinessAddressStreet) != ''">
                <xslt:value-of select="concat(XSLT/Contact/BusinessAddressStreet, '\n')"/>
              </xslt:if>
              <xslt:if test="normalize-space(XSLT/Contact/BusinessAddressPostalCode) != ''">
                <xslt:value-of select="XSLT/Contact/BusinessAddressPostalCode"/>
              </xslt:if>
              <xslt:if test="normalize-space(XSLT/Contact/BusinessAddressCity) != ''">
                <xslt:value-of select="concat(' ', XSLT/Contact/BusinessAddressCity)"/>
              </xslt:if>
              <xslt:if test="normalize-space(XSLT/Contact/BusinessAddressCountry) != ''">
                <xslt:value-of select="concat(' ', XSLT/Contact/BusinessAddressCountry)"/>
              </xslt:if>
            </xslt:with-param>
          </xslt:call-template>
          </td></tr>
          -->

          <!-- Accessing custom call data example -->
          <!--
            <xslt:if test="normalize-space(XSLT/Callparams/DataMap/IVRCustomerNumber) != ''">
              <tr><td>
                <xslt:value-of select="XSLT/Callparams/DataMap/IVRCustomerNumber"/>
              </td></tr>
            </xslt:if>
          -->
         </table>
      </body>
    </html>
  </xslt:template>
 
  <xslt:template name="Company">
    <xslt:param name="Company"/>
    <xslt:param name="Department"/>
    <xslt:if test="$Company != ''">
      <tr><td class="boldfont"><xslt:value-of select="concat($Company, ' ', $Department)"/></td></tr>
    </xslt:if>
  </xslt:template>
      
 <xslt:template name="RemoteContactInformation">
    <xslt:param name="Businessstreet"/>
    <xslt:param name="Businesscity"/>
    <xslt:param name="Businesscountry"/>
    <xslt:param name="Privatestreet"/>
    <xslt:param name="Privatecity"/>
    <xslt:param name="Privatecountry"/>
    <xslt:choose>
      <xslt:when test="normalize-space($Businessstreet) = '' and normalize-space($Privatestreet) = ''">
        <xslt:choose>
          <xslt:when test="normalize-space($Businesscity) != ''">    
            <tr><td><xslt:value-of select="$Businesscity"/> - <xslt:value-of select="$Businesscountry"/></td></tr>
          </xslt:when>
          <xslt:when test="normalize-space($Privatecity) != ''">    
            <tr><td><xslt:value-of select="$Privatecity"/> - <xslt:value-of select="$Privatecountry"/></td></tr>       
          </xslt:when>
        </xslt:choose>
      </xslt:when>
      <xslt:when test="normalize-space($Businesscity) != ''">    
        <tr><td><xslt:value-of select="$Businessstreet"/></td></tr>
        <tr><td><xslt:value-of select="$Businesscity"/></td></tr>
        <tr><td><xslt:value-of select="$Businesscountry"/></td></tr>       
      </xslt:when>
      <xslt:when test="normalize-space($Privatecity) != ''">    
        <tr><td><xslt:value-of select="$Privatestreet"/></td></tr>
        <tr><td><xslt:value-of select="$Privatecity"/></td></tr>
        <tr><td><xslt:value-of select="$Privatecountry"/></td></tr>       
      </xslt:when>
    </xslt:choose>
  </xslt:template>
</xslt:stylesheet>