//************************************************************************************************//
if (top != self) {top.location.href = location.href;}
var baseDomainURL = "http://www.mairie-hospitalet.com";
//************************************************************************************************//
//
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_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_reloadPage(init) {  //reloads the window if Nav4 resized
	if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
		document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
	else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

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_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];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
	if (window.focus) {
		win = window.open(theURL,winName,features);
		win.window.focus();
	}
	else
		window.open(theURL,winName,features);	
}
//
function NewWindow(cs,mypage,myname,w,h,scroll,resize) {
	var winl = 0;
	var wint = 0;	
	if (cs) {
		var winl = (screen.width - w) / 2;
		var wint = (screen.height - h) / 2;
	}
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable='+resize;
	win = window.open(mypage,myname,winprops);
	win.window.focus();
}
//
function openVideoWindow(cs,mypage,myname,w,h) {
	var winl = 0;
	var wint = 0;	
	if (cs) {
		var winl = (screen.width - w) / 2;
		var wint = (screen.height - h) / 2;
	}
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',location=no,menubar=no,status=0,scrollbars=no,resizable=no';
	win = window.open(mypage,myname,winprops);
	win.window.focus();
}
//
//************************************************************************************************//
//
function addToFavorites() {
	window.external.AddFavorite("http://www.mairie-hospitalet.com", "mairie-hospitalet.com: le site officiel de la mairie de l'Hospitalet");
}
//
function searchForm_Validator() {
	if ((document.searchForm.searchString.value == "") || (document.searchForm.searchString.value.length < 3)) {
    		alert("Entrez un mot ou une expression à rechercher.");
    		document.searchForm.searchString.focus();
    		return (false);
	}
	return(true);	
}
//
function newsletterForm_Validator() {
	if (document.newsLetterForm.newsEmail.value == "") {
    		alert("Entrez une adresse email !");
    		document.newsLetterForm.newsEmail.focus();
    		return (false);
	}
	if ((document.newsLetterForm.newsEmail.value.indexOf ('@', 0) == -1) || (document.newsLetterForm.newsEmail.value.indexOf ('.', 0) == -1)) {
		alert("Entrez une adresse email valide !");
    		document.newsLetterForm.newsEmail.focus();
    		return (false);
	}
	return(true);	
}
//
function checkEmailContent() {
	if (document.newsLetterForm.newsEmail.value == "votre email") { document.newsLetterForm.newsEmail.value = ""; }
}
//
function contactForm_Validator() {
	if (document.mailForm.mailFrom.value == "") {
    	alert("Entrez votre adresse email.");
    	document.mailForm.mailFrom.focus();
    	return (false);
	}
	if (document.mailForm.subject.value == "") {
    	alert("Entrez le sujet.");
    	document.mailForm.subject.focus();
    	return (false);
	}
	if (document.mailForm.comments.value == "") {
    	alert("Entrez votre message.");
    	document.mailForm.comments.focus();
    	return (false);
	}
	return(true);	
}
//
//************************************************************************************************//
//
function deleteAlert(deleteID) {
	var c = window.confirm("Etes vous sûr de vouloir supprimer cet élément ?");
	if (c) {
		window.document.listForm.DELETE_ID.value = deleteID;
		window.document.listForm.submit();
	}		
}
//
function itemValidate(validID) {
	var c = window.confirm("Etes vous sûr de vouloir valider cet élément ?");
	if (c) {
		window.document.listForm.VALID_ID.value = validID;
		window.document.listForm.submit();
	}		
}
//
function itemUnValidate(validID) {
	var c = window.confirm("Etes vous sûr de vouloir invalider cet élément ?");
	if (c) {
		window.document.listForm.UNVALID_ID.value = validID;
		window.document.listForm.submit();
	}		
}
//
function itemEdit(url) {
	window.location.href = url;	
}
//
function newsletterView(url)  {
	window.open(url,"newsLetterView","resizable=yes,scrollbars=yes,location=no,width=800,height=600");
}
//
function newsletterSend(url)  {
	NewWindow(true,url,"newsLetterSend",600,150,'no','no');
}
//
function newsView(url)  {
	window.open(url,"newsView","resizable=yes,scrollbars=yes,location=no,width=800,height=600");
}
//
function commentsEdit(url)  {
	window.open(url,"commentsView","resizable=yes,scrollbars=yes,location=no,width=800,height=600");
}
//
function validateNewsForm() {
	 if (document.myForm.news_title.value == "") {
	 	alert("Entrez le titre de l'article!");
		document.myForm.news_title.focus();
	 	return (false);
	 }
	 return(true);
}
//
function showLayer(object) {
	if (document.layers && document.layers[object] != null)
        document.layers[object].visibility = 'visible'; 
    else if (document.all)
        document.all[object].style.visibility = 'visible';
}
//
function hideLayer(object) {
	if (document.layers && document.layers[object] != null)
        document.layers[object].visibility = 'hidden'; 
    else if (document.all)
        document.all[object].style.visibility = 'hidden';
}
//
//
function detailedNewsletterForm_Validator() {
	if (document.dFormNews.newsEmail.value == "") {
    		alert("Entrez une adresse email !");
    		document.dFormNews.newsEmail.focus();
    		return (false);
	}
	if ((document.dFormNews.newsEmail.value.indexOf ('@', 0) == -1) || (document.dFormNews.newsEmail.value.indexOf ('.', 0) == -1)) {
		alert("Entrez une adresse email valide !");
    		document.dFormNews.newsEmail.focus();
    		return (false);
	}
	if ((document.dFormNews.subscribe.value == "") && (document.dFormNews.unsubscribe.value == "")) {
    		alert("Cliquez sur le bouton \"je m'abonne\" ou bien sur \"je me désabonne\" !");
    		document.dFormNews.newsEmail.focus();
    		return (false);
	}
	return(true); 
}
//