x = 50;
y = 0;

function setVisible(obj)
{
	obj = document.getElementById(obj);
	obj.style.visibility = (obj.style.visibility == 'visible') ? 'hidden' : 'visible';
}

function placeIt(obj)
{
	obj = document.getElementById(obj);
	if (document.documentElement)
	{
		theLeft = document.documentElement.scrollLeft;
		theTop = document.documentElement.scrollTop;
	}
	else if (document.body)
	{
		theLeft = document.body.scrollLeft;
		theTop = document.body.scrollTop;
	}
	theLeft += x;
	theTop += y;
	obj.style.left = theLeft + 'px' ;
	obj.style.top = theTop + 'px' ;
	//setTimeout("placeIt('"+obj+"')",500);
}

function ShowPopup(hoveritem, popUpDiv)
{
	hp = document.getElementById(popUpDiv);
	y = 20;
	// Set position of hover-over popup
	hp.style.top = (hoveritem.offsetTop+y)+'px';
	hp.style.left = hoveritem.offsetLeft+'px';
	
	// Set popup to visible
	//hp.style.visibility = "Visible";
	hp.style.visibility = (hp.style.visibility == 'visible') ? 'hidden' : 'visible';
}

function HidePopup(popUpDiv)
{
hp = document.getElementById(popUpDiv);
hp.style.visibility = "Hidden";
}
//window.onscroll = setTimeout("placeIt('"+obj+"')",500);

function redirect(url){
	window.location= ""+url+"";
}

function printIt(printThis)
{
  var win=null;
  var disp_setting="toolbar=no,location=no,directories=no,menubar=no,";
  disp_setting+="scrollbars=yes,width=800, height=600, left=100, top=25"; 
  win = window.open("","",disp_setting);
  self.focus();
  win.document.open();
  win.document.write('<'+'html'+'><'+'head'+'><'+'style'+'>');
  win.document.write('body, td { font-family: Verdana; font-size: 8pt; padding:5px 10px;} .header { font-family: "Times New Roman", Times, serif; font-size: 12px; font-style: normal;font-weight: bold; text-transform: uppercase; color: #ffffff; background-color: #336666;}');
  win.document.write('<'+'/'+'style'+'><'+'/'+'head'+'><'+'body'+'>');
  win.document.write(printThis);
  win.document.write('<'+'/'+'body'+'><'+'/'+'html'+'>');
  win.document.close();
  win.print();

  //win.close();
}

function tallyOccupancy(room, totalDays, totalType){
	//alert('tallyOccupancy '+room+' '+totalDays+' '+totalType); 
	
	var oFormObject = document.forms['search_room'];
	var txt = document.getElementById('validation');
	var days = oFormObject.elements['rdates[]'];
	var msg = new Array();
	noError = false;
	var printAlert = "";
	var startUL = '<ul>';
	var closeUL = '</ul>';
	
	for(i=0; i<totalDays; i++){
		var sum = 0;
		var displayDate = '';
		
		for(j=0; j<totalType; j++){
			var roomamt = document.getElementById('type'+j+'_day'+i).value; 
			sum = sum + parseInt(roomamt);
		}
		
		if(totalDays == 1){
			displayDate = days.value;
		}else{
			displayDate = days[i].value;
		}
		
		if(sum == room){
			//noError = true;
		}else{
			if(sum<room){
				printAlert += '<li>Not enough room selected on '+displayDate+'. Please add '+(room-sum)+' more room(s).</li>';
			}else if(sum>room){
				printAlert += '<li>Please select '+room+' room(s) for reservation on '+displayDate+'</li>';
			}
		}
	}
	
	//alert(printAlert);
	
	if(printAlert)
 		txt.innerHTML=startUL+printAlert+closeUL;
	else
		noError = true;

	return noError;
}

function changeLabel(){
	oFormObject = document.forms['roombest'];
	var txt = document.getElementById('room_label');
	var location = oFormObject.elements['r_location'].value;
	
	if(location == '6' || location == '7')
		txt.innerHTML="Unit(s):";
	else
		txt.innerHTML="Room(s):";
}
