
function show_hide(field) {
	if (document.getElementById(field).style.display == 'block') document.getElementById(field).style.display = 'none'
	else if (document.getElementById(field).style.display == 'none') document.getElementById(field).style.display = 'block'
}


function Opensupport2(newin) {
	Support2=window.open(newin,"Support2","resizeable=yes,scrollbars=yes,width=550,height=320 top=250,left=250");
	window.Support2.focus();
}

function Opensupport3(newin) {
	Support3=window.open(newin,"Support3","resizeable=yes,scrollbars=yes,width=600,height=435 top=250,left=250");
	window.Support3.focus();
}

function Opensupport4(newin) {
	Support4=window.open(newin,"Support4","resizeable=yes,scrollbars=yes,width=350,height=545 top=250,left=250");
	window.Support4.focus();
}


function Opensupport5(newin) {
Support5=window.open(newin,"Support5","resizeable=yes,scrollbars=yes,width=825,height=565 top=50,left=50");
window.Support5.focus();
}


function Opensupport6(newin) {
Support4=window.open(newin,"Support4","resizeable=yes,scrollbars=yes,width=800,height=565 top=50,left=50");
window.Support4.focus();
}

function Opensupport753(newin) {
Support4=window.open(newin,"Support4","resizeable=yes,scrollbars=yes,width=800,height=565 top=50,left=50");
window.Support4.focus();
}


function showImage(imgUrl) {
  	document.property_image.src = imgUrl;
}


function addToFavorites( rid ) {
		//$("div#extendstatus").html("");
			//$("div#extendstatus").css("display","none");

			var r = rid.split(",");
		 
		 	var yurl = "/Ocean-Isle-Beach-rentals/add-to-favorites.cfm?rid="+r['1'] +"&ts="+new Date();

			$.get(yurl,'',function(data) {

				var response = jQuery.trim(data);
				if (response !='') {
					if (response.search("~")) {

						var res = response.split("~");
						//$("div#extendstatus").html(res[0]);
						//$("#e"+aid).html(res[1]);
						//$("div#extendstatus").css("display","");
						//alert(res[1]);
						$("a#atf"+res[1]).html("<img class='icon' border='0' src='/images/icons/add.png'/> Added");

					} else {

						//$("div#extendstatus").html(response);
						//$("div#extendstatus").css("display","");
					}
				}
			});//$.get
		 return false;

	}

function deleteFromFavorites( rid ) {
		//$("div#extendstatus").html("");
			//$("div#extendstatus").css("display","none");
		 
		 	var yurl = "/Ocean-Isle-Beach-rentals/delete-from-favorites.cfm?rid="+rid+"&ts="+new Date();

			$.get(yurl,'',function(data) {

				var response = jQuery.trim(data);
				if (response !='') {
					if (response.search("~")) {

						var res = response.split("~");
						//alert(res[1]);
						$("li#"+res[1]).remove();
						//$("div#extendstatus").html(res[0]);
						//$("#e"+aid).html(res[1]);
						//$("div#extendstatus").css("display","");

					} else {
						
						//$("div#extendstatus").html(response);
						//$("div#extendstatus").css("display","");
					}
				}
			});//$.get
		 return false;

	}




$(document).ready(function () {

   $('#navigation li:has(ul)').hover( 
      function () {
         $(this).find('ul').fadeIn('fast');
      }, 
      function () {
         $(this).find('ul').hide();
      }
   );
   
   $('#navigation li:has(ul) > a').click( function () {
      return false;
    });
   
   

   function saturdayFilter(date) {
   	return (date.getDay() != 6) ? [false, ''] : [true, '']; 
   }
   
   function noFilter(date) {
      return [true, ''];
   }
   
   //Used on home page, advanaced search page, refine form at top of results and detail page
   if(getUrlVars()['strCountry'] == 'G'){  //Mainland Golf calendar defaults to nightly
   		$("#strCheckin").datepicker({showOn: 'button', buttonImage: '/images/layout/smallCal.png', buttonImageOnly: true, beforeShowDay: noFilter, minDate:+1});
   }else if(getUrlVars()['period'] == 'daily'){    		
   		$("#strCheckin").datepicker({showOn: 'button', buttonImage: '/images/layout/smallCal.png', buttonImageOnly: true, beforeShowDay: noFilter, minDate:+1});
   }else{
   	  $("#strCheckin").datepicker({showOn: 'button', buttonImage: '/images/layout/smallCal.png', buttonImageOnly: true, beforeShowDay: saturdayFilter, minDate:+1});
   }
  
   //Used on golf page
   $("#strCheckinGolf").datepicker({showOn: 'button', buttonImage: '/images/layout/smallCal.png', buttonImageOnly: true, beforeShowDay: noFilter, minDate:+1});	 
  
  //Used on booking_search_condotels.cfm
  $("#strCheckinCausewayInn").datepicker({showOn: 'button', buttonImage: '/images/layout/smallCal.png', buttonImageOnly: true, beforeShowDay: noFilter, minDate:0});


   //user has changed the period, options are weekly or nightly
	$("input[name='period']").click( function () {
	  
      if( $("input[name='period']:checked").val() == 'daily' ) {
         $("#strCheckin").datepicker('option', {beforeShowDay: noFilter});
         $("#intNights").html("\
            <option value='1'>1</option> \
            <option value='2'>2</option> \
            <option value='3'>3</option> \
            <option value='4'>4</option> \
            <option value='5'>5</option> \
            <option value='6'>6</option> \
            <option value='7'>7</option> \
            <option value='14'>14</option> \
            <option value='21'>21</option>");
			$("#pn").show();
      } else {
         $("#strCheckin").datepicker('option', {beforeShowDay: saturdayFilter});
         $("#intNights").html("\
             <option>7</option>\
             <option>14</option>\
             <option>21</option>");
			 $("#pn").hide();
         
      }
   });

   
   //$("input[name='period']:checked").click();  
   

	//When Mainland Golf is selected from the Island drop down, change period to 'nightly', update drop down and calendar
	$('#strLocations').change(function(){
		
		var newSelection = $('#strLocations').val();
		
		if(newSelection == 'G'){
			
			$('#nightly').attr("checked","checked");			
			
			 $("#intNights").html("\
            <option value='1'>1</option> \
            <option value='2'>2</option> \
            <option value='3'>3</option> \
            <option value='4'>4</option> \
            <option value='5'>5</option> \
            <option value='6'>6</option> \
            <option value='7'>7</option> \
            <option value='14'>14</option> \
            <option value='21'>21</option>");
                       
		}
		
		$("#strCheckin").datepicker('option', {beforeShowDay: noFilter});
		
	});



   
});

function copydate(){
	
	//$("#strCheckinBottom").val($("#strCheckin1").val());
	//$("#strCheckinBottom1").val($("#strCheckin1").val());
	
	
	}

$(document).ready( function () {

   $('.unhide').bind('click', function () {
      var id = '#' + $(this).attr('rel');
      $(id).toggle();
   });

      $('.unhide1').bind('click', function () {
      var id = '#' + $(this).attr('rel');
      $(id).toggle();

	  //alert($(this).attr('href'));
	  document.location.toString($(this).attr('href'));
   });

   $('.hidden').hide();
   
   $("#amenTable a").click(function(){
							 
			var u = $(this).attr('href');				 
			//alert(u);
			//$(this).attr('href',u+"&strcheckin="+$("#strCheckin1").val());
				    
				    
	});


})




function getUrlVars()
{
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}


