
var dragapproved = false;
var minrestore = 0;

var ie5 = document.all&&document.getElementById;
var ns6 = document.getElementById&&!document.all;
var MSIEWIN = (navigator.userAgent.indexOf('MSIE')>=0 && navigator.userAgent.indexOf('Win')>=0 && navigator.userAgent.toLowerCase().indexOf('opera')<0)?true:false;

var htcount = 0;
var intervId;

var initialCoords = new Array();
var finalCoords = new Array();

var startEventPos = new Array();
var startPosWindow = new Array();

var initialized = false;
var mediaLayerImg;

var srch_url = "";

function postalThenSubmit(url, form, packageRecordId) {
	if (postalCodePanel) {
		postalCodePanel.showPostalPanel((form == null || form == undefined)
				? "javascript:submitFormEvent('" + url + "');"
				: "javascript:submitThisFormEvent('" + form + "','"+ url + "');", packageRecordId);
	}
}

function mailtoHack(emailId, subject) {

	
	document.write ("<A href='mailto:" + emailId+"?subject="+subject+"'>" + emailId + "</A>");
	
	return;
	
}

function validateZipCode() {
	var pc=document.forms['OBESearchForm'].postal_code.value;
	var cn=document.forms['OBESearchForm'].countryres.value;
	if ( pc != "" ) {
 		var params = new SOAPClientParameters();
		params.add("zipCode", pc);
		params.add("countryCode", cn);
		SOAPClient.invoke(postalValidationServiceUrl, "isZipCodeValid", params, true, validateZipCode_callback);
	}
	else {
		alert("Please enter a valid ZIP/Postal Code");
	}
}

function validateZipCode_callback(result) {
	if(result.isValid == "true") {
		doSearch(result);
	} else {
		alert (result.message);
	}
}
			
function doSearch(result) {
					
	document.forms['OBESearchForm'].stateres.value = result.provincecode;
	document.forms['OBESearchForm'].submit();
}
			


function setMastheadEVideo(automovie) {
	if ( document.getElementById("MastheadCell") ) {
		document.getElementById("MastheadCell").innerHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"' 
+ ' codebase="https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" id="evid" align="middle" height="173" width="738">'
+ ' 		<param name="movie" value="' + automovie + '">'
+ ' 		<param name="FlashVars" value="strURL=/GetPackageDetailsScreen.event&amp;strWindow=_self">'
+ ' 		<param name="quality" value="best">'
+ ' 		<param name="menu" value="false">'
+ ' 		<param name="wmode" value="transparent">'
+ ' 		<param name="bgcolor" value="#000000">'
+ ' 	<embed src="' + automovie + '" '
+ ' 		flashvars="strURL=/GetPackageDetailsScreen.event&amp;strWindow=_self" '
+ ' 		menu="false" '
+ ' 		wmode="transparent" '
+ ' 		quality="best" '
+ ' 		bgcolor="#000000" '
+ ' 		name="mvc" '
+ ' 		type="application/x-shockwave-flash" '
+ ' 		pluginspage="https://www.macromedia.com/go/getflashplayer" '
+ ' 		swliveconnect="true" '
+ ' 		height="173" '
+ ' 		width="738" '
+ ' 		swliveconnect="true" '
+ ' 		align="center" >'
+ ' 	</object>';
	} 
}



function PreventEnter() {
  return !(window.event && window.event.keyCode == 13); 
}


// AJAX Related Functions

function createXMLHttpRequest() {
	if ( window.ActiveXObject ) {
		return new ActiveXObject("Microsoft.XMLHTTP");
	}
	else {
		return new XMLHttpRequest();
	}
}

function setSelect(selectObject, options)
{

  selectObject.disabled = true;
  selectObject.options.length = 0;
  for (i = 0 ; i < options.length ; i++)
    {
    selectObject.options[i] = options[i];
    }
  selectObject.disabled = false;
}


//

function toggleSurveyChecked(frm, fld, val) {

	rb = document.forms[frm].elements[fld];
	if(!rb)
		return;
		
	if ( rb.checked ) {
		rb.checked = false;
		document.forms[frm].elements[fld].checked = false;
		document.getElementById("surveyans" + val).className = "surveyans";
	}
	else {
		document.forms[frm].elements[fld].checked = true;
		document.getElementById("surveyans" + val).className = "surveyansOn";

	}

}


function setSurveyRadioButton(frm, fld, val) {

	rb = document.forms[frm].elements[fld];
	if(!rb)
		return;
		
	var len = rb.length;
	if(len == undefined) {
		rb.checked = (rb.value == val.toString());
		document.getElementById("surveyans" + val).className = "surveyansOn";
		return;
	}
	
	for(var i = 0; i < len; i++) {
		rb[i].checked = false;
		document.getElementById("surveyans" + i).className = "surveyans";
		if(rb[i].value == val.toString()) {
			rb[i].checked = true;
			document.getElementById("surveyans" + i).className = "surveyansOn";
			
		}
	} 
}



function setChanged(fld, val) {
	document.forms[0].elements[fld].value = val;
}

function setFormFieldFocus(fname, fld) {
	document.forms[fname].elements[fld].focus();
	if (document.forms[fname].elements[fld]['select']) {
		document.forms[fname].elements[fld].select();
	}
}

function setFocus(fld) {
	document.forms[0].elements[fld].focus();
	document.forms[0].elements[fld].select();
}

function validateDigits(strng, fldname, len) {
   if (isNaN(parseInt(strng))) {
      alert(fldname + " must only contain 3 digits.");
      return false;
   }
   else if ( strng.length != len ) {
      alert(fldname + " must contain 3 digits");
      return false;

   }


   return true;
}

function validateRequired(fld, fldname){
   if ( document.forms[0].elements[fld] ) {
	if ( document.forms[0].elements[fld].value == "" ) {
           alert(fldname + " is a required field")
	     setTimeout("setFocus('" + fld + "');", 20);

      }
   }
}

function validatePhoneField(fld, len) {

   if ( document.forms[0].elements[fld] ) {
      strng = document.forms[0].elements[fld].value;
      var stripped = strng.replace(/[\(\)\.\-\ ]/g, '');
      //strip out acceptable non-numeric characters
      if (isNaN(parseInt(stripped))) {
         alert("The phone number contains illegal characters.");
         setTimeout("setFocus('" + fld + "');", 20);
      }
      else if ( stripped.length != len ) {
         alert("Phone number must contain " + len + " digits");
         setTimeout("setFocus('" + fld + "');", 20);

      }
   }
}


function validatePhone(strng, len) {
   var stripped = strng.replace(/[\(\)\.\-\ ]/g, '');
   //strip out acceptable non-numeric characters
   if (isNaN(parseInt(stripped))) {
      alert("The phone number contains illegal characters.");
      return false;
   }
   else if ( stripped.length != len ) {
      alert("Phone number must contain " + len + " digits");
      return false;

   }
   return true;
}

function validateEmailAddress(fld){
	if ( document.forms[0].elements[fld] ) {
		var validemail=false
		var str=document.forms[0].elements[fld].value
		var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
		if (!filter.test(str)) {
			alert("Please enter a valid email address!")
			return false;
		}
	}
	return true;
}


function validateZIP(field) {
   var valid = "0123456789-";
   var hyphencount = 0;

   if (field.length!=5 && field.length!=10) {
      alert("Please enter your 5 digit or 5 digit+4 (12345-1234) zip code (for U.S. Addresses)");
      return false;
   }
   for (var i=0; i < field.length; i++) {
     temp = "" + field.substring(i, i+1);
     if (temp == "-") hyphencount++;
     if (valid.indexOf(temp) == "-1") {
        alert("Invalid characters in your zip code.  Please try again.");
        return false;
     }
     if ((hyphencount > 1) || ((field.length==10) && ""+field.charAt(5)!="-")) {
        alert("The hyphen character should be used with a properly formatted 5 digit+four zip code, like '12345-6789'.   Please try again.");
        return false;
     }
   }
   return true;
}

function iecompattest()
{
	return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}


function displayObjectCentered(Obj1) {
	var dm = getCenter();
	//the window positions
	var xpos = dm[0]
	var ypos = dm[1]
	document.getElementById(Obj1).style.display = '' ;
	document.getElementById(Obj1).style.left= xpos+"px"
	document.getElementById(Obj1).style.top=ns6? window.pageYOffset*1+ypos+"px" : iecompattest().scrollTop*1+ypos+"px"
	
}

function displayObjectAt(Obj1, xpos, ypos) {
	document.getElementById(Obj1).style.display = '' ;
	document.getElementById(Obj1).style.left= xpos+"px"
	document.getElementById(Obj1).style.top=ns6? window.pageYOffset*1+ypos+"px" : iecompattest().scrollTop*1+ypos+"px"

}


function imageFullSize(targetimage, sourceimage) {

	if ( document.images[targetimage] ) {
		document.images[targetimage].src=sourceimage.src
	}
	
}

function displayObject(Obj1) {
	if ( document.getElementById(Obj1) ) {
		document.getElementById(Obj1).style.display = 'inline' ;
	}
}

function hideObject(Obj1) {
	if ( document.getElementById(Obj1) ) {
		document.getElementById(Obj1).style.display = 'none';
	}
}



function toggleLayer(lay1) {
	document.getElementById(lay1).style.display = (document.getElementById(lay1).style.display == 'none') ? 'inline' : 'none';
}

function enableLayer(lay1, xpos, ypos){
	
	document.getElementById(lay1).style.display='inline'
	document.getElementById(lay1).style.left= xpos+"px"
	document.getElementById(lay1).style.top=ypos+"px"
}

function showSendFriend() {
	enableLayer('SendFriend', '100', '400');
}




// Start Image Enlarger
function imageEnlarger(url,width,height,resizeFactor){
	var undef;
	mediaLayer(url);

}

function closeit(layer1)
{
	if ( document.getElementById(layer1) ) {
		document.getElementById(layer1).style.display="none";
	}	
}
// End ImageEnlarger





function copyField(fromFld, toFld) {
	if ( document.forms[0].elements[fromFld] && document.forms[0].elements[toFld] ) {
		document.forms[0].elements[toFld].value  = document.forms[0].elements[fromFld].value ;
	}
}

function setPage (newAddress) {
        if (newAddress != "")  { document.location.href = newAddress; }
}


function popUpSecuritySeal(url) {
	sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=650,height=500');
	self.name = "mainWin";
}

function popupWin(url) {
win1 = window.open(url,"Popup_Window","titlebar=0,width=700,height=700,scrollbars,resizable=0");
}


function setThisFormValue(frm, fld, val) {
	if ( document.forms[frm].elements[fld] ) {
		document.forms[frm].elements[fld].value = val;
	}	
}

function submitFormField(frm, fld, val) {
       
     if ( document.forms[frm].elements[fld] ) {
        document.forms[frm].elements[fld].value=val;
        document.forms[frm].submit();
     }
}



function submitOBESearchForm (evnt) {
    document.OBESearchForm.action=evnt;
    document.OBESearchForm.submit();
}



function submitFormEvent(evnt) {
    document._Form.action=evnt;
    document._Form.submit();
}

function submitForm() {
    document._Form.submit();
}

function submitFormEventValue(evnt, fld, val) {
       
     if ( document._Form.elements[fld] ) {
        document._Form.elements[fld].value=val;
     }
     
     document._Form.action=evnt;
     document._Form.submit();

}

function submitThisFormEvent (frm, evnt) {

    if ( document.forms[frm] ) {
       document.forms[frm].action=evnt;
       document.forms[frm].submit();
    }
}


function submitOBESearch(evnt) {
    document.OBESearchForm.action=evnt;
    document.OBESearchForm.submit();
}


function setBookmark(val) {
        
     if ( document._Form.elements['BookmarkValue'] ) {
        document._Form.elements['BookmarkValue'].value=val;
        document._Form.elements['Evt'].value='Bookmark';
        document._Form.submit();

     }
}


function openVFWin(sEvent)
{
	var URLtoOpen='';
	URLtoOpen = sEvent;
      setPage ('/GetResortScreen.event') ;
	win1 = window.open(URLtoOpen,"VideoTours","width=660,height=600,scrollbars,resizable");
}

function openWin(sEvent)
{
	var URLtoOpen='';
	URLtoOpen = sEvent ;
	win1 = window.open(URLtoOpen,"Popup_Window","width=660,height=600,scrollbars,resizable");
}

function openWinOptions(sEvent, w, h, options)
{
	var URLtoOpen='';
	URLtoOpen = sEvent ;
      var sParams = "width="+w+",height="+h ;
      if ( options && options != "" )
         sParams += ","+options;

	win1 = window.open(URLtoOpen,"Popup_Window", sParams);
}


function printWindow(sEvent)
{
	var URLtoOpen='';
	URLtoOpen = sEvent ;
	win1 = window.open(URLtoOpen,"Print_Window","width=700,height=650,scrollbars,resizable");
}


/*
   name - name of the cookie
   value - value of the cookie
   [expires] - expiration date of the cookie
     (defaults to end of current session)
   [path] - path for which the cookie is valid
     (defaults to path of calling document)
   [domain] - domain for which the cookie is valid
     (defaults to domain of calling document)
   [secure] - Boolean value indicating if the cookie transmission requires
     a secure transmission
   * an argument defaults when it is assigned null as a placeholder
   * a null placeholder is not required for trailing omitted arguments
*/

function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}


/*
  name - name of the desired cookie
  return string containing value of specified cookie or null
  if cookie does not exist
*/

function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}


/*
   name - name of the cookie
   [path] - path of the cookie (must be same as path used to create cookie)
   [domain] - domain of the cookie (must be same as domain used to
     create cookie)
   path and domain default if assigned null or omitted if no explicit
     argument proceeds
*/

function deleteCookie(name, path, domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

// date - any instance of the Date object
// * hand all instances of the Date object to this function for "repairs"

function fixDate(date) {
  var base = new Date(0);
  var skew = base.getTime();
  if (skew > 0)
    date.setTime(date.getTime() - skew);
}



function update_start_date( day, mon, year ) {

     document.forms[0].elements['day'].options[day-1].selected=true;
     document.forms[0].elements['month'].options[mon-1].selected=true;

     for(i=0;i<document.forms[0].elements['year'].options.length;i++) {
        sCode=document.forms[0].elements['year'].options[i].value;
        if ( sCode == year ) {
            document.forms[0].elements['year'].options[i].selected=true;
        }
     }
}

function confirmMessage(msg)
{
    return confirm(msg);
}

   
function confirmdelete()
{
    return confirm("Are you sure you wish to delete this ?");
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v3.0
  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); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}

function updateField( fld, val ) {

	if ( document.forms[0].elements[fld] ) {
     		document.forms[0].elements[fld].value=val;
	}
}

function update_startDate( day, mon, year ) {

     document.forms[0].elements['day'].options[day-1].selected=true;
     document.forms[0].elements['month'].options[mon-1].selected=true;

     for(i=0;i<document.forms[0].elements['year'].options.length;i++) {
        sCode=document.forms[0].elements['year'].options[i].value;
        if ( sCode == year ) {
            document.forms[0].elements['year'].options[i].selected=true;
        }
     }
}



////////////////////////// CALENDAR starts from here
// Check whether the specified date is allowed, by comparing it with a start date and end date
// param: checkDate - the date to be checked;
// param: startDate - The minimum date allowed for selecting a date; may be null;
// param: endDate - The maximum date allowed for selecting a date; may be null;
// return: true if the date is allowed
function isDateAllowed(checkDate, startDate, endDate) {
	if (checkDate == null) {
		return false;
	}
	if (startDate != null) {
		if (checkDate < startDate) {
			return false;
		}
	}
	if (endDate != null) {
		if (checkDate > endDate) {
			return false;
		}
	}
	return true;
}

// Check whether the specified date matches a date from a list of dates
// param: checkDate - the date to be checked;
// param: blackoutDateslist - an array of Date objects
// return: true if the date matches
function isBlackoutDate(checkDate, blackoutDatesList) {
	if (checkDate == null) {
		return false;
	}
	if (blackoutDatesList != null) {
		for (var i = 0; i < blackoutDatesList.length; i++) {
			var bDate = blackoutDatesList[i];
			if (checkDate.getDate() == bDate.getDate() && checkDate.getMonth() == bDate.getMonth() && checkDate.getFullYear() == bDate.getFullYear()) {
				return true;
			}
		}
	}
	return false;
}

// Returns a Date object from a string representation "yyyy-MM-dd"
// param: inDate - the date to be processed; may be null of ''
// return: a Date object
function getDateFromString(inDate) {
	if (inDate == null || inDate == '') {
		return null;
	}
	var tokens = inDate.split('-', 3);
	if (tokens == null || tokens.length != 3) {
		return null;
	}
	var year = parseInt(tokens[0]);
	var month = parseInt(tokens[1]) - 1;
	var day = parseInt(tokens[2]);
	return new Date(year, month, day);
}

// Returns an array of Date objects that will need to be excluded from the 
// selectable dates
// param: blackoutDates - A list of dates that will be excluded from the selectable dates; may be ''; format: "yyyy-MM-dd,yyy-MM-dd,..."
// result: an array of Date objects
function getBlackoutDatesList(blackoutDates) {
	if (blackoutDates == null || blackoutDates == '') {
		return new Array(0);
	}
	var tokens = blackoutDates.split(',');
	var result = new Array(tokens.length);
	for (var i = 0 ; i < tokens.length; i++) {
		result[i] = getDateFromString(tokens[i]);
	}
	return result;
}

// It displays the calendar. It is called by DisplayCalendar or by a link
// 	from the calendar.
// param: target - reference to the calendar popup window;
// param: mon - selected month
// param: year - selected year
// param: endFunc - callback function that will be called when the user selects a day.
// param: startDateAsString - The minimum date allowed for selecting a date; may be ''; format: "yyyy-MM-dd"
// param: endDateAsString - The maximum date allowed for selecting a date; may be ''; format: "yyyy-MM-dd"
// param: blackoutDates - A list of dates that will be excluded from the selectable dates; may be ''; format: "yyyy-MM-dd,yyy-MM-dd,..."
function MakeCal(target, mon, year, endFunc, startDateAsString, endDateAsString, blackoutDates) { 
	// writes the calendar
	cal = ["<!doctype html public \"-//w3c//dtd html 4.0 transitional//en\">\n<html>\n<head>\n<link rel=\"stylesheet\" href=\"styles/webglobal.css\"></head>\n<body bgcolor=\"#0484A4\">\n\n<font color=\"#000000\">\n<center><table class=caltext CELLSPACING=0 CELLPADDING=3 ROWS=8 COLS=7 WIDTH=\"200\"  BGCOLOR=\"#FFFFFF\" NOSAVE >\n<tr>\n<td colspan=7 class=\"calmonth\" ALIGN=\"center\"><span class=\"top_navbar\"><b>","</b></span></td>\n</tr>\n<tr ALIGN=CENTER VALIGN=CENTER NOSAVE>\n<td NOSAVE><FONT COLOR=\"red\">S</FONT></td>\n\n<td>M</td>\n\n<td>T</td>\n\n<td>W</td>\n\n<td>T</td>\n\n<td>F</td>\n\n<td><FONT COLOR=\"red\">S</FONT></td>\n</tr>\n\n<tr ALIGN=CENTER VALIGN=CENTER NOSAVE>\n<td NOSAVE>","</td>\n\n<td>","</td>\n\n<td>","</td>\n\n<td>","</td>\n\n<td>","</td>\n\n<td>","</td>\n\n<td>","</td>\n</tr>\n\n<tr ALIGN=CENTER VALIGN=CENTER NOSAVE>\n\n<td NOSAVE>","</td>\n\n<td>","</td>\n\n<td>","</td>\n\n<td>","</td>\n\n<td>","</td>\n\n<td>","</td>\n\n<td>","</td>\n\n</tr>\n\n<tr ALIGN=CENTER VALIGN=CENTER NOSAVE>\n\n<td NOSAVE>","</td>\n\n<td>","</td>\n\n<td>","</td>\n\n<td>","</td>\n\n<td>","</td>\n\n<td>","</td>\n\n<td>","</td>\n\n</tr>\n\n<tr ALIGN=CENTER VALIGN=CENTER NOSAVE>\n\n<td NOSAVE>","</td>\n\n<td>","</td>\n\n<td>","</td>\n\n<td>","</td>\n\n<td>","</td>\n\n<td>","</td>\n\n<td>","</td>\n\n\n</tr>\n\n<tr ALIGN=CENTER VALIGN=CENTER NOSAVE>\n<td NOSAVE>","</td>\n\n<td>","</td>\n\n<td>","</td>\n\n<td>","</td>\n\n<td>","</td>\n\n<td>","</td>\n\n<td>","</td>\n\n\n</tr>\n\n<tr ALIGN=CENTER VALIGN=CENTER NOSAVE>\n<td NOSAVE>","</td>\n\n<td>","</td>\n\n<td>&nbsp;</td>\n\n<td>&nbsp;</td>\n\n<td>&nbsp;</td>\n\n<td>&nbsp;</td>\n\n<td>&nbsp;</td>\n\n</tr>\n\n<tr ALIGN=CENTER VALIGN=CENTER NOSAVE>\n<td colspan=7>\n<table height=20 align=\"center\" width=\"100%\" cellpadding=0 cellspacing=0>\n<tr class=\"calnextprev\">\n<td align=\"left\">","</td>\n<td align=\"right\">","</td>\n</tr>\n</table>\n\n</td>\n</tr>\n</table></center>\n</font>\n</body>\n</html>\n\n\n\n\n\n\n\n\n"];
	
	var startDate = getDateFromString(startDateAsString);
	var endDate = getDateFromString(endDateAsString);
	var blackoutDatesList = getBlackoutDatesList(blackoutDates);
	
	var today = new Date();
	var leap = IsLeap (year);
	var maxday = [31, 28 + leap, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
	var theDate = new Date(year, mon - 1, 1);
    // the day of the week for first day of
    var firstDay = theDate.getDay() + 1;
	// required month/year
	var i, nextY, nextM, prevM, prevY;
	// month names
	var monName = [0, "January", "February", "March","April","May","June","July","August","September","October","November","December"];
	target.document.close();
	target.document.open();
	// write the first part of the calendar HTML
	target.document.write(cal[0]);
	// writes month name and year name
	target.document.write(monName[mon] + "  "+ year);
	for (i = 1; i < (cal.length - 3); i++ ) {
		// write a segment of HTML
		target.document.write(cal[i]); 
		if ((i < firstDay) || ((i - firstDay + 1) > maxday[mon - 1])) {
			// there in no day...
			target.document.write("&nbsp;\n");
		} else {
			var currentDate = new Date(year, mon - 1, (i - firstDay + 1));
			
			// put today in bold
			if ((today.getFullYear() == year) && (today.getMonth() + 1 == mon) && (today.getDate() == (i - firstDay + 1))) {
				if (isDateAllowed(currentDate, startDate, endDate) && !isBlackoutDate(currentDate, blackoutDatesList)) {
					// day + link
					target.document.write("<a class=callink href='JavaScript:self.close();opener." + endFunc + "(" + (i - firstDay + 1) + "," + mon + "," 
						+ year + ");'><b>" + (i - firstDay + 1) + "</b></a>\n");
				} else {
					// day
					target.document.write("<b>" + (i - firstDay + 1) + "</b>\n");
				}
			} else {
				if (isDateAllowed(currentDate, startDate, endDate) && !isBlackoutDate(currentDate, blackoutDatesList)) {
					 // day + link
					target.document.write("<a class=callink href='JavaScript:self.close();opener." + endFunc + "(" + (i - firstDay + 1) + "," + mon + ","
						+ year + ");'>" + (i - firstDay + 1) + "</a>\n");
				} else {
					// day
					target.document.write((i - firstDay + 1) + "\n");
				}
			}
		}
	}
	// next month's year
	nextY = ((mon == 12) ? (year + 1) : year);
	// next month
	nextM = ((mon == 12) ? 1 : (mon + 1));
	// previous month year
	prevY = ((mon == 1) ? (year - 1) : year);
	// previous month
	prevM = ((mon == 1) ? 12 : (mon - 1)); 
	// writes a segment of HTML
	target.document.write(cal[cal.length - 3]);
	
	// compute last day of the previous month
	var lastDayPrevMonth = new Date(prevY, prevM - 1, maxday[prevM - 1]);
	// compute first day of the next month
	var firstDayNextMonth = new Date(nextY, nextM - 1, 1);
	
	// compute a string representation for the startDate that may be used in an external call
	if (isDateAllowed(lastDayPrevMonth, startDate, endDate)) {
		// previous - link
		target.document.write("<a href='JavaScript:opener.MakeCal(opener.calWindow," + prevM + "," + prevY + ",\"" + endFunc 
			+ "\",\"" + startDateAsString + "\",\"" + endDateAsString + "\",\"" + blackoutDates + "\");' class='calnextlinks'>prev</a>\n");
	} else {
		// hide previous link
		target.document.write("&nbsp;\n");
	}
	// writes a segment
	target.document.write(cal[cal.length - 2]);
	if (isDateAllowed(firstDayNextMonth, startDate, endDate)) {
		// next - link
		target.document.write("<a href='JavaScript:opener.MakeCal(opener.calWindow," + nextM + "," + nextY + ",\"" + endFunc 
			+ "\",\"" + startDateAsString + "\",\"" + endDateAsString + "\",\"" + blackoutDates + "\");' class='calnextlinks'>next</a>\n");
	} else {
		// hide next link
		target.document.write("&nbsp;\n");
	}
	// writes last segment of HTML
	target.document.write(cal[cal.length - 1]); 
	target.document.close();
}

// Check whether the specified year is leap year
// param: y - the year to be checked
// return 1 if the specified year is leap year, 0 otherwise
function IsLeap(y) {
	if (((y % 4) == 0) && (((y % 100) != 0) || ((y % 400) == 0))) {
		return 1;
	} else {
		return 0;
	}
}

// Show calendar and call the specified function when done.
// param: _function - The callback function that will be called after selecting a date.
function showCal(_function) {
	showCal(_function, null, null);
}

// Show calendar and call the specified function when done.
// param: _function - The callback function that will be called after selecting a date.
// param: startDate - The minimum date allowed for selecting a date; may be null or ''; format: "yyyy-MM-dd"
// param: endDate - The maximum date allowed for selecting a date; may be null or ''; format: "yyyy-MM-dd"
function showCal(_function, startDate, endDate) {
	showCal(_function, starttDate, endDate, null);
}

// Show calendar and call the specified function when done.
// param: _function - The callback function that will be called after selecting a date.
// param: startDate - The minimum date allowed for selecting a date; may be null or ''; format: "yyyy-MM-dd"
// param: endDate - The maximum date allowed for selecting a date; may be null or ''; format: "yyyy-MM-dd"
// param: blackoutDates - A list of dates that will be excluded from the selectable dates; may be null or ''; format: "yyyy-MM-dd,yyy-MM-dd,..."
function showCal(_function, startDate, endDate, blackoutDates) {
	// window with nothing
	window.calWindow=window.open("","Calendar","width=250,height=220,resizable=yes");// a simple
	
	today = new Date()
	cyear = today.getFullYear();
	cmon = today.getMonth() + 1;

	var normStartDate = (startDate == null) ? '' : startDate;
	var normEndDate = (endDate == null) ? '' : endDate;
	var normBlackoutDates = (blackoutDates == null) ? '' : blackoutDates;
	
	MakeCal(window.calWindow, cmon, cyear, _function, normStartDate, normEndDate, normBlackoutDates);
}





function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}


function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

// Credit Card Validation Functions

function cc_mod10( cardNumber ) { 
   var ar = new Array( cardNumber.length );
   var i = 0,sum = 0;


       for( i = 0; i < cardNumber.length; ++i ) {
          ar[i] = parseInt(cardNumber.charAt(i));
       }
       for( i = ar.length -2; i >= 0; i-=2 ) { 
          ar[i] *= 2;                  
          if( ar[i] > 9 ) ar[i]-=9;          
       }                               


           for( i = 0; i < ar.length; ++i ) {
              sum += ar[i];                   
           }
           return (((sum%10)==0)?true:false);       
    }


    function cc_expired( month, year ) {
       var now = new Date();                    
       var expiresIn = new Date(year,month,0,0,0);     
       expiresIn.setMonth(expiresIn.getMonth()+1);    
       if( now.getTime() < expiresIn.getTime() ) return false;
       return true;                   
    }


    function cc_validate_card(cardNumber,cardType,cardMonth,cardYear) {
           if( cardNumber.length == 0 ) {               
              alert("Please enter a valid card number.");
              return false;            
           }
           for( var i = 0; i < cardNumber.length; ++i ) {      
              var c = cardNumber.charAt(i);


        if( c < '0' || c > '9' ) {
			alert("Please enter a valid card number. Use only digits. Do not use spaces or hyphens.");
           return false;
           
        }
     }
     var length = cardNumber.length;        


     switch( cardType ) {
        case 'AMEX':


             if( length != 15 ) {
                alert("Please enter a valid American Express Card number.");
                return false;
             }
             var prefix = parseInt( cardNumber.substring(0,2));


             if( prefix != 34 && prefix != 37 ) {
                alert("Please enter a valid American Express Card number.");
                return false;
              }
              break;
        case 'DISC':


             if( length != 16 ) {
                alert("Please enter a valid Discover Card number.");
                return false;
             }
             var prefix = parseInt( cardNumber.substring(0,4));


             if( prefix != 6011 ) {
                alert("Please enter a valid Discover Card number.");
                return false;
             }
             break;
        case 'MAST':


             if( length != 16 ) {
                alert("Please enter a valid MasterCard number.");
                return false;
             }
             var prefix = parseInt( cardNumber.substring(0,2));

             if( prefix < 51 || prefix > 55) {
                 alert("Please enter a valid MasterCard Card number.");
                 return false;
             }
             break;
        case 'VISA':

             if( length != 16 && length != 13 ) {
                alert("Please enter a valid Visa Card number.");
                return false;
             }
             var prefix = parseInt( cardNumber.substring(0,1));


             if( prefix != 4 ) {
                alert("Please enter a valid Visa Card number.");
                return false;
             }
             break;
         }
         if( !cc_mod10( cardNumber ) ) {       
             alert("Sorry! This is not a valid credit card number.");
             return false;
         }
         if( cc_expired( cardMonth, cardYear ) ) {           
             alert("Sorry! The expiration date you have entered would make this card invalid.");
             return false;
         }
                       
         return true; 
}
                                                                    
function isEmptyString(str) {
    if (str == undefined) {
        return true;
    }
    if (str == null) {
        return true;
    }
    for (var i = 0; i < str.length; i++) {
        switch (str.charCodeAt(i)) {
        case 9:     //tab
        case 32:    //space
            break;
        default:
            return false;
        }
    }
    return true;
}

function validateDigitsFormField(formName, fieldName, fieldLabel, len) {
	var val = document.forms[formName].elements[fieldName].value;
	
	for (var i = 0; i < val.length; i++) {
		var c = val.charCodeAt(i);
		if (c < 48 || c > 57) {
			alert(fieldLabel + " must contain only digits!");
			setTimeout("setFormFieldFocus('" + formName + "', '" + fieldName + "');", 20);
			return false;
		}
	}
	
	if (val.length != len) {
		alert(fieldLabel + " must contain " + len + " digits!");
		setTimeout("setFormFieldFocus('" + formName + "', '" + fieldName + "');", 20);
		return false;
	}

	return true;
}

function validateRequiredFormField(formName, fieldName, fieldLabel, defaultValue, message) {
	var val = document.forms[formName].elements[fieldName].value;
	if (isEmptyString(val) || (!isEmptyString(defaultValue) && defaultValue == val)) {
		alert(isEmptyString(message) ? fieldLabel + " is a required field!" : message);
		setTimeout("setFormFieldFocus('" + formName + "', '" + fieldName + "');", 20);
		return false;
	}
	return true;
}

function validatePhoneFormField(formName, fieldName, fieldLabel, len) {
	var val = document.forms[formName].elements[fieldName].value;
	
	// strip out acceptable non-numeric characters
	var stripped = val.replace(/[\(\)\.\-\ ]/g, ''); 
	
	for (var i = 0; i < stripped.length; i++) {
		var c = stripped.charCodeAt(i);
		if (c < 48 || c > 57) {
			alert(fieldLabel + " contains illegal characters!");
			setTimeout("setFormFieldFocus('" + formName + "', '" + fieldName + "');", 20);
			return false;
		}
	}
	if (len != undefined && len != null && len > 0 && stripped.length != len) {
		alert(fieldLabel + " must contain " + len + " digits!");
		setTimeout("setFormFieldFocus('" + formName + "', '" + fieldName + "');", 20);
		return false;
	}
	
	return true;
}

function validateEmailFormField(formName, fieldName, fieldLabel, message) {
	var val = document.forms[formName].elements[fieldName].value;
	var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (!filter.test(val)) {
		alert(isEmptyString(message) ? fieldLabel + " must be a valid email address!" : message);
		setTimeout("setFormFieldFocus('" + formName + "', '" + fieldName + "');", 20);
		return false;
	}
	return true;
}

function validateConfirmEmailFormField(formName, fieldName, confirmFieldName, fieldLabel, confirmFieldLabel, message) {
	var val1 = document.forms[formName].elements[fieldName].value;
	var val2 = document.forms[formName].elements[confirmFieldName].value;
	if (val1.toLowerCase() != val2.toLowerCase()) {
		alert(isEmptyString(message) ? confirmFieldLabel + " must match " + fieldLabel + "!" : message);
		setTimeout("setFormFieldFocus('" + formName + "', '" + confirmFieldName + "');", 20);
		return false;
	}
	return true;
}

function validateOtherZipFormField(formName, fieldName, fieldLabel) {
	var val = document.forms[formName].elements[fieldName].value;
	if (val.length > 10) {
		alert("Up to 10 characters are allowed for postal code!");
		setTimeout("setFormFieldFocus('" + formName + "', '" + fieldName + "');", 20);
		return false;
	}
	return true;
}

function validateZipFormField(formName, fieldName, fieldLabel) {
	var val = document.forms[formName].elements[fieldName].value;
	var valid = "0123456789-";
	var hyphencount = 0;

	if (val.length != 5 && val.length != 10) {
		alert("Please enter your 5 digit or 5 digit+4 (12345-1234) zip code (for U.S. Addresses)");
		setTimeout("setFormFieldFocus('" + formName + "', '" + fieldName + "');", 20);
		return false;
	}
	for (var i = 0; i < val.length; i++) {
		temp = "" + val.substring(i, i + 1);
		if (temp == "-")
			hyphencount++;
		if (valid.indexOf(temp) == "-1") {
			alert("Invalid characters in your zip code.  Please try again.");
			setTimeout("setFormFieldFocus('" + formName + "', '" + fieldName + "');", 20);
			return false;
		}
		if ((hyphencount > 1)
				|| ((val.length == 10) && "" + val.charAt(5) != "-")) {
			alert("The hyphen character should be used with a properly formatted 5 digit+four zip code, like '12345-6789'. Please try again.");
			setTimeout("setFormFieldFocus('" + formName + "', '" + fieldName + "');", 20);
			return false;
		}
	}
	return true;
}

function validateCheckFormField(formName, fieldName, fieldLabel, message) {
	if (!document.forms[formName].elements[fieldName].checked) {
 		alert(isEmptyString(message) ? fieldLabel + " must be checked to continue!" : message); 	
		setTimeout("setFormFieldFocus('" + formName + "', '" + fieldName + "');", 20);
		return false;
	}
	return true;
}

function validateDateFormField(formName, fieldName, fieldLabel, message) {
	var val = document.forms[formName].elements[fieldName].value;

 	if(!val.match(/^\d{1,2}\/\d{1,2}\/\d{4}$/)) {
 		alert(isEmptyString(message) ? "Invalid date format! The date format should be : MM/DD/YYYY" : message); 	
		setTimeout("setFormFieldFocus('" + formName + "', '" + fieldName + "');", 20);
		return false;
 	}
 	
   	var f = val.split ("/");
   	var d = new Date(val);
   	if (f[0] - 1 != d.getMonth() || f[1] != d.getDate() || f[2] != d.getFullYear()) {
		alert(isEmptyString(message) ? fieldLabel + ' is not valid!' : message);
		setTimeout("setFormFieldFocus('" + formName + "', '" + fieldName + "');", 20);
		return false;
   	}
   	return true;
}

function binarySearch(arr, obj, comp) {
	var low = 0;
	var high = arr.length - 1;
	while (low <= high) {
	    var mid = (low + high) >>> 1;
	    var cmp = comp(obj, arr[mid]);
	    if (cmp < 0) {
			high = mid - 1;
	    } else if (cmp > 0) {
			low = mid + 1;
	    } else { 
			return mid;
	    }
	}
	return -1;
}

function validateDoubleFormField(formName, fieldName, fieldLabel, maxDigits, maxRightDigits) {	
	var sNumber = document.forms[formName].elements[fieldName].value; 
	var ValidChars = "0123456789.";
	var isDouble = true;
	var Char;

	var numberDigits = 0;
	var numberRightDigits = 0;
	var isOverTheDot = false;

	if (isEmptyString(sNumber)) {
		alert(fieldLabel + " is a required field!");
		setTimeout("setFormFieldFocus('" + formName + "', '" + fieldName + "');", 20);
		return false;
	}
	
	for (i = 0; i < sNumber.length && isDouble == true; i++) {
		Char = sNumber.charAt(i);

		if (i == 0 && Char == ".") {
			isDouble = false;
			continue;
		}

		var currentPosition = ValidChars.indexOf(Char);
		if (currentPosition == -1) {
			isDouble = false;
		} else {
			if (currentPosition == 10) {
				//here is the dot, but we must verify that this is the only one
				if (isOverTheDot) {
					//error case; to many dots in this input
					isDouble = false;
					continue;
				} else {
					isOverTheDot = true;
					continue;
				}
			} else {
				if (isOverTheDot) {
					numberRightDigits++;
				}
				numberDigits++;
			}
		}
	}

	if (maxDigits != "" && maxDigits < numberDigits) {
		isDouble = false;
	}

	if (maxRightDigits != "" && maxRightDigits < numberRightDigits) {
		isDouble = false;
	}

	if (!isDouble){
		alert(fieldLabel + " is not a number!");
		setTimeout("setFormFieldFocus('" + formName + "', '" + fieldName + "');", 20);
	}
	
	return isDouble;
	
}

function validateFormField(isValid, formName, fieldName, message) {
	if (!isValid) {
		alert(message);
		setTimeout("setFormFieldFocus('" + formName + "', '" + fieldName + "');", 20);
		return false;
	}
	return true;
}

/*============================================================================*/

/*

This routine checks the credit card number. The following checks are made:

1. A number has been provided
2. The number is a right length for the card
3. The number has an appropriate prefix for the card
4. The number has a valid modulus 10 number check digit if required

If the validation fails an error is reported.

The structure of credit card formats was gleaned from a variety of sources on 
the web, although the best is probably on Wikepedia ("Credit card number"):

  http://en.wikipedia.org/wiki/Credit_card_number

Parameters:
            cardnumber           number on the card
            cardname             name of card as defined in the card list below

Author:     John Gardner
Date:       1st November 2003
Updated:    26th Feb. 2005      Additional cards added by request
Updated:    27th Nov. 2006      Additional cards added from Wikipedia
Updated:    18th Jan. 2008      Additional cards added from Wikipedia
Updated:    26th Nov. 2008      Maestro cards extended
Updated:    19th Jun. 2009      Laser cards extended from Wikipedia

*/

/*
   If a credit card number is invalid, an error reason is loaded into the 
   global ccErrorNo variable. This can be be used to index into the global error  
   string array to report the reason to the user if required:
   
   e.g. if (!checkCreditCard (number, name) alert (ccErrors(ccErrorNo);
*/

var ccErrorNo = 0;
var ccErrors = new Array ()

ccErrors [0] = "Unknown card type";
ccErrors [1] = "No card number provided";
ccErrors [2] = "Credit card number is in invalid format";
ccErrors [3] = "Credit card number is invalid";
ccErrors [4] = "Credit card number has an inappropriate number of digits";

function checkCreditCard (cardnumber, cardname) {
     
  // Array to hold the permitted card characteristics
  var cards = new Array();

  // Define the cards we support. You may add addtional card types.
  
  //  Name:      As in the selection box of the form - must be same as user's
  //  Length:    List of possible valid lengths of the card number for the card
  //  prefixes:  List of possible prefixes for the card
  //  checkdigit Boolean to say whether there is a check digit
  
  cards [0] = {name: "Visa", 
               length: "13,16", 
               prefixes: "4",
               checkdigit: true};
  cards [1] = {name: "MasterCard", 
               length: "16", 
               prefixes: "51,52,53,54,55",
               checkdigit: true};
  cards [2] = {name: "DinersClub", 
               length: "14,16", 
               prefixes: "305, 36, 38, 54,55",
               checkdigit: true};
  cards [3] = {name: "CarteBlanche", 
               length: "14", 
               prefixes: "300,301,302,303,304,305",
               checkdigit: true};
  cards [4] = {name: "AmEx", 
               length: "15", 
               prefixes: "34,37",
               checkdigit: true};
  cards [5] = {name: "Discover", 
               length: "16", 
               prefixes: "6011,622,64,65",
               checkdigit: true};
  cards [6] = {name: "JCB", 
               length: "16", 
               prefixes: "35",
               checkdigit: true};
  cards [7] = {name: "enRoute", 
               length: "15", 
               prefixes: "2014,2149",
               checkdigit: true};
  cards [8] = {name: "Solo", 
               length: "16,18,19", 
               prefixes: "6334, 6767",
               checkdigit: true};
  cards [9] = {name: "Switch", 
               length: "16,18,19", 
               prefixes: "4903,4905,4911,4936,564182,633110,6333,6759",
               checkdigit: true};
  cards [10] = {name: "Maestro", 
               length: "12,13,14,15,16,18,19", 
               prefixes: "5018,5020,5038,6304,6759,6761",
               checkdigit: true};
  cards [11] = {name: "VisaElectron", 
               length: "16", 
               prefixes: "417500,4917,4913,4508,4844",
               checkdigit: true};
  cards [12] = {name: "LaserCard", 
               length: "16,17,18,19", 
               prefixes: "6304,6706,6771,6709",
               checkdigit: true};
               
  // Establish card type
  var cardType = -1;
  for (var i=0; i<cards.length; i++) {

    // See if it is this card (ignoring the case of the string)
    if (cardname.toLowerCase () == cards[i].name.toLowerCase()) {
      cardType = i;
      break;
    }
  }
  
  // If card type not found, report an error
  if (cardType == -1) {
     ccErrorNo = 0;
     return false; 
  }
   
  // Ensure that the user has provided a credit card number
  if (cardnumber.length == 0)  {
     ccErrorNo = 1;
     return false; 
  }
    
  // Now remove any spaces from the credit card number
  cardnumber = cardnumber.replace (/\s/g, "");
  
  // Check that the number is numeric
  var cardNo = cardnumber
  var cardexp = /^[0-9]{13,19}$/;
  if (!cardexp.exec(cardNo))  {
     ccErrorNo = 2;
     return false; 
  }
       
  // Now check the modulus 10 check digit - if required
  if (cards[cardType].checkdigit) {
    var checksum = 0;                                  // running checksum total
    var mychar = "";                                   // next char to process
    var j = 1;                                         // takes value of 1 or 2
  
    // Process each digit one by one starting at the right
    var calc;
    for (i = cardNo.length - 1; i >= 0; i--) {
    
      // Extract the next digit and multiply by 1 or 2 on alternative digits.
      calc = Number(cardNo.charAt(i)) * j;
    
      // If the result is in two digits add 1 to the checksum total
      if (calc > 9) {
        checksum = checksum + 1;
        calc = calc - 10;
      }
    
      // Add the units element to the checksum total
      checksum = checksum + calc;
    
      // Switch the value of j
      if (j ==1) {j = 2} else {j = 1};
    } 
  
    // All done - if checksum is divisible by 10, it is a valid modulus 10.
    // If not, report an error.
    if (checksum % 10 != 0)  {
     ccErrorNo = 3;
     return false; 
    }
  }  

  // The following are the card-specific checks we undertake.
  var LengthValid = false;
  var PrefixValid = false; 
  var undefined; 

  // We use these for holding the valid lengths and prefixes of a card type
  var prefix = new Array ();
  var lengths = new Array ();
    
  // Load an array with the valid prefixes for this card
  prefix = cards[cardType].prefixes.split(",");
      
  // Now see if any of them match what we have in the card number
  for (i=0; i<prefix.length; i++) {
    var exp = new RegExp ("^" + prefix[i]);
    if (exp.test (cardNo)) PrefixValid = true;
  }
      
  // If it isn't a valid prefix there's no point at looking at the length
  if (!PrefixValid) {
     ccErrorNo = 3;
     return false; 
  }
    
  // See if the length is valid for this card
  lengths = cards[cardType].length.split(",");
  for (j=0; j<lengths.length; j++) {
    if (cardNo.length == lengths[j]) LengthValid = true;
  }
  
  // See if all is OK by seeing if the length was valid. We only check the 
  // length if all else was hunky dory.
  if (!LengthValid) {
     ccErrorNo = 4;
     return false; 
  };   
  
  // The credit card is in the required format.
  return true;
}
