﻿//var mapToBodyOffset=150+48+48;
//var contentToBodyOffset=150+48+48+48;
var contentToBodyOffset=150+48+48;
var panelClosedOffset=64;
var panelOpenOffset=270+64+8+6-16;
//var panelVOffset=218;
var layoutTableVOffset=24;
var extendedDetailsPanelWidth=640;
var extendedDetailsPanelHeight=480;

function CustomPrePreStartup()
{
$("#divPreloadingMessage").css("left",(GetWindowWidth()-240)/2 + "px");
}
function CustomPostStartup()
{
$("#contentContainer").css("display","block");
$("#PageHeaderPanel").css("display","block");
$("#PageHeaderPanel2").css("display","block");
$("#PageFooterPanel").css("display","block");
$("#divPreloadingMessage").css("display","none");
$("#MapLegendPanel").css("display","block");


var bounds = [new VELatLongRectangle(new VELatLong(54,0),new VELatLong(48,14))];
var tileSourceSpec;
tileSourceSpec = new VETileSourceSpecification("tilelayer", "http://gis.tourismus-untersee.eu/images/tilestus/%4.png"); 
tileSourceSpec.MinZoomLevel = 11;
tileSourceSpec.NumServers = 1;            
tileSourceSpec.MaxZoomLevel = 17;            
tileSourceSpec.Opacity = 0.0;           
tileSourceSpec.ZIndex = 1;            
map.AddTileLayer(tileSourceSpec, true);	

AddToHolidayPlaner('REFRESH^^^3');
}

function CustomBodyOnResize()
{
var o;var width;var height;var x;var y;var panelVisible=false;
try{
$("#divHeaderImageContainer").css("width",GetWindowWidth()-64);

o=document.getElementById("contentContainer");
o.style.height=(GetWindowHeight()-(contentToBodyOffset)) + "px";
width = GetWindowWidth()-panelClosedOffset;
o=document.getElementById(panelContainerTableClientID);
panelVisible=(o.style.display!="none");
if (panelVisible==true) width=GetWindowWidth()-panelOpenOffset;
map.Resize(width,GetWindowHeight()-contentToBodyOffset);
ShowPanel(currentPanel);
if (currentPanel == "TourPanel")
	TourPanel_OnResize();
o=document.getElementById("divLoadingMessage");
o.style.left=GetWindowWidth()-114;
o.style.top=GetWindowHeight()-116;
o=document.getElementById("divMessage");
o.style.width=width;
o.style.top=(GetWindowHeight()-64);
o.style.left=(panelVisible==true ? 300 : 32);
$("#MapLegendPanel").css("left",GetWindowWidth()-210);
}catch (e) {}
}

function CustomOnChangeView()
{
var c=map.GetZoomLevel();if(c<10) {window.setTimeout("map.SetZoomLevel(10);",1);return;}
c=map.GetCenter();var ch=false;
if(c.Latitude>47.950385640510113) {c.Latitude=47.950385640510113;ch=true;}
else if(c.Latitude<47.371849600499047) {c.Latitude=47.371849600499047;ch=true;}
if(c.Longitude<8.5020446777343626) {c.Longitude=8.5020446777343626;ch=true;}
else if(c.Longitude>9.8973083496093643) {c.Longitude=9.8973083496093643;ch=true;}
if(ch==true){window.setTimeout("map.SetCenter(new VELatLong(" + c.Latitude + "," + c.Longitude + "));",1);return;}

if(AutoMove == false)
{    
try
{
var center=map.GetCenter();
if (center.Latitude!=lastLatitude||center.Longitude!=lastLongitude)
{
lastLatitude=center.Latitude;
lastLongitude=center.Longitude;
if (timerID!=null)
window.clearTimeout(timerID);
if (map.GetMapStyle()!="o")
if (document.getElementById("WeatherPanel")!=null)
timerID = window.setTimeout("DoFindWeather()",2000);
}
}catch (e){}
	
try
{
// update traffic data
if (timerTrafficID!=null)
window.clearTimeout(timerTrafficID);

if (document.getElementById("TrafficPanel")!=null)
if (map.GetMapStyle()!="o")
timerTrafficID = window.setTimeout("DoFindTmc()",2000);
}catch (e){}

// update poi data	
try
{

if (timerPoiID!=null)window.clearTimeout(timerPoiID);
if (map.GetMapStyle()!="o")
timerPoiID=window.setTimeout("DoFindPois()",2000);
}catch (e){}

options_have_changed = true;
// update lodging data	
try
{
if (timerLodID!=null)window.clearTimeout(timerLodID);
if (map.GetMapStyle()!="o")  timerLodID=window.setTimeout("DoFindLodging()",2000);                    
}catch (e){}	
		
}


if (timerAccomodationTypesID!=null)
	window.clearTimeout(timerAccomodationTypesID);
timerAccomodationTypesID=window.setTimeout("DoFindAvailableAccomodationTypes();",10);

if (timerAvailableTourTypesID!=null)
	window.clearTimeout(timerAvailableTourTypesID);
timerAvailableTourTypesID=window.setTimeout("DoFindAvailableTourTypes();",10);

}


function CustomShowMyMessage(text)
{
customShowMyMessageRefCount++;
var o=document.getElementById("divLoadingMessage");
if (o!=null) o.style.display="block";
}

function CustomHideMyMessage()
{
var o=document.getElementById("divLoadingMessage");
customShowMyMessageRefCount--;
if (customShowMyMessageRefCount<=0)
	if(o!=null)o.style.display="none";
}

function CustomShowErrorMessage(text)
{

window.clearTimeout(customShowMyMessageTimerID);
var o=document.getElementById("divMessage");
o.innerHTML=text;
o.style.display="block";
customShowMyMessageTimerID =window.setTimeout("CustomHideErrorMessage()",10000);
window.setTimeout("CustomAnimErrorMessage()",100);
}

function CustomAnimErrorMessage()
{


}

function CustomHideErrorMessage(){var o=document.getElementById("divMessage");o.style.display="none";}


function CustomHighlightPin(tableRow,id, bHighlight,imageIndex)
{
lastHighlightedPinID=id;
lastHighlightedPinImageIndex=imageIndex;
var shape;
if (tableRow!=null) tableRow.className=(bHighlight==true ? "accRTC1S" : "accRTC1");

if (id.substring(0,3)=="ACC")
{

shape=GetShapeById(accomodationShapeLayer,id);
if (shape!=null) shape.SetCustomIcon(bHighlight==true ? "images/i/baw/68h.gif" : "images/i/baw/68.gif");
if (tableRow!=null)
{
var t=tableRow.childNodes[0].childNodes[0].src=(bHighlight==true ? "images/i/baw/68h.gif" : "images/i/baw/68.gif");
}
}

if (id.substring(0,3)=="POI")
{
if (tableRow!=null)tableRow.childNodes[0].childNodes[0].style.filter=(bHighlight==true ? "Invert" : "");
shape=GetShapeById(poiShapeLayer,id);
if (shape!=null) shape.SetCustomIcon("<img src='images/i/tus/" + imageIndex + ".gif' " + (bHighlight==true ? "style='filter:Invert'" : "") + "/>");
}


if (id.substring(0,3)=="TOU")
{
if (tableRow!=null)tableRow.childNodes[0].childNodes[0].src="images/mapicon_start" + (bHighlight==true ? "S" : "") + ".gif";
shape=GetShapeById(tourShapeLayer,id);
if (shape!=null) shape.SetCustomIcon("images/mapicon_start" + (bHighlight==true ? "S" : "") + ".gif");
}

if (shape!=null)
{
shape.SetZIndex(bHighlight==true ? 5000:1000);
shape.Redraw(true,true,true,true);
}
}



function CustomShowPanel(name,setAsCurrent)
{
	if (setAsCurrent==true)
		currentPanel = name;


	var lastVisiblePanel=null;
	
	for(var ii=0;ii<panels.length;ii++)
	{
		panels[ii].style.display="none";
		
		if (panels[ii].id==name)
		{	
			panels[ii].style.height=GetWindowHeight()-contentToBodyOffset +"px";
			panels[ii].style.display="block";
		}
		
	}

}
