<%-- 
    Document   : exampleDateAndTime
    Created on : Sep 22, 2008, 7:56:08 PM
    Author     : Ivan
--%>
<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<f:view>
    <html>
        <head>
            <link type="text/css" rel="stylesheet" href="styles.css"/>
            <script type="text/javascript" src="fat.js"></script>
            
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title><h:outputText value="#{msgs.title}"/></title>
            <script type="text/javascript">
               
                var asyncRequest;
                // fja getContent,kreiramo url servleta i iz skripta poyivamo AjaxServlet,po generisanju odgovora 
                //poziva se script fja stateChange
                function getContent(){
                
                    try{
                        var url="AjaxServlet";
                        init();
                        asyncRequest.onreadystatechange=stateChange;
                        asyncRequest.open('GET', url, true);
                        asyncRequest.send(null);
                    
                    }catch(exception){alert("Zahtev nije uspeo!");}
                }
                function init(){
                    if(window.XMLHttpRequest) //za mozillu
                        asyncRequest=new XMLHttpRequest();
                    else if(window.ActiveXObject) //starije verzije explorera
                        asyncRequest=new ActiveXObject("Microsoft.XMLHTTP");   
                }           
                                
                function stateChange(){
                
                    if(asyncRequest.readyState==4  //request je završen
                        && asyncRequest.status==200 ){ // uspešno!
                        clearContent();
                        document.getElementById("output").innerHTML=asyncRequest.responseText; 
                        Fat.fade_element("output",60,4000,"#dfeeff","#dddddd");
                        
                    }
                }
                function clearContent(){
                    document.getElementById("output").innerHTML="";
                 
                }
            </script> 
        </head>
        <body>
            <div class="container">
                <div class="banner">
                    <h:outputText value="#{msgs.headerEx1}"
                                  styleClass="bannerText"/>
                </div>
                <hr/>
                <br/>
                <div class="center">
                    <h:commandButton type="button" value="#{msgs.button1Ex1}" onclick="getContent()" />
                    <h:commandButton type="button" value="#{msgs.button2Ex1}" onclick="clearContent()"/>
                </div>
                <br/>
                <div id="output" class="watch"></div> <br/>
                <h:form>
                    <div class="center"><h:commandButton value="#{msgs.button3Ex1}" action="nazad"/></div>
                    <br/>
                </h:form>
                <br/>
                <div class="footer">&copy;2008 Šerić Ivan</div>
            </div>
        </body>
    </html>
</f:view>