// VideoSearch
function changePlayer(selObj) {
	self.location.href = 'http://www.team-tennis.fr/la-technique-des-champions/rechercher-une-video-de-joueur-de-tennis.html?no_cache=1&player='+selObj.value;
}

// MentalTest
function mentaltest_validate() {
    var total = 0;
    formElements = document.getElementById('form_mentaltest').elements;
    for(i=0 ; i < formElements.length ; i++) {
    	if(formElements[i].checked) total += parseInt(formElements[i].value);
    }
    var message = 'Résultat : ' + total+ '/20<br />';
    /*
    if(total < 5) {
        message += 'Mental très faible !';
    }
    if(total >= 5 && total < 10) {
    	message += 'Mental assez faible';
    }
    if(total >=10 && total < 12) {
    	message += 'Mental moyen';
    }
    if(total >= 12 && total < 14) {
    	message += 'Bon mental';
    }
    if(total >= 14 && total < 19) {
    	message += 'Très bon mental';
    }
    if(total == 19) {
    	message += 'Mental excellent !';
    }
    */
    $("#dialog_content").html(message);
    $("#dialog").dialog({
			bgiframe: true,
			resizable: true,
			height:340,
			modal: true,
			overlay: {
				backgroundColor: '#000',
				opacity: 0.5
			},
			buttons: {
				'Oui': function() {
					// $.get("http://www.team-tennis.fr/typo3conf/ext/mentaltest/process-dialog.ajax.php", { choice: "oui"} );
					$(this).dialog('close');
				},
				'Non': function() {
					// $.get("http://www.team-tennis.fr/typo3conf/ext/mentaltest/process-dialog.ajax.php", { choice: "non"} );
					$(this).dialog('close');
				}
			}
		});
    $("#dialog").dialog('open');

}

// SearchTour
function validateFormSearchTour() {
    var message = '';
    var regexp = /^[0-9]{2}\/[0-9]{2}\/[0-9]{4}$/;
    // Ligue ?
    if(document.getElementById('form_toursearch').sboxLigue.value == -1) {
        message += 'Veuillez choisir une ligue\n';
    }
    // Date debut ?
    if(!document.getElementById('date_debut').value.match(regexp)) {
        message += 'Format de date de début incorrect (jj/mm/aaaa)\n';
    }
    // Date fin ?
    if(!document.getElementById('date_fin').value.match(regexp)) {
        message += 'Format de date de fin incorrect (jj/mm/aaaa)\n';
    }
    if(message != '') {
    	alert(message);
    	return false;
    }
    return true;
}
