﻿/*
    Viewing camping Field
*/
// START
function view(fieldNo)
{
    getTerrain(fieldNo);
        
    $find("viewMPE").show();
}
function loadImage(img)
{
    $get("ctl00_ContentPlaceHolder1_fullImage").src = img;
}
// END
// Gets the session state value.
function getTerrain(no) 
{
    PageMethods.getTerrain(no, OnSucceeded);
}

// Callback function invoked on successful 
// completion of the page method.
function OnSucceeded(result, userContext, methodName) 
{
    if (methodName == "getTerrain")
    {
        resetPopup();
        $get("ctl00_ContentPlaceHolder1_fullImage").src = result.Photos[0].Photo;
        $get("title").innerHTML = "SITE " + result.No + " > Domaine des cantons";
        $get("contenu").innerHTML = result.Contenu;
        for(var i = 1; i < result.Photos.length; i++)
        {
            $get("image-" + i).src = result.Photos[i].Thumb;
            $get("a-image-" + i).href = "javascript:loadImage('" +result.Photos[i].Photo+ "')";
            var tmp = document.createElement("img");
            tmp.src = result.Photos[i].Photo;
            $get("preloadBoard").appendChild(tmp);
        }
    }
}
function resetPopup()
{
    $get("ctl00_ContentPlaceHolder1_fullImage").src = null;
    $get("title").innerHTML = "SITE " + " > Domaine des cantons";
    $get("contenu").innerHTML = "Chargement...";
    $get("image-1").src = null;
    $get("image-2").src = null;
    $get("image-3").src = null;
}

if (typeof(Sys) !== "undefined") Sys.Application.notifyScriptLoaded();

