<!DOCTYPE xsl:stylesheet SYSTEM "http://commons.omniupdate.com/dtd/standard.dtd" >

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
			      xmlns:ou="http://omniupdate.com/XSL/Variables" exclude-result-prefixes="ou" >
 <xsl:output omit-xml-declaration="yes" indent="yes" method="html" />
 <xsl:param name="ou:action" />
 <xsl:param name="isPoll">
<xsl:if test="//ouform">
		<xsl:for-each select="//ouform/elements/element">
		<xsl:if test="./@type = 'input-text'">
			<xsl:if test="(contains(./advanced/node(),'type=poll'))">true</xsl:if>
		</xsl:if>
		</xsl:for-each>
</xsl:if>
</xsl:param>
 
<xsl:template match="/">
<xsl:text disable-output-escaping="yes">&lt;!DOCTYPE html&gt;</xsl:text>
	<html lang="en">
	<head>
		<meta charset="utf-8" />
		<!-- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> -->
		<meta name="viewport" content="width=device-width; initial-scale=1.0" />
		<title>Gallena University - <xsl:value-of select="document/title/node()"/></title>

<xsl:if test="$isPoll='true'">
<style type="text/css">
form input{
			margin: 10px 5px 4px 12px
		}
                .ldp-poll-graph {
  width: 510px;
  position: relative;
  /* right: 78px;*/
}
.ldp-poll-bar-title {
  position: relative;
  /* float: left; */
  width: 250px;
  line-height: 20px;
  margin-right: 17px;
  font-weight: bold;
  /* text-align: right; */
}
.ldp-poll-bar-container {
  position: relative;
  float: left;
  width: 261px;
  height: 10px;
  margin: 0px 0px 20px;
}

.ldp-poll-bar-container div {
 
  height: 20px;
  
    background-color: #FF030D;
    background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(.25, rgba(255, 255, 255, .3)), color-stop(.25, transparent), color-stop(.5, transparent), color-stop(.5, rgba(255, 255, 255, .3)), color-stop(.75, rgba(255, 255, 255, .3)), color-stop(.75, transparent), to(transparent)),
    					-webkit-gradient(linear, 0 100%, 100% 0, color-stop(.25, rgba(255, 0, 102, .2)), color-stop(.25, transparent), color-stop(.5, transparent), color-stop(.5, rgba(255, 0, 102, .2)), color-stop(.75, rgba(255, 0, 102, .2)), color-stop(.75, transparent), to(transparent));
    background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, .3) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .3) 50%, rgba(255, 255, 255, .3) 75%,  transparent 75%, transparent),
    					-webkit-linear-gradient(45deg, rgba(255, 0, 102, .2) 25%, transparent 25%, transparent 50%, rgba(255, 0, 102, .2) 50%, rgba(255, 0, 102, .2) 75%,  transparent 75%, transparent);
    background-image: -moz-linear-gradient(45deg, rgba(255, 255, 255, .3) 25%, transparent 25%,transparent 50%, rgba(255, 255, 255, .3) 50%, rgba(255, 255, 255, .3) 75%, transparent 75%, transparent),
    					-moz-linear-gradient(45deg, rgba(255, 0, 102, .2) 25%, transparent 25%,transparent 50%, rgba(255, 0, 102, .2) 50%, rgba(255, 0, 102, .2) 75%, transparent 75%, transparent);
    background-image: -ms-linear-gradient(45deg, rgba(255, 255, 255, .3) 25%, transparent 25%,transparent 50%, rgba(255, 255, 255, .3) 50%, rgba(255, 255, 255, .3) 75%,transparent 75%, transparent),
    					-ms-linear-gradient(45deg, rgba(255, 0, 102, .2) 25%, transparent 25%,transparent 50%, rgba(255, 0, 102, .2) 50%, rgba(255, 0, 102, .2) 75%,transparent 75%, transparent);
    background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, .3) 25%, transparent 25%,transparent 50%, rgba(255, 255, 255, .3) 50%, rgba(255, 255, 255, .3) 75%,transparent 75%, transparent),
    					-o-linear-gradient(45deg, rgba(255, 0, 102, .2) 25%, transparent 25%,transparent 50%, rgba(255, 0, 102, .2) 50%, rgba(255, 0, 102, .2) 75%,transparent 75%, transparent);
    background-image: linear-gradient(45deg, rgba(255, 255, 255, .3) 25%, transparent 25%,transparent 50%, rgba(255, 255, 255, .3) 50%, rgba(255, 255, 255, .3) 75%,transparent 75%, transparent),
    					linear-gradient(45deg, rgba(255, 0, 102, .2) 25%, transparent 25%,transparent 50%, rgba(255, 0, 102, .2) 50%, rgba(255, 0, 102, .2) 75%,transparent 75%, transparent);


  border-radius: 4px 4px 4px 4px;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset, 0 -2px 0 rgba(0, 0, 0, 0.1) inset, 0 0 10px rgba(255, 255, 255, 0.5) inset, 0 0 0 1px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.2);
  
}
.ldp-poll-bar-container strong {
  position: absolute;
  right: 227px;
  top: 0px;
  overflow: hidden;
  color: #FFF;
}

.ldp-poll-results  {
display:none;
    /*position: relative;*/
    /*top: -218px;*/
   padding-top:5px;
   padding-bottom:5px;
   padding-left:5px;
}
.ldp-poll-results h3{
    color: #4B4B4B;
    font-family: Georgia,"Times New Roman",Times,serif;
    text-rendering: optimizelegibility;
    margin:10px 1px 10px 1px;
}
.ldp-poll-results p{
margin:10px 0px 7px 5px;
}
.ldp-poll-form{
   padding-top:5px;
   padding-bottom:5px;
   padding-left:5px;
}
.ldp-poll-container{
     /*   height:250px; */
     width:272px; 
     min-height:250px;
  padding:5px;
      background: #e5e5e5; /* Old browsers */
      background: -moz-linear-gradient(top, #EEEEEE 0%, #C3CAD4 100%); /* FF3.6+ */
      background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#EEEEEE), color-stop(100%,#C3CAD4)); /* Chrome,Safari4+ */
      background: -webkit-linear-gradient(top, #EEEEEE 0%,#C3CAD4 100%); /* Chrome10+,Safari5.1+ */
      background: -o-linear-gradient(top, #EEEEEE 0%,#C3CAD4 100%); /* Opera11.10+ */
      background: -ms-linear-gradient(top, #EEEEEE 0%,#C3CAD4 100%); /* IE10+ */
      filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#EEEEEE', endColorstr='#C3CAD4',GradientType=0 ); /* IE6-9 */
      background: linear-gradient(top, #EEEEEE 0%,#C3CAD4 100%); /* W3C */
  border-radius: 4px 4px 4px 4px;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset, 0 -2px 0 rgba(0, 0, 0, 0.1) inset, 0 0 10px rgba(255, 255, 255, 0.5) inset, 0 0 0 1px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.2);

}
#ldp-poll input#button{
    margin-left: 5px;
    padding:5px;
    width:68px;
}
.results,.poll-back{
color:#000000;
}
</style>
</xsl:if>
		<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" >
		//comment1
		</script>	
	
	</head>
	<body>
															  <xsl:copy>
								   <xsl:apply-templates select="//content/node()" mode="maincontent" />
								  </xsl:copy>
	</body>
	</html>

</xsl:template>
	
<xsl:template match="processing-instruction('php')" mode="maincontent">
	<xsl:processing-instruction name="php"><xsl:copy-of select="concat(current(),'?')"/></xsl:processing-instruction>
</xsl:template>
	
<xsl:template match="ouform" mode="maincontent">

<!-- LDP FORMS STARTS -->
<xsl:choose>
			<xsl:when test="$isPoll='true'">
			<xsl:variable name="uuid" select="//ouform/@uuid"/>
			<div class="ldp-poll-container">
            <div class="ldp-poll-form">
            
			<form id="ldp-poll" name="ldp-poll" method="post" class="ldpforms">
					<xsl:for-each select="//ouform/elements/element">
					<xsl:if test="./@type = 'input-text'">
							<xsl:if test="./@type = 'input-text'">
							
								 <h3><xsl:value-of select="./default/node()"/></h3>
							</xsl:if>
					</xsl:if>
					<xsl:if test="./@type = 'input-radio'">
					
					<span id="{./@name}" class="none">
							<xsl:variable name="field_name" select="./@name"/>
							<span>
							<xsl:for-each select="./options/option">
								<input type="radio" name="{$field_name}" value="{./@value}" title="{./node()}">
									<xsl:if test="./@selected = 'true'">									
										<xsl:attribute name="checked">checked</xsl:attribute>
									</xsl:if>
								</input><xsl:copy-of select="./node()"/>&nbsp;<br/>
							</xsl:for-each>
							</span>
							<br/>
					</span>
					</xsl:if>
					</xsl:for-each>	
					<input type="hidden" name="polltext" value ="poll_text"/>	
					<input type="hidden" name="type" value ="poll"/>	
					<input type="hidden" name="form_uuid" value ="{$uuid}"/>
					<xsl:if test="not($ou:action='prv')">
						<input type="submit" name="button" id="button" class="submit" value="Submit" />
					</xsl:if>
			</form>		
			<xsl:if test="not($ou:action='prv')">
			<br/><a href="#" class="results" style="color:#000">View Results</a>
			</xsl:if>
            </div>
              <div class="ldp-poll-results">
             
            </div>
          </div>
          
          
          
          
          <script type="text/javascript" charset="utf-8">
			var poll="true";
			var form_id="<xsl:value-of select="$uuid"/>";
 
     		var names="";
  			$('#ldp-poll input:radio').each(function(data){
  			names=$(this).val()+":"+$(this).attr('title')+","+names;
  			});
			var ajax_data="uuid="+form_id+"&amp;response=html"+"&amp;names="+names; 
        
			function animateResults(){
			  $(".ldp-poll-results div").each(function(){
			      var percentage = $(this).next().text();
			      $(this).css({width: "0%"}).animate({width: percentage}, 'slow');});
			}
			function get_results(){
			    $('.ldp-poll-results').html("");
			    $('.ldp-poll-form').fadeOut(5);
			    $('.ldp-poll-results').fadeIn(700);
			      $.ajax({
			        url:"/_resources/php/get_poll.php",
			        data: ajax_data,
			        success:function(data){
			          $(".ldp-poll-results").html(data);
			          $(".ldp-poll-results").append('<a href="#" class="poll-back">Return To Poll</a>');
			          animateResults();
			        }
			        });
			}
			  $(document).ready(function(){
			  
			  $(".results").click(function(){
			      get_results();
			      return false;
			      });
			  $(".ldp-poll-results").delegate(".poll-back","click",function(){
			    $('.ldp-poll-results').hide();
			    $('.ldp-poll-form').fadeIn(700);
			    
			      return false;
			      });
			
			  });
			  
			                
			</script>
          
          		       <script type="text/javascript">
			        $(document).ready(function(){
				 var form_data = $('#ldp-poll').serialize();
				$("#ldp-poll").bind("submit", function() {
			
				 $.ajax({
				  type  : "POST",
				  cache : false,
				  url  : "/_resources/php/ldp/modules/form_test.php",
				  data  : $(this).serialize(),
				  complete: function(){},
				  success: function(data) {
				  $(".spanerror").removeClass("spanerror");$(".errmsg").html("").removeClass("errmsg");
				   var resultObj = jQuery.parseJSON(data);
				   var errC=/[faultcode]+\s:/;
				   var faultCode=errC.exec(resultObj.message);
				   if(resultObj.active == false){
					   if(!faultCode)
					   {
				   	$("#status").removeClass("success");
				   	$("#status").addClass("error");
				   	var dataSet=resultObj.message+"<br/>";
					$.each(resultObj.data, function(i,data){
						var d = data.message;
				      		highlightID="#"+data.name;
				      		$(highlightID).addClass("spanerror");
				      		$(highlightID).find("span").html(data.message).addClass("errmsg");
				      	});
				      	$("#status").html(dataSet);
				      	} //err Code
				      	else
				      	{
				      			var dataSet=resultObj.message+" "+resultObj.data;
				      			$("#status").addClass("error");
				      			$("#status").html(dataSet);
				      	}
				   }
				   else{
				   	$("#status").removeClass("error");
				   	$("#status").addClass("success");
				   	if(!poll){
				   	$("#ldp-poll").remove();
				   	$("#status").html(resultObj.message);
				   	}
				   	else{
				   	get_results();
				   	}
				   		   
				   }
			
				  },
				  error: function(data){
				  	
				  }
				 });
				
				 return false;
				});
			
			
				 });
			        </script>
          
			</xsl:when>
	<xsl:otherwise>


<xsl:if test="//ouform">		
		<!--
	
	Predefined Attributes:
	1.legend : To create a placeholder text inside a form. Format: legend=true;
	2.addclass: To add a class to an element block. Format: addclass=[CLASS NAME];
	3.fieldset_start: Defines the statring block for a fieldset. Format: fieldset_start=true;
	4.fieldset_end: Defines the ending block for a fieldset. Format: fieldset_end=true;
	5.fieldset_label: Defines the label of the fieldset. Format: fieldset_label=[FIELDSET LABEL];
	
	Rules:
	1. Every declaration in the advanced field must be terminated with a semicolon. Eg. legend=true;addclass=form_legend;
	2. Attributes are always lowercase.
	-->
		
		<xsl:variable name="uuid" select="//ouform/@uuid"/>
		<div id="status"></div>
		<form id="form" name="contact-form" method="post" class="ldpforms">
			<xsl:for-each select="//ouform/elements">
				
				<xsl:for-each select="./element">
					
					<xsl:variable name="adv" select="./advanced/node()"/>
					
					<xsl:if test="contains(ou:get-adv($adv,'fieldset_start'),'true')">
						<xsl:text disable-output-escaping="yes">&lt;fieldset&gt;</xsl:text>
						<legend class="none">
							<xsl:attribute name="class">
								<xsl:value-of select="ou:ldp-create-class($adv,'none')"/>
							</xsl:attribute>
							<xsl:value-of select="ou:get-adv($adv,'fieldset_label')"/>
						</legend>
					</xsl:if>
					<xsl:if test="./@type = 'input-text'">
						<xsl:choose>
							<xsl:when test="contains(ou:get-adv($adv,'legend'),'true')">
								<br/>
								<span class="none">
									<xsl:if test="not(contains(ou:get-adv($adv,'addclass'),'false'))">
										<xsl:attribute name="class">
											<xsl:value-of select="ou:ldp-create-class($adv,'none')"/>
										</xsl:attribute>
									</xsl:if>
									<xsl:copy-of select="./default/node()"/>
								</span>
							</xsl:when>
							<xsl:otherwise>
								<span id="{./@name}" class="none">
									<xsl:if test="not(contains(ou:get-adv($adv,'addclass'),'false'))">
										<xsl:attribute name="class">
											<xsl:value-of select="ou:ldp-create-class($adv,'none')"/>
										</xsl:attribute>
									</xsl:if>
									<label for="{concat('id_',./@name)}"><xsl:value-of select="./label/node()"/></label>
									<!-- if the document is HTML5 you can use placeholder attribute eg. placeholder="{./default/node()}" -->
									<input type="text" name="{./@name}" id="{concat('id_',./@name)}" />
								</span>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:if>
					<xsl:if test="./@type = 'textarea'">
						<span id="{./@name}" class="none">
							<xsl:if test="not(contains(ou:get-adv($adv,'addclass'),'false'))">
								<xsl:attribute name="class">
									<xsl:value-of select="ou:ldp-create-class($adv,'none')"/>
								</xsl:attribute>
							</xsl:if>
							<label for="{concat('id_',./@name)}"><xsl:value-of select="./label/node()"/></label>
							<!-- if the document is HTML5 you can use placeholder attribute eg. placeholder="{./default/node()}" -->
							<textarea rows="10" cols="50" name="{./@name}" id="{concat('id_',./@name)}" ></textarea>
						</span>
					</xsl:if>
					<xsl:if test="./@type = 'input-radio'">
						<span id="{./@name}" class="none">
							<xsl:if test="not(contains(ou:get-adv($adv,'addclass'),'false'))">
								<xsl:attribute name="class">
									<xsl:value-of select="ou:ldp-create-class($adv,'none')"/>
								</xsl:attribute>
							</xsl:if>
							<xsl:variable name="field_name" select="./@name"/>
							<span><xsl:value-of select="./label/node()"/></span><br/>
							<xsl:for-each select="./options/option">
								<input type="radio" name="{$field_name}" value="{./@value}">
									<xsl:if test="./@selected = 'true'">
										<xsl:attribute name="checked">checked</xsl:attribute>
									</xsl:if>
								</input><xsl:copy-of select="./node()"/><br/>
							</xsl:for-each>
							<br/>
						</span>
					</xsl:if>
					<xsl:if test="./@type = 'input-checkbox'">
						<span id="{./@name}" class="none">
							<xsl:if test="not(contains(ou:get-adv($adv,'addclass'),'false'))">
								<xsl:attribute name="class">
									<xsl:value-of select="ou:ldp-create-class($adv,'none')"/>
								</xsl:attribute>
							</xsl:if>
							<xsl:variable name="field_name" select="concat(./@name,'[]')"/>
							<span ><xsl:value-of select="./label/node()"/></span><br/>
							<xsl:for-each select="./options/option">
								<input type="checkbox" name="{$field_name}" value="{./@value}" >
									<xsl:if test="./@selected = 'true'">
										<xsl:attribute name="checked">checked</xsl:attribute>
									</xsl:if>
								</input>
								<xsl:copy-of select="./node()"/><br/>
							</xsl:for-each>
							<br/>
						</span>
					</xsl:if>
					<xsl:if test="./@type = 'select-single'">
						<span id="{./@name}" class="none">
							<xsl:if test="not(contains(ou:get-adv($adv,'addclass'),'false'))">
								<xsl:attribute name="class">
									<xsl:value-of select="ou:ldp-create-class($adv,'none')"/>
								</xsl:attribute>
							</xsl:if>
							<xsl:variable name="field_name" select="concat(./@name,'[]')"/>
							<label for="{concat('id_',./@name)}"><xsl:value-of select="./label/node()"/></label>
							<select name="{$field_name}" id="{concat('id_',./@name)}">
								<xsl:for-each select="./options/option">
									<option value="{./@value}" >
										<xsl:if test="./@selected = 'true'">
											<xsl:attribute name="checked">checked</xsl:attribute>
										</xsl:if>
										<xsl:copy-of select="./node()"/>
									</option>
								</xsl:for-each>
							</select>
							<br/>
						</span>
					</xsl:if>
					<xsl:if test="./@type = 'select-multiple'">
						<span id="{./@name}" class="none">
							<xsl:if test="not(contains(ou:get-adv($adv,'addclass'),'false'))">
								<xsl:attribute name="class">
									<xsl:value-of select="ou:ldp-create-class($adv,'none')"/>
								</xsl:attribute>
							</xsl:if>
							<xsl:variable name="field_name" select="concat(./@name,'[]')"/>
							<label for="{concat('id_',./@name)}"><xsl:value-of select="./label/node()"/></label>
							<select name="{$field_name}" multiple="multiple" size="5" id="{concat('id_',./@name)}">
								<xsl:for-each select="./options/option">
									<option value="{./@value}">
										<xsl:if test="./@selected = 'true'">
											<xsl:attribute name="checked">checked</xsl:attribute>
										</xsl:if>
										<xsl:copy-of select="./node()"/>
									</option>
								</xsl:for-each>
							</select>
							<br/>
						</span>
					</xsl:if>
					<xsl:if test="contains(ou:get-adv($adv,'fieldset_end'),'true')">
						<xsl:text disable-output-escaping="yes">&lt;/fieldset&gt;</xsl:text>
					</xsl:if>
				</xsl:for-each>
				
			</xsl:for-each>
			
			<input type="hidden" name="form_uuid" value ="{$uuid}"/>
			<xsl:if test="not($ou:action='prv')">
				<input type="submit" name="button" id="button" class="submit" value="Submit" />
			</xsl:if>
		</form>

	

</xsl:if>
<xsl:if test="//ouform">

       <script type="text/javascript">
        $(document).ready(function(){
	 var form_data = $('#form').serialize();
	$("#form").bind("submit", function(e) {
	e.preventDefault();
	 $.ajax({
	  type  : "POST",
	  cache : false,
	  url  : "/_resources/php/ldp/modules/form_test.php",
	  data  : $(this).serialize(),
	  success: function(data) {
	   var resultObj = jQuery.parseJSON(data);
	   var errC=/[faultcode]+\s:/;
	   var faultCode=errC.exec(resultObj.message);
	   if(resultObj.active == false){
		   if(!faultCode)
		   {
	   	$("#status").removeClass("main-formsuccess");
	   	
	   	$("#status").addClass("main-formerror");
	   	var dataSet=resultObj.message+"<br/>";

		$.each(resultObj.data, function(i,data){
			var d = data.message;
	      		highlightID="#id_"+data.name;
	      		
				errorHTML='<span class="formerror">'+data.message+'</span>';
	      		$(highlightID).after(errorHTML);
	      	});
	      	$("#status").html(dataSet);
	      	} //err Code
	      	else
	      	{
	      		var dataSet=resultObj.message+" "+resultObj.data;
	      		$("#status").addClass("fielderror");
	      		$("#status").addClass("main-formerror");
	      		$("#status").html(dataSet);
	      	}
	   }
	   else{
	   	$("#status").removeClass("main-formerror");
	   	$("#status").addClass("main-formsuccess");
	   	$("#form").remove();
	   	$("#status").html(resultObj.message);	   
	   }
	  },
	  error: function(data){
	  }
	 });
	 return false;
	});
	 });
        </script>
</xsl:if>
</xsl:otherwise>

</xsl:choose>

<!-- LDP FORMS ENDS -->
</xsl:template>

	<xsl:function name="ou:get-adv">
		<xsl:param name="adv"/>
		<xsl:param name="key"/>
		<xsl:choose>
			<xsl:when test="contains($adv,$key)">
				<xsl:value-of select="substring-before(substring-after($adv,concat($key,'=')),';')"/>
			</xsl:when>
			<xsl:otherwise>
				false
			</xsl:otherwise>
		</xsl:choose>
	</xsl:function>
	
	<xsl:function name="ou:ldp-create-class">
		<xsl:param name="adv" />
		<xsl:param name="predefined-class" />
		<xsl:variable name="class-name">
			<xsl:if test="contains($adv,'addclass')">
				<xsl:value-of select="ou:get-adv($adv,'addclass')"/>
			</xsl:if>
		</xsl:variable>
		<xsl:value-of select="normalize-space(concat($predefined-class,' ',$class-name))"/>
	</xsl:function>
	

<xsl:template match="comment()|node()|@*|text()" mode="maincontent" >
  <xsl:copy>
  <xsl:copy-of select="@*"/>
  	<xsl:apply-templates mode="maincontent"/>
  </xsl:copy>
</xsl:template>


</xsl:stylesheet>
