﻿
function mover(obj) {
	if (obj.getAttribute('oldCssClass') == null) {
		obj.setAttribute('oldCssClass', obj.className);
	}
	obj.className = 'On';
}

function mout(obj) {
	obj.className = obj.getAttribute('oldCssClass');
}

function wSetTabActive(obj, targetId) {
    var i = 0;
    nodeList= obj.parentNode.childNodes;
    for (i = 0; i < nodeList.length; i++) {
		var curNode = nodeList[i];
		if (curNode.nodeType == 1) {
			curNode.className = 'Off'
			//try { // la liste des fils peux contenir des elements texte
				curNode.setAttribute('oldCssClass', 'Off');
			//} catch (e) {}
        }
    }
    obj.className = 'On';
    obj.setAttribute('oldCssClass','On');
    wSetDivActive(targetId);
}

function wSetDivActive(targetId) {
	document.getElementById(divOuvertID).value = targetId;
    if (true == isMapShown) {
        //if ('Search' == targetId) {
        //    swapToList();
        //    wSetTabActive(document.getElementById('spanSearch'), 'Search');
        //} else {
            showPushPins(targetId, false);
        //}
	} else {
	    showDiv(targetId);
	}
}

function reShowVideos() {
    var divShown = document.getElementById(divOuvertID).value;
    if ('' == divShown) {
        // if there's nothing in divOuvert, that's because the default
        // tab is shown (which is the "most recent videos")
        divShown = 'MostRecent';
    }
    wSetDivActive(divShown);
}

function showDiv(targetId) {
    var node = document.getElementById('div' + targetId);
	nodeListDiv = node.parentElement.childNodes;
	for (var i = 0; i < nodeListDiv.length; i++) {
		var curNode = nodeListDiv[i];
		if ((curNode.nodeType == 1) && (curNode.nodeName == 'DIV')) {
			//try { // la liste des fils peux contenir des elements texte
				curNode.style.display = 'none';
			//} catch (e) {}
        }
	}
	node.style.display = 'block'
}

function showPushPins(what, changeZoom) {
    wClearMap();
    if ('Selection' == what) {
        addSelectionVideoPushPins();
    } else if ('MostRecent' == what) {
        addMostRecentVideoPushPins();
    } else if ('MostViewed' == what) {
        addMostViewedVideoPushPins();
    } else if ('Search' == what) {
        addSearchVideoPushPins();
    }
    if (g_spotSomewhere) {
        wReCenterMap(false);
    }
}

// we declare these functions just to avoid errors
// there are overrided inside the page
function addSelectionVideoPushPins() { }
function addMostRecentVideoPushPins() { }
function addMostViewedVideoPushPins() { }
function addSearchVideoPushPins() { }

function setOngletSelectionActif() {
    document.getElementById('spanSelection').style.display = 'inline'
    wSetTabActive(document.getElementById('spanSelection'), 'Selection');
}
