var resortlimit = 1;

function ResortTotal(form1)
{
	var total = 0;
	for (var i=0;i<form1.peopleType.length;i++)
		if (form1.peopleType[i].checked)
			total++;
	return total;
}


function CheckResortLimit(form1)
{
	var isValid = true;
	var total = ResortTotal(form1);

	if (total > resortlimit)
	{
		isValid = false;
		alert("You can only select " + resortlimit + " field.");
	}
	return isValid;
}

function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function openWin( windowURL, windowName, windowFeatures ) { 
		return window.open( windowURL, windowName, windowFeatures ) ; 
} 
	
function ShowCalendar(FormName, FieldName)
<!--
{
	window.open("../calendar/calendar.cfm?FormName=" + FormName + "&FieldName=" + FieldName, "CalendarWindow", "width=200,height=220");
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function refreshParent() {
  window.opener.location.reload(); 
}
function MM_popupMsg(msg,url) { //v1.0
  if(confirm(msg)) {
  	MM_goToURL('parent',url);
  }
}


function byquantity() {
	document.getElementById('minbutton').disabled=false;
	document.getElementById('maxbutton').disabled=false;
	document.getElementById('minbutton1').disabled=false;
	document.getElementById('maxbutton1').disabled=false;
	document.getElementById('minitems').innerHTML=' items';
	document.getElementById('maxitems').innerHTML=' items';
	document.getElementById('mindollars').innerHTML='';
	document.getElementById('maxdollars').innerHTML='';
	document.getElementById('MaxOrder').disabled=false;
	document.getElementById('MinOrder').disabled=false;
}
function byamount() {
	document.getElementById('minbutton').disabled=false;
	document.getElementById('maxbutton').disabled=false;
	document.getElementById('minbutton1').disabled=false;
	document.getElementById('maxbutton1').disabled=false;
	document.getElementById('minitems').innerHTML='';
	document.getElementById('maxitems').innerHTML='';
	document.getElementById('mindollars').innerHTML='$';
	document.getElementById('maxdollars').innerHTML='$';
	document.getElementById('MaxOrder').disabled=false;
	document.getElementById('MinOrder').disabled=false;
}
function maxminNO() {
	document.getElementById('minbutton').disabled=true;
	document.getElementById('maxbutton').disabled=true;
	document.getElementById('minbutton1').disabled=true;
	document.getElementById('minbutton1').checked=true;
	document.getElementById('maxbutton1').disabled=true;
	document.getElementById('maxbutton1').checked=true;
	document.getElementById('MinOrder').value="";
	document.getElementById('MaxOrder').value="";
	document.getElementById('MinOrder').disabled=true;
	document.getElementById('MaxOrder').disabled=true;
	document.getElementById('minitems').innerHTML='';
	document.getElementById('maxitems').innerHTML='';
	document.getElementById('mindollars').innerHTML='';
	document.getElementById('maxdollars').innerHTML='';
}

function confirmation(message,link_to) {
	var yes = confirm(message);
	if (yes) {
		window.location=link_to;
	}
}

function notempty(field) {

	if (document.getElementById(field).value=="") {
		document.getElementById(field).value=0;
	}
}
