document.write('<div id=\"jrs_calendar_form\" style=\"overflow:hidden;\">\n');
document.write('    <table width=\"434px\" cellpadding=\"0\" cellspacing=\"0\" class=\"jrs_table\">\n');
document.write('    <input type=\"hidden\" name=\"cloneID\" id=\"cloneID\" value=\"115\" />\n');
document.write('	<input type=\"hidden\" name=\"group_id\" id=\"group_id\" value=\"1102\" />\n');
document.write('    <input type=\"hidden\" name=\"rooms\" value=\"1\" />\n');
document.write('    <input type=\"hidden\" name=\"nights\" id=\"nights\" value=\"1\" />\n');
document.write('    <input type=\"hidden\" name=\"sDay\" id=\"sDay\" value=\"30\" />\n');
document.write('    <input type=\"hidden\" name=\"sMonth\" id=\"sMonth\" value=\"07\" />\n');
document.write('    <input type=\"hidden\" name=\"sYear\" id=\"sYear\" value=\"2010\" />\n');
document.write('        <tr>\n');
document.write('            <td align=\"left\" colspan=\"6\">\n');
document.write('                <img src=\"http://www.prod.bookdirect.net/images/bookdirect_images/visitminneapolisnorth.com/planYourTrip.gif\" style=\"border:none;\" />\n');
document.write('            </td>\n');
document.write('        </tr>\n');
document.write('        <tr>\n');
document.write('        	<td>\n');
document.write('            	<img src=\"http://www.prod.bookdirect.net/images/bookdirect_images/visitminneapolisnorth.com/leftEdge.gif\" style=\"border:none;\" />\n');
document.write('            </td>\n');
document.write('            <td class=\"jrs_td\" align=\"left\" valign=\"top\">\n');
document.write('                <input type=\"text\" name=\"start-date\" id=\"start-date\" class=\"date-pick\" value=\"Check-In\" /><a class=\"jrs_calimg\" href=\"#\" onclick=\"return false\"><img src=\"http://www.prod.bookdirect.net/images/bookdirect_images/visitminneapolisnorth.com/calIcon.gif\" id=\"start-date-img\" class=\"jrs_calimg\" /></a>\n');
document.write('            </td>\n');
document.write('            <td class=\"jrs_td\" align=\"left\" valign=\"top\">\n');
document.write('            	<input type=\"text\" name=\"end-date\" id=\"end-date\" class=\"date-pick\" value=\"Check-Out\"/><a class=\"jrs_calimg\" href=\"#\" onclick=\"return false\"><img src=\"http://www.prod.bookdirect.net/images/bookdirect_images/visitminneapolisnorth.com/calIcon.gif\" id=\"end-date-img\" class=\"jrs_calimg\" /></a>\n');
document.write('            </td>\n');
document.write('            <td class=\"jrs_td\" align=\"left\" id=\"jrs_lodging_td\" valign=\"top\">\n');
document.write('                <select id=\"lodgingID\" name=\"lodgingID\" class=\"jrs_form_select_item\" style=\"width:125px;\">\n');
document.write('                                            <option value=\"103\" >All Lodging</option>	\n');
document.write('                                            <option value=\"50\" >Hotels, Motels &amp; Inns</option>	\n');
document.write('                    				\n');
document.write('                </select>     \n');
document.write('            </td>              \n');
document.write('            <td class=\"jrs_td\" align=\"left\" valign=\"middle\">\n');
document.write('	            <input type=\"image\" src=\"http://www.prod.bookdirect.net/images/bookdirect_images/visitminneapolisnorth.com/goBtn.gif\" onclick=\"jrs_submit_form(); return false;\" style=\"height:21px; width:46px; border:none;\" >\n');
document.write('            </td>\n');
document.write('            <td>\n');
document.write('            	<img src=\"http://www.prod.bookdirect.net/images/bookdirect_images/visitminneapolisnorth.com/rightEdge.gif\" style=\"border:none;\" />\n');
document.write('            </td>        \n');
document.write('        </tr>\n');
document.write('        <tr>\n');
document.write('            <td align=\"left\" colspan=\"6\" style=\"background-color:#ffcc59;\">\n');
document.write('                <img src=\"http://www.prod.bookdirect.net/images/bookdirect_images/visitminneapolisnorth.com/bottomEdge.gif\" style=\"border:none;\" />\n');
document.write('            </td>\n');
document.write('        </tr>        \n');
document.write('    </table>\n');
document.write('</div>\n');
document.write('\n');
document.write('<style>\n');
document.write('#datepicker_div, .datepicker_inline {\n');
document.write('	font-family: Arial, Helvetica, sans-serif;\n');
document.write('	font-size: 14px;\n');
document.write('	padding: 0;\n');
document.write('	margin: 0;\n');
document.write('	background: #ddd;\n');
document.write('	width: 185px;\n');
document.write('}\n');
document.write('#datepicker_div {\n');
document.write('	display: none;\n');
document.write('	border: 1px solid #999999;\n');
document.write('	z-index: 10; /*must have*/\n');
document.write('}\n');
document.write('.datepicker_inline {\n');
document.write('	float: left;\n');
document.write('	display: block;\n');
document.write('	border: 0;\n');
document.write('}\n');
document.write('.datepicker_dialog {\n');
document.write('	padding: 5px !important;\n');
document.write('	border: 4px ridge #ddd !important;\n');
document.write('}\n');
document.write('button.datepicker_trigger {\n');
document.write('	width: 25px;\n');
document.write('}\n');
document.write('img.datepicker_trigger {\n');
document.write('	margin: 2px;\n');
document.write('	vertical-align: middle;\n');
document.write('}\n');
document.write('.datepicker_prompt {\n');
document.write('	float: left;\n');
document.write('	padding: 2px;\n');
document.write('	background: #ddd;\n');
document.write('	color: #000;\n');
document.write('}\n');
document.write('* html .datepicker_prompt {\n');
document.write('	width: 185px;\n');
document.write('}\n');
document.write('.datepicker_control, .datepicker_links, .datepicker_header, .datepicker {\n');
document.write('	clear: both;\n');
document.write('	float: left;\n');
document.write('	width: 100%;\n');
document.write('	color: #fff;\n');
document.write('}\n');
document.write('.datepicker_control { /* header row with \"close\" */\n');
document.write('	background: #999999;\n');
document.write('	padding: 2px 0px;\n');
document.write('}\n');
document.write('.datepicker_links {\n');
document.write('	background: #DDDDDD;\n');
document.write('	padding: 2px 0px;\n');
document.write('}\n');
document.write('.datepicker_control, .datepicker_links {\n');
document.write('	font-weight: bold;\n');
document.write('	font-size: 80%;\n');
document.write('	letter-spacing: 1px;\n');
document.write('}\n');
document.write('.datepicker_links label { /* disabled links */\n');
document.write('	padding: 2px 5px;\n');
document.write('	color: #888;\n');
document.write('}\n');
document.write('.datepicker_clear, .datepicker_prev {\n');
document.write('	float: left;\n');
document.write('	width: 34%;\n');
document.write('}\n');
document.write('.datepicker_current {\n');
document.write('	float: left;\n');
document.write('	width: 30%;\n');
document.write('	text-align: center;\n');
document.write('}\n');
document.write('.datepicker_close, .datepicker_next {\n');
document.write('	float: right;\n');
document.write('	width: 34%;\n');
document.write('	text-align: right;\n');
document.write('}\n');
document.write('.datepicker_header {\n');
document.write('	padding: 1px 0 3px;\n');
document.write('	background: #DDDDDD;\n');
document.write('	text-align: center;\n');
document.write('	font-weight: bold;\n');
document.write('	height: 1.3em;\n');
document.write('}\n');
document.write('.datepicker_header select {\n');
document.write('	background: #DDDDDD;\n');
document.write('	color: #000;\n');
document.write('	border: 0px;\n');
document.write('	font-weight: bold;\n');
document.write('}\n');
document.write('.datepicker {\n');
document.write('	background: #ccc;\n');
document.write('	text-align: center;\n');
document.write('	font-size: 100%;\n');
document.write('}\n');
document.write('.datepicker a {\n');
document.write('	display: block;\n');
document.write('	width: 100%;\n');
document.write('}\n');
document.write('.datepicker_titleRow { /* days of the week */\n');
document.write('	background: #FFFFFF;\n');
document.write('	color: #000 !important;\n');
document.write('}\n');
document.write('.datepicker_daysRow {\n');
document.write('	background: #FFF;\n');
document.write('	color: #666;\n');
document.write('}\n');
document.write('.datepicker_daysCell {\n');
document.write('	color: #000;\n');
document.write('	border: 1px solid #ddd;\n');
document.write('}\n');
document.write('.datepicker_daysCell a{\n');
document.write('	display: block;\n');
document.write('}\n');
document.write('.datepicker_weekEndCell {\n');
document.write('	background: #EEEEEE;\n');
document.write('}\n');
document.write('.datepicker_daysCellOver {\n');
document.write('	background: #fff;\n');
document.write('	border: 1px solid #ff6600;\n');
document.write('}\n');
document.write('.datepicker_unselectable {\n');
document.write('	color: #888;\n');
document.write('}\n');
document.write('.datepicker_today {\n');
document.write('	background: #ccc !important;\n');
document.write('}\n');
document.write('.datepicker_currentDay {\n');
document.write('	background: #999 !important;\n');
document.write('}\n');
document.write('/* ________ Datepicker Links _______\n');
document.write('** Reset link properties and then override them with !important */\n');
document.write('#datepicker_div a, .datepicker_inline a {\n');
document.write('	cursor: pointer;\n');
document.write('	margin: 0;\n');
document.write('	padding: 0;\n');
document.write('	background: none;\n');
document.write('	color: #000;\n');
document.write('}\n');
document.write('.datepicker_inline .datepicker_links a {\n');
document.write('	padding: 0 5px !important;\n');
document.write('}\n');
document.write('.datepicker_control a, .datepicker_links a {\n');
document.write('	padding: 2px 5px !important;\n');
document.write('	color: #000 !important;\n');
document.write('}\n');
document.write('.datepicker_titleRow a {\n');
document.write('	color: #000 !important;\n');
document.write('}\n');
document.write('.datepicker_control a:hover {\n');
document.write('	/*background: #fdd !important;*/\n');
document.write('	color: #333 !important;\n');
document.write('}\n');
document.write('.datepicker_links a:hover, .datepicker_titleRow a:hover {\n');
document.write('	background: #dddddd !important;\n');
document.write('	color: #333 !important;\n');
document.write('}\n');
document.write('/* ___________ MULTIPLE MONTHS _________*/\n');
document.write('.datepicker_multi .datepicker {\n');
document.write('	border: 1px solid #777;\n');
document.write('}\n');
document.write('.datepicker_oneMonth {\n');
document.write('	float: left;\n');
document.write('	width: 185px;\n');
document.write('}\n');
document.write('.datepicker_newRow {\n');
document.write('	clear: left;\n');
document.write('}\n');
document.write('/* ___________ IE6 IFRAME FIX ________ */\n');
document.write('.datepicker_cover {\n');
document.write('    display: none; /*sorry for IE5*/\n');
document.write('    display/**/: block; /*sorry for IE5*/\n');
document.write('    position: absolute; /*must have*/\n');
document.write('    z-index: -1; /*must have*/\n');
document.write('    filter: mask(); /*must have*/\n');
document.write('    top: -4px; /*must have*/\n');
document.write('    left: -4px; /*must have*/\n');
document.write('    width: 200px; /*must have*/\n');
document.write('    height: 200px; /*must have*/\n');
document.write('}#jrs_calendar_form{\n');
document.write('	font-family:Arial, Helvetica, sans-serif;\n');
document.write('	font-size:11px;\n');
document.write('	color:#000;\n');
document.write('	width:434px;\n');
document.write('	margin-left:14px;\n');
document.write('	background-color:#ffcc59;\n');
document.write('}\n');
document.write('.jrs_table{\n');
document.write('	font-family:Arial, Helvetica, sans-serif;\n');
document.write('	font-size:11px;\n');
document.write('	color:#000;\n');
document.write('	width:100%;\n');
document.write('	background-color:#ffa100;\n');
document.write('}\n');
document.write('.date-pick{\n');
document.write('	width:75px;\n');
document.write('	font-size:11px;\n');
document.write('	font-size:10px;\n');
document.write('	margin:0px 0px 0px 0px !important;\n');
document.write('	height:16px !important;\n');
document.write('	padding-left:2px !important;\n');
document.write('	padding-top:4px !important;\n');
document.write('	float:none !important;\n');
document.write('	\n');
document.write('}\n');
document.write('.jrs_td{\n');
document.write('	font-family:Arial, Helvetica, sans-serif;\n');
document.write('	font-size:11px;\n');
document.write('	color:#000;\n');
document.write('	padding-left:2px;\n');
document.write('}\n');
document.write('#jrs_booking_header{\n');
document.write('}\n');
document.write('#jrs_booking_sub_header{\n');
document.write('}\n');
document.write('.jrs_form_text{\n');
document.write('}\n');
document.write('#jrs_adults_div{\n');
document.write('}\n');
document.write('#jrs_kids_div{\n');
document.write('}\n');
document.write('.jrs_clr{\n');
document.write('	clear:both;\n');
document.write('}\n');
document.write('.jrs_form_select_item{	\n');
document.write('}\n');
document.write('#jrs_arrival_input{\n');
document.write('	float:left;\n');
document.write('	\n');
document.write('}\n');
document.write('#jrs_departure_input{\n');
document.write('	float:left;\n');
document.write('}\n');
document.write('#jrs_lodging_select_div{\n');
document.write('}\n');
document.write('#jrs_location_dropdown_div{\n');
document.write('	float:left;\n');
document.write('}\n');
document.write('.jrs_calimg{\n');
document.write('	display:inline !important;\n');
document.write('	border:none !important;\n');
document.write('	position:relative !important;\n');
document.write('	height:20px !important;\n');
document.write('	width:26px !important;\n');
document.write('	margin-bottom:0px !important;\n');
document.write('	top:.2em;\n');
document.write('}\n');
document.write('.jrs_form_select_item{\n');
document.write('	font-size:11px;\n');
document.write('}\n');
document.write('#jrs_search_submit{\n');
document.write('	float:left;\n');
document.write('	padding-top:3px;\n');
document.write('}\n');
document.write('#datepicker_div a, .datepicker_inline a {\n');
document.write('	font-size:11px;\n');
document.write('}\n');
document.write('</style>\n');
document.write('<!--[if lte IE 7]>\n');
document.write('<style type=\"text/css\">\n');
document.write('.jrs_calimg{ top: .2em !important; }\n');
document.write('.date-pick{\n');
document.write('			height:14px !important;\n');
document.write('			padding-top:2px !important;\n');
document.write('		}\n');
document.write('.jrs_lodging_td{ padding-top:0px; }\n');
document.write('</style>\n');
document.write('<![endif]-->\n');
document.write('\n');


function update_hiddens(whichdate, chosenvalue) {
    var arrival, departure;
    
    if (whichdate == 'arrival') {
        arrival = new Date(chosenvalue);
    } else {
        arrival = new Date(document.getElementById('start-date').value);
    }
    
    if (whichdate == 'departure') {
        departure = new Date(chosenvalue);
    } else {
        departure = new Date(document.getElementById('end-date').value);
    }
    
    var now = new Date();
    var one_day=1000*60*60*24;							
    var nights = Math.max(1, Math.ceil(document.getElementById('nights').value));
   
    if (isNaN(arrival.getTime())) {
        arrival = new Date(now.getTime() + one_day);
    }
    
    if (isNaN(departure.getTime())) {
        departure = new Date(now.getTime() + (one_day * 2));
    }
    document.getElementById('sDay').value = arrival.getDate();
    if(document.getElementById('sDay').value.length==1){
    	document.getElementById('sDay').value = '0'+document.getElementById('sDay').value;
    }    
    document.getElementById('sMonth').value = arrival.getMonth() + 1;  // Jan = 0
    if(document.getElementById('sMonth').value.length==1){
    	document.getElementById('sMonth').value = '0'+document.getElementById('sMonth').value;
    }
    document.getElementById('sYear').value = arrival.getFullYear();

    if (whichdate == 'arrival') {
        departure = new Date(arrival.getTime() + (one_day * nights));
        $('#end-date').val(format_date(departure.getTime()));
        $.datepicker.reconfigureFor('#end-date', {minDate: new Date(arrival.getTime() + one_day)});
        $.datepicker.setDateFor('#end-date', departure);
    }

    nights = Math.ceil((departure.getTime()-arrival.getTime())/(one_day));
    nights = Math.max(nights, 1);
    document.getElementById('nights').value = nights;
}

function safe_add_days (thedate, numdays) {
    
}

function set_arrival (chosenvalue) {
    update_hiddens('arrival', chosenvalue); 
}
function set_departure (chosenvalue) {
    update_hiddens('departure', chosenvalue); 
}

function format_date(ms) {
    var thedate;
    thedate = new Date(ms);
    return (thedate.getMonth() + 1) + '/' + zeropad(thedate.getDate(),2) + '/' + thedate.getFullYear();  // Jan = 0
}

function zeropad (num, zeros) {
    var retval = '';
    var numstr = num.toString();
    for (var i=numstr.length; i < zeros; i++) {
        retval += '0';
    }
    retval += numstr;
    return retval;
}

function check_dates(){
	if(document.getElementById('start-date').value == 'Check-In' || document.getElementById('end-date').value == 'Check-Out'){
    	document.getElementById('start-date').value = '07/30/2010';
        document.getElementById('end-date').value = '07/31/2010';
    }
}
function jrs_submit_form(){

    var now = new Date();
    var one_day=1000*60*60*24;							
    var nights = Math.max(1, Math.ceil(document.getElementById('nights').value));
	
    if(document.getElementById('start-date').value == 'Check-In' || document.getElementById('end-date').value == 'Check-Out'){
    	document.getElementById('start-date').value = '07/30/2010';
        document.getElementById('end-date').value = '07/31/2010';
    }
        
    arrival = new Date(document.getElementById('start-date').value);
	departure = new Date(document.getElementById('end-date').value);
    
    document.getElementById('sDay').value = arrival.getDate();
    if(document.getElementById('sDay').value.length==1){
    	document.getElementById('sDay').value = '0'+document.getElementById('sDay').value;
    }    
    document.getElementById('sMonth').value = arrival.getMonth() + 1;  // Jan = 0
    if(document.getElementById('sMonth').value.length==1){
    	document.getElementById('sMonth').value = '0'+document.getElementById('sMonth').value;
    }
    document.getElementById('sYear').value = arrival.getFullYear(); 
 
    nights = Math.ceil((departure.getTime()-arrival.getTime())/(one_day));
    nights = Math.max(nights, 1);
    document.getElementById('nights').value = nights; 
 
	var clone_id = document.getElementById('cloneID').value;
    var group_id = document.getElementById('group_id').value;
   	var nights = document.getElementById('nights').value;
    
    var sDay = document.getElementById('sDay').value;
    var sMonth = document.getElementById('sMonth').value;
    var sYear = document.getElementById('sYear').value;
    var lodgingID = document.getElementById('lodgingID').value;
    var s_date = document.getElementById('start-date').value;
    var e_date = document.getElementById('end-date').value;
	var submit_url = 'http://minneapolisnorth-bookdirect.com/redirect_booking.php?cloneID='+clone_id+'&group_id='+group_id+'&nights='+nights+'&sDay='+sDay+'&sMonth='+sMonth+'&sYear='+sYear+'&lodgingID='+lodgingID+'&start-date='+s_date+'&end-date='+e_date;
	window.location = submit_url;
}