function validate(f) {
                var eltArr = new Array("request_first_name", "First Name", "request_last_name", "Last Name", "request_email", "Email", "request_phone_day", "Day Phone", "destination", "Destination", "sup_name", "Cruise Line", "m_request_travel_date", "Travel Month", "d_request_travel_date", "Travel Date", "y_request_travel_date", "Travel Year");
                for (var i=0; i<eltArr.length; i+=2) {
                        var e = f.elements[eltArr[i]];
                        if (e != null) {
                                if (e.name.indexOf("email") > -1 &&
                                    !ValidEmail(e.value)) {
                                        alert("The email address is not valid.");
                                        return;
                                } else if (trim(e.value) == "") {
                                        alert("Please fill in a value for \"" + eltArr[i+1] + "\".");
                                        return;
                                }   // if
                        } else {
                                //alert("Element " + eltArr[i] + " not found.");
                        } // if
                }   // for
                f.submit();
        }   // validate
function toggleRoom(imgName, divId) { 
		var s = document.images[imgName].src; 
		if (s.indexOf('collapsed.gif') > -1) { 
			s = '/images/expanded.gif'; 
			$('#' + divId).show(); 
		} else { 
			s = '/images/collapsed.gif';
			$('#' + divId).hide(); 
		}   // if 
		document.images[imgName].src = s;
	} 
	
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_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);  }
  
		

function reloadPage() {
        var searchStr = location.search;

        var i;
        for (i=0; i<arguments.length; i+=2) {
                var paramName = arguments[i];
                var paramVal = arguments[i+1];
                var paramExpr = paramName + "=" + escape(paramVal);
                if (getParam(paramName) != null) {
                        var replaceParamValRegEx = new RegExp(paramName + "=([^&]*)");
                        searchStr = searchStr.replace(replaceParamValRegEx, paramExpr);
                } else {
                        if (searchStr != "" && searchStr != "?") searchStr += "&";
                        searchStr += paramExpr;
                }
        }

        if (searchStr.charAt(0) != '?') searchStr = "?" + searchStr;
        var url = location.pathname + searchStr;

        location = url;
}

        function isFloat(s)
        {
                if (isInteger(s)) {
                        return true;
                }   // if
                var n = trim(s);
                return n.length>0 && !(/[^0-9.]/).test(n) && (/\.\d/).test(n);
        }   // isFloat

        function formatPrice(value) {
                var ret = Math.round(value * 100).toString();
                var len = ret.length;
                if (len == 1) {ret = "00" + ret; len = 3}
                if (len == 2) {ret =  "0" + ret; len = 3}
                return ret.substring(0,len-2) + "." + ret.substring(len-2,len);
        }   //formatPrice

        function isInteger(s)
        {
                var n = trim(s);
                return n.length > 0 && !(/[^0-9]/).test(n);
        }

	function trim(s) 
        {
                return s.replace(/^\s+|\s+$/g, "");
        }   // trim
 
	/* This function is borrowed from http://javascript.internet.com/forms/check-email.html */
	function ValidEmail (emailStr) {
		/* The following pattern is used to check if the entered e-mail address
		   fits the user@domain format.  It also is used to separate the username
		   from the domain. */
		var emailPat=/^(.+)@(.+)$/
		/* The following string represents the pattern for matching all special
		   characters.  We don't want to allow special characters in the address. 
		   These characters include ( ) < > @ , ; : \ " . [ ]    */
		var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
		/* The following string represents the range of characters allowed in a 
		   username or domainname.  It really states which chars aren't allowed. */
		var validChars="\[^\\s" + specialChars + "\]"
		/* The following pattern applies if the "user" is a quoted string (in
		   which case, there are no rules about which characters are allowed
		   and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
		   is a legal e-mail address. */
		var quotedUser="(\"[^\"]*\")"
		/* The following pattern applies for domains that are IP addresses,
		   rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
		   e-mail address. NOTE: The square brackets are required. */
		var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
		/* The following string represents an atom (basically a series of
		   non-special characters.) */
		var atom=validChars + '+'
		/* The following string represents one word in the typical username.
		   For example, in john.doe@somewhere.com, john and doe are words.
		   Basically, a word is either an atom or quoted string. */
		var word="(" + atom + "|" + quotedUser + ")"
		// The following pattern describes the structure of the user
		var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
		/* The following pattern describes the structure of a normal symbolic
		   domain, as opposed to ipDomainPat, shown above. */
		var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
		
		
		/* Finally, let's start trying to figure out if the supplied address is
		   valid. */
		
		/* Begin with the coarse pattern to simply break up user@domain into
		   different pieces that are easy to analyze. */
		var matchArray=emailStr.match(emailPat)
		if (matchArray==null) {
		  /* Too many/few @'s or something; basically, this address doesn't
		     even fit the general mould of a valid e-mail address. */
			//alert("Email address seems incorrect (check @ and .'s)")
			return false
		}
		var user=matchArray[1]
		var domain=matchArray[2]
	
		// See if "user" is valid 
		if (user.match(userPat)==null) {
		    // user is not valid
		    //alert("The username doesn't seem to be valid.")
		    return false
		}
		
		/* if the e-mail address is at an IP address (as opposed to a symbolic
		   host name) make sure the IP address is valid. */
		var IPArray=domain.match(ipDomainPat)
		if (IPArray!=null) {
		    // this is an IP address
			  for (var i=1;i<=4;i++) {
			    if (IPArray[i]>255) {
			        //alert("Destination IP address is invalid!")
				return false
			    }
		    }
		    return true
		}
		
		// Domain is symbolic name
		var domainArray=domain.match(domainPat)
		if (domainArray==null) {
			//alert("The domain name doesn't seem to be valid.")
		    return false
		}
		
		/* domain name seems valid, but now make sure that it ends in a
		   three-letter word (like com, edu, gov) or a two-letter word,
		   representing country (uk, nl), and that there's a hostname preceding 
		   the domain or country. */
		
		/* Now we need to break up the domain to get a count of how many atoms
		   it consists of. */
		var atomPat=new RegExp(atom,"g")
		var domArr=domain.match(atomPat)
		var len=domArr.length
		if (domArr[domArr.length-1].length<2 || 
		    domArr[domArr.length-1].length>3) {
		   // the address must end in a two letter or three letter word.
		   //alert("The address must end in a three-letter domain, or two letter country.")
		   return false
		}
		
		// Make sure there's a host name preceding the domain.
		if (len<2) {
		   var errStr="This address is missing a hostname!"
		   //alert(errStr)
		   return false
		}
		
		// If we've gotten this far, everything's valid!
		return true;
	}
function getParam(paramName) {
        var searchStr = location.search;        // Get the location's query string.
        var paramValRegEx = new RegExp(paramName + "=([^&]*)");
        var matchArr = searchStr.match(paramValRegEx);
        if (matchArr != null) {
                return unescape(matchArr[1]);
        } else {
                return null;
        }
}

	function validateLandSearch(f) { 
		var destListArr = new Array(); 
		var e = document.getElementById('offer_dest_id'); 
		for (var i=0; i<e.options.length; i++) { 
			if (e.options[i].selected && e.options[i].value != "") 
				destListArr[destListArr.length] = e.options[i].value; 
		}   // for 	
		document.getElementById('dest_list').value = destListArr.join(",");  
	
		/* var featuredDestListArr = new Array();
		var e = document.getElementById('destinationID'); 
		for (var i=0; i<e.options.length; i++) { 
			if (e.options[i].selected && e.options[i].value != "") 
				featuredDestListArr[featuredDestListArr.length] = e.options[i].value; 
		}   // for 	
		document.getElementById('featured_dest_list').value = featuredDestListArr.join(","); */  

		var tourLengthListArr = new Array();
		var e = document.getElementById('tour_length'); 
		for (var i=0; i<e.options.length; i++) { 
			if (e.options[i].selected && e.options[i].value != "") 
				tourLengthListArr[tourLengthListArr.length] = e.options[i].value; 
		}   // for 	
		document.getElementById('tour_length_list').value = tourLengthListArr.join(","); 

		/* var ratingListArr = new Array();
		var e = document.getElementById('rating'); 
		for (var i=0; i<e.options.length; i++) { 
			if (e.options[i].selected && e.options[i].value != "") 
				ratingListArr[ratingListArr.length] = e.options[i].value; 
		}   // for 	
		document.getElementById('rating_list').value = ratingListArr.join(",");  */   
		
		if (document.getElementById('supplier')) { 
			var supplierListArr = new Array();
			var e = document.getElementById('supplier'); 
			for (var i=0; i<e.options.length; i++) { 
				if (e.options[i].selected && e.options[i].value != "") 
					supplierListArr[supplierListArr.length] = e.options[i].value; 
			}   // for 	
			document.getElementById('supplier_list').value = supplierListArr.join(","); 
		}   // if 
	
		var fromDate = document.getElementById('fromDate').value; 
		if (fromDate != "" && !isDate(fromDate, 'M/d/yy')) { 
			alert("Please enter \"fromDate\" in the form M/d/yy");
			return false; 
		}   // if 
		var toDate = document.getElementById('toDate').value; 
		if (toDate != "" && !isDate(toDate, 'M/d/yy')) { 
			alert("Please enter \"toDate\" in the form M/d/yy");
			return false; 
		}    // if 
 
		f.submit(); 
	}   // validateLandSearch 

	function submitCruiseSearchForm(f)
	{
		var supMenu = document.getElementById('supplier');
		supArr = new Array(); 
		for (var i=0; i<supMenu.options.length; i++) { 
			if (supMenu.options[i].selected)
				supArr[supArr.length] = supMenu.options[i].value; 
		}   // for
		document.getElementById('supplier_list').value = supArr.join(',');
		f.submit(); 
	}   // submitCruiseSearchForm 
	
	function show(sw,obj) {
		var ns4 = (document.layers) ? true : false;
		var ie4 = (document.all && !document.getElementById) ? true : false;
		var ie5 = (document.all && document.getElementById) ? true : false;
		var ns6 = (!document.all && document.getElementById) ? true : false;
		// show/hide the divisions
		if (sw && (ie4 || ie5) ) document.all[obj].style.visibility = 'visible';
		if (!sw && (ie4 || ie5) ) document.all[obj].style.visibility = 'hidden';
		if (sw && ns4) document.layers[obj].visibility = 'visible';
		if (!sw && ns4) document.layers[obj].visibility = 'hidden';
	}
	
	function processRequest(){
		show(false,'div2');
		show(true, 'div1');
	}

