			oHotel = new Object();
			
			$(document).ready(function() {
				if($('input.iReviewRating').length > 0) $('input.iReviewRating').rating();
				$('#review_write input').keyup(function() { $(this).prev().removeClass('labelerror').addClass('label'); });
				$('#review_write textarea').keyup(function() { $(this).prev().removeClass('labelerror').addClass('label'); });
				$('.iReviewRating').click(function() { $(this).parent().parent().find('div:eq(0)').removeClass('labelerror').addClass('label'); });
				$('#reviewWrite .submit').click(oHotel.reviewAdd);
			});
			
			oHotel.self = function() {
				sLink = location.pathname.split('/');
				if(sLink[1] == 'view') 
					return 'http://'+location.host+'/view/'+sLink[2]+'/';
				else
					return 'http://'+location.host+'/';
			}
			
			oHotel.reviewSent = function(iId) {
				if($('#reviewShow').is(':visible')) $('#reviewShow').slideUp();
				if($('#reviewMap').is(':visible')) $('#reviewMap').slideUp();
				if($('#reviewWrite').is(':visible')) $('#reviewWrite').slideUp();
				if($('#reviewSent').is(':visible') && $('#reviewSent').prev().is('#ad'+iId)) {
					$('#reviewSent').slideUp();
					return false;
				}
				if(!$('#reviewSent').prev().is('#ad'+iId)) {
					$('#reviewSent').slideUp('normal',function() {
						$('#ad'+iId).after($('#reviewSent'));
						$('#reviewSent').slideDown();
					});
				}
				else $('#reviewSent').slideDown();
				return false;
			}
			
			oHotel.reviewWrite = function(iId) {
				if($('#reviewShow').is(':visible')) $('#reviewShow').slideUp();
				if($('#reviewMap').is(':visible')) $('#reviewMap').slideUp();
				if($('#reviewSent').is(':visible')) $('#reviewSent').slideUp();
				if($('#reviewWrite').is(':visible') && $('#reviewWrite').prev().is('#ad'+iId)) {
					$('#reviewWrite').slideUp();
					return false;
				}
				if(!$('#reviewWrite').prev().is('#ad'+iId)) {
					$('#reviewWrite').slideUp('normal',function() {
						$('#ad'+iId).after($('#reviewWrite'));
						$('#reviewWrite').slideDown();
					});
				}
				else $('#reviewWrite').slideDown();
				return false;
			}
			
			oHotel.reviewMap = function(iId,sStreet,sCity,sCountry,sState,sPostal,fLat,fLng,iZoom) {
				if($('#reviewShow').is(':visible')) $('#reviewShow').slideUp();
				if($('#reviewWrite').is(':visible')) $('#reviewWrite').slideUp();
				if($('#reviewSent').is(':visible')) $('#reviewSent').slideUp();
				if($('#reviewMap').is(':visible') && $('#reviewMap').prev().is('#ad'+iId)) {
					$('#reviewMap').slideUp();
					return false;
				}
				if(!$('#reviewMap').prev().is('#ad'+iId)) {
					$('#reviewMap').slideUp('normal',function() {
						$('#ad'+iId).after($('#reviewMap'));
						$('#reviewMap').slideDown('normal',function() { oHotel.showMap(iId,sStreet,sCity,sCountry,sState,sPostal,fLat,fLng,iZoom); });
					});
				}
				else $('#reviewMap').slideDown('normal',function() { oHotel.showMap(iId,sStreet,sCity,sCountry,sState,sPostal,fLat,fLng,iZoom); });
				return false;
			}
			
			oHotel.reviewPhone = function(iId,sPhone) {
				$('#phoneLink'+iId).html('Phone: '+sPhone);
				$.ajax({url:oHotel.self()+'ajax.html?a=review_stats&iId='+iId+'&sType=phone',type: "POST",dataType:"json"});
				return false;
			}
			
			oHotel.showMap = function(iId,sStreet,sCity,sCountry,sState,sPostal,fLat,fLng,iZoom) {
				$.ajax({url:oHotel.self()+'ajax.html?a=review_stats&iId='+iId+'&sType=address',type: "POST",dataType:"json"});
				
				if(sCountry == 'USA') 
					if(sCity == " " || sCity == "")sText = "<font style=\"font-size:11px;\">"+sState+"</font>";
					else sText = "<font style=\"font-size:11px;\">"+sStreet+"<br />"+sCity+", "+sState+" "+sPostal+"</font>";
				else 
					if(sCity == " " || sCity == "") sText = "<font style=\"font-size:11px;\">"+sCountry+"</font>";
					else sText = "<font style=\"font-size:11px;\">"+sStreet+"<br />"+sCity+", "+sCountry+" "+sPostal+"</font>";
				
				if(iGoogleMode == -1) {
					$('#reviewMapWindow').html('<div style="width:100%;text-align:center;"><div style="position:relative;left:460px;top:60px;margin-right:-100px;margin-bottom:-40px;max-width:300px;width:300px;height:auto;overflow:hidden;" class="easyTooltip">'+sText+'</div><iframe src="http://www.prebuilt.com/googleMap.php?iId='+iId+'" style="width:630px;height:300px;border:none;padding:0;margin:0;" frameborder="0" scrolling="no" marginwidth="0" marginheight="0"></iframe></div>');
				}
				else {
					if (GBrowserIsCompatible()) {
						// create map
						var map = new GMap2(document.getElementById("reviewMapWindow"));
						// get point
						var point = new GLatLng(fLat,fLng);
						// center map
						map.setCenter(new GLatLng(fLat,fLng), parseInt(iZoom));
						// define UI
						map.setUIToDefault();
						// add marker
						map.addOverlay(new GMarker(point));
						// add info window
						map.openInfoWindowHtml(map.getCenter(),sText);
					}
				}
			}
			
			oHotel.reviewShow = function(iId) {
				oHotel.iId = iId;
				if($('#reviewWrite').is(':visible')) $('#reviewWrite').slideUp();
				if($('#reviewMap').is(':visible')) $('#reviewMap').slideUp();
				if($('#reviewSent').is(':visible')) $('#reviewSent').slideUp();
				if($('#reviewShow').is(':visible') && $('#reviewShow').prev().is('#ad'+iId)) {
					$('#reviewShow').slideUp();
					return false;
				}
				if(!$('#reviewShow').prev().is('#ad'+iId)) {
					$('#reviewShow').slideUp('normal',function() {
						$('#ad'+iId).after($('#reviewShow'));
						$('#reviewShow').html('<div style="width:100%;text-align:center;padding-top:2px;font-weight:bold;color:#F4F3EC;padding-bottom:2px;"><img src="view/templates/limo/img/ajax-loader.gif" alt="" /><br />Loading</div>');
						$('#reviewShow').slideDown('normal',oHotel.reviewShowLoad);
					});
				}
				else {
					$('#reviewShow').html('<div style="width:100%;text-align:center;padding-top:2px;font-weight:bold;color:#F4F3EC;padding-bottom:2px;"><img src="view/templates/limo/img/ajax-loader.gif" alt="" /><br />Loading</div>');
					$('#reviewShow').slideDown('normal',oHotel.reviewShowLoad);
				}
				$.ajax({url:oHotel.self()+'ajax.html?a=review_stats&iId='+iId+'&sType=reviews',type: "POST",dataType:"json"});
				
				return false;
			}
			oHotel.reviewShowLoad = function(iId) {
				if(oHotel.iId == -1) {
					var today = new Date();
					sNow = (today.getMonth()+1) + "/" + today.getDate() + "/" + today.getYear() + ' @ 1:00 AM';
					sHtml = '<div class="review">'+
								'<div class="head">Posted by: <a href="mailto:general@prebuilt.com">Consumer</a> on <a href="#">'+sNow+'</a></div>'+
								'<div class="rating">'+
										'<div style="display:inline;line-height:16px;">Rating:</div> '+
										'<div class="rating_bar"><div style="width:60%"></div>'+
										'</div>'+
									'</div>'+
									'<div class="label" style="line-height: 20px;">Review:</div>'+
									'<div class="content">This might be your ad! If you want to see yourself here, please click the link on the bottom of a page.</div>'+
								'</div><div style="clear:both;"></div>';
								
					$('#reviewShow').html('<div id="review_read">'+sHtml+'</div>');
					$('#reviewShow').slideDown();
					return false;
				}
				$.ajax({url:oHotel.self()+'ajax.html?a=reviews_read&id='+oHotel.iId,type: "POST",dataType:"json",success:function(r){
					$('#reviewShow').slideUp('normal', function() {
						sHtml = '';
						if(r.asReviews.length > 0) {
							$(r.asReviews).each(function() {
								sHtml += '<div class="review">'+
										'<div class="head">Posted by: <a href="mailto:'+this.sUserEmail+'">'+this.sUser+'</a> on <a href="#">'+this.dCreated+'</a></div>'+
										'<div style="display:inline;line-height:16px;">Rating: <div class="rating_bar"><div style="width:'+this.iRating+'%"></div></div></div>'+
										'<div class="label" style="line-height: 20px;">Review:</div>'+
										'<div class="content">'+this.sContent+'</div>'+
										'</div><div style="clear:both;"></div>';
							});
						}
						else {
							sHtml = '<div class="review"><div class="head">There are no reviews yet</div></div><div style="clear:both;"></div>';
						}
						$('#reviewShow').html('<div id="review_read">'+sHtml+'</div>');
						$('#reviewShow').slideDown();
					});
				}});
			}
			
			oHotel.reviewAdd = function(oClick, bForce) {
				bSubmit = true;
				$('.error').removeClass('error');
				if($('#sReviewName').val() == "") {
					$('#sReviewName').parent().prev().addClass('error');
					bSubmit = false;
				}
				if($('#sReviewEmail').val() == "") {
					$('#sReviewEmail').parent().prev().addClass('error');
					bSubmit = false;
				}
				if($('#iReviewRating').val() == "") {
					$('#iReviewRating').parent().prev().addClass('error');
					bSubmit = false;
				}
				if($('#sReviewContent').val() == "") {
					$('#sReviewContent').parent().prev().addClass('error');
					bSubmit = false;
				}
				if($('#sReviewCaptcha').val() == "" || $('#sReviewCaptcha').val().length != 6) {
					$('#sReviewCaptcha').parent().prev().addClass('error');
					bSubmit = false;
				}
				if(bSubmit && bForce != 1) {
					$.ajax({url:oHotel.self()+'ajax.html?a=captcha_check&sCaptcha='+$('#sReviewCaptcha').val(),type: "POST",dataType:"json",success:function(r){
						if(r.iCheck == 1) oHotel.reviewAdd(1,1);
						else {
							tmp = new Date(); 
							document.images['captchaImage'].src='captcha.html?color=limo&time='+tmp.getTime();
							$('#sReviewCaptcha').parent().prev().addClass('error');
						}
					}});
					return false;
				}
				if(bForce) {
					iId = $('#reviewWrite').prev().attr('id').replace('ad','');
					d = 'id='+iId+'&'+
						'sName='+$('#sReviewName').val()+'&'+
						'sEmail='+$('#sReviewEmail').val()+'&'+
						'iRating='+$('#iReviewRating').val()+'&'+
						'sContent='+$('#sReviewContent').val()+'&'+
						'sCaptcha='+$('#sReviewCaptcha').val()+'&';
					$.ajax({url:oHotel.self()+'ajax.html?a=review_add',type: "POST",data:d,dataType:"json",success:function(r){
						tmp = new Date(); 
						document.images['captchaImage'].src='captcha.html?color=limo&time='+tmp.getTime();
						oHotel.reviewSent(iId);
						$('#sReviewName').val('');
						$('#sReviewEmail').val('');
						$('#iReviewRating').val('');
						$('#sReviewContent').val('');
						$('#sReviewCaptcha').val('');
					}});
				}
			}
			
			oHotel.showAddress = function(iId,sStreet,sCity,sCountry,sState,sPostal) {
				$.ajax({url:oHotel.self()+'ajax.html?a=review_stats&iId='+iId+'&sType=address',type: "POST",dataType:"json"});
				return false;
			}
			oHotel.showPhone = function(iId,sPhone) {
				$.ajax({url:oHotel.self()+'ajax.html?a=review_stats&iId='+iId+'&sType=phone',type: "POST",dataType:"json"});
				return false;
			}

			 /*
			 * Function getting window width
			 */
			 function GetWidth() {
					var x = 0;
					if (self.innerHeight) x = self.innerWidth;
					else if (document.documentElement && document.documentElement.clientHeight) x = document.documentElement.clientWidth;
					else if (document.body)  x = document.body.clientWidth;
					return x;
			}
			
			 /*
			 * Function getting window height
			 */
			function GetHeight() {
					var y = 0;
					if (self.innerHeight) y = self.innerHeight;
					else if (document.documentElement && document.documentElement.clientHeight) y = document.documentElement.clientHeight;
					else if (document.body) y = document.body.clientHeight;
					return y;
			}
			 
			function addReview(aid) {
				data = "action=add&aid="+aid+"&sReviewName="+$("#sReviewName").val()+"&sReviewEmail="+$("#sReviewEmail").val()+"&sReviewContent="+$("#sReviewContent").val()+"&iReviewRating="+$("#iReviewRating").val()+"&iReviewCaptcha="+$("#iReviewCaptcha").val();
				$.ajax({
					beforeSend:  function() {
						if(bLoadResponse == true) $('#iestates_view_window_content').html("<div style=\"margin: auto;\"><img src=\"view/templates/hotel/img/ajax-loader.gif\" alt=\"Loading data\" /></div>");
					},
					url: "ajax_review_write.html",
					type: "POST",
					data: data,
					success: function(response){
						$('#iestates_view_window_content').html(response);
					}
				});
			 }
			 	 
			function bookmark(url, title){
				if (window.sidebar) // firefox
					window.sidebar.addPanel(title, url, "");
				else if(window.opera && window.print){
					var elem = document.createElement('a');
					elem.setAttribute('href',url);
					elem.setAttribute('title',title);
					elem.setAttribute('rel','sidebar');
					elem.click();
				}
				else if(document.all)// ie
					window.external.AddFavorite(url, title);
				return false;
			}