

function formHandler(fn) {

     var uri = fn.options[fn.selectedIndex].value;



     if (uri == "http://meteo.chamonix.com/MetPreE.php3") {
		MM_openBrWindow('http://meteo.chamonix.com/MetPreE.php3','weather','menubar=yes,resizable=yes,scrollbars=yes,width=600,height=400');
     } else if (uri == "summers.html") {
		MM_openBrWindow('http://www.bigfoot-travel.co.uk/2003/summers.html','xsum','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=475,height=420,left=0,top=0');
     } else if (uri != "") {
        location.href = uri;
     }

}


function selfHandler(fn) {
     var uri = fn.options[fn.selectedIndex].value;
     if (uri != "") {
        window.location.href = uri;
     }
}

function verifyform (theForm) {
	var message = "";

	if (typeof(theForm.year) != 'undefined') {
		date1      = new Date (theForm.year.value,(theForm.month.value-1),theForm.days.value);
		aujourdhui = new Date ();
		aujourdhui = new Date (aujourdhui.getYear(),aujourdhui.getMonth(),(aujourdhui.getDate()));
		demain     = new Date (aujourdhui.getYear(),aujourdhui.getMonth(),(aujourdhui.getDate() + 1)); 
	
		if (date1 < aujourdhui) {
			message = message + "Your arrival date is before today.\n";
		}
		
		if (date1.getDate() != theForm.days.value) {
			message = message + "Your arrival date is incorrect \(Date doesn't exist\)\n";
		}
	}

	if ( (theForm.acc_hotel.value == "") && (theForm.acc_apartment.value == "") && (theForm.acc_chalet.value == "") ) {
		message = message + "Please choose a Hotel, Appartment or a Chalet.\n";

	}

	if (message != "") {
    		alert(message);
		return (false);
	}

	  return (true);
}

function GP_popupConfirmMsg(msg) { //v1.0
  document.MM_returnValue = confirm(msg);
}


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


// FUNCTION CHECK INPUTS GENERAL IN FORMS LARS FORNELL - ATIPIC JULY-2003 Ver 0.5
function checkform(x,det,pers) {
	var mess = 0;
	var message = '     You have not completed the form.     \n\n     Please check the highlighted fields.     ';

	for (var i=0;i<x.elements.length;i++)
	{


// CHECK FOR FIELDS WITH NUMBER, NAME THE ID WITH "num_" IN THE BEGINNING
		if (document.getElementById(x.elements[i].name).id.match(/^num_/g)) {
			if (!x.elements[i].value.match(/[0-9]/g)) {
				mess = -1;
				document.getElementById(x.elements[i].name).className = 'formitextx';
			} else {
				document.getElementById(x.elements[i].name).className = 'formitext';
			}
		 }

// CHECK FOR FIELDS WITH LESS THAN 2 CHARACTERS, NAME THE ID WITH "man_" IN THE BEGINNING

		if (document.getElementById(x.elements[i].name).id.match(/^man_/g)) {
			if (x.elements[i].value.length < 2) {
				mess = -1;
				document.getElementById(x.elements[i].name).className = 'formitextx';
			} else {
				document.getElementById(x.elements[i].name).className = 'formitext';
			}
		 }
	

// CHECK FOR SELECT FIELDS WITH THE VALUE 0, NAME THE ID WITH "mansel_" IN THE BEGINNING

		if (document.getElementById(x.elements[i].name).id.match(/^mansel_/g)) {
			if (x.elements[i].value == 0) {
				mess = -1;
				document.getElementById(x.elements[i].name).className = 'formitextx';
			} else {
				document.getElementById(x.elements[i].name).className = 'formitext';
			}
		 }

// CHECK FOR VALID EMAIL, NAME THE ID WITH "email_" IN THE BEGINNING

		if (document.getElementById(x.elements[i].name).id.match(/^email_/g)) {
			if (!x.elements[i].value.match("^[\\w\.=-]+@[\\w\\.-]+\\.[a-zA-Z]{2,4}$")) {

				mess = -1;
				document.getElementById(x.elements[i].name).className = 'formitextx';
			} else {
				document.getElementById(x.elements[i].name).className = 'formitext';
			}
		 }

	}

	if (det) {
		// CHECK FOR VALID IN PARTY, NAME THE ID WITH "sel_" IN THE BEGINNING
	

		var nbpers = 0;
		var ArrSel = new Array();
		var y = 0;
		var fnbpers = x.nbpers.value;

		for (i=0;i<x.elements.length;i++)
		{
			if (document.getElementById(x.elements[i].name).id.match(/^sel_/g)) {
			nbpers = nbpers + parseInt(x.elements[i].value);
			ArrSel[y] = x.elements[i].name;
			y++;
			}
		}
	
		for (i=0;i<ArrSel.length;i++)
		{
			if (nbpers == fnbpers) {
				document.getElementById(ArrSel[i]).className = 'formitext';
			} else {
				mess = -1;
				document.getElementById(ArrSel[i]).className = 'formitextx';
			}
		}
	}


	if (pers) {
		// CHECK FOR VALID IN PARTY, NAME THE ID WITH "room_" IN THE BEGINNING
		
		var ArrElem = new Array();
		var ArrPers = new Array();
		y = 0;
		var xrooms = x.xroom.value.split(",");
		xrooms.sort();

		for (i=0;i<x.elements.length;i++)
		{
			if (document.getElementById(x.elements[i].name).id.match(/^room_/g)) {
			ArrElem[y] = x.elements[i].name;
			ArrPers[y] = parseInt(x.elements[i].value);
			y++;
			}
		}

		ArrPers.sort();


		for (i=0;i<ArrElem.length;i++)
		{
			if (String(xrooms) != String(ArrPers)) {
				mess = -1;
				document.getElementById(ArrElem[i]).className = 'formitextx';
			} else {
				document.getElementById(ArrElem[i]).className = 'formitext';
			}
		}
	}

//document.x.accept
	if (x.accept) {
		if (!x.accept.checked) {
			if (!mess) {
				message = '';
			}

			message = message + '\n\n     You have not accepted the sales conditons.     \n\n     Please check the checkbox.     \n     \"I agree with the conditions of sale\"     ';
			mess = - 1;
		}
	}
	
	if (mess) {
		alert(message);
		return false;
	} else {
	//	alert('Works!!!');
		return true;

	}
}

function openPictureWindow_Fever(imageType,imageName,imageWidth,imageHeight,alt,posLeft,posTop) {  // v4.01
	newWindow = window.open("","newWindow","width="+imageWidth+",height="+imageHeight+",scrollbars=no,left="+posLeft+",top="+posTop);
	newWindow.document.open();
	newWindow.document.write('<html><title>'+alt+'</title><body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onBlur="self.close()">'); 
	if (imageType == "swf"){
	newWindow.document.write('<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0\" width=\"'+imageWidth+'\" height=\"'+imageHeight+'\">');
	newWindow.document.write('<param name=movie value=\"'+imageName+'\"><param name=quality value=high>');
	newWindow.document.write('<embed src=\"'+imageName+'\" quality=high pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" width=\"'+imageWidth+'\" height=\"'+imageHeight+'\">');
	newWindow.document.write('</embed></object>');	}else{
	newWindow.document.write('<img src=\"'+imageName+'\" width='+imageWidth+' height='+imageHeight+' alt=\"'+alt+'\">'); 	}
	newWindow.document.write('</body></html>');
	newWindow.document.close();
	newWindow.focus();
}
