﻿// 29/06/2011 21:55
//window.onload=montre;

/*********************************************************************
* Get an object, this function is cross browser
* *** Please do not remove this header. ***
* This code is working on my IE7, IE6, FireFox, Opera and Safari
* @Author Hamid Alipour Codehead @ webmaster-forums.code-head.com		*/
function get_object(id) {
    var object = null;
    if (document.layers) {
        object = document.layers[id];
    } else if (document.all) {
        object = document.all[id];
    } else if (document.getElementById) {
        object = document.getElementById(id);
    }
    return object;
}

/*********************************************************************
* No onMouseOut event if the mouse pointer hovers a child element 
* *** Please do not remove this header. ***
* This code is working on my IE7, IE6, FireFox, Opera and Safari
* Usage: 
* <div onMouseOut="fixOnMouseOut(this, event, 'JavaScript Code');"> 
*		So many childs 
*	</div> 
* @Author Hamid Alipour Codehead @ webmaster-forums.code-head.com		*/
function is_child_of(parent, child) {
    if (child != null) {
        while (child.parentNode) {
            if ((child = child.parentNode) == parent) {
                return true;
            }
        }
    }
    return false;
}
function fixOnMouseOut(element, event, JavaScript_code) {
    var current_mouse_target = null;
    if (event.toElement) {
        current_mouse_target = event.toElement;
    } else if (event.relatedTarget) {
        current_mouse_target = event.relatedTarget;
    }
    if (!is_child_of(element, current_mouse_target) && element != current_mouse_target) {
        eval(JavaScript_code);
    }
}




function montre(id) {
    var d = document.getElementById(id);
    for (var i = 0; i <= 10; i++) {
        if (document.getElementById('smenu' + i)) {
            document.getElementById('smenu' + i).style.display = 'none';
        }
    }
    if (d) {
        d.style.display = 'block';
    }
}

function afficherImage(controlId, imageUrl) {
    var gogo = '<img style="position:absolute; bottom:50px; left:-20; background-color:#FFFFFF; " src="' + imageUrl + '" />';
    document.getElementById(controlId).innerHTML = gogo;
}
function afficherImage2(controlId, surfReportFid, photoNum) {
    var gogo = '<img style="position:absolute; bottom:0px; left:-20; background-color:#FFFFFF; " src="SurfImager.ashx?PhotoSurfReportFid=' + surfReportFid + '&PhotoNumber=' + photoNum + '" />';
    document.getElementById(controlId).innerHTML = gogo;
}

function enleverImage2(controlId) {
    document.getElementById(controlId).innerHTML = '';
}

function afficherImageTRUC() {
    var gogo = '<img src="SurfImager.ashx?PhotoFromSession=true&amp;PhotoNumber=1001&NoResize=1" />';
    document.getElementById('ZoneSensible').innerHTML = gogo;
}


// Updates Surf map according to DAY only (not hour)
function UpdateImageMap(dayNumber) {
    var imageMapUrl = 'SurfImager.ashx?WaveMap=' + dayNumber + ';' + TEST;

    var waveMapImage = document.getElementById('ctl00_ContentPlaceHolder1_WaveMapControl1_limage');
    if (waveMapImage != null)
        waveMapImage.setAttribute('src', imageMapUrl);

    UpdateTideDay(dayNumber);
    UpdateBestSurfSpotDay(dayNumber);
}

function UpdateBestSurfSpotDay(dayNumber) {
    var testControl = document.getElementById('BestSpot_0_0');
    if (testControl == null)
        return;
        
    for (day = 0; day < 7; day++) {
        var displayDay = 'none';
        if (day == dayNumber)
            displayDay = 'block';

        for (spotRank = 0; spotRank < 5; spotRank++) {
            var controlId = 'BestSpot_' + spotRank + '_' + day;
            var control = document.getElementById(controlId);
            control.style.display =  displayDay;    
        }
    }
}

// Updates Surf map according to DAY and HOUR
function UpdateImageMap2(dayNumber, hourNumber) {
    var imageMapUrl = 'SurfImager.ashx?WaveMap=' + dayNumber + '_' + hourNumber + ';' + TEST;
    var waveMapImage = document.getElementById('ctl00_ContentPlaceHolder1_WaveMapControl1_limage');
    if (waveMapImage != null)
        waveMapImage.setAttribute('src', imageMapUrl);

    UpdateTideDay(dayNumber);
}

function SetImageMapToDefault() {
    UpdateImageMap(0);
}

function LaunchTimer() {
    //setTimeout("AfterTwoSeconds()",2000);
}

var waveMapArray = new Array(50);
// http://www.yadusurf.com/SurfImager.ashx?WaveMap=0
function AfterTwoSeconds() {
    for (var i = 0; i < 50; i++) {
        var numDay = i / 8;
        var numHour = (i % 8) * 3;
        var imagePath = "http://localhost/SurfImager.ashx?WaveMap=" + numDay + "_" + numHour + ";MED";
        var theImage = new Image();
        theImage.src = imagePath;
        waveMapArray[i] = theImage;
    }

    AtlanticImage0_0 = new Image();
    AtlanticImage0_0.src = "http://localhost/SurfImager.ashx?WaveMap=0_0;MED";
    AtlanticImage0_1 = new Image();
    AtlanticImage0_1.src = "http://localhost/SurfImager.ashx?WaveMap=0_3;MED";
    AtlanticImage0_2 = new Image();
    AtlanticImage0_2.src = "http://localhost/SurfImager.ashx?WaveMap=0_6;MED";
    AtlanticImage0_3 = new Image();
    AtlanticImage0_3.src = "http://localhost/SurfImager.ashx?WaveMap=0_9;MED";
    AtlanticImage0_4 = new Image();
    AtlanticImage0_4.src = "http://localhost/SurfImager.ashx?WaveMap=0_12;MED";
    AtlanticImage0_5 = new Image();
    AtlanticImage0_5.src = "http://localhost/SurfImager.ashx?WaveMap=0_15;MED";

    AtlanticImage1_0 = new Image();
    AtlanticImage1_0.src = "http://localhost/SurfImager.ashx?WaveMap=1_0;MED";
    AtlanticImage1_1 = new Image();
    AtlanticImage1_1.src = "http://localhost/SurfImager.ashx?WaveMap=1_3;MED";
    AtlanticImage1_2 = new Image();
    AtlanticImage1_2.src = "http://localhost/SurfImager.ashx?WaveMap=1_6;MED";
    AtlanticImage1_3 = new Image();
    AtlanticImage1_3.src = "http://localhost/SurfImager.ashx?WaveMap=1_9;MED";
    AtlanticImage1_4 = new Image();
    AtlanticImage1_4.src = "http://localhost/SurfImager.ashx?WaveMap=1_12;MED";
    AtlanticImage1_5 = new Image();
    AtlanticImage1_5.src = "http://localhost/SurfImager.ashx?WaveMap=1_15;MED";

    AtlanticImage2_0 = new Image();
    AtlanticImage2_0.src = "http://localhost/SurfImager.ashx?WaveMap=2_0;MED";
    AtlanticImage2_1 = new Image();
    AtlanticImage2_1.src = "http://localhost/SurfImager.ashx?WaveMap=2_3;MED";
    AtlanticImage2_2 = new Image();
    AtlanticImage2_2.src = "http://localhost/SurfImager.ashx?WaveMap=2_6;MED";
    AtlanticImage2_3 = new Image();
    AtlanticImage2_3.src = "http://localhost/SurfImager.ashx?WaveMap=2_9;MED";
    AtlanticImage2_4 = new Image();
    AtlanticImage2_4.src = "http://localhost/SurfImager.ashx?WaveMap=2_12;MED";
    AtlanticImage2_5 = new Image();
    AtlanticImage2_5.src = "http://localhost/SurfImager.ashx?WaveMap=2_15;MED";

    AtlanticImage3_0 = new Image();
    AtlanticImage3_0.src = "http://localhost/SurfImager.ashx?WaveMap=3_0;MED";
    AtlanticImage3_1 = new Image();
    AtlanticImage3_1.src = "http://localhost/SurfImager.ashx?WaveMap=3_3;MED";
    AtlanticImage3_2 = new Image();
    AtlanticImage3_2.src = "http://localhost/SurfImager.ashx?WaveMap=3_6;MED";
    AtlanticImage3_3 = new Image();
    AtlanticImage3_3.src = "http://localhost/SurfImager.ashx?WaveMap=3_9;MED";
    AtlanticImage3_4 = new Image();
    AtlanticImage3_4.src = "http://localhost/SurfImager.ashx?WaveMap=3_12;MED";
    AtlanticImage3_5 = new Image();
    AtlanticImage3_5.src = "http://localhost/SurfImager.ashx?WaveMap=3_15;MED";

    //AtlanticImage4_0 = new Image(); 
    //AtlanticImage4_0.src = "SurfImager.ashx?WaveMap=4_0";
    //AtlanticImage4_1 = new Image(); 
    //AtlanticImage4_1.src = "SurfImager.ashx?WaveMap=4_3";
    //AtlanticImage4_2 = new Image(); 
    //AtlanticImage4_2.src = "SurfImager.ashx?WaveMap=4_6";
    //AtlanticImage4_3 = new Image(); 
    //AtlanticImage4_3.src = "SurfImager.ashx?WaveMap=4_9";
    //AtlanticImage4_4 = new Image(); 
    //AtlanticImage4_4.src = "SurfImager.ashx?WaveMap=4_12";
    //AtlanticImage4_5 = new Image(); 
    //AtlanticImage4_5.src = "SurfImager.ashx?WaveMap=4_15";

    //AtlanticImage5_0 = new Image(); 
    //AtlanticImage5_0.src = "SurfImager.ashx?WaveMap=5_0";
    //AtlanticImage5_1 = new Image(); 
    //AtlanticImage5_1.src = "SurfImager.ashx?WaveMap=5_3";
    //AtlanticImage5_2 = new Image(); 
    //AtlanticImage5_2.src = "SurfImager.ashx?WaveMap=5_6";
    //AtlanticImage5_3 = new Image(); 
    //AtlanticImage5_3.src = "SurfImager.ashx?WaveMap=5_9";
    //AtlanticImage5_4 = new Image(); 
    //AtlanticImage5_4.src = "SurfImager.ashx?WaveMap=5_12";
    //AtlanticImage5_5 = new Image(); 
    //AtlanticImage5_5.src = "SurfImager.ashx?WaveMap=5_15";

    //AtlanticImage6_0 = new Image(); 
    //AtlanticImage6_0.src = "SurfImager.ashx?WaveMap=6_0";
    //AtlanticImage6_1 = new Image(); 
    //AtlanticImage6_1.src = "SurfImager.ashx?WaveMap=6_3";
    //AtlanticImage6_2 = new Image(); 
    //AtlanticImage6_2.src = "SurfImager.ashx?WaveMap=6_6";
    //AtlanticImage6_3 = new Image(); 
    //AtlanticImage6_3.src = "SurfImager.ashx?WaveMap=6_9";
    //AtlanticImage6_4 = new Image(); 
    //AtlanticImage6_4.src = "SurfImager.ashx?WaveMap=6_12";
    //AtlanticImage6_5 = new Image(); 
    //AtlanticImage6_5.src = "SurfImager.ashx?WaveMap=6_15";


}

LaunchTimer();
     

