﻿var ___timerId = null;

function MorphImage()
{
    if(___timerId)
        clearTimeout(___timerId);

    var _img1 = $('imgSwapImage1');
    var _img2 = $('imgSwapImage2');
    
    if(_img1.style.display == "none" && _img2.style.display == "none")
    {
        _img1.src = ___imageArray.shift();        
        ___imageArray.push(_img1.src);
        _img1.onload = function() { First(_img1) };
    }
    else
    {
        if(_img1.style.display == "none")
        {
            Effect.Fade(_img2, {duration: 1, afterFinish: StartTimer});
            Effect.Appear(_img1, {duration: 1});
        }
        else
        {
            Effect.Fade(_img1, {duration: 1, afterFinish: StartTimer});
            Effect.Appear(_img2, {duration: 1});
        }
    }     
}

function First(s) 
{
    s.onload = null;
    Effect.Appear(s, {duration: 1, afterFinish: StartTimer});
}

function StartTimer()
{
    LoadImage();
    ___timerId = setTimeout("MorphImage()", 4000);
}

function LoadImage()
{
    var _img1 = $('imgSwapImage1');
    var _img2 = $('imgSwapImage2');
    
    
    if(_img1.style.display == "none")
    {
        _img1.src = ___imageArray.shift();
        ___imageArray.push(_img1.src);
    }
    else
    {
        _img2.src = ___imageArray.shift();
        ___imageArray.push(_img2.src);
    }
}


function initContactSjabloon() 
{
    if (GBrowserIsCompatible()) 
    {
        var map = new GMap2(document.getElementById("googleMaps"));
        map.addControl(new GSmallMapControl);
        map.setCenter(new GLatLng(53.212447, 6.572860), 13);
        var icon = new GIcon;
        icon.image = "http://labs.google.com/ridefinder/images/mm_20_red.png";
        icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
        icon.iconSize = new GSize(12, 20);
        icon.shadowSize = new GSize(22, 20);
        icon.iconAnchor = new GPoint(6, 20);
        icon.infoWindowAnchor = new GPoint(5, 1);
        var point = new GLatLng(53.212447, 6.572860);
        map.addOverlay(new GMarker(point, icon));
    }
 } 