﻿isOP = (navigator.userAgent.indexOf('Opera') > 0)?true:false;
isIE = (navigator.appName=='Microsoft Internet Explorer' && !isOP)?true:false;
isMOZ = (navigator.appName.indexOf=='Netscape')?true:false;
var flaHeaderLib;

if (!document.getElementById){
	document.getElementById = function(){return null;}
	document.getElementsByTagName = function(){return null;}
}

function addListener(elm, evtName, callback){
	if(elm.addEventListener){
		elm.addEventListener(evtName,callback, false);
	}
	else if(elm.attachEvent){
		elm.attachEvent("on"+evtName, callback);
	}
	else{
		elm["on"+evtName] = callback;
	}
	return callback;
}

//@@ Add Events @@//////////////////////////////////////////////////////////////////////////
function bsLoad() {
  setMoos();
  bsLoad3();
  var originalDoPostBack = window.__doPostBack;
  if (originalDoPostBack) {
    window.__doPostBack = function(eventTarget, eventArgument) {
			if(theForm._isExternal) { 
				theForm._isExternal = false;
				theForm.target='_blank';
				theForm._oldAction = theForm.action;
			}else{
				theForm.target='';
				if(theForm._oldAction == theForm.action) {
					theForm.action = theForm._initialAction;
				}
			}
			originalDoPostBack(eventTarget, eventArgument);
    }
  }
  var email = $('email');
  var feedback = $('feedback');
  if((email && email.style.display == 'block') || (feedback && feedback.style.display == 'block')) {
		var fader = $('fader');
		var page = $('page');
		if(fader) {
  		fader.style.height = page.offsetHeight + 'px';
			fader.style.display = 'block';
		}
		if(page) {
			page.className += ' noSelects';
		}
  }
}

function showWait(b) {
	var wait = $('wait');
	var page = $('page');
	if(wait) {
		wait.style.height = page.offsetHeight + 'px';
		wait.style.display = b ? 'block' : 'none';
		wait.style.visibility = b ? 'visible' : 'hidden';
		if (window.ActiveXObject) wait.style.filter = b ? 'alpha(opacity=0)' : null;
		wait.style.opacity = b ? 0 : null;
	}
}

function bsLoad2() {
  bsLoad3();
  if(pageTracker && pageURL && trackAjaxPageview)
    pageTracker._trackPageview(pageURL);
}

function bsLoad3() {
  setPreview();
  setHrefTarget();
  setFlaHeads();
}

function Page_Load(sender, args) {
  showWait(false);
  var dataItems = args.get_dataItems();
  if(dataItems.__Page && dataItems.__Page=='Pager' && setPaging)
		setPaging();
  //if(dataItems.__Page && dataItems.__Page=='Pager' && window.scrollTo)
  //	window.scrollTo(0,0);
}

function setPreview(){
  var PopUpImg = $('itemPreviewPopUp');
  if(PopUpImg){
  	previewItems = document.getElementsByClassName('itemPreview');
  	for(var i = 0; i < previewItems.length; i++){
  		previewItem = $(previewItems[i]);
   		addListener(previewItem, "mouseover", function(e){
   			var Img = getEventSource(e);
        if(Img) {
          var regexp = new RegExp('id=([^&]*)');
          var match = regexp.exec(Img.src);
          if(match) {
						var id = match[1];
						PopUpImg.infoid = id;
        	  var myServiceProxy = new boligsiden.BSWeb.Services();
						myServiceProxy.GetPropertyPreview(id,
							function(res, context) {
							  if(PopUpImg.infoid==context) {
   								var p = $('itemPreviewPopUp');
   								if(p) p.innerHTML = res;
   								itemPreviewPop.togglePreviewOn(Img);
   							}
							},
							function() {}, id);
					}
				}
   		});
  		addListener(previewItem, "mouseout", function(e){itemPreviewPop.toggleOff(e);PopUpImg.infoid=null;PopUpImg.style.left='0px';PopUpImg.style.top='0px';});
  	}
  }
}
function setHrefTarget(){	
	
	hrefs = document.getElementsByClassName('external');
	for(var i = 0; i < hrefs.length; i++){
		hrefs[i].target = '_blank';
	}
	
}


//@@ Extending Moo with custom class for showing popups @@//////////////////////////////////
fx.ShowPopUp = Class.create();
Object.extend(Object.extend(fx.ShowPopUp.prototype, fx.Opacity.prototype), {	
	toggle: function(e) {
		if (this.now > 0){
			this.custom(1, 0);
		}else{
			pos = findCursor(e);
			setPosToCursor(this.el,pos[0],pos[1], false);
			this.custom(0, 1);
		}
	}, 
	
	toggleOn: function(e) {
		var item = getEventSource(e);
		if(item.nodeName == 'IMG'){
			pos = findPos(item);
			setPosToCursor(this.el,pos[0] + 105,pos[1], true);	
			this.custom(0,1);
		}
	},
	
	togglePreviewOn: function(item) {
		pos = findPos(item);
		setPosToCursor(this.el,pos[0] + 105,pos[1], true);	
		this.custom(0,1);
	}, 
	
	toggleOff: function(e) {
		this.clearTimer();
		this.hide();
		this.el.style.left = '-500px';
	}
	
});

//@@ Initialize animations @@////////////////////////////////////////////////////////////////
function setMoos() {
//	//Expand / Collapse SearchOptions
//	if($('searchOptions')){
//		searchOption = new fx.Height('searchOptions', {onComplete: setToggle, height: true, opacity: false,duration: 400} );
//		$('searchOptions').style.display = 'block';	
//    if(!(typeof(isExtended)=="undefined") && isExtended())
//      $('content').className = 'expanded';
//		else {
//			searchOption.hide();
//			$('searchOptions').style.height = '0px';	
//		}
//		scrollToOptions = new fx.Scroll({duration: 400} );
//	}

	//Expand / Collapse SearchOptions
	if($('searchOptions')){
		searchOption = new fx.Height('searchOptions', {onComplete: setToggle, height: true, opacity: false,duration: 400} );
		searchOption.hide();
		$('searchOptions').style.height = '0px';
		$('searchOptions').style.display = 'block';	
		scrollToOptions = new fx.Scroll({duration: 400} );
		if(!(typeof(isExtended)=="undefined") && isExtended()) {
      $('content').className = 'expanded';
		  searchOption.toggle();
		}
	}
	
	if($('page')){
		pagingScroll = new fx.Scroll({duration: 400} );
	}
	
	//Popup for Preview
	if($('itemPreviewPopUp')){
		itemPreviewPop = new fx.ShowPopUp('itemPreviewPopUp', {duration: 200} );
		$('itemPreviewPopUp').style.display = 'block';
		itemPreviewPop.hide();
	}
	
	//mapNav
	if($('mapNav')){
	  mapNavNames = new Array('mapFlapDk','mapFlapAddy','mapFlapAdv');
		mapNavContent = new Array;
		inputs = $('mapNav').getElementsByTagName('input');
		if(inputs.length==1) {
		  tab = inputs[0].value;
		} else {
		  tab = 0;
		}
		for(var i = 0;i<mapNavNames.length;i++) {
		  mapNavContent[i] = new fx.Opacity(mapNavNames[i]);
		  $(mapNavNames[i]).style.display = 'block';
      if(tab!=i) {
		    mapNavContent[i].hide();
      }
		}
		
		tabs = $('mapNav').getElementsByTagName('li');
		for(var i = 0; i < tabs.length; i++) {
		  if(tab!=i)
		    tabs[i].className = '';
		  else
		    tabs[i].className = 'sel';
		}
	}
	
	//typealert
	if($('typeAlert')){
		//typeAlertTxt = new fx.Opacity('typeAlert', {duration: 200} );
		//$('typeAlert').style.display = 'block';
		//typeAlertTxt.hide();
	}
	if($('cbHider')){
		//typeCbHider = new fx.Opacity('cbHider', {duration: 200} );
		typeCbHide1000 = new fx.Opacity('cb1000', {duration: 200} );
		typeCbHide1100 = new fx.Opacity('cb1100', {duration: 200} );
		typeCbHide1200 = new fx.Opacity('cb1200', {duration: 200} );
		typeCbHide1300 = new fx.Opacity('cb1300', {duration: 200} );
		typeCbHide1500 = new fx.Opacity('cb1500', { duration: 200 });
		typeCbHiders = new Array(typeCbHide1000, typeCbHide1100, typeCbHide1200, typeCbHide1300, typeCbHide1500);
		
		setTypeAlert();
	}	
	
}


//@@ Functions @@/////////////////////////////////////////////////////////////////////

function markRow(obj){
    td = obj.parentNode;
    tr = td.parentNode;
    marked = td.getElementsByTagName('input')[0].checked;
  
    if(marked){
        td.className = 'c marked';
        tr.className += ' printIt';        
    }
    else{
        td.className = 'c';
        tr.className -= ' printIt';
    }  
}
function setTypeAlert(){
  if($('cbMutual')) {
    if($('cbMutual').getElementsByTagName('input')[0].checked) {
      typeCbHide1500.options.onComplete = function() {setChecks($('cbHider'), false); };
      for (i = 0; i < typeCbHiders.length; i++) {
        typeCbHiders[i].custom(1, 0.2);
      }
	    //typeCbHider.options.onComplete = function() {setChecks($('cbHider'), false); };
		  $('typeAlert').style.display = 'block';
		  //typeCbHider.custom(1,0.2);
	  }
	  else{
	    typeCbHide1500.options.onComplete = function() { setChecks($('cbHider'), true); };
	    for (i = 0; i < typeCbHiders.length; i++) {
	      typeCbHiders[i].custom(0.2, 1);
	    }
	    
	    //typeCbHider.options.onComplete = function() {setChecks($('cbHider'), true); };
		  $('typeAlert').style.display = 'none';
		  //typeCbHider.custom(0.2,1);
	  }
	}
}

function setChecks(elem, enabled){
  if(elem) {
	  checks = elem.getElementsByTagName('input');
	  state = (enabled)?'':'disabled';
  	
	  for(i=0;i<checks.length;i++){
		  checks[i].disabled = state;
	  }
	}
}

function setTab(tab){
	if (tab != 0) {
		document.getElementById('DynamicMap_locator').style.visibility = 'visible';
		document.getElementById('DynamicMap_divMapstyle').style.display = 'block';
	}	

tabs = $('mapNav').getElementsByTagName('li');
	inputs = $('mapNav').getElementsByTagName('input');
	if(inputs.length==1) {
	  inputs[0].value = tab
	}
	
	if(tabs[tab].className != 'sel'){
		for(i=0;i<tabs.length;i++){
			tabs[i].className = '';
			if(mapNavContent[i]){
				mapNavContent[i].hide();
				mapNavContent[i].el.style.display = 'none';			
			}
		}
		tabs[tab].className = 'sel';
		mapNavContent[tab].el.style.display = 'block';
		mapNavContent[tab].custom(0,1);
	}
}

function appendTypes(){
	$('addTypeDemoTarget').className += ' showSkip';
}
function openOptions(){
	$('content').className = 'expanded';
	setExtended(true);
	searchOption.toggle();
}
function closeOptions(){
	setExtended(false);
  searchOption.toggle();
}
function setToggle(){
	panel = $('searchOptions');
	cont = $('content');
	if(panel.offsetHeight < 10){
		cont.className = '';
	}else{
			scrollToOptions.scrollTo(panel);
	}
}
function setPaging(){
	pagingScroll.scrollTo($('page'));
}
function setFlaHeads(){
	var arrHead = $('main').getElementsByTagName('h1');
	
	for (var i=arrHead.length;i!=0;i--){
		var head = arrHead[i-1];
		if (head.className != 'fla') continue;
		
		if(canPlayFlash()){
			vars = 'strTxt=' + head.innerHTML ;
			url = 'include/header.swf';
			
			if(flaHeaderLib && flaHeaderLib != ''){
				url = 'include/' + flaHeaderLib + '/header.swf';
			}
			
			flHead = document.createElement('div');
			flHead.className = 'flHead print';
			flHead.innerHTML = getFlashString(url,vars,700,23);
			
			head.parentNode.replaceChild(flHead,head);
		}else{
			head.className = '';
		}
	}
}
function objectEmbed(url,vars,w,h){
	if(canPlayFlash()){
		document.write(getFlashString(url,vars,w,h));
	}
}
function getFlashString(url,vars,w,h){
		return '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+w+'" height="'+h+'" id="kampagnefelt" align="" VIEWASTEXT><param name="FlashVars" value="'+ vars +'"><param name="movie" value="'+url+'"><param name="menu" value="false"><param name="quality" value="high"><param name="wmode" value="transparent"><embed src="'+url+'" menu="false" quality="high" wmode="transparent" width="'+w+'" height="'+h+'" FlashVars="'+ vars +'" name="" align="" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed></object>';
}

function getQueryVariable(variable) {
	var query = window.location.search.substring(1);
	var vars = query.split("&");
	for (var i=0;i<vars.length;i++) {
		var pair = vars[i].split("=");
		if (pair[0] == variable) {
			return pair[1];
		}
	} 
}
function findCursor(e) {
    var posX = 0;
	var posY = 0;
	if (!e) var e = window.event;

	if (e.pageX || e.pageY)
	{
		posX = e.pageX;
		posY = e.pageY;
	}
	else if (e.clientX || e.clientY)
	{
		posX = e.clientX;
		posY = e.clientY;
		if (isIE)
		{
			posX += document.documentElement.scrollLeft;
			posY += document.documentElement.scrollTop;
		}
	}
	return [posX,posY];	
}

function setPosToCursor(elm,x,y,isPreview, width, height){
	elmW = width ? width : elm.offsetWidth;
	elmH = height ? height : elm.offsetHeight;
	
	if(isPreview){
	//	elmH = 363;
	}
	else{
		if(x-(elmW + 10)>0)
			x -= (elmW + 10);
		y += 10;
	}
	
	if(x + elmW > (document.documentElement.clientWidth + document.documentElement.scrollLeft)){
		x -= elmW;
	}
	if(y + elmH > (document.documentElement.clientHeight + document.documentElement.scrollTop)){
		y -= elmH;
		if(isPreview)y += 82;
	}
	elm.style.left = x + "px";
	elm.style.top = y + "px";
}

function getEventSource(e) {
	var targ = null;
	if (!e) var e = window.event;
	if (e.target) targ = e.target;
	else if (e.srcElement) targ = e.srcElement;
	if (targ.nodeType == 3) // defeat Safari bug
		targ = targ.parentNode;
	return targ;
}

function findPos(obj) {
	var curleft = curtop = 0;

	if (obj.offsetParent) {
		curleft = obj.offsetLeft;
		curtop = obj.offsetTop;
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}


//@@ FLASH CHECK @@//////////////////////////////////////////////////////////////////////////

minPlayer = 6;

function Flash_checkForPlugIn() {
  var plugin = (navigator.mimeTypes &&
  navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
  if (plugin) {
    var pluginversion = parseInt(plugin.description.substring(plugin.description.indexOf(".")-1))
    if(pluginversion >= minPlayer) {return true;}
  }
  return false;
}

// vbscript check for Flash ActiveX control in windows IE
if(isIE) {
  document.write(
    '<script language=VBScript>' + '\n' +
    'Function Flash_checkForActiveX()' + '\n' +
    'Dim hasPlayer, playerversion' + '\n' +
    'hasPlayer = false' + '\n' +
    'playerversion = 10' + '\n' +
    'Do While playerversion >= minPlayer' + '\n' +
    'On Error Resume Next' + '\n' +
    'hasPlayer = (IsObject(CreateObject(\"ShockwaveFlash.ShockwaveFlash.\" & playerversion & \"\")))' + '\n' +
    'If hasPlayer = true Then Exit Do' + '\n' +
    'playerversion = playerversion - 1' + '\n' +
    'Loop' + '\n' +
    'Flash_checkForActiveX = hasPlayer' + '\n' +
    'End Function' + '\n' +
    '<\/script>'
  );
}
function canPlayFlash(){
	if(isIE){
		return Flash_checkForActiveX();
	}else{
		return Flash_checkForPlugIn();
	}
	
}

function showPopUp(name, a, b, c, d) {
	faderElem = $('fader');
	pageElem = $('page');
	activeElem = $(name);
  if(activeElem && faderElem) {
		if(a) {
		  var x;
		  var y;
			if(!b || (c && !d) ) {
				pos = findCursor(a);
				x = pos[0];
				y = pos[1];
			}else{
				x = a;
				y = b;
			}
  		setPosToCursor(activeElem, x, y, false, d ? c : b, d ? d : c);//setPosToCursor(elm,x,y,isPreview, width, height)
  	}
  	faderElem.style.height = pageElem.offsetHeight + 'px';
    fadeIn('fader', 0.8, function() {fadeIn(name, 1, null);});
	}
	if(pageElem) {
	  pageElem.className += ' noSelects';
	}
}

function hidePopUp(name, e) {
	var faderElem = $('fader');
	var pageElem = $('page');
	var activeElem = $(name);
  if(activeElem && faderElem) {
    fadeOut(name, 1, function() {fadeOut('fader', 0.8, null);});
	}
	if(pageElem) {
	  pageElem.className -= ' noSelects';
	}
}

function fadeIn(name, opacity, onCompletion) {
	var activeElem = $(name);
  if(activeElem) {
    var fader = new fx.Opacity(name, {duration: 300, onComplete: function() {if(onCompletion)onCompletion();this.el=null;}});
    activeElem.style.display = 'block';
    fader.hide();
    fader.custom(0, opacity);
  }
}

function fadeOut(name, opacity, onCompletion) {
  if($(name)) {
    var fader = new fx.Opacity(name, {duration: 300, onComplete: function() {if(onCompletion)onCompletion();this.el=null;}});
    fader.setOpacity(opacity);
    fader.custom(opacity, 0);
  }
}

function bsFocus(element) {
	if(isNaN(element.value)){
	  element.value = '';
	  var className = element.className.replace('novalue', '');
	  className.trim();
	  element.className = className;
	}
}
function bsBlur(element, text) {
	var className = element.className.replace('novalue', '');
	className.trim();
	if(element.value=='' || element.value==text){
	  element.value = text;
	  className += ' novalue';
	  className.trim();
	}
	element.className = className;
}
function externalLink() {
	theForm._isExternal = true;
}
function markAllFavourites() {
  favourites = document.getElementsByClassName('favourite');
  for(var i = 0; i < favourites.length; i++){
    var favourite = $(favourites[i]);
    favourite.checked = 'checked';
    markRow(favourite);
 	}
}
function unmarkAllFavourites() {
  favourites = document.getElementsByClassName('favourite');
  for(var i = 0; i < favourites.length; i++){
    var favourite = $(favourites[i]);
    favourite.checked = '';
    markRow(favourite);
 	}
}
function printMarked() {
  printNone();
	var favourites = document.getElementsByClassName('favourite');
  for(var i = 0; i < favourites.length; i++){
    var favourite = $(favourites[i]);
		var td = favourite.parentNode;
		var tr = td.parentNode;
		var table = tr.parentNode;
		if(table.tagName.toLowerCase()=="tbody")
		  table = table.parentNode;
		var div = table.previousSibling;
		if(div.nodeType==3 && div.previousSibling)
			div = div.previousSibling;
		var marked = favourite.checked;

		if(marked && div.className){
			div.className = div.className.replace(' noPrint',' print');       
		} 
	}
	var p = $('printList');
	if(p) {
	  p.className = 'section hideForPrint';
	  window.print();
	}
}
function printNone() {
	var favourites = document.getElementsByClassName('favourite');
  for(var i = 0; i < favourites.length; i++){
    var favourite = $(favourites[i]);
		var td = favourite.parentNode;
		var tr = td.parentNode;
		var table = tr.parentNode;
		if(table.tagName.toLowerCase()=="tbody")
		  table = table.parentNode;
		var div = table.previousSibling;
		if(div.nodeType==3 && div.previousSibling)
			div = div.previousSibling;

		if(div.className){
			div.className = div.className.replace(' print',' noPrint');       
		} 
		
	}
}
function printAll() {
	var favourites = document.getElementsByClassName('favourite');
  for(var i = 0; i < favourites.length; i++){
    var favourite = $(favourites[i]);
		var td = favourite.parentNode;
		var tr = td.parentNode;
		var table = tr.parentNode;
		if(table.tagName.toLowerCase()=="tbody")
		  table = table.parentNode;
		var div = table.previousSibling;
		if(div.nodeType==3 && div.previousSibling)
			div = div.previousSibling;

		if(div.className){
			div.className = div.className.replace(' noPrint',' print');
		} 
		
	}
	var p = $('printList');
	if(p) {
	  p.className = 'section';
	  window.print();
	}
}

function ToggleCounty(o) {
	var li = o.parentNode;
	if(li) {
		li.className = (li.className == 'sel') ? '' : 'sel';
	}
}

function getPropertyPoints(ix, ex, iy, ey, map) {
	var proxy = new boligsiden.BSWeb.Services();
	proxy.GetPropertyPoints(ix, ex, iy, ey, boligsiden.BSWeb.Services.get_defaultUserContext(),mapPanSuccess,mapPanFailed,map);
}

function getFavouritePoints(ix, ex, iy, ey, map) {
	var proxy = new boligsiden.BSWeb.Services();
	proxy.GetFavouritePoints(ix, ex, iy, ey, mapPanSuccess,mapPanFailed,map);
}

function getSellerPoints(ix, ex, iy, ey, map) {
	var proxy = new boligsiden.BSWeb.Services();
	proxy.GetSellerPoints(ix, ex, iy, ey, $get('SellerSearchID').value, mapPanSuccess,mapPanFailed,map);
}

function getEmailPoints(ix, ex, iy, ey, map) {
	var proxy = new boligsiden.BSWeb.Services();
	proxy.GetEmailPoints(ix, ex, iy, ey, $get('EmailID').value, mapPanSuccess,mapPanFailed,map);
}

function getPropertyPointInfo(e) {
  if(!e) e = window.event;

  try {
      var o_id = e.target.id;
  } catch(ex) {
      var o_id = e.srcElement.id;
  }
  var o = document.getElementById(o_id);
  var arrtmp = o_id.toString().split(/_/);
  var theme_id = arrtmp[1];
  var poi_id = arrtmp[2];
  var point = this.POIenabled[theme_id].points[poi_id];
	var myServiceProxy = new boligsiden.BSWeb.Services();
  myServiceProxy.GetPropertyPointsInfo(
		this.bbox.current.ix,
		this.bbox.current.ex,
		this.bbox.current.iy,
		this.bbox.current.ey,
		point.x,
		point.y,
		1,
		(parseInt(o.parentNode.parentNode.parentNode.style.top) + parseInt(o.parentNode.style.top) + parseInt(o.parentNode.style.height)*0.5)<250,
		o_id,
		boligsiden.BSWeb.Services.get_defaultUserContext(),
		getPointInfoSuccess,
		getPointInfoFailed,
		{map: this, point: point, id: o_id});
}

function getEmailPointInfo(e) {
  if(!e) e = window.event;

  try {
      var o_id = e.target.id;
  } catch(ex) {
      var o_id = e.srcElement.id;
  }
  var o = document.getElementById(o_id);
  var arrtmp = o_id.toString().split(/_/);
  var theme_id = arrtmp[1];
  var poi_id = arrtmp[2];
  var point = this.POIenabled[theme_id].points[poi_id];
	var myServiceProxy = new boligsiden.BSWeb.Services();
  myServiceProxy.GetEmailPointInfo(
		this.bbox.current.ix,
		this.bbox.current.ex,
		this.bbox.current.iy,
		this.bbox.current.ey,
		point.x,
		point.y,
		1,
		(parseInt(o.parentNode.parentNode.parentNode.style.top) + parseInt(o.parentNode.style.top) + parseInt(o.parentNode.style.height)*0.5)<250,
		o_id,
		$get('EmailID').value,
		getPointInfoSuccess,
		getPointInfoFailed,
		{map: this, point: point, id: o_id});
}

function getFavouritePointInfo(e) {
	if(!e) e = window.event;

  try {
      var o_id = e.target.id;
  } catch(ex) {
      var o_id = e.srcElement.id;
  }
  var o = document.getElementById(o_id);
  var arrtmp = o_id.toString().split(/_/);
  var theme_id = arrtmp[1];
  var poi_id = arrtmp[2];
  
  var point = this.POIenabled[theme_id].points[poi_id];
  
	var myServiceProxy = new boligsiden.BSWeb.Services();
  myServiceProxy.GetFavouritePointInfo(
		this.bbox.current.ix,
		this.bbox.current.ex,
		this.bbox.current.iy,
		this.bbox.current.ey,
		point.x,
		point.y,
		1,
		(parseInt(o.parentNode.parentNode.parentNode.style.top) + parseInt(o.parentNode.style.top) + parseInt(o.parentNode.style.height)*0.5)<250,
		o_id,
		getPointInfoSuccess,
		getPointInfoFailed,
		{map: this, point: point, id: o_id});
}

function getSellerPointInfo(e) {
	if(!e) e = window.event;

  try {
      var o_id = e.target.id;
  } catch(ex) {
      var o_id = e.srcElement.id;
  }
  var o = document.getElementById(o_id);
  var arrtmp = o_id.toString().split(/_/);
  var theme_id = arrtmp[1];
  var poi_id = arrtmp[2];
  
  var point = this.POIenabled[theme_id].points[poi_id];
	var myServiceProxy = new boligsiden.BSWeb.Services();
  myServiceProxy.GetSellerPointInfo(
		this.bbox.current.ix,
		this.bbox.current.ex,
		this.bbox.current.iy,
		this.bbox.current.ey,
		point.x,
		point.y,
		1,
		(parseInt(o.parentNode.parentNode.parentNode.style.top) + parseInt(o.parentNode.style.top) + parseInt(o.parentNode.style.height)*0.5)<250,
		o_id,
		$get('SellerSearchID').value,
		getPointInfoSuccess,
		getPointInfoFailed,
		{map: this, point: point, id: o_id});
}

function getPointInfoSuccess(result, userContext, methodName) {
	var o = document.getElementById(userContext.id);
	var id = userContext.id + '_content';
	//userContext.point.onmouseoverinfo = '<div style="position:relative" id="' + id + '">' + buildPointInfo(result, id, methodName) + '</div>';
	var dx = parseInt(o.parentNode.parentNode.parentNode.style.left) + parseInt(o.parentNode.style.left) + parseInt(o.parentNode.style.width)*0.5;
	
	var x = parseInt(o.parentNode.style.left);
	var y = parseInt(o.parentNode.parentNode.parentNode.style.top) + parseInt(o.parentNode.style.top) + parseInt(o.parentNode.style.height)*0.5;
	var offsetx = (dx < 174 ? 6+dx : 180);
	var x = (x - offsetx) + "px";
	//var x = (x - 180) + "px";
	var top = null;
	var bottom = null;

	var flip = y<220;

	userContext.point.onmouseoverinfo = '<div style="z-index:100" class="mapItem' + (flip ?  ' flipped' : '') + '"><div id="' + id + '">' + result.infoBox + '</div><div class="pointer" style="left:' + offsetx + 'px"></div></div>';

	if(!flip) {
	  top = null;
		bottom = -parseInt(o.parentNode.style.top) + 27 + "px";
	} else {
	  top = parseInt(o.parentNode.style.top) + parseInt(o.parentNode.style.height) + 27 + "px";
	  bottom = null;
	}
	userContext.map.showInfoBox(userContext.id, x, bottom, top);
}

function getPointInfoFailed() {
}

function updatePropertyPointInfo(ix, ex, iy, ey, x, y, number, flip, id) {
	var myServiceProxy = new boligsiden.BSWeb.Services();
  myServiceProxy.GetPropertyPointsInfo(ix, ex, iy, ey, x, y, number, flip, id,
    boligsiden.BSWeb.Services.get_defaultUserContext(),
		updatePointInfoSuccess,
		updatePointInfoFailed,
		id);
}

function updateFavouritePointInfo(ix, ex, iy, ey, x, y, number, flip, id) {
	var myServiceProxy = new boligsiden.BSWeb.Services();
  myServiceProxy.GetFavouritePointInfo(ix, ex, iy, ey, x, y, number, flip, id,
		updatePointInfoSuccess,
		updatePointInfoFailed,
		id);
}

function updateSellerPointInfo(ix, ex, iy, ey, x, y, number, flip, id) {
	var myServiceProxy = new boligsiden.BSWeb.Services();
  myServiceProxy.GetSellerPointInfo(ix, ex, iy, ey, x, y, number, flip, id,
    $get('SellerSearchID').value,
		updatePointInfoSuccess,
		updatePointInfoFailed,
		id);
}

function updateEmailPointInfo(ix, ex, iy, ey, x, y, number, flip, id) {
	var myServiceProxy = new boligsiden.BSWeb.Services();
  myServiceProxy.GetEmailPointInfo(ix, ex, iy, ey, x, y, number, flip, id,
    $get('EmailID').value,
		updatePointInfoSuccess,
		updatePointInfoFailed,
		id);
}

function updatePointInfoSuccess(result, userContext, methodName) {
	$get(userContext+'_content').innerHTML = result.infoBox; //buildPointInfo(result, userContext, methodName);
}

function updatePointInfoFailed() {
}

function buildPointInfo(result, id, methodName) {
	return '<div class="mapItem' + (result.flip ?  ' flipped' : '') + '">' + result.infoBox + '<div class="pointer"></div></div>';
}

function mapPanFailed() {
}

function mapPanSuccess(result, userContext, methodName) {
  var events = new Object();
  //events["click"] = "zoomPoint"
  //events["mouseover"] = "getPointInfo";
  events["mouseup"] = "Test";
  events["mousedown"] = "Test";
  events["click"] = "getPointInfo";
  events["mouseout"] = "releaseInfoBox";

  var points = new Object();
	var j = 1;
	for(var i = 0; i<result.length; i++) {
		var p = result[i];
		points[j] = {
			x: p.x,
			y: p.y,
			iconname: p.count > 1 ? "hus_flere.gif" : "hus_et.gif",
			iconwidth: "17",
			iconheight: p.count > 1 ? "25" : "20"
		};
		j++;
	}
	userContext.setPOI("",1,10,"include/","",22, 22, events, points,1);
}

function remember(id) {
	var myServiceProxy = new boligsiden.BSWeb.Services();
  myServiceProxy.Remember(id,
		rememberSuccess,
		rememberFailed);
}

function rememberFailed() {
}

function rememberSuccess() {
}

function showFeedbackChoice(e) {
	$('feedbackConfirm').style.display = 'none';
	$('feedbackInfo').style.display = 'none';
	$('feedbackNoEmail').style.display = 'none';
	$('feedbackChoice').style.display = 'block';
	showPopUp('feedback',e, 211, 273);
}

function showFeedbackInfo() {
	$('feedbackInfo').style.display = 'block';
	$('feedbackChoice').style.display = 'none';
}

function sendFeedback() {
	
}

function exitLink(url) {
  if(typeof(pageTracker)=="object" && url)
    pageTracker._trackPageview("/exitlinks/" + url + "/");
}
