
function PayPalDVD1() 	{ document.fPayPalDVD1.submit() ; }
function PayPalAlbum1()	{ document.fPayPalAlbum1.submit() ; }
function PayPalAlbum2()	{ document.fPayPalAlbum2.submit() ; }
function PayPalAlbum3()	{ document.fPayPalAlbum3.submit() ; }
function PayPalAlbum4()	{ document.fPayPalAlbum4.submit() ; }

function FormZoneTextInsertSmiley(pSmiley)
{
	var iZoneText = document.fGuestbook.message ;
	var iRange ;
	var iStart ;
	var iEnd ;
	var iPos ;
//	---------------------------
//	Focus sur la zone à traiter
//	---------------------------
	iZoneText.focus() ;
//	-----------------------------------------------
//	Prise en charge du Navigateur Internet Explorer
//	-----------------------------------------------
  	if (typeof document.selection != 'undefined')
	{
		iRange = document.selection.createRange() ;
		iRange.text = pSmiley ;
		iRange = document.selection.createRange() ;
		iRange.moveStart('character',(0 - iRange.text.length)) ;
		iRange.select() ;
	}
//	-----------------------------------------------
//	Prise en charge des Navigateurs basés sur Gecko
//	-----------------------------------------------
  	else if (typeof iZoneText.selectionStart != 'undefined')
	{
		iStart = iZoneText.selectionStart ;
		iEnd   = iZoneText.selectionEnd ;
		iZoneText.value = iZoneText.value.substr(0,iStart) + pSmiley + iZoneText.value.substr(iEnd) ;
		iPos = iStart + pSmiley.length ;
		iZoneText.selectionStart = iPos ;
		iZoneText.selectionEnd   = iPos ;
	}
}

function FormZoneTextInsertBalise(pChamp,pBalise)
{
	var iBaliseOpen  = '[' + pBalise + ']' ;
	var iBaliseClose = '[/' + pBalise + ']' ;
	var iZoneText    = pChamp ;
	var iRange ;
	var iStart ;
	var iEnd ;
	var iText ;
	var iPos ;
	if (pBalise == 't')
	{
	    iBaliseOpen  = iBaliseOpen + '"' ;
	    iBaliseClose = '"' + iBaliseClose ;
     }
//	---------------------------
//	Focus sur la zone à traiter
//	---------------------------
	iZoneText.focus() ;
//	-----------------------------------------------
//	Prise en charge du Navigateur Internet Explorer
//	-----------------------------------------------
  	if (typeof document.selection != 'undefined')
	{
		iRange = document.selection.createRange() ;
		iText  = iRange.text ;
		if (iText.length > 0)
		{
			iRange.text = iBaliseOpen + iText + iBaliseClose ;
			iRange = document.selection.createRange() ;
			iRange.moveStart('character',(iBaliseOpen.length + iText.length + iBaliseClose.length)) ;
			iRange.select() ;
		}
		else
		{
			alert(glNoTextSelected) ;
		}
	}
//	-----------------------------------------------
//	Prise en charge des Navigateurs basés sur Gecko
//	-----------------------------------------------
  	else if (typeof iZoneText.selectionStart != 'undefined')
	{
		iStart = iZoneText.selectionStart ;
		iEnd   = iZoneText.selectionEnd ;
		iText  = iZoneText.value.substring(iStart,iEnd) ;
		if (iText.length > 0)
		{
			iZoneText.value = iZoneText.value.substr(0,iStart) + iBaliseOpen + iText + iBaliseClose + iZoneText.value.substr(iEnd) ;
			iPos = iStart + iBaliseOpen.length + iText.length + iBaliseClose.length ;
			iZoneText.selectionStart = iPos ;
			iZoneText.selectionEnd   = iPos ;
		}
		else
		{
			alert(glNoTextSelected) ;
		}
	}
}

function FormToCalendar()
{
	var iDate = DATEFromForm(document.fUpdate.date.value) ;
	if ((iDate[2] != gCalendarYear) || (iDate[1] != gCalendarMonth))
	{
		gCalendarMonth = iDate[1] ;
		gCalendarYear  = iDate[2] ;
		InitCalendar() ;
	}
}

function FormToCity()
{
	var iCity = document.fUpdate.ville.value.toUpperCase() ;
	if ((iCity.length > 1) && (gSConcertDept[iCity] != null))
	{
		document.fUpdate.dept.value = gSConcertDept[iCity] ;
	}
	else
	{
		document.fUpdate.dept.value = '' ;
	}
	document.fUpdate.ville.value = iCity ;
}

function FormToCountry()
{
	var iLength = document.fUpdate.pays.value.length ;
	var iFirst  = document.fUpdate.pays.value.charAt(0).toUpperCase() ;
	var iWord   = document.fUpdate.pays.value.toLowerCase().substring(1,iLength) ;
	document.fUpdate.pays.value = iFirst + iWord ;
}

function FormMessageSubmit()
{
	if ((document.fGuestbook.nom.value     == '') || (document.fGuestbook.code.value == '') ||
	    (document.fGuestbook.message.value == ''))
	{
		alert(glNoData) ;
	}
	else
	{
		var iArobase = document.fGuestbook.email.value.indexOf('@') ;
		var iPoint   = document.fGuestbook.email.value.indexOf('.') ;
		var iCode    = document.fGuestbook.code.value.toUpperCase() ;
		if ((document.fGuestbook.email.value != '') && ((iArobase < 0) || (iPoint < 0)))
		{
			alert(glNoEmail) ;
		}
		else
		{
			if (iCode == gCAPTCHACode)
			{
				if (document.fGuestbook.email.value == '')
				{
					document.fGuestbook.email.value = '-' ;
				}
				document.fGuestbook.concert.value = gConcertActive ;
				document.fGuestbook.cle.value     = '4338a78be7488d7c5f2b002e2c2119e7' ;
				document.fGuestbook.submit() ;
			}
			else
			{
				alert(glNoCAPTCHA) ;
			}
		}
	}
}

function FormLoggOnEnter(pEvent)
{
	if (pEvent.keyCode == 13)
	{
		if ((document.fLoggon.utilisateur.value.toLowerCase() == 'doolin') ||
		   ((document.fLoggon.utilisateur.value.length > 1) && (document.fLoggon.motdepasse.value.length > 1)))
		{
			document.fLoggon.submit() ;
		}
	}
}

function FormLoggOnSubmit()
{
	document.fLoggon.submit() ;
}

function FormSendServer(pPage)
{	
	var iMsg = (gMessageConfirm + 'Toutes les modifications seront prises en compte !\nSouhaitez-vous mettre à jour les données du serveur maintenant ?') ;
	if (confirm(iMsg))
	{
		var iReg = new RegExp('[\']','g') ;
		var iStr ;
		if (gConcertsNb > 0)
		{
			var iC ;
			document.fUpdate.data1.value = '[r]' ;
			for (iC = 0 ; iC < gSConcert.length ; iC++)
			{
				iStr = STRINGNumberFormat('' + iC + '',3) ;
				document.fUpdate.data1.value += 'gSConcert[' + iStr + '] = { ' ;
				document.fUpdate.data1.value += 'date: [g]' + gSConcert[iC].date + '[g], ' ;
				document.fUpdate.data1.value += 'heure: [g]' + gSConcert[iC].heure + '[g], ' ;
				document.fUpdate.data1.value += 'manif: [g]' + gSConcert[iC].manif.replace(iReg,'&#39;') + '[g], ' ;
				document.fUpdate.data1.value += 'salle: [g]' + gSConcert[iC].salle.replace(iReg,'&#39;') + '[g], ' ;
				document.fUpdate.data1.value += 'avec: [g]' + gSConcert[iC].avec.replace(iReg,'&#39;') + '[g], ' ;
				document.fUpdate.data1.value += 'ville: [g]' + gSConcert[iC].ville.replace(iReg,'&#39;') + '[g], ' ;
				document.fUpdate.data1.value += 'dept: [g]' + gSConcert[iC].dept + '[g], ' ;
				document.fUpdate.data1.value += 'pays: [g]' + gSConcert[iC].pays + '[g], ' ;
				document.fUpdate.data1.value += 'guest: ' + gSConcert[iC].guest + ', ' ;
				document.fUpdate.data1.value += 'ref: ' + gSConcert[iC].ref + ', ' ;
				document.fUpdate.data1.value += 'en: ' + gSConcert[iC].en + ', ' ;
				document.fUpdate.data1.value += 'nivc: ' + gSConcert[iC].nivc + ', ' ;
				document.fUpdate.data1.value += 'qui: ' + gSConcert[iC].qui ;
				document.fUpdate.data1.value += ' } ;[r]' ;
			}
		}
		if (pPage == 'maintenance')
		{
			document.fUpdate.data2.value  = '[r]' ;
			document.fUpdate.data2.value += 'gSNews[0] = [g]' + document.fUpdate.news_fr.value + '[g] ;[r]';
			document.fUpdate.data2.value += 'gSNews[1] = [g]' + document.fUpdate.news_en.value + '[g] ;[r]';
		}
		else if (gSIndispo.length > 0)
		{
			var iI ;
			document.fUpdate.data2.value = '[r]' ;
			for (iI = 0 ; iI < gSIndispo.length ; iI++)
			{
				iStr = STRINGNumberFormat('' + iI + '',3) ;
				document.fUpdate.data2.value += 'gSIndispo[' + iStr + '] = { ' ;
				document.fUpdate.data2.value += 'date: [g]' + gSIndispo[iI].date + '[g], ' ;
				document.fUpdate.data2.value += 'pseudo: [g]' + gSIndispo[iI].pseudo + '[g], ' ;
				document.fUpdate.data2.value += 'valeur: ' + gSIndispo[iI].valeur + ', ' ;
				document.fUpdate.data2.value += 'nivc: ' + gSIndispo[iI].nivc + ', ' ;
				document.fUpdate.data2.value += 'qui: ' + gSIndispo[iI].qui ;
				document.fUpdate.data2.value += ' } ;[r]' ;
			}
		}
		document.fUpdate.submit() ;
	}
}

function FormClose(pPage)
{
	if (confirm(gMessageConfirm + 'Toutes les modifications en cours seront perdues !\nSouhaitez-vous quand-même quitter cette page ?'))
	{
		window.location = pPage ;
	}
}

function FormCancel()
{
	FormClose('doolin.htm?page=1') ;
}

function InitFormGuestbook()
{
	document.fGuestbook.nom.focus() ;
}

function InitFormLoggOn()
{
	if ((gParametres['id']) && (gParametres['id'] != 'inconnu'))
	{
		document.fLoggon.motdepasse.focus() ;
	}
	else document.fLoggon.utilisateur.focus() ;
}

function InitFormMaintenance()
{
	if (gConcertsNb > 0)
	{
		document.fUpdate.date.value = DATEFormate(DATEFromServer(gSConcert[gConcertActive - 1].date)) ;
	}
	else
	{
		document.fUpdate.date.value = DATEFormate(DATEArray()) ;
	}
	if ((gConcertsNb > 0) && (document.fUpdate.mode.value > 0))
	{
		document.fUpdate.heure.value   = gSConcert[gConcertActive - 1].heure ;
		document.fUpdate.manif.value   = STRINGApostrophe(gSConcert[gConcertActive - 1].manif) ;
		document.fUpdate.salle.value   = STRINGApostrophe(gSConcert[gConcertActive - 1].salle) ;
		document.fUpdate.avec.value    = STRINGApostrophe(gSConcert[gConcertActive - 1].avec) ;
		document.fUpdate.ville.value   = STRINGApostrophe(gSConcert[gConcertActive - 1].ville) ;
		document.fUpdate.dept.value    = gSConcert[gConcertActive - 1].dept ;
		document.fUpdate.pays.value    = gSConcert[gConcertActive - 1].pays ;
		document.fUpdate.guest.checked = gSConcert[gConcertActive - 1].guest ;
		document.fUpdate.ref.checked   = gSConcert[gConcertActive - 1].ref ;
		document.fUpdate.en.checked    = gSConcert[gConcertActive - 1].en ;
		document.fUpdate.nivc[gSConcert[gConcertActive - 1].nivc].checked = true ;
		document.fUpdate.qui[gSConcert[gConcertActive - 1].qui  ].checked = true ;
	}
	else
	{
		document.fUpdate.heure.value     = '21:00' ;
		document.fUpdate.manif.value     = '' ;
		document.fUpdate.salle.value     = '' ;
		document.fUpdate.avec.value      = '' ;
		document.fUpdate.ville.value     = '' ;
		document.fUpdate.dept.value      = '' ;
		document.fUpdate.pays.value      = 'France' ;
		document.fUpdate.guest.checked   = false ;
		document.fUpdate.ref.checked     = true ;
		document.fUpdate.en.checked      = true ;
		document.fUpdate.nivc[0].checked = true ;
		document.fUpdate.qui[0].checked  = true ;
	}
     FormToCalendar() ;
	document.fUpdate.date.focus() ;
}

