
$(window).load(function(){
        var pages = $('#slideShow li'), current=0;
        var currentPage,nextPage;
        var timeoutID;
        var buttonClicked=0;

        var handler1=function(){
            buttonClicked=1;
            $('#slideShow .arrow').unbind('click');
            currentPage= pages.eq(current);
            if($(this).hasClass('previous'))
            {
                if (current <= 0)
                    current=pages.length-1;
                    else
                    current=current-1;
            }
            else
            {

                if (current >= pages.length-1)
                    current=0;
                else
                    current=current+1;
            }
            nextPage = pages.eq(current);   
            currentPage.fadeTo('slow',0.3,function(){
                nextPage.fadeIn('slow',function(){
                    nextPage.css("opacity",1);
                    currentPage.hide();
                    currentPage.css("opacity",1);
                    $('#slideShow .arrow').bind('click',handler1);
                }); 
            });         
        }

        var handler2=function(){
            if (buttonClicked==0)
            {
            $('#slideShow .arrow').unbind('click');
            currentPage= pages.eq(current);
            if (current >= pages.length-1)
                current=0;
            else
                current=current+1;
            nextPage = pages.eq(current);   
            currentPage.fadeTo('slow',0.3,function(){
                nextPage.fadeIn('slow',function(){
                    nextPage.css("opacity",1);
                    currentPage.hide();
                    currentPage.css("opacity",1);
                    $('#slideShow .arrow').bind('click',handler1);              
                }); 
            });
            timeoutID=setTimeout(function(){
                handler2(); 
            }, 4000);
            }
        }

        $('#slideShow .arrow').click(function(){
            clearTimeout(timeoutID);
            handler1();
        });

        timeoutID=setTimeout(function(){
            handler2(); 
            }, 4000);
        
});


// google analytics linK

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-25977389-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
  
// Open new window script for picture popup 

function showImage(url,height,width) {
	window.open(url, "", "toolbar=no,scrollbars=no,status=no,resizable=no,marginwidth=0,marginheight=0,framespacing=0,framepadding=0," + ",width=" + width + ",height=" + height);
}
