function menu(item) {
    if (document.getElementById('menu-'+item).style.visibility == 'hidden' || document.getElementById('menu-'+item).style.visibility == '') {
        document.getElementById('btn-'+item).style.backgroundPosition = '0 -40px';
        document.getElementById('menu-'+item).style.visibility = 'visible';
    } else {
        if (document.getElementById('btn-'+item).className == 'btn') {
            document.getElementById('btn-'+item).style.backgroundPosition = '0 0';
        }
        document.getElementById('menu-'+item).style.visibility = 'hidden';
    }
}

function search() {
    window.open('http://www.google.com/search?q=site:swinglesingers.com '+document.getElementById('q').value,'search','');
}

function clearField(name,value) {
    if (document.getElementById(name).value == value) {
        document.getElementById(name).value = '';
    }
}

function checkFieldLimit(field,number) {
    if (document.getElementById(field).value.length > number) {
        document.getElementById(field).value = document.getElementById(field).value.slice(0,number);
    }
}

function showPlace(date) {
    document.getElementById('show-'+date).style.visibility = 'visible';
}

function hidePlace(date) {
    document.getElementById('show-'+date).style.visibility = 'hidden';
}

lastSample = 0;
function stopSample(exception) {
    if (lastSample != 0 && lastSample != exception) {
        var s = new SWFObject("/audio/samples/miniplayer.swf",Math.round(Math.random()*100000),"36px","12px","7");
        s.addParam("wmode","transparent");
        s.addVariable("url",aTracks[lastSample]);
        s.addVariable("num",lastSample);
        s.write("swf-miniplayer-"+lastSample);
    }
    lastSample = exception;
}

function showCopyright() {
    alert('All Rights Reserved');
}

idLastGallery = 1;
function showGallery(id,path) {
    document.getElementById('zoom').innerHTML = '<img src="/images/gallery/'+path+'" alt="" />';
    document.getElementById('thumb-'+idLastGallery).className = '';
    document.getElementById('thumb-'+id).className = 'active';
    document.getElementById('number-'+idLastGallery).className = '';
    document.getElementById('number-'+id).className = 'active';

    nbPictures = aPictures.length-1;

    idPrevious = id-1;
    if (id == 1) {
        idPrevious = nbPictures;
    }

    idNext = id+1;
    if (id == nbPictures) {
        idNext = 1;
    }

    document.getElementById('previous').innerHTML = '<a href="javascript:showGallery('+idPrevious+',\''+aPictures[idPrevious]+'\');"><</a>';
    document.getElementById('next').innerHTML = '<a href="javascript:showGallery('+idNext+',\''+aPictures[idNext]+'\');">></a>';

    idLastGallery = id;

}

idLastGroupPhotos = 1;
function showGroupPhotos(id,path) {
    document.getElementById('zoom').innerHTML = '<img src="/images/sections/media/promo-photos-and-logos/group-photos/'+path+'.jpg" alt="" />';
    document.getElementById('download').href = '/documents/swingles-'+path+'.zip';
    document.getElementById('thumb-'+idLastGroupPhotos).className = '';
    document.getElementById('thumb-'+id).className = 'active';
    document.getElementById('number-'+idLastGroupPhotos).className = '';
    document.getElementById('number-'+id).className = 'active';

    nbPictures = aPictures.length-1;

    idPrevious = id-1;
    if (id == 1) {
        idPrevious = nbPictures;
    }

    idNext = id+1;
    if (id == nbPictures) {
        idNext = 1;
    }

    document.getElementById('previous').innerHTML = '<a href="javascript:showGroupPhotos('+idPrevious+',\''+aPictures[idPrevious]+'\');"><</a>';
    document.getElementById('next').innerHTML = '<a href="javascript:showGroupPhotos('+idNext+',\''+aPictures[idNext]+'\');">></a>';


    idLastGroupPhotos = id;

}

function getNewXMLHTTP() {
    try {
        return new XMLHttpRequest();
    } catch(e) {
        try {
            var aObj = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                var aObj = new ActiveXObject("Microsoft.XMLHTTP");
            } catch(e) {
                return false;
            }
        }
    }
    return aObj;
}

function showMonth(year,month) {
    try {
        chk = getNewXMLHTTP();
        chk.open("GET", "/scripts/ajax/calendar.php?y="+year+"&m="+month+"&hash="+Math.random(), true);
        chk.onreadystatechange = showMonth_end;
        chk.send(null);
    } catch(e) {
        //alert("Une erreur s'est produite, veuillez réessayer de nouveau!");
    }
}

function showMonth_end() {
    if (chk.readyState == 4) {
        if (chk.status == 200) {
            x = chk.responseXML.getElementsByTagName('response');
            code = decodeURIComponent(x[0].getAttribute('calendar'));

            reg = new RegExp('\\+','g');
            code = code.replace(reg,' ') ;

            document.getElementById('module-calendar-month').innerHTML = code;
            //alert(calendar);
        }
    }
}