Monday, December 22, 2014

In Content editor webpart , Image Rotation at the time of page refreshing


<div id="mainarea"><!-- Start Featured Items -->
<div class="cta cta_featured f0">

target="_blank"><img src="/EN/Documents/images/GlobalInnovators_2.jpg" alt=""/></a>
</div>
<div class="cta cta_featured f1" style="display: none;">
                <a href="http://www.latimes.com/business/realestate/la-fi-robinsons-asian-

investors-20140912-story.html" target="_blank"><img src="/EN/Documents/images/Asian-

Capital.jpg" alt=""/></a>
</div>
<div class="cta cta_featured f2" style="display: none;">
                <a href="/EN/aboutus/MediaCentre/2014/Pages/Euromoney-2014.aspx"><img

src="/EN/Documents/images/Euromoney-Awards-2014.jpg" alt=""/></a>
</div>
<div class="cta cta_featured f3" style="display: none;">
                <a href="/EN/aboutus/corporateresponsibility/Pages/default.aspx"><img

src="/EN/Documents/images/2013-corporate-responsibility.jpg" alt=""/></a>
</div>

<div class="cta cta_featured f4" style="display: none;">
                <a href="http://annualreport.cbre.com/"><img src="/EN/Documents/images/Annual-

Report.jpg" alt=""/></a>
</div>
<!-- End Featured Items -->

<script>
(function() {

                // Begin Featured randomizing/cycling section
                function createCookie(name, value, days) {
                                if (days) {
                                                var date = new Date();
                                                date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
                                                var expires = "; expires=" + date.toGMTString();
                                }
                                else var expires = "";
                                document.cookie = name + "=" + value+expires + "; path=/";
                }

                function readCookie(name) {
                                var nameEQ = name + "=",
                                                ca = document.cookie.split(';');
                                for(var i = 0; i < ca.length; i += 1) {
                                                var c = ca[i];
                                                while (c.charAt(0)==' ') {
                                                                c = c.substring(1,c.length);
                                                }
                                                if (c.indexOf(nameEQ) == 0) {
                                                                return c.substring(nameEQ.length,c.length);
                                                }
                                }
                                return null;
                }

                function eraseCookie(name) {
                                createCookie(name,"",-1);
                }
               
                function itemCyclerRandomizer($collection, cookieName) {
                                var len = $collection.length,
                                                rand = Math.floor(Math.random() * len),
                                                lastItem = parseInt(readCookie(cookieName));

                                if (lastItem !== lastItem) { // true if NaN, which means no cookie
                                                lastItem = rand;
                                } else {
                                                if (lastItem >= len - 1) {
                                                                lastItem = 0;
                                                } else {
                                                                lastItem += 1;
                                                }
                                }

                                createCookie(cookieName, lastItem);

                                $($collection.get(lastItem)).show();
                               
                }
               
                itemCyclerRandomizer($('.cta_featured'), 'lastFeatured');
                itemCyclerRandomizer($('.cta_news .item'), 'lastNews');
                itemCyclerRandomizer($('.cta_case-study .item'), 'lastCaseStudy');
                // End Featured randomizing/cycling section
               
                // Click functionality for world office location dropdown
                $("#mapCtaLink").click(function() {
                                openWorldMenu();
                                $('html, body').animate({
                                                scrollTop: $("#world_office_menu").offset().top
                                }, 1000);
                });
               
                // Add class to fix IE8 nth-child support
                $('.cta_x2:nth-child(2n+2), .cta_x3:nth-child(3n+3)').addClass('row-end');
}());

$( document ).ready(function() {
    // alert("hi");
    $(".cta cta_featured f0").show();
});

</script>

No comments:

Post a Comment