
String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ''); };

// JavaScript Document
var arrayDestination = new Array();
var defaultDateText = 'Choisir la date';

var monthArray = new Array('','Jan','Fev','Mars','Avr','Mai','Juin','Juil','Aout','Sept','Oct','Nov','Dec');

function menu(idNumb, statement) {
var i=0;
	if(statement=='true') {
		for(i=0; i<arrayDestination.length; i++) {
			document.getElementById(arrayDestination[i]).style.display = 'none';
		}
	}
	else {
		for(i=0; i<arrayDestination.length; i++) {
			if(i!=idNumb) {
			document.getElementById(arrayDestination[i]).style.display = 'none';
			}
			else {
			document.getElementById(arrayDestination[idNumb]).style.display = 'block';
			}
		}
	}
}


function popupWindow(url,title,resizable,aHeight,aWidth,scrollbars) {
   pop = window.open(url,title,"resizable="+resizable+",height="+aHeight+",width="+aWidth+",scrollbars="+scrollbars);
   pop.focus();
}

// general popup function
function popupSized(prefix,id,width,height,wind) {
 popup = window.open(prefix+id,
 wind,
 "resizable=yes,width="+width+",height="+height+",left=100,top=100,dependent=no,scrollbars=yes");
} 

 function PopupLargeImage(img) {
	w=open("",'image','width=400,height=400,toolbar=no,scrollbars=yes,resizable=yes');	
	w.document.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\"><title>Fnac.com - Voyages</title></head>");
	w.document.write("<script language=javascript type=\"text/javascript\">function checksize() { if (document.images[0].complete) {  var imgX=document.images[0].width+30; var imgY=document.images[0].height+30; if(imgX>screen.width)imgX=screen.width-30;if(imgY>screen.height)imgY=screen.height-30; window.resizeTo(imgX,imgY); window.focus();} else { setTimeout('check()',250) } }</"+"script>");
	w.document.write("<body onload='checksize()' bgcolor='#000000' leftMargin=0 topMargin=0 marginwidth=0 marginheight=0><img src='"+img+"' border=0/>");
	w.document.write("");
	w.document.write("</body></html>");
	w.document.close();
}

function isAnEmptyDate(date) {
	if (date == null || date == "" 
		|| (date.indexOf("jj/mm/aaaa")) != -1
		|| (date.indexOf(defaultDateText)) != -1) return true;
	return false;
}

function checkDate(date){

if (isAnEmptyDate(date)) return true;

        if(date.length<10) return false;
        ok = "1234567890/";

        for(i=0; i < date.length ;i++)
        {
        if(ok.indexOf(date.charAt(i))<0)
        {
            return (false);
        }

        }
        var jj=date.substring(0,2);
        var mm=date.substring(3,5);
        var aa=date.substring(6,10);
        var newDate=aa+"/"+mm+"/"+jj;

        var Expression = /^((((1[6-9]|[2-9]\d)\d{2})(\/|\-)(0?[13578]|1[02])(\/|\-)(0?[1-9]|[12]\d|3[01]))|(((1[6-9]|[2-9]\d)\d{2})(\/|\-)(0?[13456789]|1[012])(\/|\-)(0?[1-9]|[12]\d|30))|(((1[6-9]|[2-9]\d)\d{2})(\/|\-)0?2(\/|\-)(0?[1-9]|1\d|2[0-8]))|(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-))$/;

        var objExp = new RegExp(Expression);

        if(objExp.test(newDate)==true)

            return true

        else return false;

    }
	
	
	function searchFormSubmit(form) {
		var buffer = "";
		var obj;
		var lobj;
		var f=document.getElementById("searchForm");
		var tmp = f['dateDepart'].value;
		obj = f['dateDepart']
		tmp = tmp.trim();

		if (!checkDate(tmp)) {
			buffer += "Veuillez corriger votre date de d\xE9part jj/mm/aaaa" ;
			lobj = obj;
		} else if (!isAnEmptyDate(tmp)) {

			document.getElementById('searchForm').dd.value = tmp.substring(0,2);
			document.getElementById('searchForm').dmy.value = tmp.substring(3,10);

		}

		buffer += "\n" ;
		if (buffer!="\n") {
		buffer = buffer;
		alert(buffer);
		lobj.focus();
		return false;
		} else f.submit();

	}
    
	
	function PopupImage(img) {
        w=open("",'image','width=400,height=400,toolbar=no,scrollbars=no,resizable=yes');
        w.document.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\"><title>Fnac.com - Voyages</title></head>");
        w.document.write("<script language=javascript type=\"text/javascript\">function checksize() { if (document.images[0].complete) {  window.resizeTo(document.images[0].width+13,document.images[0].height+31); window.focus();} else { setTimeout('check()',250) } }</"+"script>");
        w.document.write("<body onload='checksize()' bgcolor='#000000' leftMargin=0 topMargin=0 marginwidth=0 marginheight=0><img src='"+img+"' border=0/>");
        w.document.write("");
        w.document.write("</body></html>");
        w.document.close();

}
