// 
// /*  --------------------------------------------
//     home.js
//     com.pushhere.www
//     regi e.(regi@pushhere.com, Lead Dev)
//     - Requires(Location):
//       (script/home.js)
//     --------------------------------------------  */
// 
/*      Ready
        ---------------------------------------------  */
        var options = {
            speed: 500,
            easing: "easeOutExpo",
            timer : 4000,
            count : 2
        };
        
        var t;
        
        function homeSlideAutoAnim() {
            if( options.count > 4 ) {
                options.count = 1;
            }
            
            if( options.count === 1 ) {
                homeSlideAnim("-2530px", 0, '#control-1');
            }
            else if( options.count === 2 ) {
                homeSlideAnim("-2290px", "-500px", '#control-2');
            }
            else if( options.count === 3 ) {
                homeSlideAnim("-2050px", "-1000px", '#control-3');
            }
            else if( options.count === 4 ) {
                homeSlideAnim("-1810px", "-1500px", '#control-4');
            }
            options.count++;
        }
        
        function homeSlideAnim(arrowValue, slideValue, list){
            var $li = jQuery(list);
            jQuery('#feature-clients ul').stop(true, true).animate({ "top": slideValue}, options.speed, options.easing, function(){
                jQuery('#client-arrow span').stop(true, true).animate({ "left": arrowValue}, options.speed, options.easing);
                $li.siblings().css({"opacity": 0.3});
                $li.stop(true, true).animate({"opacity": 1}, 100, options.easing );
            });
        }
        
        jQuery(document).ready(function() {
            if(document.width <= 480 || navigator && navigator.platform && navigator.platform.match(/^(iPhone)$/)) {
                document.location = '/pmobile/'
            }
            var ie = /MSIE (\d+\.\d+);/;
            if( ie.test(navigator.userAgent) ) {
                jQuery('#feature-clients-controls li:not(:first-child)').css('opacity', '0.3');
            }
            t = setInterval( homeSlideAutoAnim , options.timer );
            jQuery('#feature-clients-controls li').mouseenter(function(e){
                clearInterval( t );
                var $li = jQuery(e.target);
                var id = $li.closest('li').attr('id');
                switch(id) {
                    case 'control-1':
                           homeSlideAnim("-2530px", 0, '#control-1');
                    break;
                    case 'control-2':
                           homeSlideAnim("-2290px", "-500px", '#control-2');
                    break;
                    case 'control-3':
                           homeSlideAnim("-2050px", "-1000px", '#control-3');
                    break;
                    case 'control-4':
                           homeSlideAnim("-1810px", "-1500px", '#control-4');
                    break;
                }
            });
            
            
            //To get lifetime Access Token you have to use scope=offline_access
            //Enables your application to perform authorized requests on behalf of the user at any time
                            // var url = "https://graph.facebook.com/114138295284199/feed?access_token=AAACEdEose0cBAAF3Vgv70Icyom3lM45dJ0b32QCwyeoZCx5wnVQ1d0ZAR7TxN3mq2OB0GsP8eJRZBYCoM4CvZChZB2OSEsPGa48NTKi6WfgBpbihqvqIj&scope=offline_accessm&expires_in=600000000000000&limit=1&type=web_server";
                            
            // jQuery.ajax({
            //     url: url,
            //     type: "GET",
            //     dataType: "jsonp",
            //     success: function(data) {
            //       var latestFeed = data["data"][0].message;
            //       
            //       if( latestFeed == null || latestFeed == 0 || latestFeed == "undefined" ) {
            // 
            //       } else {
            //           // Trim the characters if it has more than 1500 words
            //           var wordLimit = 150;
            //           if( latestFeed.length > wordLimit ) {
            //               var trimFeed = latestFeed.substring(0, wordLimit) + " ...";
            //               jQuery('#facebook_feed').text(trimFeed);
            //           } else {
            //               jQuery('#facebook_feed').text(latestFeed);
            //           }
            //           
            //       }
            //     }
            // });
            
            //GetAccessTokenClient();
            // function GetAccessTokenClient() {
            // 
            //         var redirURL = "http://pushhere/";
            //         var scope = "user_online_presence"; // user_photos, email, user_birthday, user_online_presence
            //         var clientID = "114138295284199";
            // 
            //         try {
            //             jQuery.ajax({
            //                 type: "GET",
            //                 url: "https://www.facebook.com/dialog/oauth", //"https://graph.facebook.com/oauth/authorize",
            //                 cache: false,
            //                 dataType: 'JSONP',
            //                 data: "client_id=" + clientID + "&redirect_uri=" + redirURL + "&reponse_type=token",
            //                 error: function(xhr, status, error) {
            //                     alert(error);
            //                 },
            //                 success: function(response) {
            //                     for (key in repsonse)
            //                         console.log(key);
            //                 },
            //                 complete: function(request, textStatus) {
            //                     //alert('RESPONSETEXT: ' + request.responseText);
            //                     //alert('COMPLETE: ' + textStatus);
            //                 }
            //             });
            //         }
            //         catch (Error) {
            //             alert(Error);
            //         }
            // }
            // 
            
            
            //var $bg_pattern_top = jQuery('#home-page #shell').position().top;
            //jQuery('#home-page #bg-pattern').css('top', $bg_pattern_top + "px");
            
         });
         
         
        jQuery.Juitter.start({
          searchType:"fromUser", // needed, you can use "searchWord", "fromUser", "toUser"
          searchObject:"pushthinking", // pushthinking.  needed, you can insert a username here or a word to be searched for, if you wish multiple search, separate the words by comma.

          // The values below will overwrite the ones on the Juitter default configuration.
          // They are optional here.
          // I'm changing here as a example only
          lang:"en", // restricts the search by the given language
          live:"live-2000", // the number after "live-" indicates the time in seconds to wait before request the Twitter API for updates.
          placeHolder:"tweet", // Set a place holder DIV which will receive the list of tweets example <div id="juitterContainer"></div>
          loadMSG: "Loading messages...", // Loading message, if you want to show an image, fill it with "image/gif" and go to the next variable to set which image you want to use on
          imgName: "loader.gif", // Loading image, to enable it, go to the loadMSG var above and change it to "image/gif"
          total: 1, // number of tweets to be show - max 100
          filter:"sex->*BAD word*,porn->*BAD word*,fuck->*BAD word*,shit->*BAD word*"  // insert the words you want to hide from the tweets followed by what you want to show instead example: "sex->censured" or "porn->BLOCKED WORD" you can define as many as you want, if you don't want to replace the word, simply remove it, just add the words you want separated like this "porn,sex,fuck"... Be aware that the tweets will still be showed, only the bad words will be removed
        });
