function initPage()
{
	clearFormFields({
		clearInputs: true,
		clearTextareas: true,
		passwordFieldText: false,
		addClassFocus: "focus",
		filterClass: "default"
	});
}
function clearFormFields(o)
{
	if (o.clearInputs == null) o.clearInputs = true;
	if (o.clearTextareas == null) o.clearTextareas = true;
	if (o.passwordFieldText == null) o.passwordFieldText = false;
	if (o.addClassFocus == null) o.addClassFocus = false;
	if (!o.filterClass) o.filterClass = "default";
	if(o.clearInputs) {
		var inputs = document.getElementsByTagName("input");
		for (var i = 0; i < inputs.length; i++ ) {
			if((inputs[i].type == "text" || inputs[i].type == "password") && inputs[i].className.indexOf(o.filterClass) == -1) {
				inputs[i].valueHtml = inputs[i].value;
				inputs[i].onfocus = function ()	{
					if(this.valueHtml == this.value) this.value = "";
					if(this.fake) {
						inputsSwap(this, this.previousSibling);
						this.previousSibling.focus();
					}
					if(o.addClassFocus && !this.fake) {
						this.className += " " + o.addClassFocus;
						this.parentNode.className += " parent-" + o.addClassFocus;
					}
				}
				inputs[i].onblur = function () {
					if(this.value == "") {
						this.value = this.valueHtml;
						if(o.passwordFieldText && this.type == "password") inputsSwap(this, this.nextSibling);
					}
					if(o.addClassFocus) {
						this.className = this.className.replace(o.addClassFocus, "");
						this.parentNode.className = this.parentNode.className.replace("parent-"+o.addClassFocus, "");
					}
				}
				if(o.passwordFieldText && inputs[i].type == "password") {
					var fakeInput = document.createElement("input");
					fakeInput.type = "text";
					fakeInput.value = inputs[i].value;
					fakeInput.className = inputs[i].className;
					fakeInput.fake = true;
					inputs[i].parentNode.insertBefore(fakeInput, inputs[i].nextSibling);
					inputsSwap(inputs[i], null);
				}
			}
		}
	}
	if(o.clearTextareas) {
		var textareas = document.getElementsByTagName("textarea");
		for(var i=0; i<textareas.length; i++) {
			if(textareas[i].className.indexOf(o.filterClass) == -1) {
				textareas[i].valueHtml = textareas[i].value;
				textareas[i].onfocus = function() {
					if(this.value == this.valueHtml) this.value = "";
					if(o.addClassFocus) {
						this.className += " " + o.addClassFocus;
						this.parentNode.className += " parent-" + o.addClassFocus;
					}
				}
				textareas[i].onblur = function() {
					if(this.value == "") this.value = this.valueHtml;
					if(o.addClassFocus) {
						this.className = this.className.replace(o.addClassFocus, "");
						this.parentNode.className = this.parentNode.className.replace("parent-"+o.addClassFocus, "");
					}
				}
			}
		}
	}
	function inputsSwap(el, el2) {
		if(el) el.style.display = "none";
		if(el2) el2.style.display = "inline";
	}
}
if (window.addEventListener)
	window.addEventListener("load", initPage, false);
else if (window.attachEvent)
	window.attachEvent("onload", initPage);
	
function showpicker(pick)	{
if (pick=="in"){
document.getElementById("in-date-field").focus();
}else{
document.getElementById("out-date-field").focus();
}

}


$(document).ready(function(){


$(".subscriber").colorbox({width:  "800px", height: "600px", iframe:true});
$("#grouproomrequest").colorbox({width:  "800px", height: "600px", iframe:true});
$("#homevideo").colorbox({width:  "800px", height: "600px", iframe:true});
$(".bios").colorbox({width:  "720px", height: "600px", iframe:true});
$(".showFBcomments").colorbox({width:  "550px", height: "400px", inline:true, href:"#fbc"});

/////Navigate DropDown//////
$('#nav li').hover(function(){
$(this).children('img').attr("src", "/wp-content/themes/hotelsforhope/images/arrow-down-p.gif");
$(this).children('div.submenu').slideDown();
},function(){
	if ($(this).css("display", "block")){
	$(this).children("img").attr("src", "/wp-content/themes/hotelsforhope/images/arrow-right-p.gif");
	$(this).children('div.submenu').slideUp();
	}
});


$('#nav li div.submenu').hover(function(){
$(this).css("display", "block");

},function(){
$(this).slideUp();
});

//$(function() {
//                $("#carousel").webwidget_slideshow_dot({
//                    slideshow_time_interval: '5000',
//                    slideshow_window_width: '1002',
//                    slideshow_window_height: '302',
//                    slideshow_title_color: '#FFF',
//                    soldeshow_foreColor: 'transparent',
//                    directory: 'css/img/'
//                });
//            }); 
//            
//$(function() {
//                $("#charities").webwidget_slideshow_dot({
//                    slideshow_time_interval: '3000',
//                    slideshow_window_width: '185',
//                    slideshow_window_height: '75',
//                    slideshow_title_color: '#17CCCC',
//                    soldeshow_foreColor: '#000',
//                    directory: 'images/'
//                });
//            });            
//            

$(function(){
			// Set starting slide to 1
			var startSlide = 1;
			// Get slide number if it exists
			if (window.location.hash) {
				startSlide = window.location.hash.replace('#','');
			}
			// Initialize Slides
			$('#slides').slides({
				preload: true,
				preloadImage: '/wp-content/themes/hotelsforhope/img/loading.gif',
				generatePagination: true,
				play: 5000,
				pause: 2500,
				hoverPause: true,
				// Get the starting slide
				start: startSlide,
				animationComplete: function(current){
					// Set the slide number as a hash
					//window.location.hash = '#' + current;
				}
			});
		});
		
$(function(){
			// Set starting slide to 1
			var startSlide = 1;
			// Get slide number if it exists
			if (window.location.hash) {
				startSlide = window.location.hash.replace('#','');
			}
			// Initialize Slides
			$('#charities').slides({
				preload: true,
				preloadImage: '/wp-content/themes/hotelsforhope/img/loading.gif',
				generatePagination: true,
				play: 5000,
				pause: 2500,
				hoverPause: true,
				// Get the starting slide
				start: startSlide,
				animationComplete: function(current){
					// Set the slide number as a hash
					//window.location.hash = '#' + current;
				}
			});
		});
		
		
		
    $(function() {
        $('#in-date-field').datepicker({minDate: '0', maxDate: '+1Y+6M', onSelect: function(dateStr) {
            var min = $(this).datepicker('getDate'); // Get selected date
            $('#out-date-field').datepicker('option', 'minDate', min || '0'); // Set other min, default to today
        }});
        $('#out-date-field').datepicker({minDate: '0', maxDate: '+1Y+6M', onSelect: function(dateStr) {
            var max = $(this).datepicker('getDate'); // Get selected date
            $('#in-date-field').datepicker('option', 'maxDate', max || '+1Y+6M'); // Set other max, default to +18 months
        }});
    });      
                 
          
}); 


function getRandImg(){

var text = new Array();
text[1] = "Your reservations provide support for the 28 million people battling cancer through LIVESTRONG\'s following programs: LIVESTRONG at School and the LIVESTRONG Young Adult Alliance.";
text[2] = "Hotels for Hope donations bring clean water, education, healthcare and microfinance to rural Ethiopia.  Additionally, local contributions support Camp Glimmer, a summer program for disadvantaged youth in Austin.";
text[3] = "Donations through Hotels for Hope support crucial programs like Young Athletes and Healthy Athletes which offer valuable resources and services that SOTX athletes and families would otherwise not have available.";
text[4] = "Hotels for Hope\'s donations help to provide a peer support network and military survivor seminars for adults as well as Good Grief Camps for children. ";


var img = new Array();
img[1] = "/wp-content/themes/hotelsforhope/images/charot-livestrong.jpg";
img[2] = "/wp-content/themes/hotelsforhope/images/charot-glimmer.jpg";
img[3] = "/wp-content/themes/hotelsforhope/images/charot-special.jpg";
img[4] = "/wp-content/themes/hotelsforhope/images/charot-taps.jpg";

var charlink = new Array();
charlink[1] = "/our-story/corporate-social-responsibility/";
charlink[2] = "/our-story/our-charities/";
charlink[3] = "/how-it-works/groups/";
charlink[4] = "/our-story/because/";

var x = Math.floor(Math.random()*4);
//x=x+1;
if (x==0){
document.getElementById("charottxt").innerHTML=text[4];
document.getElementById("charotimg").src=img[4];
//document.getElementById("charlink").href=charlink[5];
}else{
document.getElementById("charottxt").innerHTML=text[x];
document.getElementById("charotimg").src=img[x];
//document.getElementById("charlink").href=charlink[x];
}


}




