/* 	Fonctions JavaScript pour le site
	Stats Turfiste V1.0 */
// ******************************************
// *** Déclaration des variables globales ***
// ******************************************
var PHVar_TimeNow = Math.round(Math.random()*1000000000);
// ****************************
// *** Trim sur theStringPH ***
// ****************************
function PH_TrimString(theStringPH){
	txtStringPH = new String(theStringPH);
	while (txtStringPH.substring(0,1) == ' '){
		txtStringPH = txtStringPH.substring(1, txtStringPH.length);
	}
	while (txtStringPH.substring(txtStringPH.length-1, txtStringPH.length) == ' '){
		txtStringPH = txtStringPH.substring(0,txtStringPH.length-1);
	}
	return txtStringPH;
}
// *******************************
// *** Fonctions Ouverture POP ***
// *******************************
function PH_OpenPop(filepopname,namepopwin){
	window.open(filepopname,namepopwin,"menubar=yes,toolbar=no,scrollbars=yes,status=yes,width=500,height=400,top=0,left=0");
}
function PH_OpenPopXY(filepopname,namepopwin,popxsize,popysize){
	window.open(filepopname,namepopwin,"menubar=no,toolbar=no,scrollbars=no,status=yes,width="+popxsize+",height="+popysize+",top=0,left=0");
}
function PH_OpenPopCenter(filepopname,namepopwin,popxsize,popysize){
	var popwinleftpos = Math.round((screen.width-popxsize)/2);
	var popwintoppos  = Math.round((screen.height-popysize)/2);
	window.open(filepopname,namepopwin,"menubar=no,toolbar=no,scrollbars=no,status=yes,width="+popxsize+",height="+popysize+",top="+popwintoppos+",left="+popwinleftpos+"");
}
// *****************************************
// *** Aller sur une page id_doc+options ***
// *****************************************
function PH_GoPageInclude(IdDoc,IdDocOpt){
	document.location = "index.php?id_doc="+IdDoc+IdDocOpt;
}
function PH_GoWebDirect(call_doc){
	document.location = call_doc;
}
// ***************************
// *** Retour History.Back ***
// ***************************
function PH_GoGack(){
	history.back();
}
// **********************************
// *** Ajouter le site au Favoris ***
// **********************************
function PH_AddFavoris(){
	if (navigator.appName!='Microsoft Internet Explorer'){
		window.sidebar.addPanel("Statistique Turfiste","http://www.stats-turfiste.com/","");
	}else{
		window.external.AddFavorite("http://www.stats-turf.com/","Statistique Turfiste");
	}
}
// ***********************************************
// *** Verifier les données formulaire Contact ***
// ***********************************************
function PH_CheckContactForm(theForm){
	theForm.ph_contactname.value = PH_TrimString(theForm.ph_contactname.value);
	theForm.ph_contactmail.value = PH_TrimString(theForm.ph_contactmail.value);
	theForm.ph_contacttxt.value = PH_TrimString(theForm.ph_contacttxt.value);
	if (theForm.ph_contactname.value.length<3 ||
		theForm.ph_contactmail.value.length<3 ||
		theForm.ph_contacttxt.value.length<10){
		alert('Formulaire incomplet!\n\nVeuillez renseigner tous les champs du formulaire.');
		return false;
	}else{
		return true;
	}
}
// *************************************************
// *** verficier les données de l'identification ***
// *************************************************
function PH_CheckLogForm(theForm){
	theForm.st_uname.value = PH_TrimString(theForm.st_uname.value);
	theForm.st_upass.value = PH_TrimString(theForm.st_upass.value);
	if (theForm.st_uname.value.length<4 ||
		theForm.st_upass.value.length<4){
		alert('Formulaire incomplet!\n\nVeuillez renseigner correctement les champs du formulaire.');
		return false;
	}else{
		return true;
	}
}
// ***********************************************************
// *** Vérifier les données de l'enregistrement abonnement ***
// ***********************************************************
function PH_CheckAboForm(theForm){
	var frm_message = 'Formulaire incomplet!\n\n';
	var err_count	= 0;
	theForm.st_abonom.value		= PH_TrimString(theForm.st_abonom.value);
	theForm.st_aboprenom.value	= PH_TrimString(theForm.st_aboprenom.value);
	if (!theForm.st_monthpay[0].checked && !theForm.st_monthpay[1].checked){
		frm_message = frm_message+'- Veuillez choisir un montant SVP.\n';
		err_count++;
	}
	if (theForm.st_abonom.value.length<3 || theForm.st_aboprenom.value.length<3){
		frm_message = frm_message+'- Veuillez renseigner correctement les champs nom, prénom et adresse e-mail.\n';
		err_count++;
	}
	if (!theForm.st_abocgv.checked){
		frm_message = frm_message+"- Veuillez lire les conditions générales d'utilisation.\n";
		err_count++;
	}
	if (err_count!=0){
		alert(frm_message);
		return false;
	}else
		return true;
}
// *****************************************************
// *** Ouvrir le bulletin d'adhésion pour impression ***
// *****************************************************
function PH_OpenBulletinAbo(JSVar_PHUser,JSVar_PHPass,JSVar_PHMail){
	window.open('print_bulletin.php?ident_user='+JSVar_PHUser+'&pass_user='+JSVar_PHPass+'&mail_user='+JSVar_PHMail,'POP_Bulletin',"menubar=yes,toolbar=no,scrollbars=yes,status=yes,width=600,height=400,top=0,left=0");
}
// ***************************************
// *** Afficher d'autres résultats PMU ***
// ***************************************
function PH_ChangeResDisplay(theForm){
	PH_GoWebDirect('rapport-quinte-pmu-'+theForm.value+'.html');
//	PH_GoPageInclude('rapport-quinte-pmu-'+theForm.value+'.html','&Res_Date='+theForm.value+'&idtime='+PHVar_TimeNow);
	return true;
}

/*
	// ******************************************
	// *** Déclaration des variables globales ***
	// ******************************************
	var PHVar_TimeNow = Math.round(Math.random()*1000000000);
	// ****************************
	// *** Trim sur theStringPH ***
	// ****************************
	function PH_TrimString(theStringPH){
		txtStringPH = new String(theStringPH);
		while (txtStringPH.substring(0,1) == ' '){
			txtStringPH = txtStringPH.substring(1, txtStringPH.length);
		}
		while (txtStringPH.substring(txtStringPH.length-1, txtStringPH.length) == ' '){
			txtStringPH = txtStringPH.substring(0,txtStringPH.length-1);
		}
		return txtStringPH;
	}
	// *************************************************
	// *** verficier les données de l'identification ***
	// *************************************************
	function PH_CheckLogForm(theForm){
		theForm.st_uname.value = PH_TrimString(theForm.st_uname.value);
		theForm.st_upass.value = PH_TrimString(theForm.st_upass.value);
		if (theForm.st_uname.value.length<4 ||
			theForm.st_upass.value.length<4){
			alert('Formulaire incomplet!\\n\\nVeuillez renseigner correctement les champs du formulaire.');
			return false;
		}else{
			return true;
		}
	}
	// *******************************
	// *** Fonctions Ouverture POP ***
	// *******************************
	function PH_OpenPop(filepopname,namepopwin){
		window.open(filepopname,namepopwin,\"menubar=yes,toolbar=no,scrollbars=yes,status=yes,width=500,height=400,top=0,left=0\");
	}
	// **********************************
	// *** Ajouter le site au Favoris ***
	// **********************************
	function PH_AddFavoris(){
		if (navigator.appName!='Microsoft Internet Explorer'){
			window.sidebar.addPanel(\"Statistique Turfiste\",\"http://www.stats-turfiste.com/\",\"\");
		}else{
			window.external.AddFavorite(\"http://www.stats-turf.com/\",\"Statistique Turfiste\");
		}
	}
*/