Whenever I am adding the following code for lazy scrolling to my index.xhtml I am getting an exception


Code:
<script type="text/javascript">
    
    $(document).ready(function(){
        function lastAddedLiveFunc()
        {
            $('div#lastPostsLoader').html('<img src="bigLoader.gif">');
    
            $.get("loadmore.php", function(data){
                if (data != "") {
                    //console.log('add data..');
                    $(".items").append(data);
                }
                $('div#lastPostsLoader').empty();
            });
        };
    
        //lastAddedLiveFunc();
        $(window).scroll(function(){
    
            var wintop = $(window).scrollTop(), docheight = $(document).height(), winheight = $(window).height();
            var  scrolltrigger = 0.95;
    
            if  ((wintop/(docheight-winheight)) > scrolltrigger) {
             //console.log('scroll bottom');
             lastAddedLiveFunc();
            }
        });
    });


1) Index.xhtml



Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml"
    	xmlns:ui="http://java.sun.com/jsf/facelets"
    	xmlns:h="http://java.sun.com/jsf/html"
    	xmlns:f="http://java.sun.com/jsf/core"
    	xmlns:p="http://primefaces.org/ui"
    	xmlns:c="http://java.sun.com/jsp/jstl/core">
    
    
    <h:head>
    	<link href="Css/StyleSheet.css" rel="stylesheet" type="text/css"
    		media="screen" />
    
    <script type="text/javascript">
    
    $(document).ready(function(){
        function lastAddedLiveFunc()
        {
            $('div#lastPostsLoader').html('<img src="bigLoader.gif">');
    
            $.get("loadmore.php", function(data){
                if (data != "") {
                    //console.log('add data..');
                    $(".items").append(data);
                }
                $('div#lastPostsLoader').empty();
            });
        };
    
        //lastAddedLiveFunc();
        $(window).scroll(function(){
    
            var wintop = $(window).scrollTop(), docheight = $(document).height(), winheight = $(window).height();
            var  scrolltrigger = 0.95;
    
            if  ((wintop/(docheight-winheight)) > scrolltrigger) {
             //console.log('scroll bottom');
             lastAddedLiveFunc();
            }
        });
    });
    
    </script>
    
    
    </h:head>
    
    
    
    <h:body class="thrColElsHdr">
    </h:body>
    </html>
3) Exception

Code:
 Feb 28, 2013 6:21:32 PM org.apache.catalina.core.StandardWrapperValve invoke
    SEVERE: Servlet.service() for servlet [Faces Servlet] in context with path [/FreeBird_v.6] threw exception [null source] with root cause
    java.lang.IllegalArgumentException: null source
    	at java.util.EventObject.<init>(EventObject.java:56)
    	at javax.faces.event.SystemEvent.<init>(SystemEvent.java:67)
    	at javax.faces.event.ComponentSystemEvent.<init>(ComponentSystemEvent.java:69)
    	at javax.faces.event.PostRestoreStateEvent.<init>(PostRestoreStateEvent.java:69)
    	at com.sun.faces.lifecycle.RestoreViewPhase.deliverPostRestoreStateEvent(RestoreViewPhase.java:256)
    	at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:245)
    	at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97)
    	at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:107)
    	at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:114)
    	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:308)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    	at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
    	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
    	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1001)
    	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
    	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    	at java.lang.Thread.run(Thread.java:722)