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_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_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 MM_nbGroup(event, grpName) { //v3.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : args[i+1];
      nbArr[nbArr.length] = img;
    }
    //document.layers["layerCorpPopup"].zIndex = 0;
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    if ((nbArr = document[grpName]) != null)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = args[i+1];
      nbArr[nbArr.length] = img;
  } }
}


function ShowDialogModal(page, title, attributes)
{
	//window.alert(navigator.userAgent);
	if (navigator.userAgent.indexOf("MSIE") != -1)
	{
	  //window.alert("MSIE");
	  attributes = attributes.replace(/,/g, ';');
	  attributes = attributes.replace(/=/g, ':');
	  attributes = attributes.replace(/width/, 'dialogWidth');
	  attributes = attributes.replace(/height/, 'dialogHeight');
	  attributes = attributes.replace(/top/, 'dialogTop');
	  attributes = attributes.replace(/left/, 'dialogLeft');
	  attributes = attributes.replace(/scrollbars/, 'scroll');
  	return window.showModalDialog( page, title, attributes );
  }
  else
  {
    //window.alert("Other");
    if (attributes != "") attributes = attributes + ",";
    return window.open(page, title, attributes + 'dependent=YES,dialog=YES,modal=YES');//.opener.MyArgs;
  }
}

function Start(page)
{
	if (navigator.userAgent.indexOf("MSIE") != -1)
	{
	  //window.alert("MSIE");
  	return window.showModalDialog( page, "CurrencyConverter", "height=400,width=390,resizable=yes,scrollbars=yes" );
  }
  else
  {
    //window.alert("Other");
    if (attributes != "") attributes = attributes + ",";
    return window.open(page, "CurrencyConverter", 'height=400,width=390,resizable=yes,scrollbars=yes,dependent=YES,dialog=YES,modal=YES').opener.MyArgs;
  }
}

function CurrencyWindow(page)
{
  ShowDialogModal( page, "CurrencyConverter", "height=700px,width=415px,resizable=yes,scrollbars=yes" );
}

function SendToAFriendWindow(page)
{
  this.open( page, "sendtoafriend", 'width=390,height=610,top=' +((screen.height/2)-210)+ ',left='+((screen.width/2)-230) + ',scrollbars=auto,menubar=no,resizable=no' );
}

function VirtualTourWindow(page) 
	{ 
		OpenWin = this.open(page, "VirtualTour", "height=525,width=630,resizable=yes,scrollbars=yes"); 
	} 

function GoogleMapWindow(page)
{
    this.open( page, "findWithGoogleMap", 'width=620,height=535,top=' +((screen.height/2)-210)+ ',left='+((screen.width/2)-230) + ',scrollbars=no,resizable=no,titlebar=no,location=no,status=no' );
}

//browser resize
function maxtable()
{
//alert("resizing window");

var isNS  =(document.layers)?true:false;

bodyW = (isNS) ? window.innerWidth : document.body.offsetWidth;

if (bodyW < 1000)
	{MainTable.width = "100%"}
  else
	{MainTable.width = 1000}
}

function hideshow(whichdiv){
//
// hide them all 

	// hide divFindOffices
	document.getElementById('divFindOffices').style.display = "none";
	document.getElementById('divFindOffices').style.visibility = "hidden";
	// hide divFindProp
	document.getElementById('divFindProp').style.display = "none";
	document.getElementById('divFindProp').style.visibility = "hidden";
	// hide divFindAgents
//	document.getElementById('divFindAgents').style.display = "none";
//	document.getElementById('divFindAgents').style.visibility = "hidden";

// now show selected tab

	document.getElementById(whichdiv).style.display = "block";
	document.getElementById(whichdiv).style.visibility = "visible";
//
}

function hideshowEurope(whichdiv){
//
// hide them all 

	// hide divFindOffices
//	document.getElementById('divSellProperty').style.display = "none";
//	document.getElementById('divSellProperty').style.visibility = "hidden";
	// hide divFindProp
	document.getElementById('divFindProp').style.display = "none";
	document.getElementById('divFindProp').style.visibility = "hidden";
	// hide divFindAgents
	document.getElementById('divFindAgents').style.display = "none";
	document.getElementById('divFindAgents').style.visibility = "hidden";

// now show selected tab

	document.getElementById(whichdiv).style.display = "block";
	document.getElementById(whichdiv).style.visibility = "visible";
//
}




function visibilityToggle(id)
{ 
	var objectClicked = null;
	if (!/string/i.test(typeof(id)))
		{objectClicked = id[0];//THIS IS HERE FOR LATER USE:
								//FIX THE DISTANCE BETWEEN THE ITEM CLICKED AND THE POPUP LIST DISPLAY
		id = id[1];
		}
	var el = document.getElementById(id).style;

	if(id == "countrypopup"){
		var el2 = document.getElementById('myState');
	} else if (id == "currencypopup") {
		var el2 = document.getElementById('myStateCurrency');
	}
	//
	if(el.visibility == "hidden") { 
		el.visibility = "visible";
		el.display = "block";
	 if (id == "countrypopup" || id == "currencypopup"){
		  el2.value = 1;
		  showHideSelect('hidden');
	 }
	} else if(el.visibility == "visible") { 
		el.visibility = "hidden"; 
		el.display = "none";
		if (id == "countrypopup" || id == "currencypopup"){
			el2.value = 0;
			showHideSelect('visible');
		}
	}
}


function checkState(e){
	var IE = document.all?true:false;
	if (!IE) document.captureEvents(Event.MOUSEMOVE)
	
	var tempX = 0;
	var tempY = 0;
	
	if (IE) { // grab the x-y pos.s if browser is IE
	tempX = event.clientX + document.body.scrollLeft;
	tempY = event.clientY + document.body.scrollTop;
	}
	else {  // grab the x-y pos.s if browser is NS
		tempX = e.pageX;
		tempY = e.pageY;
	}  
	if (tempX < 0){tempX = 0;}
	if (tempY < 0){tempY = 0;}  
		
	var div = document.getElementById('countrypopup');
	div.style.left = tempX + 50 + "px";
	div.style.top = tempY - 200 + "px";
	
	var target = (e && e.target) || (event && event.srcElement); 
	
	var el = document.getElementById('myState').value;
	

	if(el == 1) {
		
		var obj = document.getElementById('shoCountry'); 
		var obj2 = document.getElementById('shoFlag'); 
		var obj3 = document.getElementById('shoArrow');
		
		if(target!=obj && target.parentNode !=obj2 && target.parentNode !=obj3){
		
			var el2 = document.getElementById('countrypopup').style;
			el2.visibility = "hidden"; 
			el2.display = "none";
			el = 0;
			showHideSelect('visible');
		}
	} 
	if(document.getElementById('myStateCurrency') != null)
	{
		var div = document.getElementById('currencypopup');
		div.style.left = tempX + 30 + "px";
		div.style.top = tempY - 100 + "px";
		
		el2 = document.getElementById('myStateCurrency').value;	
		
		if (el2 == 1){
			var obj = document.getElementById('shoCurrency'); 
			var obj2 = document.getElementById('shoCoins'); 
			var obj3 = document.getElementById('shoCurArrow');

			
			if(target.parentNode!=obj && target.parentNode !=obj2 && target.parentNode !=obj3){
			
				var el2 = document.getElementById('currencypopup').style;
				el2.visibility = "hidden"; 
				el2.display = "none";
				el = 0;
				showHideSelect('visible');
			}
		}
	}
}



function showHideSelect(action) {
	  if (navigator.appName.indexOf("MSIE")) {
		for (var S = 0; S < document.forms.length; S++){
			for (var R = 0; R < document.forms[S].length; R++) {
				if (document.forms[S].elements[R].options) {
					document.forms[S].elements[R].style.visibility = action;
				}
			}
		}
	}
}

// Applies  styles to input controls based on input "type"
function appendInputTypeClasses() 
{
  if ( !document.getElementsByTagName )
  {
    return;
  }
  var inputs = document.getElementsByTagName('input');
  var inputLen = inputs.length;
  for ( i=0;i<inputLen;i++ ) 
  {
    if ( inputs[i].getAttribute('type') )
    {
      inputs[i].className += ' '+inputs[i].getAttribute('type');
    }
  }
}
// Change which searchtype radio button is selected  (property or agent/office)
	function changeSearchType(searchType){
		if (searchType == 'SearchType1'){
			el = document.getElementById('SearchType1');
			el.checked = true;
			el = document.getElementById('SearchType2');
			el.checked = false;
		}
		if (searchType == 'SearchType2'){
			el = document.getElementById('SearchType2');
			el.checked = true;
			el = document.getElementById('SearchType1');
			el.checked = false;
		}
	}
	function sendMyRemaxLostPassword()
	{
	  //path to js file:  \\gttstweb02\webs$\testgeneric.slingshot.com\Sites\RemaxEuropeCommon\Includes
	  var emailTextBox = MM_findObj("ctl01_txtEmailAddress");
	  var emailAddress = emailTextBox.value;
	  //todo:  if emailAddress is blank, do nothing, else pop up the dialog
	  if((emailAddress != null)&&(emailAddress.length >1))
	  {
	    ShowDialogModal("/MyRemaxLostPassword.aspx?email=" + emailTextBox.value, "Email Lost Password", "height=200,width=350" );
	  }
	}

function OpenOfficeSelect(divOfficeNameID, emailID) 
{
  var ParmA; 
  var ParmB; 
  var MyArgs = new Array(ParmA, ParmB);
  var WinSettings = "center:yes;resizable:no;dialogHeight:300px"
  
  v_emailID = emailID;
  v_divOfficeNameID = divOfficeNameID;
  

  
  //ALTER BELOW LINE - supply correct URL for Child Form
  //var MyArgs = window.showModalDialog("http://localhost/ModalWin/ChildWebForm.aspx", MyArgs, WinSettings);
	//MyArgs = window.showModalDialog('http://www.remax-wales.com/PubScripts/SelectOffice.asp',MyArgs,'width=460,height=420,top='+((screen.height/2)-210)+',left='+((screen.width/2)-230) + ',scrollbars=yes,dependent=yes,menubar=no,resizable=no');
	MyArgs = ShowDialogModal('/Common/SelectOffice.aspx',MyArgs,'width=460px,height=420px,top='+((screen.height/2)-210)+',left='+((screen.width/2)-230) + ',scrollbars=yes,dependent=yes,menubar=no,resizable=no');
  if (MyArgs == null)
  {
    window.alert("No Office Selected");
  }
  else if (MyArgs[0].toString() == null || MyArgs[0].toString() == "")
  {
    window.alert("This office does not have email, please select another");
  }
  else
  {
    document.getElementById(emailID).value=MyArgs[0].toString();
    document.getElementById(divOfficeNameID).innerHTML=MyArgs[1].toString();
  }
}



var v_emailID;
var v_divOfficeNameID ;

function GetFF(MyArgs)
{
	document.getElementById(v_emailID).value=MyArgs[0].toString();
	document.getElementById(v_divOfficeNameID).innerHTML=MyArgs[1].toString();
}

  
function OpenOfficeSelectSell(divOfficeNameID, emailID, regionID) 
{
  var ParmA; 
  var ParmB; 
  var MyArgs = new Array(ParmA, ParmB);
  var WinSettings = "center:yes;resizable:no;dialogHeight:300px"
  var Url;
  Url = '/Common/SelectOfficeFrame.aspx?RegionID='+regionID;
  //ALTER BELOW LINE - supply correct URL for Child Form
  //var MyArgs = window.showModalDialog("http://localhost/ModalWin/ChildWebForm.aspx", MyArgs, WinSettings);
 //MyArgs = window.showModalDialog('http://www.remax-wales.com/PubScripts/SelectOffice.asp',MyArgs,'width=460,height=420,top='+((screen.height/2)-210)+',left='+((screen.width/2)-230) + ',scrollbars=yes,dependent=yes,menubar=no,resizable=no');
  MyArgs = window.showModalDialog(Url,MyArgs,'width=460,height=420,top='+((screen.height/2)-210)+',left='+((screen.width/2)-230) + ',scrollbars=no,dependent=yes,menubar=no,resizable=no');
  if (MyArgs == null)
  {
    window.alert("No Office Selected");
  }
  else if (MyArgs[0].toString() == null || MyArgs[0].toString() == "")
  {
    window.alert("This office does not have email, please select another");
  }
  else
  {
    document.getElementById(emailID).value=MyArgs[0].toString();
    document.getElementById(divOfficeNameID).innerHTML=MyArgs[1].toString();
  }
}

function ShowHideDiv(div, show)
{
  if ('True' != 'True')
  {
    if (show && ('False' == 'True'))
    {
      document.getElementById(div).style.display = "inline";
      document.getElementById(div).style.visibility = "visible";
    }
    else
    {
      document.getElementById(div).style.display = "none";
      document.getElementById(div).style.visibility = "hidden";
    }
  }
}

// This should be deprecated as it is less customizable and more vague.. Use OpenOfficeSelect() above
function OpenChild() 
{
    var ParmA; 
    var ParmB; 
    var MyArgs = new Array(ParmA, ParmB);
    var WinSettings = "center:yes;resizable:no;dialogHeight:300px"
    //ALTER BELOW LINE - supply correct URL for Child Form
    //var MyArgs = window.showModalDialog("http://localhost/ModalWin/ChildWebForm.aspx", MyArgs, WinSettings);
	//MyArgs = window.showModalDialog('http://www.remax-wales.com/PubScripts/SelectOffice.asp',MyArgs,'width=460,height=420,top='+((screen.height/2)-210)+',left='+((screen.width/2)-230) + ',scrollbars=yes,dependent=yes,menubar=no,resizable=no');
	MyArgs = ShowDialogModal('/Common/SelectOffice.aspx',MyArgs,'width=460,height=420,top='+((screen.height/2)-210)+',left='+((screen.width/2)-230) + ',scrollbars=yes,dependent=yes,menubar=no,resizable=no');
    if (MyArgs == null)
    {
        window.alert("No Office Selected");
    }
    else
    {
                                                                        // Commented because Wales was getting emails for every site
        document.getElementById('HSENDTO').value=MyArgs[0].toString(); // + ',recruitment@remax-wales.com';
        document.getElementById('officename').innerHTML=MyArgs[1].toString();
    }
}

function LangaugeChanged(LangVal)
{var curURL = location.href;
var Params = location.search.replace(/^\?/,"");
if (Params.length > 0)
	Params = Params.split('&');
if (Params.length > 0)
	curURL = curURL.replace(/\?(.*)$/, "?");
var KeyVal = null;
var curQueryString = "";

var LangKeyNotFound = true;
for (var x = 0;x<Params.length;x++)
	{KeyVal = Params[x].split('=');
	if (/^lang$/i.test(KeyVal[0]))
		{KeyVal[1] = LangVal;
		LangKeyNotFound = false;
		}
	curQueryString += "&" + KeyVal[0] + "=" + KeyVal[1]
	}

if (LangKeyNotFound)
	curQueryString += "&Lang=" + LangVal
if (/\/$/.test(curURL))
	{curURL += "Default.aspx?"
	}
else if (curURL.Length - 4 == location.hostname.length)
	{curURL += "/Default.aspx?"
	}
if (!/\?$/.test(curURL))
	curURL += '?'
//location = curURL + curQueryString.replace(/^\&/,"");
location.replace(curURL + curQueryString.replace(/^\&/,""));
}

function changeMap(){
	curURL = location.href;
	curSearch = curURL.split('SearchType=');
	curSearch = curSearch[1];
	curSearch = curSearch.split("",1);
	curSearch = curSearch[0];
	el = document.getElementById("mapImage");
	if (curSearch == 'O'){
		el.src = '/sites/REMAXSlovakia/mapimages/bratislava.gif';	
	} else {
		el.src = '/sites/REMAXSlovakia/mapimages/bratislava2.gif';	
	}
}

/* Popup div for images on Favourites/Recently Viewed */
var viewport = {
  getWinWidth: function () {
    this.width = document.body.clientWidth;
  },
  
  getWinHeight: function () {
    this.height = document.body.clientHeight;
  },
  
  getScrollX: function () {
    this.scrollX = this.scrollX = document.body.scrollLeft;
  },
  
  getScrollY: function () {
    this.scrollY = document.body.scrollTop;
  },
  
  getAll: function () {
    this.getWinWidth(); this.getWinHeight();
    this.getScrollX();  this.getScrollY();
  }
  
}

var ImagePopup = {
    followMouse: true,
    offX: 0,
    offY: 12,
    elemID: "ImagePopupDiv",
    showDelay: 100,
    hideDelay: 200,
    ready:false,
    timer:null,
    elem:null,
    init:function() {
      if(document.createElement && document.body && typeof document.body.appendChild!="undefined") {/*
        if(!document.getElementById(this.elemID)) {
          var elem=document.createElement("DIV");
          elem.id=this.elemID;
          document.body.appendChild(elem);
        }*/
        this.ready=true;
      }
    },
    show:function(e,msg) {
      if(this.timer) {
        clearTimeout(this.timer);
        this.timer=0;
      }
      this.elem=document.getElementById(this.elemID);
      if(this.followMouse) {
        if (document.addEventListener) document.addEventListener("mousemove", this.trackMouseCallback, true);
        else if (document.attachEvent) document.attachEvent("onmousemove", this.trackMouseCallback);
      }
      this.writePopup("");
      this.writePopup(msg);
      viewport.getAll();
      this.positionPopup(e);
      this.timer=setTimeout("ImagePopup.toggleVis('"+this.elemID+"', 'visible')",this.showDelay);
    },
    writePopup:function(msg) {
      if(this.elem&&typeof this.elem.innerHTML!="undefined")
        this.elem.innerHTML=msg;
    },
    hide:function() {
      if(this.timer) {
        clearTimeout(this.timer);
        this.timer=0;
      }
      this.timer=setTimeout("ImagePopup.toggleVis('"+this.elemID+"', 'hidden')",this.hideDelay);
      if(this.followMouse) {
        if (document.removeEventListener) document.removeEventListener("mousemove", this.trackMouseCallback, true);
        else if (document.detachEvent) document.detachEvent("onmousemove", this.trackMouseCallback);
      }
      this.elem=null;
    },
    toggleVis:function(id,vis) {
      var el=document.getElementById(id);
      if(el)
        el.style.visibility=vis;
    },
    trackMouseCallback:function(e) {
      e = e? e: window.event;
      e.tgt = e.srcElement? e.srcElement: e.target;
      
      if (!e.preventDefault) e.preventDefault = function () { return false; }
      if (!e.stopPropagation) e.stopPropagation = function () { if (window.event) window.event.cancelBubble = true; }
      ImagePopup.positionPopup(e);
    },
    positionPopup:function(e) { 
      if(this.elem&&this.elem.style) {
		var x = 0
		if (this.offX > 0)
			{x= e.clientX
			if(x+this.elem.offsetWidth+this.offX > viewport.width+viewport.scrollX)
				{x-=this.elem.offsetWidth-this.offX;
				if(x<0)x=0;
				}
			else{x+=this.offX;
				}
			}
		else{x = e.clientX - this.elem.parentElement.offsetLeft - this.elem.parentElement.offsetWidth - this.elem.scrollWidth
			if (document.body.clientWidth - e.clientX + this.elem.scrollWidth + 4 - this.offX*2 > document.body.clientWidth)
				{x+= this.elem.scrollWidth;
				}
			else{x+=this.offX;
				}
			}

		var y=e.pageY?e.pageY:e.clientY+viewport.scrollY;
        if(y+this.elem.offsetHeight+this.offY > viewport.height+viewport.scrollY){
          y=y-this.elem.offsetHeight-this.offY;
          if(y<viewport.scrollY)
            y=viewport.height+viewport.scrollY-this.elem.offsetHeight;
        }
        else 
          y=y+this.offY;
		this.elem.style.left=(x - (typeof divStayTopLeft != "undefined"?divStayTopLeft.offsetLeft:0) - (typeof CurFloater != 'undefined'?CurFloater.offsetLeft:0))+"px";
        this.elem.style.top=(y - (typeof divStayTopLeft != "undefined"?divStayTopLeft.offsetTop:0) - (typeof CurFloater != 'undefined'?CurFloater.offsetTop:0) - this.elem.parentElement.offsetTop)+"px";
      }
    }
};

function showImagePopup(e, img, txt) {
  if ( typeof ImagePopup == "undefined" || !ImagePopup.ready ) return;
	
  ImagePopup.offX = /rtl/i.test(document.dir)?-8:8
  var content = "";
  if ( img ) content += '<div class="thumb_img"><img src="' + img + '"></div>';
  if ( txt ) content += '<div class="thumb_txt">' + txt + '</div>';
  ImagePopup.show(e, content)
}

function hideImagePopup() {
  if ( typeof ImagePopup == "undefined" || !ImagePopup.ready ) return;
  ImagePopup.hide();
}
/* END Popup div for images on Favourites/Recently Viewed */

//Function to retrieve cookie value
function getCookie(name) 
{ 
    var sPos = document.cookie.indexOf(name + "="); 
    var len = sPos + name.length + 1; 
    if((!sPos) && (name != document.cookie.substring(0, name.length))){ 
        return null; 
    } 
    if(sPos == -1){ 
        return null; 
    } 
    var ePos = document.cookie.indexOf(';', len); 
    if(ePos == -1) ePos = document.cookie.length; 
    return unescape(document.cookie.substring(len, ePos)); 
} 

//The onclick event for scrolling or not scrolling from the checkbox
function StopStartScrolling()
{
    if (document.getElementById("CanScrollRegional") != null)
    {
      if (document.getElementById("CanScrollRegional").checked == true)
      {
          document.cookie = "CanScroll=NO;";
      }
      else
      {
          document.cookie = "CanScroll=YES;";
      }
      JSFX_FloatTopDiv();
    }
}

function SetScrolling()
{
    if (document.getElementById("CanScrollRegional") != null)
    {    
	  if(document.getElementById("CanScrollText") != null)
		{
		  document.getElementById("CanScrollText").innerHTML = Gryphtech.RemaxEurope.RemaxEuropeSlingshotAddin.AjaxMethods.GetTranslations("GtTranslationManagerScroll", "130.DontScrollColumn", "Remax", "130", "Lang").value;
		}
      if (getCookie("CanScroll") == "NO")
      {
          document.getElementById("CanScrollRegional").checked = true;
      }
      else if (getCookie("CanScroll") == "YES")
      {
          document.getElementById("CanScrollRegional").checked = false;
      }
      else
      {
          document.getElementById("CanScrollRegional").checked = false;
      }
    }
}

/* Floating Sidebar */
function JSFX_FloatTopDiv()
{
    var scrolling;
    
    if (getCookie("CanScroll") == "NO")
    {
        scrolling = false;
		if(document.getElementById("CanScrollRegional") != null)
		{
	        document.getElementById("CanScrollRegional").checked = true;
		}
    }
    else if (getCookie("CanScroll") == "YES")
    {
        scrolling = true;
		if(document.getElementById("CanScrollRegional") != null)
		{
	        document.getElementById("CanScrollRegional").checked = false;
		}
    }
    else
    {//When coookie "CanScroll" is null
        scrolling = true;
		if(document.getElementById("CanScrollRegional") != null)
		{
	        document.getElementById("CanScrollRegional").checked = false;
		}
    }
    
    function ml(id) 
    {
        var el=d.getElementById?d.getElementById(id):(d.all?d.all[id]:d.layers[id]);
        if(d.layers)el.style=el;
        el.sP=function(x,y)
        {
            this.style.left=x;
            if (y > -1)
            {           
                this.style.top=y;
            }
            else
            {//Sends floating div back to top
                this.style.top=0;
            }
        };
        el.x = startX;
        
        if (typeof verticalpos == 'undefined')
        {
            el.y = 0;
        }
        else if (verticalpos=='fromtop')
        {
            el.y = startY;
        }
        else
        {
            el.y = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
            el.y -= startY;
        }
        
        return el;
    }
    
    window.stayTopLeft=function() 
    {
        if (typeof verticalpos == 'undefined')
        {
	        var pY = 0;
	        ftlObj.y = 0;
        }
        else if (verticalpos=='fromtop')
        {
	        var pY = ns ? pageYOffset : document.body.scrollTop;
	        ftlObj.y += (pY + startY - ftlObj.y)/8;
        }
        else
        {
	        var pY = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
	        ftlObj.y += (pY - startY - ftlObj.y)/8;
        }
        if (document.body.scrollTop + (typeof CurChildFloater != 'undefined'?CurChildFloater.scrollHeight:0) + 5> MainFooterDiv.offsetTop)
        {
          ftlObj.y = MainFooterDiv.offsetTop - (typeof CurChildFloater != 'undefined'?CurChildFloater.scrollHeight:0) - (typeof CurrentFloatingTop != 'undefined'?CurrentFloatingTop:0) - 5;
        }
        else if (document.body.scrollTop - (typeof CurrentFloatingTop != 'undefined'?CurrentFloatingTop:0) < 0)
        {
          ftlObj.y = 0
        }

        ftlObj.sP(ftlObj.x, ftlObj.y);
        setTimeout('stayTopLeft()', 10);
    }
    var startX = 0;
    var startY;
    var ns = (navigator.appName.indexOf('Netscape') != -1);
    var d = document;
    
    if (scrolling)
    {
        startY = (typeof CurrentFloatingTop != 'undefined'?-CurrentFloatingTop:0) + 5;
        ftlObj = ml('divStayTopLeft');
        stayTopLeft();
    }
}


/* Europe Modules */
function loadRegion(whichForm){
	el = document.getElementById(whichForm).value;
	if (el != "Select Region")
		window.location.href = el;
}

function enableButton(whichForm,whichButton){
	el = document.getElementById(whichButton);
	el2 = document.getElementById(whichForm).value;
	if (el2 != "Select Region"){
		el.disabled = false;
		el.className = "btnEnabled"
	} else {
		el.disabled = true;
		el.className = "btnDisabled"
	}
}

/**/

/*Portugal's Form */

function validate(frmForm)
{
	// Place validation code here if required.
	var requiredInfoMissing = false;
	var bgcolorRed = "#ff0000";
	var bgcolorWhite = "#ffffff";
	
	if (document.all["Nome Completo"].value == "")
	{
		document.all["Nome Completo"].style.background = bgcolorRed;
		document.all["Nome Completo"].focus();
		requiredInfoMissing = true;
	}
	else
	{
	    document.all["Nome Completo"].style.background = bgcolorWhite;
	}
	 
	if (document.all["Telefone"].value == "") 
	{
		document.all["Telefone"].style.background = bgcolorRed;
		document.all["Telefone"].focus();
		requiredInfoMissing = true;
	} 
	else
	{
	    document.all["Telefone"].style.background = bgcolorWhite;
	}
		
	if (document.all["Telemovel"].value == "") 
	{
		document.all["Telemovel"].style.background = bgcolorRed;
		document.all["Telemovel"].focus();
		requiredInfoMissing = true;
	} 
	else
	{
	    document.all["Telemovel"].style.background = bgcolorWhite;
	}
	
	
	
	if (requiredInfoMissing)
	{
	    return false;
	}
	else
	{
		frmForm.submit();
		return true;
	}
		
}

function ValidateForm()

{

            var office = MM_findObj("officename");     

            if (!office.innerText.length > 0 ) {

                        // copy needed.

                        alert('Por favor seleccione a Loja.');

                        return false;

            }

}


/**/

function SetQueryStringParam(qs, pname, pvalue)
{
  if(qs.length > 1) this.q = qs.substring(1, qs.length);
	else this.q = null;
	this.keyValuePairs = new Array();
	if(this.q) {
		for(var i=0; i < this.q.split("&").length; i++) {
			this.keyValuePairs[i] = this.q.split("&")[i];
		}
	}
	this.found = false;
	for(var j=0; j < this.keyValuePairs.length && !this.found; j++) {
		if(this.keyValuePairs[j].split("=")[0] == pname) {
			this.keyValuePairs[j] = pname + "=" + pvalue;
			this.found = true;
		}
	}
	if(!this.found) {
	  this.keyValuePairs[this.keyValuePairs.length] = pname + "=" + pvalue;
	}
	this.q = "?";
	for(var k=0; k < this.keyValuePairs.length; k++) {
	  this.q += keyValuePairs[k] + "&";
	}
	this.q = this.q.substring(0,this.q.length - 1);
	return this.q;
}

function CheckValue(obj, target)
{if (document.getElementById(target) != null)
  	{return document.getElementById(target).value == obj.value;
    }
return true;
}

function SetValue(obj, target) {
  if (document.getElementById(target) != null)
  	{document.getElementById(target).value = obj.value;
    }
}

function SetZero(target) {
  if (document.getElementById(target) != null)
  	document.getElementById(target).value = '0';
}

function AjaxBind_Select_DataTable(selectObj, dataTableObj, valueFieldName, textFieldName, defaultOptionText) {
  //clear select before binding
  selectObj.options.length = 1;

  if (dataTableObj != null && dataTableObj.value != null && dataTableObj.value.Rows != null) {
    var isIE = false;
    if (navigator.appVersion.indexOf("MSIE")!=-1) isIE = true;
    for (var i=0; i < dataTableObj.value.Rows.length; ++i) {
      var row = dataTableObj.value.Rows[i];
      var oOption = new Option(row[textFieldName], row[valueFieldName]);
      if (isIE) {
        selectObj.add(oOption); // IE only
      } else {
        selectObj.add(oOption, null); // standards compliant
      }
      /*
      try {
        selectObj.add(oOption, null); // standards compliant
      }
      catch(ex) {
        selectObj.add(oOption); // IE only
      }
      */
    }
  }
  if (defaultOptionText != null && defaultOptionText != "") {
    selectObj.options[0].text = defaultOptionText;
    selectObj.options[0].value = '0';
  }
  else
  {
    selectObj.remove(0);
  }
}

function GetSelectedItem(ddlId) {
  var DDL = document.getElementById(ddlId);
  var val = "";
  if (DDL != null && DDL.selectedIndex != -1)
    val = DDL.options[DDL.selectedIndex].value;
  	if (isNaN(val))
	{
		return 0;
	}
	else
	{
  		return val;
	}
}

function SetSelectValue(ddlId, val) {
  var selectobj = document.getElementById(ddlId);
  if (selectobj != null && val != null && val >= 0) {
    for (var i=0; i < selectobj.length; i++)
      if (selectobj.options[i].value == val)
        selectobj.selectedIndex = i;
  }
}

/* RE/MAX Europe's menu*/

var persistmenu="yes" //"yes" or "no". Make sure each SPAN content contains an incrementing ID starting at 1 (id="sub1", id="sub2", etc)
var persisttype="sitewide" //enter "sitewide" for menu to persist across site, "local" for this page only


function clearCookie(){
	var cookie_date = new Date ( );  // current date & time
   cookie_date.setTime ( cookie_date.getTime() - 1 );
   blockid = 1;
	var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname;
	var cookievalue=(persisttype=="sitewide")? blockid+";path=/" : blockid;
	//alert(cookiename);
	document.cookie=cookiename+"="+cookievalue;
}

/* */	

/* Thinking of Selling Validation */

function checkMyForm(){
	form = document.getElementById("sellContactForm");
	
	if (form.txtFullName.value == ""){
		alert("Please fill in your full name");
		form.txtFullName.focus();
		return false;
	}
	
	if (form.txtEmailAddress.value == ""){
		alert("Please fill in your email address");
		form.txtEmailAddress.focus();
		return false;
	}
	
	if (form.txtPhone.value == ""){
		alert("Please fill in your phone number");
		form.txtPhone.focus();
		return false;
	}
	
	if (form.txtCityLong.value == ""){
		alert("Please fill in your city");
		form.txtCityLong.focus();
		return false;
	}

		if (form.txtOfficeEmail.value == ""){
		alert("Please select an office");
		return false;
	}
	
	if (form.selPropertyType.value == "0"){
		alert("Please select a Property Type");
		return false;
	}

	return true;
	
}


function CheckRequiredFields() {
var errormessage = new String();
// Put field checks below this point.

/*
if(NoneWithCheck(document.exampleform.radioOne))
	{ errormessage += "\n\nPlease click one radio button of the set of three."; }
if(WithoutCheck(document.exampleform.radioLoner))
	{ errormessage += "\n\nThe \"Loner\" radio button must be clicked."; }
if(NoneWithCheck(document.exampleform.checkOne))
	{ errormessage += "\n\nPlease check one or more check boxes of the set of three."; }
if(WithoutCheck(document.exampleform.checkLoner))
	{ errormessage += "\n\nThe \"Loner\" check box must be checked."; }
*/
if(WithoutContent(document.all.officename.innerHTML))
	{ errormessage += "\n\nBitte wählen Sie ein Büro aus durch anklicken des Büronamens."; }
/*
if(NoneWithContent(document.exampleform.oneOrTheOther))
	{ errormessage += "\n\nSomething must be typed in one or both of the set of form text fields."; }
if(WithoutContent(document.exampleform.areaName.value))
	{ errormessage += "\n\nSomething must be typed in the textarea box."; }
if(WithoutContent(document.exampleform.FileGet.value))
	{ errormessage += "\n\nA file name must be provided for uploading."; }
if(WithoutSelectionValue(document.exampleform.dropname))
	{ errormessage += "\n\nPlease select something from the dropdown list."; }
*/

// Put field checks above this point.
if(errormessage.length > 2) {
	alert(errormessage);
	return false;
	}
return true;
} // end of function CheckRequiredFields()


function WithoutContent(ss) {
if(ss.length > 0) { return false; }
return true;
}

/*
function NoneWithContent(ss) {
for(var i = 0; i < ss.length; i++) {
	if(ss[i].value.length > 0) { return false; }
	}
return true;
}

function NoneWithCheck(ss) {
for(var i = 0; i < ss.length; i++) {
	if(ss[i].checked) { return false; }
	}
return true;
}

function WithoutCheck(ss) {
if(ss.checked) { return false; }
return true;
}

function WithoutSelectionValue(ss) {
for(var i = 0; i < ss.length; i++) {
	if(ss[i].selected) {
		if(ss[i].value.length) { return false; }
		}
	}
return true;
}
*/

function clearDefault(el){
    if(el.defaultValue==el.value) el.value="";
    //el.style.color='black';
}
function restoreDefault(el){
    if(el.value==""){
    el.value = el.defaultValue;
    //el.style.color='gray';
    }
}

function ShowHideFeatures(obj)
{
	if(obj != null)
	{
		if(obj.value == 2) //Residential
		{
			if (document.all["divPropertyType"] != null)
			{
				document.all["divPropertyType"].style.display = "inline";
			}
			if (document.all["divCommPropertyType"] != null)
			{
				document.all["divCommPropertyType"].style.display = "none";
			}
		}
		if(obj.value == 1) //Commercial
		{
			if (document.all["divPropertyType"] != null)
			{
				document.all["divPropertyType"].style.display = "none";
			}
			if (document.all["divCommPropertyType"] != null)
			{
				document.all["divCommPropertyType"].style.display = "inline";
			}
		}
	}
}

/* The <%%> does not work in pure js file, only work with .aspx file CR # 46009

*/
		
function ClearValue()
{
	document.forms[0].reset;
}

function SetStatusValue(obj, target)
{
	if(obj.checked)
	{
		document.getElementById(target).value = obj.value;
	}
	else
	{
		document.getElementById(target).value = "";
	}
}

        function SetMinMaxPriceRange(obj, divPriceClientId, divRentalPriceClientId, ddlMinPriceClientId, ddlMaxPriceClientId, ddlRentalMinPriceClientId, ddlRentalMaxPriceClientId)
		{	 
			//alert(obj.value);
			var ddlMinPrice = document.getElementById(ddlMinPriceClientId.id);
			var ddlMaxPrice = document.getElementById(ddlMaxPriceClientId.id);
			var ddlRentalMinPrice = document.getElementById(ddlRentalMinPriceClientId.id);
			var ddlRentalMaxPrice = document.getElementById(ddlRentalMaxPriceClientId.id); 
			
			if (obj.value == '260' || obj.value == '262' || obj.value == 'For Rent/Lease' || obj.value == 'Holiday/Short Term Rental')
			{
					if (document.all[divPriceClientId.id] != null)
					{
						document.all[divPriceClientId.id].style.visibility = "hidden";
						document.all[divPriceClientId.id].style.display = "none";
					}
					if (document.all[divRentalPriceClientId.id] != null)
					{
						document.all[divRentalPriceClientId.id].style.visibility = "visible";
						document.all[divRentalPriceClientId.id].style.display = "";  
					}
					if(ddlMinPrice != null)
					{
					    ddlMinPrice.selectedIndex = 0;
					}
					if(ddlMaxPrice != null)
					{
					    ddlMaxPrice.selectedIndex = 0;
					}
			}   
			else
			{
					if (document.all[divPriceClientId.id] != null)
					{
						document.getElementById(divPriceClientId.id).style.visibility = "visible";
						document.getElementById(divPriceClientId.id).style.display = "";
					}
					if (document.all[divRentalPriceClientId.id] != null)
					{
						document.getElementById(divRentalPriceClientId.id).style.visibility = "hidden"; 
						document.getElementById(divRentalPriceClientId.id).style.display = "none";
					}
					if(ddlRentalMinPrice != null)
					{
					    ddlRentalMinPrice.selectedIndex = 0;
					}
					if(ddlRentalMaxPrice != null)
					{
					    ddlRentalMaxPrice.selectedIndex = 0;
					}
			}
		}
		
	function ToggleFavourite(obj, Remove)
	{
	  if (Remove)
	  {
	    if(document.getElementById("divFavAdd_" + obj))document.getElementById("divFavAdd_" + obj).style.display = "none";
	    if(document.getElementById("divFavRem_" + obj))document.getElementById("divFavRem_" + obj).style.display = "";
	  }
	  else
	  {
	    if(document.getElementById("divFavAdd_" + obj))document.getElementById("divFavAdd_" + obj).style.display = "";
	    if(document.getElementById("divFavRem_" + obj))document.getElementById("divFavRem_" + obj).style.display = "none";
	  }
	  return false;
	}
	
	function AddRemoveFavourite(obj, Add)
	{
	  if (Add)
	  {
    	SmartModuleMyRemaxRegistration.SmartModuleMyRemaxFavourites.AddPropertyToFavourites(obj, maxFavs, cookieExp, langMF, encLangMF, formatRegionId);
      }
  	  else
  	  {
        SmartModuleMyRemaxRegistration.SmartModuleMyRemaxFavourites.RemovePropertyFromFavourites(obj, cookieExp);
  	  }
  	  ToggleFavourite(obj, Add);
  	// Call function from MyRemaxFavourites module, if it exists.
  	if (typeof(UpdateMyFavouritesDatagrid) != 'undefined') UpdateMyFavouritesDatagrid();
	}
	
	
	function sizeAdjust(imgObj)
    {
        imgObj = document.getElementById('SLIDESIMG');
	    imgObj.style.visibility = 'hidden';
        imgObj.style.height = 'auto';
        imgObj.style.display = 'inline';
        if (imgObj.height > 375) imgObj.style.height = 375; 
	    imgObj.style.visibility = 'visible';
    }

function swap(imageID,imageNumber, imageCount, ofTranslation) 
{
	 try
    {
	      SLIDES.pause();
	     
	      //alert(SLIDES.xOfy);
	      //alert("[" + imageNumber + " "+ ofTranslation +" " + imageCount + "]");
	      SLIDES.goto_slide(imageNumber - 1);
	      
	      /*alert(SLIDES.xOfy.innerHTML);
	       alert(imageCount);
	      SLIDES.xOfy.innerHTML = "[" + imageNumber + " "+ ofTranslation +" " + imageCount + "]";
	      var img = MM_findObj(imageID);
	      var mainimg = MM_findObj('SLIDESIMG');
	      var transImage = img.src;
	      mainimg.src = img.src;
	      */
	 }
	 catch(ex)
	 {
	    alert(ex.description);
	 }
}

//This is used in ListingList
function GotoPage(val)
{
    var qs = SetQueryStringParam(window.location.search, 'CurrentPage', val);
    window.location.href = window.location.protocol + '//' + window.location.host + window.location.pathname + qs;
    return false;
}