/* 	Fonctions JavaScript pour le site
	Pronostic Hippique V1.0 */
// ******************************************
// *** Déclaration des variables globales ***
// ******************************************
var CTVar_TimeNow = Math.round(Math.random()*1000000000);
// ****************************
// *** Trim sur theStringCT ***
// ****************************
function CT_TrimString(theStringCT){
	txtStringCT = new String(theStringCT);
	while (txtStringCT.substring(0,1) == ' '){
		txtStringCT = txtStringCT.substring(1, txtStringCT.length);
	}
	while (txtStringCT.substring(txtStringCT.length-1, txtStringCT.length) == ' '){
		txtStringCT = txtStringCT.substring(0,txtStringCT.length-1);
	}
	return txtStringCT;
}
// *******************************
// *** Fonctions Ouverture POP ***
// *******************************
function CT_OpenPop(filepopname,namepopwin){
	window.open(filepopname,namepopwin,"menubar=yes,toolbar=no,scrollbars=yes,status=yes,width=500,height=400,top=0,left=0");
}
function CT_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 CT_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 CT_GoPageInclude(IdDoc,IdDocOpt){
	document.location = "index.php?id_doc="+IdDoc+IdDocOpt;
}
function CT_GoWebDirect(call_doc){
	document.location = call_doc;
}
// ***************************
// *** Retour History.Back ***
// ***************************
function CT_GoGack(){
	history.back();
}
// **********************************
// *** Ajouter le site au Favoris ***
// **********************************
function CT_AddFavoris(){
/*
	var CT_NavNom=new String(navigator.userAgent);
	alert(CT_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 CT_CheckContactForm(theForm){
	theForm.ct_contactname.value = CT_TrimString(theForm.ct_contactname.value);
	theForm.ct_contactmail.value = CT_TrimString(theForm.ct_contactmail.value);
	theForm.ct_contacttxt.value  = CT_TrimString(theForm.ct_contacttxt.value);
	if (theForm.ct_contactname.value.length<3 ||
		theForm.ct_contactmail.value.length<3 ||
		theForm.ct_contacttxt.value.length<10){
		alert('Formulaire incomplet!\n\nVeuillez renseigner tous les champs du formulaire.');
		return false;
	}else{
		return true;
	}
}
// ************************************************
// *** verifier les données de l'identification ***
// ************************************************
function CT_CheckLogForm(theForm){
	theForm.ph_uname.value = CT_TrimString(theForm.ph_uname.value);
	theForm.ph_upass.value = CT_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 CT_CheckAboForm(theForm){
	var frm_message = 'Formulaire incomplet!\n\n';
	var err_count	= 0;
	theForm.bt_abonom.value		= CT_TrimString(theForm.bt_abonom.value);
	theForm.bt_aboprenom.value	= CT_TrimString(theForm.bt_aboprenom.value);
	if (!theForm.bt_monthpay[0].checked && !theForm.bt_monthpay[1].checked &&
		!theForm.bt_monthpay[2].checked){
		frm_message = frm_message+'- Veuillez choisir un montant SVP.\n';
		err_count++;
	}
	if (theForm.bt_abonom.value.length<3 ||
		theForm.bt_aboprenom.value.length<3){
		frm_message = frm_message+'- Veuillez renseigner correctement les champs du formulaire.\n';
		err_count++;
	}
	if (!theForm.bt_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 CT_OpenBulletinAbo(JSVar_CTUser,JSVar_CTPass,JSVar_CTMail){
	window.open('print_bulletin.php?ident_user='+JSVar_CTUser+'&pass_user='+JSVar_CTPass+'&mail_user='+JSVar_CTMail,'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 CT_ChangeResDisplay(theForm){
	CT_GoWebDirect('rapport-quinte-pmu-'+theForm.value+'.htm');
	return true;
}
// ********************************
// *** Afficher le détail sur	***
// ***l'abonnement sélectionné	***
// ********************************
function ExpandTBoxDetailsAbo(TheBox_Name,TheBox_Indx){
	if (TheBox_Indx=="1"){
		document.getElementById(TheBox_Name+'1').style.display = "block";
		document.getElementById(TheBox_Name+'2').style.display = "none";
	}else{
		document.getElementById(TheBox_Name+'2').style.display = "block";
		document.getElementById(TheBox_Name+'1').style.display = "none";
	}
}