﻿// JavaScript Document

		function findimg()
		{
			var i,imgs;
		// loop through all images of the document
			imgs=document.getElementsByTagName('img');
			for(i=0;i<imgs.length;i++)
			{
		// test if the class 'roll' exists
				if(/roll/.test(imgs[i].className))
				{
		// add the function roll to the image onmouseover and onmouseout and send
		// the image itself as an object
					imgs[i].onmouseover=function(){roll(this);};
					imgs[i].onmouseout=function(){roll(this);};
				}
			}
		}
		function roll(o)
		{
		// get the src of the image, and find out the file extension
			var src = o.src;
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
		// check if the src already has an _on and delete it, if that is the case 
			if(/_on/.test(src))
			{
				var newsrc = src.replace('_on','');
			}else{
		// else, add the _on to the src 
				var newsrc = src.replace(ftype, '_on'+ftype);
			}
			o.src=newsrc;
		}

function addLoadListener(func) {
   if (window.addEventListener) {
      window.addEventListener("load", func, false);
   } else if (document.addEventListener) {
      document.addEventListener("load", func, false);
   } else if (window.attachEvent) {
      window.attachEvent("onload", func);
   } else if (typeof window.onload != "function") {
      window.onload = func;
   } else {
      var oldonload = window.onload;
      window.onload = function() {
         oldonload();
         func();
      };
   }
}


addLoadListener(findimg);


function visibilite(thingId)
	{
		targetElement = document.getElementById(thingId);
		if(targetElement)
			targetElement.style.display = "" ;
	}
function unvisibilite(thingId)
	{
		targetElement = document.getElementById(thingId);
		if(targetElement)
			targetElement.style.display = "none" ;
	}

// -------------------- OPENWINDOW --------------------
function openWindow(url,nom,dimx,dimy,type) {
	featur0 = "top=20,left=20,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width="+ dimx + ",height=" + dimy;
  featur1 = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width="+ dimx + ",height=" + dimy;
	featur2 = "toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width="+ dimx + ",height=" + dimy;
	featur3 = "toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width="+ dimx + ",height=" + dimy;
	props = eval('featur'+type);
	window.open(url,nom,props);
}

function subscribeFromEmailTop() {
openWindowNews("?email=" + document.FormNewsTop.EMAIL.value); 
}

function subscribeFromEmail() {
openWindowNews("?email=" + document.FormNews.EMAIL.value); 
}

function openWindowNews(strParam) {
var strURL = "http://inscription.flvacances.com/pages/flv/neolane/inscription.php"; 
window.open(strURL + strParam, "newWindow", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width=624,height=450");
}

function subscribeUser(checkboxId) 
{
	var check = $(checkboxId);
	if(!check || check.checked) return;
	var url = "http://flv-s.neolane.net/nms/jsp/webForm.jsp";
	email = escape($F('TableCoord1_mail'));
	titleSel = $('TableCoord1_civilite');
	title = escape(titleSel.options[titleSel.selectedIndex].innerHTML);
	firstName = escape($F('TableCoord1_prenom'));
	lastName = escape($F('TableCoord1_nom'));
	origin = escape('Resa FLV');
	street1 = escape($F('TableCoord1_numvoie'));
	street2 = escape($F('TableCoord1_voie'));
	street3 = escape($F('TableCoord1_complementadresse'));
	street = street1+' '+street2+' '+street3;
	zipcode = escape($F('TableCoord1_cp'));
	city = escape($F('TableCoord1_ville'));
	country = escape($F('TableCoord1_pays'));
	var params = '?fo=forminflv&email='+email+'&civilite='+title+'&prenom='+firstName+'&nom='+lastName+'&origin='+origin+'&street='+street+'&zipcode='+zipcode+'&city='+city+'&country=�+country+�&action=submit';
	var news = $('newsLetter');
	if(news) 
	{
		news.src = url + params;
		//alert("Votre inscription à notre newsletter a bien été enregistrée.");
	}
}

function getSelectedText(combo)
{
	if(!document.getElementById(combo))
		return '';
	var oCombo = document.getElementById(combo);
	if(oCombo.selectedIndex == 0)
		return '';
	return oCombo.options[oCombo.selectedIndex].text;
}
