﻿//    var mycarousel_itemList = [
//        {url: "http://static.flickr.com/66/199481236_dc98b5abb3_s.jpg", title: "Flower1", year: "2006"},
//        { url: "http://static.flickr.com/75/199481072_b4a0d09597_s.jpg", title: "Flower2", year: "2006" },
//        { url: "http://static.flickr.com/57/199481087_33ae73a8de_s.jpg", title: "Flower3", year: "2005" },
//        { url: "http://static.flickr.com/77/199481108_4359e6b971_s.jpg", title: "Flower4", year: "2006" },
//        { url: "http://static.flickr.com/58/199481143_3c148d9dd3_s.jpg", title: "Flower5", year: "2007" },
//        { url: "http://static.flickr.com/72/199481203_ad4cdcf109_s.jpg", title: "Flower6", year: "2006" },
//        { url: "http://static.flickr.com/58/199481218_264ce20da0_s.jpg", title: "Flower7", year: "2006" },
//        { url: "http://static.flickr.com/69/199481255_fdfe885f87_s.jpg", title: "Flower8", year: "2008" },
//        { url: "http://static.flickr.com/60/199480111_87d4cb3e38_s.jpg", title: "Flower9", year: "2006" },
        //        { url: "http://static.flickr.com/70/229228324_08223b70fa_s.jpg", title: "Flower10", year: "2006" }
//{ Title: "", Client: "", About: "", Product: "", Technology: "", Tools: "", Scope: "", Image: "" }
//    ];



    var selectedFolioItem = null;


    function mycarousel_itemLoadCallback(carousel, state)
    {
        for (var i = carousel.first; i <= carousel.last; i++) 
        {
            if (carousel.has(i)) 
            {
                continue;
            }

            if (i > mycarousel_itemList.length) 
            {
                break;
            }

            carousel.add(i, mycarousel_getItemHTML(mycarousel_itemList[i-1]));
        }
    };

    /**
     * Item html creation helper.
     */
    function mycarousel_getItemHTML(item)
    {
        return '<div class="project"><div class="test"></div><h1>' + item.Title +
               '</h1><div class="description"><h2>Client</h2><p>' + item.Client +
               '</p><h2>About</h2><p>' + item.About +
               '</p><h2>Product</h2><p>' + item.Product +
               '</p><h2>Technology</h2><p>' + item.Technology +
               '</p><h2>Tools used</h2><p>' + item.Tools +
               '</p><h2>Scope ' + item.Scope + 
               '</h2></div><div class="images"><img src="' + item.Image + '" alt="" /></div></div>';        
    };
    
    function itemVisibleInCallback(carousel, listItem, selectedIndex, state)
    {
        selectedFolioItem = mycarousel_itemList[selectedIndex - 1];

        $("#visitPageTab").hide();
        $("#liveDemoTab").hide();
        $("#pdfDemoTab").hide();

        if (selectedFolioItem.VisitPage != "")
        {
            $("#visitPageTab").show();
        }

        if (selectedFolioItem.LiveDemo != "")
        {
            $("#liveDemoTab").show();
        }

        if (selectedFolioItem.ViewProduct != "")
        {
            $("#pdfDemoTab").show();
        }        
    }

    jQuery(document).ready(function()
    {

        jQuery('#mycarousel').jcarousel({
            size: mycarousel_itemList.length,
            visible: 1,
            scroll: 1,
            start: 0,
            itemLoadCallback: { onBeforeAnimation: mycarousel_itemLoadCallback },
            itemVisibleInCallback: itemVisibleInCallback
        });

        //flipPopOut
        $("#visitPageTab").hide().click(function(event)
        {
            if (selectedFolioItem != null)
            {
                window.open(selectedFolioItem.VisitPage);
            }
        });


        $("#liveDemoTab").hide().click(function(event)
        {
            if (selectedFolioItem != null)
            {
                window.open(selectedFolioItem.LiveDemo);
            }
        });

        $("#pdfDemoTab").hide().click(function(event)
        {
            if (selectedFolioItem != null)
            {
                window.open(selectedFolioItem.ProductDemo);
            }
        });

    });