function checkForJpg(dastr)
{
    var extstr = "";

    extstr= (dastr.charAt(dastr.length-3) + dastr.charAt(dastr.length-2) + dastr.charAt(dastr.length-1));

    if (dastr=="") { return 1; }

    if ((extstr.toUpperCase() != "JPG") && (extstr.toUpperCase() != "PEG") && (extstr.toUpperCase() != "GIF") && (extstr.toUpperCase() != "BMP") && (extstr.toUpperCase() != "TIF") && (extstr.toUpperCase() != "IFF") && (extstr.toUpperCase() != "PNG"))
	{
        alert('Sorry, only JPG/JPEG/TIF/TIFF/GIF/PNG/BMP files are supported.');
        return 0;
    }

    return 1;
}

function selectObj()
{
	this.options = new Array();

	this.addOption = function(value)
	{
		this.options[value] = new optionObj();
	}
}

function optionObj()
{
	this.options = new Array();

	this.createOption = function(name, value)
	{
		this.options[this.options.length] = new Option(name, value);
	}
}

function fAddListItem(strDate)
{
	var dl=document.form.dateList;
	dl.options[dl.options.length]=new Option(strDate,strDate);
}

function fRemoveListItem(strDate)
{
		var dl=document.form.dateList;
	 for (var i=0;i<dl.options.length;i++)
		 if (strDate==dl.options[i].value)
			 break;
	 dl.options[i]=null;
}
			
function checkfield2()
{
	var pass = true;

	if (document.form.villes.value < 1)
	{
		alert("Sorry, you must enter your region / area.");
		pass = false;
	}

	else if (document.form.secteur.value < 1)
	{
		alert("Sorry, you must enter your city / neighborhood.");
		pass = false;
	}

    else if ( (form.mer.checked == false) && (form.fleuve.checked == false) && (form.lac.checked == false) && (form.montagne.checked == false) && (form.foret.checked == false) && (form.campagne.checked == false) && (form.village.checked == false)  && (form.ville.checked == false) )
    {
        alert("Sorry, you must enter your surroundings");
        pass = false;    
	}
	else if (form.habitation.value < 1)
	{
		alert("Sorry, you must enter your property type.");
		pass = false;
	}

	else if (form.meter.value < 1)
	{
		alert("Sorry, you must enter the surface area.");
		pass = false;
	}

	else if (form.pieces.value < 1)
	{
		alert("Sorry, you must enter the number of rooms.");
		pass = false;
	}

	else if (form.personnes.value == "")
	{
		alert("Sorry, you must enter the maximum number of persons.");
		document.form.personnes.select();
		pass = false;
	}

	else if (form.semaine1.value  < 1)
	{
		alert("Sorry, the price/week field is mandatory. You must put a price other than 0.");
		document.form.semaine1.select();
		pass = false;
	}

	else if ( (!(parseInt(form.moisdb1.value) <= parseInt(form.moisfn1.value) )) || ( (parseInt(form.moisdb1.value) == parseInt(form.moisfn1.value) ) && (parseInt(form.jrdb1.value) > parseInt(form.jrfn1.value) ) ) )
	{
		alert("Sorry, your date is incorrect on the 1st line.");
		document.form.jrdb1.select();
		pass = false;
	}

	else if ( (!(parseInt(form.moisdb2.value) <= parseInt(form.moisfn2.value) )) || ( (parseInt(form.moisdb2.value) == parseInt(form.moisfn2.value) ) && (parseInt(form.jrdb2.value) > parseInt(form.jrfn2.value) ) ) )
	{
		alert("Sorry, your date is incorrect on the 2nd line.");
		document.form.jrdb2.select();
		pass = false;
	}

	else if ( (!(parseInt(form.moisdb3.value) <= parseInt(form.moisfn3.value) )) || ( (parseInt(form.moisdb3.value) == parseInt(form.moisfn3.value) ) && (parseInt(form.jrdb3.value) > parseInt(form.jrfn3.value) ) ) )
	{
		alert("Sorry, your date is incorrect on the 3th line.");
		document.form.jrdb3.select();
		pass = false;
	}

	else if ( (!(parseInt(form.moisdb4.value) <= parseInt(form.moisfn4.value) )) || ( (parseInt(form.moisdb4.value) == parseInt(form.moisfn4.value) ) && (parseInt(form.jrdb4.value) > parseInt(form.jrfn4.value) ) ) )
	{
		alert("Sorry, your date is incorrect on the 4th line.");
		document.form.jrdb4.select();
		pass = false;
	}

	else if ( (!(parseInt(form.moisdb5.value) <= parseInt(form.moisfn5.value) )) || ( (parseInt(form.moisdb5.value) == parseInt(form.moisfn5.value) ) && (parseInt(form.jrdb5.value) > parseInt(form.jrfn5.value) ) ) )
	{
		alert("Sorry, your date is incorrect on the 5th line.");
		document.form.jrdb5.select();
		pass = false;
	}

	else if ( (!(parseInt(form.moisdb6.value) <= parseInt(form.moisfn6.value) )) || ( (parseInt(form.moisdb6.value) == parseInt(form.moisfn6.value) ) && (parseInt(form.jrdb6.value) > parseInt(form.jrfn6.value) ) ) )
	{
		alert("Sorry, your date is incorrect on the 6th line.");
		document.form.jrdb6.select();
		pass = false;
	}

	else if ( (!(parseInt(form.moisdb7.value) <= parseInt(form.moisfn7.value) )) || ( (parseInt(form.moisdb7.value) == parseInt(form.moisfn7.value) ) && (parseInt(form.jrdb7.value) > parseInt(form.jrfn7.value) ) ) )
	{
		alert("Sorry, your date is incorrect on the 7th line.");
		document.form.jrdb7.select();
		pass = false;
	}

	else if (form.usertext.value == "")
	{
		alert("Sorry, you must enter your comments in english.");
		document.form.usertext.select();
		pass = false;
	}

	else if (form.usertext2.value == "")
	{
		alert("Sorry, you must enter your comments in french.");
		document.form.usertext2.select();
		pass = false;
	}

	else if (form.usertext2.value.length > 450)
	{
		alert("Sorry, you have reach the limit of 450 characters in the french comments field's.");
		document.form.usertext2.select();
		pass = false;
	}

	else if (form.usertext.value.length > 450)
	{
		alert("Sorry, you have reach the limit of 450 characters in the english comments field's.");
		document.form.usertext.select();
		pass = false;
	}

	else if ( (form.phone1.value == "") && (form.courriel.value == "") )
	{
		alert("Sorry, you must provide a way to reach you (phone or email).");
		document.form.phone1.select();
		pass = false;
	}

	document.form.allSelected.value="";

	for (var i=0; i<document.form.dateList.length; i++)
	{
		if (i>0) document.form.allSelected.value+=",";
			document.form.allSelected.value+=document.form.dateList.options[i].value;
	}
	
	if (pass)
		document.form.submit()
}  
			
function count_txt_fr()
{
	document.form.textcount2.value = 450 - document.form.usertext2.value.length;
	if (document.form.usertext2.value.length > 450)
		alert("Sorry, you have reach the limit of 450 characters.");
	return false;
}

function count_txt_en()
{
	document.form.textcount.value = 450 - document.form.usertext.value.length;
	if (document.form.usertext.value.length > 450)
		alert("Sorry, you have reach the limit of 450 characters.");
	return false;
}			