/*Set the directoty for the php files*/
var php_dir = 'sk_php/';












/*DO NOT EDIT BELOW THIS LINE
PROPERTY OF skyfirestudio.com
YOU ARE NOT ALLOWED TO USE ANY PORTION OF THIS CODE
WITH OUT EXPLICIT CONSENT FROM skyfirestudio.com*/

function preload_imgs() {

  var pic2 = new Image(25, 25); 
  pic2.src="sk_images/sk_images/loading.gif";


}


function updatePhotos(pid) {
var Fpid = '';
var tempPid = pid;

if (tempPid != null ) {

var Fpid = tempPid.substr(11);

} 

if (document.getElementById('sk_photoWrap') != null) {

var photodiv = document.getElementById('sk_photoWrap');

photodiv.innerHTML = '<div style="height:'+photodiv.offsetHeight+'px; width:'+photodiv.offsetWidth+'px;" ><div class="sk_loadingImg" style="padding-top:'+(photodiv.offsetHeight/2)+'px"><img src="sk_images/loading.gif" style="border:0; width:25px; height:25px;"/></div></div><div style="clear:both;"></div>';


	 var query = 'pid='+Fpid;
     var url = php_dir+"update_room_photos.php?"+query;
     

     
  return !grabFile(url, 'sk_photoWrap');



}//end if id exists



}//end function


//function to get month and year from clicked on day
function getMonthYearofDay(data, content) {
		
		//I beleive data is the id
		//content is the innerHTML
	
                if (Number(data.substr(6)) != content) {//its the second month
                
                var MonthYear = document.getElementById('monthNav2').innerHTML;
                
                } else {//its the first month
                
                var MonthYear = document.getElementById('monthNav1').innerHTML;
                
                }
                 
                 
                 //now break it up to get it in the right format
                 var dateSplit = MonthYear.split(' ');
                 
                 var output = dateSplit[1]+'-'+getTheMonthnum(dateSplit[0])+'-'+content;
                 
                 return output;
                 
                 }//end new fucntion


//function to send what room was clicked to update_dates
function sendRoomID(whichway, rid) {
		
		if (document.getElementById('monthNav1') != null) {
		var date = document.getElementById('monthNav1').innerHTML;
		var dateArray = date.split(" ");
		var finalDate = dateArray[1]+'-'+getTheMonthnum(dateArray[0]);
		}
		
		//this is actually the rates id
		
		
var Frid = '';
var tempRid = rid;

if (tempRid != null ) {

var Frid = tempRid.substr(11);

} 
		
		
		
		
		var whichway = whichway;
		
		
		
		//we need to get these,
		//run the forloop
		var sdate ='poop';
		var edate = 'poop';
		
		if (document.getElementById('skbe_table_div') != null) {
 var tbodies = document.getElementById("skbe_table_div");
 var rows = tbodies.getElementsByTagName("td");
     
     for (var i=0; i<rows.length; i++) {
		
		if (rows[i].className == 'selected') {
		
		
		//i need to find how i figured out what dat is with what year
		if (sdate == 'poop') {
		
		var sdate = rows[i].id;
		
		//edit Poop marker
		var spanC = rows[i].getElementsByTagName("span");
		var sdateValue = spanC[0].innerHTML;
		
		}
		
		//edit Poop marker
		var edate = rows[i].id;
		var spanC = rows[i].getElementsByTagName("span");
		var edateValue = spanC[0].innerHTML;
		
		}
		
	}//end for loop
	
	
				var finalStartingDate = '';
                var finalEndDate = '';
	
                if (sdate != 'poop') {
                var finalStartingDate = getMonthYearofDay(sdate, sdateValue);
                var finalEndDate = getMonthYearofDay(edate, edateValue);
            } 
	
	//alert('s: '+finalStartingDate + ' | f:'+finalEndDate);
	
}//end if id exists
		
		
		
	  
	  
	  
	  
	  //display our preloader
	  
	  
	  if (document.getElementById('sk_calendar') != null) {
	  
	  var Caldiv = document.getElementById('sk_calendar');
	  
	 
	  
	  Caldiv.innerHTML = '<div style="height:'+Caldiv.offsetHeight+'px; width:'+Caldiv.offsetWidth+'px;" ><div class="sk_loadingImg" id="sk_loading_img_div" style="padding-top:'+(Caldiv.offsetHeight/2)+'px"><img src="sk_images/loading.gif" style="border:0; width:25px; height:25px;"/></div></div><div style="clear:both;"></div>';
	  }
      var query = 'date='+finalDate+'&rid='+Frid+'&s='+finalStartingDate+'&e='+finalEndDate+'&whichway='+whichway;
      var url = php_dir+"update_dates.php?"+query;
     
//alert(url);

    
   return !grabFile(url, 'sk_calendar');
  
 
   

}


//Here are my ajax functions to request different pages

function grabFile(file, whichDiv, togs) {

var togs = togs;
var whichDiv = whichDiv;
  var request = getHTTPObject();
  if (request) {
    request.onreadystatechange = function() {
      parseResponse(request, whichDiv, togs);
    };
    request.open("GET", file, true);
    request.send(null);
    return true;
  } else {
    return false;
  }
}

function parseResponse(request, whichDiv, togs) {
  
  var whichDiv = whichDiv;
  var togs = togs;
  var ftogs = '';
  ftogs = togs;

  
  if (request.readyState == 4) {
    if (request.status == 200 || request.status == 304) {
      
     if (document.getElementById(whichDiv) != null) {
      var details = document.getElementById(whichDiv);
       details.innerHTML = request.responseText;
      
     }
      
     
      
              	
              	//update our onload functions for the re-written content
              	highlightCell();		
				clickDate();	
				reset_onclick();
				monthNav();
				clickPic();
				
				
				



				
				if (whichDiv != 'sk_totalPrice' ) {
				
				
				if (ftogs == null) {
				
				//alert('here');
				updateCost();
				
				} else {
				
				finishCostUpdate(ftogs);
				
				}
				
				
				
				
				
				} 
				
				highlightRooms();
				toggleRoomsRates();
				SelectPakageRate();
				toggleRoomsandPackages();
      			
      
      
    }
  }
}

function getHTTPObject() {
  var xhr = false;
  if (window.XMLHttpRequest) {
    xhr = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    try {
      xhr = new ActiveXObject("Msxml2.XMLHTTP");
    } catch(e) {
      try {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
      } catch(e) {
        xhr = false;
      }
    }
  }
  return xhr;
}

//end ajax functions

function getTheDay(thisdate)

{

myDays=

["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]

myDate=new Date(thisdate);

//need it to ouput like Monday March 24, 2010
//right now it reads Wednesday24 March, 2010
var MydateArray = thisdate.split(" ");
var noCommaInMonth = MydateArray[1].split(',');

return myDays[myDate.getDay()] + ', ' + noCommaInMonth[0] + ' ' + MydateArray[0] +', '+MydateArray[2];

}



function getTheMonthnum(thisdate)

{

var month=new Array(12);
month['January']="01";
month['February']="02";
month['March']="03";
month['April']="04";
month['May']="05";
month['June']="06";
month['July']="07";
month['August']="08";
month['September']="09";
month['October']="10";
month['November']="11";
month['December']="12";

return month[thisdate];

}




function updateHeaderDates(myEid, myDiv) {

//we need to check and see if the beginning of month 2 is in table 1
//in the first month the id of the cell should match up with the date of the cell, if not we are in month 2


 if (document.getElementById(myEid) != null) {

                 var data = document.getElementById(myEid);
                 var spanC = data.getElementsByTagName("span");
                 
                 var more = spanC[0].innerHTML; //this was the date,
                 
                 
               
					



//var getparent = data.parentNode.id;
                
                
              //  alert(getparent.substr(0,5));
                if (Number(myEid.substr(6)) != more) {//its the second month
                
                var ourDate = document.getElementById('monthNav2').innerHTML;
                
                } else {//its the first month
                
                var ourDate = document.getElementById('monthNav1').innerHTML;
                
                }
                 
                 
                 //now break it up to get it in the right format
                 var dateSplit = ourDate.split(' ');
                 
                 //make it look like this 25 December, 2000
                 document.getElementById(myDiv).innerHTML = getTheDay(more+' '+dateSplit[0]+', '+dateSplit[1]);

}//end if this id exists
}




function resetHeaderDates() {

	if (document.getElementById('edate') != null && document.getElementById('sdate') != null) {
				document.getElementById('edate').innerHTML = '';
				document.getElementById('sdate').innerHTML = '';
			}
}

function resetAllDates() {
if (document.getElementById('skbe_table_div') != null) {
var newtable = document.getElementById("skbe_table_div");
 				 	var newrows = newtable.getElementsByTagName("td");
						
						for (var p=0; p<newrows.length; p++) {
						
							if (newrows[p].className.indexOf("noroom") == -1 && newrows[p].className.indexOf("emptyCell") == -1) {
                			newrows[p].className = 'normal';
                			clearOutRateinDays(newrows[p].id);
                			}
							
						}//end for loop
			
			//now reset the header dates
			resetHeaderDates();
			update_room_list();
			
			//now send something to our room selection page
}//if id exists
}

//reset the calendar
function reset_onclick () {
if (document.getElementById('sk_reset') != null) {

document.getElementById('sk_reset').onclick = function() {

resetAllDates();
updateCost();
}
}//if id exists
}


function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}



function CheckToResetDates(newrows) {
                 
                 
                 
                 var classcheck = 1;
                 for (var p=0; p<newrows.length; p++) {
                 
                  if (newrows[p].className.indexOf("selected") != -1) {
                 
                     var classcheck = 2;
                 	}
                 }
                 
                 if (classcheck == 1) {
                 
                 	resetHeaderDates();
                 	
                 }

}




//function to update costs
function updateCost() {

//we are going to need to send away to find the price
var rm_div = 'sk_roomlistcontainer';
var rm_room_id = '';
var rm_pack_id = '';
var uc_sdate = '';
var uc_edate= '';

//now we need to get know what days are clicked

if (document.getElementById('skbe_table_div') != null) {
 var tbodies = document.getElementById("skbe_table_div");
 var rows = tbodies.getElementsByTagName("td");
     
     for (var i=0; i<rows.length; i++) {
		
		
		
		if (rows[i].className == 'selected') {
		
		if (uc_sdate == '') {
		var uc_sdate = rows[i].id;
		}
		
		var uc_edate = rows[i].id;
		
		}//end if classname == selected
		
		
	}//end for loop
}//end if id exists


//now get the real dates from the ids taken
if (uc_edate != '' && uc_sdate != '') {


	//get the edate
	if (document.getElementById(uc_sdate) != null) { 	
		
		//edit poop marker
		var sdkj = document.getElementById(uc_sdate);
		
		var spanC = sdkj.getElementsByTagName("span");
		
		var uc_sdate_value = spanC[0].innerHTML;
		
		
		var uc_final_sdate = getMonthYearofDay(uc_sdate, uc_sdate_value);
	
	}//end if exists



	//get the edate
	if (document.getElementById(uc_edate) != null) { 	
	
	var sdkj = document.getElementById(uc_edate);
	var spanC = sdkj.getElementsByTagName("span");
		
	
		var uc_edate_value = spanC[0].innerHTML;
		var uc_final_edate = getMonthYearofDay(uc_edate, uc_edate_value);
	
	}//end if exists




//now lets see if we have any rooms or packages selected
	if (document.getElementById(rm_div) != null) {
	
	var rm_update_div = document.getElementById(rm_div);
	var roomDivs = rm_update_div.getElementsByTagName("div");
	for (var i=0; i<roomDivs.length; i++) {
		
		
		if (roomDivs[i].className == 'sk_roomlist_selected') {
			
			//get our room id
			var rm_room_id = roomDivs[i].id.substr(11);
		
		}//end if we have a room selected
		
		if (roomDivs[i].className == 'sk_indRate_selected') {
		
			var rm_pack_id = roomDivs[i].id.substr(11);
		}
		
		
	}//end for loop
}//end if exists

if (uc_final_edate == uc_final_sdate) {

if (document.getElementById('sk_totalPrice') != null) {
document.getElementById('sk_totalPrice').innerHTML = '0.00';
}

} else {

//update the cost
//make sure the calendar is not loading



if (document.getElementById('sk_totalPrice') != null) {

	//now we need to show the preloader
	document.getElementById('sk_totalPrice').innerHTML = ' <span style="text-decoration:blink; color:#ffffff">Loading</span>';
	
var data_array = new Array();
data_array[0] = uc_final_edate;
data_array[1] = uc_final_sdate;
data_array[2] = rm_room_id;
data_array[3] = rm_pack_id;

var mcScroats = 'poop';
var mcScroats = addRateToDays(data_array);





}//end if dates are not the same



}//if exists 


}//end if we have clicked on dates


 else {
 //set it to zero

if (document.getElementById('sk_totalPrice') != null) {
document.getElementById('sk_totalPrice').innerHTML = '0.00';
}

}//end if we have a starting date and ending date
}
//end function 



function finishCostUpdate(data) {

var data = data;
var uc_final_edate = data[0];
var uc_final_sdate = data[1];
var rm_room_id = data[2];
var rm_pack_id = data[3];

if (document.getElementById('sk_totalPrice') != null) {

	//now we need to show the preloader
	document.getElementById('sk_totalPrice').innerHTML = ' <span style="text-decoration:blink; color:#ffffff">Loading</span>';

var url = php_dir+"update_price.php?edate="+uc_final_edate+"&sdate="+uc_final_sdate+"&rid="+rm_room_id+"&pid="+rm_pack_id;
return !grabFile(url, 'sk_totalPrice');
}


}//end function



//function to add rates into calendar days
function addRateToDays(data) {
	var data = data;
	var uc_final_edate = data[0];
	var uc_final_sdate = data[1];
	var rm_room_id = data[2];
	var rm_pack_id = data[3];
	
	
	



if (document.getElementById('monthNav1') != null) {
		var date = document.getElementById('monthNav1').innerHTML;
		var dateArray = date.split(" ");
		var finalDate = dateArray[1]+'-'+getTheMonthnum(dateArray[0]);
		}



	 if (document.getElementById('sk_calendar') != null) {
	  
	  var Caldiv = document.getElementById('sk_calendar');
	  
	 
	  
	  Caldiv.innerHTML = '<div style="height:'+Caldiv.offsetHeight+'px; width:'+Caldiv.offsetWidth+'px;" ><div class="sk_loadingImg" id="sk_loading_img_div" style="padding-top:'+(Caldiv.offsetHeight/2)+'px"><img src="sk_images/loading.gif" style="border:0; width:25px; height:25px;"/></div></div><div style="clear:both;"></div>';
	  }
			
		
	var query = 'date='+finalDate+'&roomid='+rm_room_id+'&pid='+rm_pack_id+'&s='+uc_final_sdate+'&e='+uc_final_edate;
      		var url = php_dir+"update_dates.php?"+query;
     
//alert(url);
     
        
   return !grabFile(url, 'sk_calendar', data);

	
	}

//end function





//function to hide room rates
function toggleRoomsRates () {

if (document.getElementById('sk_roomWrap') != null) {

var divId = document.getElementById('sk_roomWrap');
var roomDivs = divId.getElementsByTagName("div");
	for (var i=0; i<roomDivs.length; i++) {
		
		
		
		if ( roomDivs[i].id.substr(0, 11) == 'roomHeading') {
		
		roomDivs[i].onclick = function() {
		
		
		//grab the id through substr
		//we need to close up any opened ones
		//and highlight the one that has been clicked
		
		
		//grab the div we are working with
		var endingNum = Number(this.id.substr(11));
		var roomRateDiv = document.getElementById('sk_roomrates'+endingNum);
		if (roomRateDiv.className.indexOf("sk_roomratesWrap_hide") != -1) {
		
		var currentlyClicked = 'no';
		
		} else {
		var currentlyClicked = 'yes';
		}
		
		//hide all others
		 for (var j=0; j<roomDivs.length; j++) {
		 
		 	if (roomDivs[j].id.substr(0, 12) == 'sk_roomrates') {
		 	 roomDivs[j].className = "sk_roomratesWrap_hide";
		 	}
		 	
		 	
		 	if (roomDivs[j].id.substr(0, 11) == 'roomHeading') {
		 	 roomDivs[j].className = "sk_roomlist";
		 	}
		 	
		 //we also want to hide any individual roomrates
		 if (roomDivs[j].id.substr(0, 11) == 'sk_indvrate') {
		 	 roomDivs[j].className = "sk_indRate";
		 	}
		 
		 }//end for loop
		
		
		
		//open this one and highlight it
		
		
		
		
		
		if (currentlyClicked == 'no') {
		
		//alert(roomRateDiv.className);
		
		this.className = "sk_roomlist_selected";
		roomRateDiv.className = "sk_roomratesWrap_show";
		updatePhotos(this.id);
		//alert(roomRateDiv.id);
		
		} else {
		roomRateDiv.className = "sk_roomratesWrap_hide";
		this.className = "sk_roomlist";
		updatePhotos();
		updateCost();
		
		
		}
		
		
		
		
		
		}//end onclick function
		
		
		}//end if
	
	}//end for loop
}//end if id exists

}//end function


//function to show what package rate you have selected
function SelectPakageRate () {

if (document.getElementById('sk_roomWrap') != null) {

var divId = document.getElementById('sk_roomWrap');
var roomDivs = divId.getElementsByTagName("div");
	for (var i=0; i<roomDivs.length; i++) {
		
		
		
		if (roomDivs[i].id.substr(0, 11) == 'sk_indvrate') {
		
		roomDivs[i].onclick = function() {
		
		
		//grab the id through substr
		//we need to close up any opened ones
		//and highlight the one that has been clicked
		
		//grab the div we are working with
		if (this.className  != "sk_indRate_selected") {
		//alert(this.className);
		var currentlyClicked = 'no';
		
		} else {
		
		var currentlyClicked = 'yes';
		}
		
		//hide all others
		 for (var j=0; j<roomDivs.length; j++) {
		 
		 	if (roomDivs[j].id.substr(0, 11) == 'sk_indvrate') {
		 	 roomDivs[j].className = "sk_indRate";
		 	}
		 	
	}//end for loop
		
		
		
		if (currentlyClicked == 'no') {
		
		
		this.className = "sk_indRate_selected";
		updateCost();
		//sendRoomID('0', this.id); //send data to update_dates.php
		
		
		 
		
		} else {
		//alert(this.className);
		this.className = "sk_indRate";
		sendRoomID('0');
		
		}
		
		
		
		
		}//end onclick function
		
		
		}//end if
	
	}//end for loop
}//end if id exists

}//end function






















function addClass(element,value) {
  if (!element.className) {
    element.className = value;
  } else {
    newClassName = element.className;
    newClassName+= " ";
    newClassName+= value;
    element.className = newClassName;
  }
}



function highlightCell() {


  if(!document.getElementsByTagName) return false;
  var tbodies = document.getElementsByTagName("table");
  for (var j=0; j<tbodies.length; j++) {
     var rows = tbodies[j].getElementsByTagName("td");
     for (var i=0; i<rows.length; i++) {
           //rows[i].oldClassName = 'normal';
           rows[i].onmouseover = function() {
              
             if ( this.className != "selected" && this.className != "noroom" && this.className != "emptyCell") {
                 
                
                 this.className = "highlight";
                
                 
                 }//if
           }//funonc
           
           rows[i].onmouseout = function() {
              if( this.className == "highlight") {
                
                
                this.className = 'normal';
                 
                 
                 }// if
                 }//function
           
     } //inner for loop
  }//for loop
}//function



//function to highlight room list
function highlightRooms() {

if (document.getElementById('sk_roomWrap') != null) {
 
 var inDiv = document.getElementById('sk_roomWrap');
 
 }
 
  var rows = document.getElementsByTagName("div");
  for (var i=0; i<rows.length; i++) {
     
          //get all the rate packages
          if (rows[i].id.substr(0, 11) == 'sk_indvrate') {
          
           //rows[i].oldClassName = 'normal';
           rows[i].onmouseover = function() {
              
             if ( this.className != "sk_indRate_selected") {
                 
                
                 this.className = "sk_indRate_highlight";
                
                 
                 }//if
           }//funonc
           
           rows[i].onmouseout = function() {
              if( this.className == "sk_indRate_highlight") {
                
                
                this.className = 'sk_indRate';
                 
                 
                 }// if
                 }//function
           
     } //end if we are targeting the right divs
     
     
     
     //now target just the room type
     if (rows[i].id.substr(0, 11) == 'roomHeading') {
     
      rows[i].onmouseover = function() {
              
             if ( this.className != "sk_roomlist_selected") {
                 
                
                 this.className = "sk_roomlist_highlight";
                
                 
                 }//if
           }//funonc
           
           rows[i].onmouseout = function() {
              if( this.className == "sk_roomlist_highlight") {
                
                
                this.className = 'sk_roomlist';
                 
                 
                 }// if
                 }//function
     
     
     }///end if we are dealing with room types
     
     
     
  }//for loop
}//function



////end function


//function to swap big image with little image
function swapImage(data) {

var data = data;


if (document.getElementById(data) != null) {

var myImage = data.substr(8);
var myId = document.getElementById(data);


//now reset the other imgs
var myDiv = document.getElementById('sk_photoWrap');
var rows = myDiv.getElementsByTagName("div");

for (var i=0; i<rows.length; i++) {
		
		if (rows[i].className == 'sk_selectedImgs') {
		rows[i].className = 'sk_otherImgs';
		}
}

myId.className = 'sk_selectedImgs';

//now switch this into the big picture
if (document.getElementById('sk_BigImg') != null) {

	var bigImg = document.getElementById('sk_BigImg');
	bigImg.innerHTML = '<img src="sk_room_images/'+myImage+'.jpg" border="0" width="100%" alt="hotel image" />';
     
}//end if id exists
}//end if id exist

}//end swap function


/*Deal with our pretty pictures*/
function clickPic() {

//we should probably preload the images also

if (document.getElementById('sk_photoWrap') != null) {

	var myDiv = document.getElementById('sk_photoWrap');
	var rows = myDiv.getElementsByTagName("div");
		
		for (var i=0; i<rows.length; i++) {
		
		if (rows[i].className == 'sk_otherImgs' || rows[i].className == 'sk_selectedImgs') {
		
			rows[i].onclick = function() {
			
				//send request to page to swith the pic
				swapImage(this.id);
				
			
			}//end function
		
		}//end if we have our classname
		
		}//end for loop

}/*End if our id exists*/


}/*End clickPic*/




//function to erase rates in days

function clearOutRateinDays(myId) {

var myId = myId;

if (document.getElementById(myId) != null) {

var myTD = document.getElementById(myId);
var InsideDiv = myTD.getElementsByTagName("div");

InsideDiv[0].innerHTML = '';


}//end if exists




}

//end function




function clickDate() {
  	  
  	  if(!document.getElementsByTagName) return false;
 	 var tbodies = document.getElementById("sk_calendar");
  
  
 if (tbodies.getElementsByTagName("td") != null) {
 	 var rows = tbodies.getElementsByTagName("td");
 	 
 	 }
 	 
 	 
     for (var i=0; i<rows.length; i++) {
        rows[i].oldClassName = rows[i].className
        rows[i].onclick = function() {
              
                 
                 //Prep our loop variables to run through to determine what needs to be selected
              	 var newtable = document.getElementById("skbe_table_div");
 				 var newrows = newtable.getElementsByTagName("td");
              
             
                 
                 
                 
                 //1
                 //see how many cells are 'selected'
                 	
                 	var selectCount = 0;
                 	
                 	for (var p=0; p<newrows.length; p++) {
                 	
                 		if (newrows[p].className == 'selected') {
                 		
                 			selectCount++; //count its
                 			var selectedCell = newrows[p].id;
                 			newrows[p].className = 'normal'; //reset it to normal
                 			
                 			//lets also clear out the rate
                 			clearOutRateinDays(newrows[p].id);
                 			
                 		}
                 	
                 	
                 		}//end foreach 1
                 		
                 		
                 	//if we have more than one cell selected, clear it out
                 	if (selectCount > 1) {
                 	
                 	//2
                 	for (var p=0; p<newrows.length; p++) {
                 	
                 		
                 		
                 		if (newrows[p].className == 'selected') {
                 		   
                 			newrows[p].className = 'normal';
                 			//lets also clear out the rate
                 			clearOutRateinDays(newrows[p].id);
                 		}
                 	
                 	
                 		}//end foreach 2
                 	
                 	
                 	}//end if	
                 		
                 		
                 		
                 //now figure out the starting id, and the ending id
                 if (selectCount == 1) {
                 
                
                	//just get the number value of the id
                	var si = Number(this.id.substr(6));
                 	var ei = Number(selectedCell.substr(6));
                
                
                
                		//determine which comes first
                		if (si > ei) {
                
                			var startId = selectedCell;
                			var endId = this.id;
                
                			} else {
                
                				var startId = this.id;
                				var endId = selectedCell;
                
               			 }//end if
                
                
                
                 
                 }//end if we have one selected
                 
                 else {
                 
                 	//set both of them to this id
                 	var startId = this.id;
                	var endId = this.id;
                 
                 }	
                 
               
                 
                 //now loop through and select any between cells
                 //but not if we hit any noroom cells along the way
                 //first we want to check and see if it is the same click on a single, and clear it
                 if (this.id == endId && this.id == startId && selectCount == 1) {
                 
                 
                 CheckToResetDates(newrows);
                 
                 } else {
                 
                 
                 var contSelect = 'no';
                 var stopSelecting = 'no';
                 var sendAlert = 'yes';
                 
                 
                
                 
                 for (var p=0; p<newrows.length; p++) {
                 	
                 		//register the start date
                 		if (newrows[p].id == startId && newrows[p].className != 'noroom' && this.className != 'emptyCell') {
                 		
                 		
                 		
                 			//set the class
                 			newrows[p].className = 'selected';
                 			
                 			
                 			
                 			//update the header
                 			updateHeaderDates(startId, 'sdate');
                 			
                 			
                 			
                 			
                 			//give the cue to start selecting next dates
                 			var contSelect = 'yes';
                 			var tempEndId = newrows[p].id;
                 			
                 		}
                 		
                 		
                 		//check to see if we cross any noroom dates
                 		if (newrows[p].className == 'noroom' && Number(newrows[p].id.substr(6)) > Number(startId.substr(6)) && Number(newrows[p].id.substr(6)) < Number(endId.substr(6))) {
                 		
                 			var stopSelecting = 'yes';
                 			
                 			
                 			//update the header
                 			updateHeaderDates(tempEndId, 'edate');
                 			
                 			//give the cue to stop selecting next dates
                 			var contSelect = 'no';
                 			
                 			 //and send out an alert
                  			if (sendAlert == 'yes' && endId != startId) {
                  			 alert('One of your selected dates is not available.');
                  			 
                  			 var sendAlert = 'no';
                  			 }
                 			
                 		}
                 		
                 		
                 		
                 		
                 		//register the end date
                 		if (newrows[p].id == endId && stopSelecting == 'no' && newrows[p].className != 'noroom' && newrows[p].className != 'emptyCell') {
                 		
                 			//set the class
                 			
                 			newrows[p].className = 'selected';
                 			
                 			
                 			//update the header
                 			updateHeaderDates(endId, 'edate');
                 			
                 			//give the cue to start selecting next dates
                 			var contSelect = 'no';
                 			
                 		}
                 		
                 		
                 		
                 		
                 		
                 		
                 		//select in bewtween dates
                 		if (contSelect == 'yes' && stopSelecting == 'no') {
                 		
                 		newrows[p].className = 'selected';
                 		var tempEndId = newrows[p].id;
                 		
                 		
                 		}
                 		
                 		
                 		
                 		}//end foreach
                 		
                 	}//end if it is the same click on the same only selected cell	
                 
                 
                 
                 //I think this is where we want to send the update room list function
                 		//we have a start date and end date
                 		//not a good place for it
                 		
                 		
                 		update_room_list();
                 		
                 		
                 
           } //end fucntion onclick
          }//end intial for loop
              
     }//end function
  
	
/*Create and deal with month navigation*/
function monthNav() {

var pid= '';
//lets run through a for loop to see if there is a selected room yet
 if (document.getElementById('sk_roomWrap') != null) {
 
 var roomrates = document.getElementById('sk_roomWrap');
 
 	var roomDivs = roomrates.getElementsByTagName("div");
	
	for (var i=0; i<roomDivs.length; i++) {
	
	if (roomDivs[i].className == 'sk_indRate_selected') {
	
		/*This is the Package Id*/
		var pid = roomDivs[i].id
	
	}
	
	}//end for loop
 

 
 }//end search for clicked on room


//deal with the previous nav first
 if (document.getElementById('sk_prevMonth') != null) {
  var prevNav = document.getElementById("sk_prevMonth");
   
   prevNav.onclick = function() {
   
   //send it
   //we need to see if there is a room rate selected
   
   //lets clear the dates
   resetAllDates();
   sendRoomID('-1', pid);
   
   
   
   }//end onclick function

}//end previous month



//now deal with next nav
if (document.getElementById('sk_nextMonth') != null) {
  var nextNav = document.getElementById("sk_nextMonth");
   
   nextNav.onclick = function() {
   
   //send it
   //we need to see if there is a room rate selected
   
   resetAllDates();
   sendRoomID('+1', pid); //its plus two, not one, becuase the control is from the first month
   
   
   }//end onclick function

}//end next month




}//end function


//lets hide the packages and toggle it 
function toggleRoomsandPackages() {

if (document.getElementById('sk_packageWrap') != null) {

var divwrap = document.getElementById('sk_packageWrap');
divwrap.style.display = 'none';

}//end if exists


if (document.getElementById('sk_rooms') != null) {

var sk_rooms = document.getElementById('sk_rooms');

        sk_rooms.onclick = function() {
				
				if (document.getElementById('sk_roomWrap') != null && document.getElementById('sk_RoomandPackages') != null) {
				 
				 var activeDiv = document.getElementById('sk_roomWrap');
				 var nonactive = document.getElementById('sk_packageWrap');
				 activeDiv.style.display = 'block';
				 nonactive.style.display = 'none';
				 
				 
				 //change the class as well
				 this.className = 'sk_tabnav_Active';
				 
				 if (document.getElementById('sk_packages') != null) {
				 
				 document.getElementById('sk_packages').className = 'sk_tabnav';
				 }
				 
				}//end if exists

			}//end on click
			
			}//end if exists
			
			
	if (document.getElementById('sk_packages') != null) {

var sk_rooms = document.getElementById('sk_packages');

        sk_rooms.onclick = function() {
				
				if (document.getElementById('sk_roomWrap') != null && document.getElementById('sk_RoomandPackages') != null) {
				 
				 document.getElementById('sk_roomWrap').style.display = 'none';
				 document.getElementById('sk_packageWrap').style.display = 'block';
				 
				 //change the class
				 this.className = 'sk_tabnav_Active';
				 if (document.getElementById('sk_rooms') != null) {
				 
				 document.getElementById('sk_rooms').className = 'sk_tabnav';
				 }
				 
				}//end if exists

			}//end on click
			
			
			//now handle the second onclick
			
			
		
	}//end if exists
	
	
	
}//end function




//Update Room List
//so send this when dates are clicked on
//so the only thing we need is the dates
//we can figure out if there is a package or room
//selected in the function

function update_room_list() {

var data = data;

var rm_div = 'sk_roomlistcontainer';
var rm_starting = '';
var rm_ending = '';
var rm_room_id = '';
var rm_pack_id = '';


//get our dates
if (document.getElementById('skbe_table_div') != null) {
 var tbodies = document.getElementById("skbe_table_div");
 var rows = tbodies.getElementsByTagName("td");
     
     for (var i=0; i<rows.length; i++) {
		
		
		
		if (rows[i].className == 'selected') {
		
		if (rm_starting == '') {
		var rm_starting = rows[i].id;
		}
		
		var rm_ending = rows[i].id;
		
		}//end if classname == selected
		
		
	}//end for loop
}//end if id exists






//get the sdate
if (document.getElementById(rm_starting) != null) { 	
	
//edit poop marker	
var sdkj = document.getElementById(rm_starting);
var spanC = sdkj.getElementsByTagName("span");	
var sdate_value = spanC[0].innerHTML;

var final_sdate = getMonthYearofDay(rm_starting, sdate_value);
	
}//end if exists



//get the edate
if (document.getElementById(rm_ending) != null) { 	

var sdkj = document.getElementById(rm_ending);
var spanC = sdkj.getElementsByTagName("span");	
	
var edate_value = spanC[0].innerHTML;
var final_edate = getMonthYearofDay(rm_ending, edate_value);
	
}//end if exists	
	
	
	
	//send it with our div
	
	if (document.getElementById(rm_div) != null) {
	
	var rm_update_div = document.getElementById(rm_div);

	
	
	//lets find out if we have any room and/or package selected
	
	var roomDivs = rm_update_div.getElementsByTagName("div");
	for (var i=0; i<roomDivs.length; i++) {
		
		
			
			
		
		if (roomDivs[i].className == 'sk_roomlist_selected') {
			
			//get our room id
			var rm_room_id = roomDivs[i].id.substr(11);
		
		
		}//end if we have a room selected
		
		
		if (roomDivs[i].className == 'sk_indRate_selected') {
		
			var rm_pack_id = roomDivs[i].id.substr(11);
		
		}
		
		
	}//end for loop
		
	
	//end search for selected room and package
	
	//lets show our loading gif
		
	rm_update_div.innerHTML = '<div style="height:'+rm_update_div.offsetHeight+'px; width:'+rm_update_div.offsetWidth+'px;" ><div class="sk_loadingImg" style="padding-top:'+(rm_update_div.offsetHeight/2)+'px"><img src="sk_images/loading.gif" style="border:0; width:25px; height:25px;"/></div></div><div style="clear:both;"></div>';

	} //end if id exists
	
	
	//if (document.getElementById('monthNav1') != null) {
	
	// var MonthYear = document.getElementById('monthNav1').innerHTML;
	 
	// }
	 
	 
     var url = php_dir+"update_room_list.php?edate="+final_edate+"&sdate="+final_sdate+"&rid="+rm_room_id+"&pid="+rm_pack_id;
    
    var p = 1;
 
 while (p == 1) {   
   
   if (document.getElementById('sk_loading_img_div') == null) {  
   
    	//alert(url);
     return !grabFile(url, rm_div);
//updateCost();
p++;
}
}


}//end function










function initial_load() {


//send request to launch.php
if (document.getElementById('sk_booking_calendar') != null) {

var photodiv = document.getElementById('sk_booking_calendar');

photodiv.innerHTML = '<div style="height:'+photodiv.offsetHeight+'px; width:'+photodiv.offsetWidth+'px;" ><div class="sk_loadingImg" style="padding-top:'+(photodiv.offsetHeight/2)+'px"><img src="sk_images/loading.gif" style="border:0; width:25px; height:25px;"/></div></div><div style="clear:both;"></div>';


	
     var url = php_dir+"launch.php";
     

     
  return !grabFile(url, 'sk_booking_calendar');



}//end if id exists




preload_imgs();


}

addLoadEvent(initial_load);
