﻿$(document).ready(function() {
    $('.anythingSlider').anythingSlider({
        easing: "easeInOutExpo",
        autoPlay: true,
        delay: 3000,
        startStopped: false,
        animationTime: 600,
        hashTags: true,
        buildNavigation: true,
        pauseOnHover: true,
        startText: "Commencer",
        stopText: "Arrêter",
        navigationFormatter: null
    });
    if (p != "") { GoToSlide(p); }

    $(".grispale a").click(function() {
        if ($(this).attr("id") != "popupwebsite") {
            var name = $(this).attr("href").replace("portfoliodetail.aspx?p=", "");
            GoToSlide(name);
            return false;
        } else {
            return true;
        }
    });

    $("#plusdedetails").click(ShowPortfolioFiche);
});

function GetItemIndex(name) {
    return $(".anythingSlider>div>ul>li").index($("#item_" + name));
}

function GoToSlide(name) {
    $(".anythingSlider").anythingSlider(GetItemIndex(name));
}

var currentId = -1;
function SetProjectInfo(index) {
    var item = $(".anythingSlider>div>ul>li:eq(" + index + ")");

    var name = item.find(".name").html();
    var url = item.find(".url").html();
    $("#subdetail_name").html(name);
    $("#subdetail_url").attr("href", url).html(url);

    if (item.find(".id").html() != null) {
        currentId = item.find(".id").html();
        $("#plusdedetails").show();
    } else {
        currentId = -1;
        $("#plusdedetails").hide();
    }
}

function ShowPortfolioFiche() {
	if (currentId != -1) {
		$.ajax({
			type: "POST",
			cache: "false",
			url: "Portfoliodetail.aspx/GetPortfolioDetail",
			data: "{PortfolioId:" + currentId + "}",
			contentType: "application/json; charset=utf-8",
			dataType: "json",
			success: function (msg) {
				$("#popupname").html(msg.d.Name);
				$("#popupwebsite").html(msg.d.Url).attr("href", msg.d.Url);
				$("#popupsector").html(msg.d.Sector);
				$("#popupplace").html(msg.d.Place);
				$("#popuptechno").html(msg.d.Techno);
				$("#popupmandate").html(msg.d.Mandate);
				showFiche("fiche");
			}
		});
    }
    return false;
}