/* 	Fonctions JavaScript pour le site
	Pronostic Hippique 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(){
/*
	var PH_NavNom=new String(navigator.userAgent);
	alert(PH_NavNom.indexOf('Firefox'));
	alert(navigator.appName+'\\n'+navigator.userAgent);
	if (navigator.appName!='Microsoft Internet Explorer'){
		window.sidebar.addPanel("Annonces matrimoniales Franco-Roumaine","http://www.matrimoniale-fr.com/","");
	}else{
		window.external.AddFavorite("http://www.matrimoniale-fr.com/","Annonces matrimoniales Franco-Roumaine");
	}*/
}
// ***********************************************
// *** 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.ph_uname.value = PH_TrimString(theForm.ph_uname.value);
	theForm.ph_upass.value = PH_TrimString(theForm.ph_upass.value);
	if (theForm.ph_uname.value.length<4 ||
		theForm.ph_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.ph_abonom.value		= PH_TrimString(theForm.ph_abonom.value);
	theForm.ph_aboprenom.value	= PH_TrimString(theForm.ph_aboprenom.value);
	if (!theForm.ph_monthpay[0].checked && !theForm.ph_monthpay[1].checked &&
		!theForm.ph_monthpay[2].checked && !theForm.ph_monthpay[3].checked){
		frm_message = frm_message+'- Veuillez choisir un montant SVP.\n';
		err_count++;
	}
	if (theForm.ph_abonom.value.length<3 ||
		theForm.ph_aboprenom.value.length<3){
		frm_message = frm_message+'- Veuillez renseigner correctement les champs du formulaire.\n';
		err_count++;
	}
	if (!theForm.ph_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;
}