// -------------------------------------------------------
// Librairie Javascript
// Club Automobile Laval Auto Sport
// © ASPIX MEDIA - SOLUTIONS WEB INTERACTIVES
// Creation : 18.02.2005 - tim
// Modification : 25.07.2005 - tre
// -------------------------------------------------------

// =======================================================
//Détection du frame, si il n'y est pas on le load avec la page demandée
// =======================================================
var URL=document.location.href;
if ((/_p\d\.htm$/).test(URL)==true)
{	
	if (top.frames.length==0)
	{
		if ((/album/).test(URL)==true)
		{
			document.location.replace('http://www.lavalautosport.com/album.htm');
		}else{
			URL=URL.replace(/_p\d\.htm$/,'.htm')
			document.location.replace(URL);
		}
	}
	
}

// =======================================================
// PRELOAD & ROLLOVER
// =======================================================
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


// =======================================================
// AFFICHAGE TITRE IMAGE - ALBUM PHOTO
// =======================================================
function fTitre(pTexte){
	document.getElementById("IDshow").innerHTML = pTexte	
}


// =======================================================
// MESSAGE STATUS BAR
// =======================================================
function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}


// =======================================================
// PAGINATION - DIAPO
// =======================================================
var vCurrentPage = 1;
var vPageMax = 0;
var vPrefixe = "";

function fGoPage(pLaquel){
	switch(pLaquel){
		case '+':
			vCurrentPage ++;
		break;
		case '-':
			vCurrentPage --;
		break;
		default: 
			vCurrentPage = pLaquel;
	}
	if (vCurrentPage < 1 ) {
		/*alert("Vous avez atteint le nombre minimal de page !")*/
		vCurrentPage = 1;
	}
	if (vCurrentPage > vPageMax ) {
		/*alert("Le nombre maximal de page est de " + vPageMax)*/
		vCurrentPage = vPageMax;
	}
	//alert(vPrefixe + "_p" + String(vCurrentPage) + ".htm");
	parent.frames['iShow'].location.href = String(vPrefixe + "_p" + String(vCurrentPage) + ".htm");
	document.frmPage.txtPage.value = String(vCurrentPage);
	document.getElementById("pageCurrent").innerHTML = String(vCurrentPage);
	document.getElementById("pageMax").innerHTML = String(vPageMax);
}


// ========================================================== 
// ROLLOVER BTN SUBMIT
// ========================================================== 
function fRollover(pEtatBtn) {
	if ("INPUT" == event.srcElement.tagName){
		event.srcElement.className = pEtatBtn
	}
}


// ========================================================== 
// empêche le form submit après un enter dans un textbox
// ========================================================== 
function noentersubmit() {
  if ((window.event && window.event.keyCode == 13) || (window.event && window.event.keyCode == 3)) { fGoPage(document.frmPage.txtPage.value); return false; }else{ return true; }
}


// ========================================================== 
// Selection de l'image du header_2
// ========================================================== 
function fChoixImgHeader() {
	var vChemin = top.location.href;
	var vPage = vChemin.substr(vChemin.lastIndexOf("/")+1);
	var vPosQM = vPage.indexOf("?")
	if (vPosQM > -1) { vPage = vPage.substr(0,vPosQM) };
	//alert(vPage)
	
	var vPrefixe = "images/img_header";
	var vSuffixe = ".jpg";
	
	switch (vPage)
	{
		case "index.htm":
			document.header.src = vPrefixe + "10" + vSuffixe ;
		break;
		case "club.htm":
			document.header.src = vPrefixe + "2" + vSuffixe;
		break;
		case "info.htm":
			document.header.src = vPrefixe + "5" + vSuffixe;
		break;
		case "e007.htm":
			document.header.src = vPrefixe + "5" + vSuffixe;
		break;
		case "archives.htm":
			document.header.src = vPrefixe + "5" + vSuffixe;
		break;
		case "album.htm":
			document.header.src = vPrefixe + "7" + vSuffixe;
		break;
		case "inscription.htm":
			document.header.src = vPrefixe + "3" + vSuffixe;
		break;
		case "annonces.htm":
			document.header.src = vPrefixe + "6" + vSuffixe;
		break;
		case "boutique.htm":
			document.header.src = vPrefixe + "6" + vSuffixe;
		break;
		case "liens.htm":
			document.header.src = vPrefixe + "8" + vSuffixe;
		break;
		case "contact.asp":
			document.header.src = vPrefixe + "4" + vSuffixe;
		break;			
		default:
			document.header.src = vPrefixe + "10" + vSuffixe;
		break;
	}	

}

// OUVERTURE FENETRE POPUP CENTREE //
	function fOuvrir(pPage) {
		window.open(pPage,"","left=" +(screen.width - 460) / 2 + ",top=" + (screen.height - 460) / 2 + ",scrollbars=0,resizable=0, width=460,height=550");
	}


