﻿
    var map;
    current_overID = "";
    last_overID = "";

function item (img_name,width,height)
  {

img_prefix = img_name;
this.slide_img = new Image (width,height);
this.slide_img.src = img_prefix + ".jpg";
  }

function new_item (img_name,width,height)
  {

item [img_name] = new item (img_name,width,height);
  }



function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function popup(url) {
MyWindow=window.open(url,'popup','toolbar=yes,location=yes,directories=no,status=no, menubar=no,scrollbars=yes,resizable=yes,width=1024,height=400');
if (window.focus) {MyWindow.focus()}
return false;
}

function popup2(url,tmpname, h,w) {
MyWindow=window.open(url,tmpname,'toolbar=no,location=no,directories=no,status=no, menubar=no,scrollbars=yes,resizable=yes,width='+w+',height='+h);
if (window.focus) {MyWindow.focus()}
return false;
}

  
    function load_map(latitude,longitude,zoom)
    {
    	load(latitude,longitude,zoom);
    	//add_MapControls("large")
    	//map.addControl(new GLargeMapControl());
	add_CustomMarker(latitude,longitude,"/Images/ownerImages/mapmarker.gif",80,80)		
				 
    }
    function load_map_owner(latitude,longitude,zoom)
    {
    	load(latitude,longitude,zoom);
    	//add_MapControls("large")
    	//map.addControl(new GLargeMapControl());
	add_CustomMarker(latitude,longitude,"/Images/ownerImages/mapmarker.gif",80,80);		
	map.addControl(new GSmallMapControl());		 
    }
    
    
    function load_map_large(latitude,longitude,zoom)
    {
    
    	load(latitude,longitude,zoom);
    	add_CustomMarker(latitude,longitude,"/Images/ownerImages/mapmarker.gif",80,80);		
    	//add_MapControls("large");
    	map.addControl(new GLargeMapControl());
				 
    }
    
    
    
    function load_loc_map(latitude,longitude,zoom,inset)
    {
    	load(latitude,longitude,zoom);
    	//add_MapControls("large")
    	map.addControl(new GLargeMapControl());
	//add_CustomMarker(latitude,longitude,"/Images/ownerImages/mapmarker.gif",80,80)		
    if (inset==-1)
    {	map.addControl(new GOverviewMapControl(new GSize(120,90))); }
				 
    }


 function toggle_visibility(id) {
       var e = document.getElementById(id);
       if(e.style.display == 'block')
          e.style.display = 'none';
       else
          e.style.display = 'block';
    }




//initial load of the map set to a latitude, longitude and zoom level
function load(latitude,longitude,zoom) 
{
	if (GBrowserIsCompatible()) 
  	{
    	map = new GMap2(document.getElementById("map"));      		  
    	map.setCenter(new GLatLng(latitude,longitude),zoom);    	
    }  
}





//add a marker with a custom image, specify the images width and hieght to set the offsets
function add_CustomMarker(latitude,longitude,image_url,image_width,image_height)
{
	var icon = new GIcon();
	icon.image = image_url;
	icon.iconSize = new GSize(image_width,image_height);
	icon.iconAnchor = new GPoint(image_width/2,image_height/2);
	var point = new GLatLng(latitude,longitude);
	var marker = new GMarker(point,icon,true);		
	map.addOverlay(marker);
//	map.addControl(new GOverviewMapControl(new GSize(120,90)));

}


// new comment requested sum function

function ComputeRequestedSum(hiddenFieldId, firstNumber, secondNumber, returnValue) {
   var hiddenFiled = document.getElementById(hiddenFieldId);
   hiddenFiled.value = firstNumber + secondNumber;
   return true;
}

//Rating functions

var commentRating = -1;
var baseRating;
var cmsRateMessage;
var cmsDisabledRateMessage;
var starArray = new Array();
var starDisabledArray = new Array();
var hiddenRatingID;
var isDisable;

function SetInitialValues(isDisabled, currentCommentRating) {
   baseRating = currentCommentRating;
   isDisable = (isDisabled != "False");

   if (isDisabled == "False")
      StarOut();
}

function SetClientIds(isDisabled, star0ClientId, star1ClientId, star2ClientId, star3ClientId, star4ClientId, hiddenFieldId, cmsMessageId) {

   if (isDisabled == "False") {
      starArray[0] = star0ClientId;
      starArray[1] = star1ClientId;
      starArray[2] = star2ClientId;
      starArray[3] = star3ClientId;
      starArray[4] = star4ClientId;
      cmsRateMessage = cmsMessageId;
   }
   else {
      starDisabledArray[0] = star0ClientId;
      starDisabledArray[1] = star1ClientId;
      starDisabledArray[2] = star2ClientId;
      starDisabledArray[3] = star3ClientId;
      starDisabledArray[4] = star4ClientId;
      cmsDisabledRateMessage = cmsMessageId;
      SetDisabledText();
   }

   hiddenRatingID = hiddenFieldId;
}

function HighlightStars(isDisabled, lastIndex) {

   for (var index = 0; index <= lastIndex; index++)
      if (!isDisabled)
      document.getElementById(starArray[index]).className = "CmsRateStarBase CmsRateStarFull";
   else
      document.getElementById(starDisabledArray[index]).className = "CmsRateStarBase CmsRateStarRated";
   for (var index = lastIndex + 1; index <= 4; index++)
      if (!isDisabled)
      document.getElementById(starArray[index]).className = "CmsRateStarBase CmsRateStarEmpty";
   else
      document.getElementById(starDisabledArray[index]).className = "CmsRateStarBase CmsRateStarEmpty";
}

function StarOver(star) {
   // Just rated
   var starIndex;

   for (var count = 0; count <= 4; count++) {
      if (starArray[count] == star)
         starIndex = count;
   }

   HighlightStars(isDisable, starIndex);
   document.getElementById(cmsRateMessage).innerHTML = document.getElementById(star).getAttribute("title");
}

function StarOut() {
   // Just rated
   HighlightStars(isDisable, baseRating - 1);
   var cmsMessage = document.getElementById(cmsRateMessage);
   if (cmsMessage != null)
      cmsMessage.innerHTML = baseRating < 1 ?
         "Rate this property." : document.getElementById(starArray[baseRating - 1]).getAttribute("title");
}

function StarClick(star) {
   // Just rated   

   var starClickIndex;

   for (var count = 0; count <= 4; count++)
      if (starArray[count] == star)
      starClickIndex = count;

   HighlightStars(isDisable, starClickIndex);
   baseRating = starClickIndex + 1;
   if (isDisable)
      SetDisabledText();
   StarOut();
   document.getElementById(hiddenRatingID).value = baseRating;
}

function SetDisabledText() {
   if (baseRating > 0) document.getElementById(cmsDisabledRateMessage).innerHTML = document.getElementById(starDisabledArray[baseRating - 1]).getAttribute("title");
   else document.getElementById(cmsDisabledRateMessage).innerHTML = "Not rated yet";
}


function OpenWindow(url) {
   MyWindow = window.open(url, 'popup', 'toolbar=yes,location=yes,directories=no,status=no, menubar=no,scrollbars=yes,resizable=yes,width=800,height=400');
   if (window.focus) { MyWindow.focus() }
   return false;
}

function LimitTextBoxCharLength(textBox, maxLimit) {
   charcounter = textBox.value.length;
   if (charcounter == maxLimit) return false;
   return true;
}

function CreateObject(objId) {
   if (document.getElementById) return document.getElementById(objId);
   else if (document.layers) return eval("document." + objId);
   else if (document.all) return eval("document.all." + objId);
   else return eval("document." + objId);
}

function UpdateCharCounter(textBox, counter, maxLimit) {
   textBoxText = textBox.value;
   if (textBoxText.length > maxLimit) {
      textBoxText.substring(0, maxLimit);
   }

   counter = CreateObject(counter);

   if (counter) {
      counter.innerText = "(Characters left: " + (maxLimit - textBoxText.length) + "/" + maxLimit + ")";
   }

   return true;
}



