function ChangeFieldsetStatus(el,newStatus)
{
	var all = el.getElementsByTagName("INPUT")
	for(var j=0;j<all.length;j++)
	{
		try
		{
			all[j].disabled=newStatus;
		}
		catch(e)
		{
			alert(e.description);
		}	
	}
}

function SwitchPickUp(what)
{
	if(what=="Froms")
	{
		var el = document.getElementById("StartPickUp");
		var selection = el.value;	
		
		var FromsFieldsets = document.getElementById("Froms");
		var allFieldsets = FromsFieldsets.getElementsByTagName("FIELDSET");

		for(var j=0;j<allFieldsets.length;j++)
		{
			allFieldsets[j].style.display = "none";
			allFieldsets[j].disabled = true;
			ChangeFieldsetStatus(allFieldsets[j],true);
		}
		
		if(selection != "0_1")
		{
			document.getElementById("Fieldset_" + selection).style.display="";
			document.getElementById("Fieldset_" + selection).disabled=false;
			ChangeFieldsetStatus(document.getElementById("Fieldset_" + selection),false);
		}
		else
		{
			document.getElementById("Fieldset_0_2").style.display="";
			document.getElementById("Fieldset_0_2").disabled=true;
			ChangeFieldsetStatus(document.getElementById("Fieldset_0_2"),true);
		}
		
	}
	else
	{
		var el = document.getElementById("EndPickUp");
		var selection = el.value;	
		var FromsFieldsets = document.getElementById("Tos");
		var allFieldsets = FromsFieldsets.getElementsByTagName("FIELDSET");
		for(var j=0;j<allFieldsets.length;j++)
		{
			allFieldsets[j].style.display = "none";
			allFieldsets[j].disabled=true;
			ChangeFieldsetStatus(allFieldsets[j],true);
		}
		
		if(selection != "1_1")
		{
			document.getElementById("Fieldset_" + selection).style.display="";
			document.getElementById("Fieldset_" + selection).disabled=false;
			ChangeFieldsetStatus(document.getElementById("Fieldset_" + selection),false);
		}	
		else
		{
			document.getElementById("Fieldset_1_2").style.display="";
			document.getElementById("Fieldset_1_2").disabled=true;
			ChangeFieldsetStatus(document.getElementById("Fieldset_1_2"),true);
		}
	}
}

function SwitchModels()
{
	var el = document.getElementById("ddlCarGroup");
	var selection = el.value;
	
	var allModelsContainer = document.getElementById("AllTheModels");
	var allModels = allModelsContainer.getElementsByTagName("SELECT");
	for(var j=0;j<allModels.length;j++)
	{
		allModels[j].style.display = "none";
	}
	
	document.getElementById("ddlModel" + selection).style.display="";
}

function LoadGallery(img_src,img_description,width,height)
{
	var el;
	var el2;
	el = document.getElementById("BigPhoto");
	el.src = img_src;
	el.style.height = height + "px";
	el.style.width = width + "px";
	
	el2 = document.getElementById("BigPhotoContainer");
	el2.style.height = height + "px";
	el2.style.width = width + "px";
	
	el = document.getElementById("PhotoDescription");
	el.innerHTML = img_description;
}


function LoadBestSelection(img_src)
{
	if(document.getElementById("CurrentBest"))
	{
		var el = document.getElementById("CurrentBest");	
		el.src = img_src;
	}
}


function GetRoundedImages()
{
	var AllRounds = document.getElementsByTagName("DIV");
	var i;
	var sOut = "";
	var oDiv;
	var oImg;
	var mImage;
	for(i=0;i<AllRounds.length;i++)
	{
		if(AllRounds[i].className=="photo_container")	
		{
			mImage = new Image();
			mImage.src = AllRounds[i].src			
			ImageHeight = parseInt(mImage.height);
			ImageWidth = parseInt(mImage.width);
			
			oImg = AllRounds[i].getElementsByTagName("IMG")[0];
			if(!oImg.style.height)
			{
				AllRounds[i].style.height = parseInt(oImg.height) + "px";
			}
			else
			{
				AllRounds[i].style.height = oImg.style.height;
			}
			
			if(!oImg.style.width)
			{
				AllRounds[i].style.width = parseInt(oImg.width) + "px";				
			}
			else
			{
				AllRounds[i].style.width = oImg.style.width;
			}
						
			oDiv = document.createElement("DIV");			
			oDiv.className = "lt_corner";			
			oImg = document.createElement("IMG");	
			oImg.src = "/images/corners/top_left.png"
			oDiv.appendChild(oImg);
			AllRounds[i].appendChild(oDiv);			
			
			oDiv = document.createElement("DIV");			
			oDiv.className = "rt_corner";			
			oImg = document.createElement("IMG");	
			oImg.src = "/images/corners/top_right.png"
			oDiv.appendChild(oImg);
			AllRounds[i].appendChild(oDiv);
			
			oDiv = document.createElement("DIV");			
			oDiv.className = "lb_corner";			
			oImg = document.createElement("IMG");	
			oImg.src = "/images/corners/bottom_left.png"
			oDiv.appendChild(oImg);
			AllRounds[i].appendChild(oDiv);
			
			oDiv = document.createElement("DIV");			
			oDiv.className = "rb_corner";			
			oImg = document.createElement("IMG");	
			oImg.src = "/images/corners/bottom_right.png"
			oDiv.appendChild(oImg);
			AllRounds[i].appendChild(oDiv);			
		}
	}
}

function Highlight(id)
{
	document.getElementById(id).style.backgroundColor = "#EDF3F9"
}

function UnHighlight(id)
{
	document.getElementById(id).style.backgroundColor = "#FFFFFF"
}

function ResizeGroups()
{
	if(document.getElementById("GroupsCount"))
	{
		var el = document.getElementById("GroupsCount");
		var groupsCount = parseInt(el.value);
		if(groupsCount>3)
		{
			var best=0;
			var cc;
			var h;
			for(var j=1;j<=groupsCount;j++)
			{
				if(document.getElementById("CarGroup_" + j))
				{					
					cc = document.getElementById("CarGroup_" + j)
					h = parseInt(cc.clientHeight);
					
					if(h >= best)
					{
						best = h;						
					}
					
					if(j%3==0)
					{
						for(var k=j;k>=j-2;k--)
						{
							cc = document.getElementById("CarGroup_" + k);
							cc.style.height=best + "px";
						}
						best = 0
					}
				}		
			}
		}
	}
}

function ResizeHotels()
{
	if (document.getElementById("HotelsCount"))
	{
		var Highest;
		var HotelsCount = parseInt(document.getElementById("HotelsCount").innerHTML);
		var nextH;
		for(var i=1;i<=HotelsCount;i+=3)
		{
			Highest = parseInt(document.getElementById("Hotel_" + i).clientHeight);
			if (document.getElementById("Hotel_" + (i+1)))
			{
				nextH = parseInt(document.getElementById("Hotel_" + (i+1)).clientHeight);
				if (nextH > Highest)
				{
					Highest = nextH;
				}
			}
			
			if (document.getElementById("Hotel_" + (i+2)))
			{
				nextH = parseInt(document.getElementById("Hotel_" + (i+2)).clientHeight);
				if (nextH > Highest)
				{
					Highest = nextH;
				}
			}
			
			if (document.getElementById("Hotel_" + i))
			{
				document.getElementById("Hotel_" + i).style.height = Highest + "px";
			}
			if (document.getElementById("Hotel_" + (i+1)))
			{
				document.getElementById("Hotel_" + (i+1)).style.height = Highest + "px";
			}
			
			if (document.getElementById("Hotel_" + (i+2)))
			{
				document.getElementById("Hotel_" + (i+2)).style.height = Highest + "px";
			}
		}
	}		
}

var AskDetails;
var DisplayTextBox;
var RoomTypes;
var RoomsCount = 0;
var lc_JsManyRooms;

function RemoveRoom()
{
	if(RoomsCount>0)
	{
		var el;
		el = document.getElementById("room_type_id_" + RoomsCount);
		el.parentNode.removeChild(el);
		
		if(document.getElementById("adults_" + RoomsCount))
		{
			el = document.getElementById("adults_" + RoomsCount);
			el.parentNode.removeChild(el);
		}
		
		if(document.getElementById("children_" + RoomsCount))
		{
			el = document.getElementById("children_" + RoomsCount);
			el.parentNode.removeChild(el);
		}
		
		if(document.getElementById("guests_" + RoomsCount))
		{
			el = document.getElementById("guests_" + RoomsCount);
			el.parentNode.removeChild(el);
		}
		
		if(document.getElementById("NoRoomTypeSelected_" + RoomsCount))
		{
			el = document.getElementById("NoRoomTypeSelected_" + RoomsCount);
			el.parentNode.removeChild(el);
		}
		if(document.getElementById("NoRoomTypeSelected_" + RoomsCount))
		{
			el = document.getElementById("NoRoomTypeSelected_" + RoomsCount);
			el.parentNode.removeChild(el);
		}
		
		
		RoomsCount -= 1;
		if(RoomsCount==0)
		{
			document.getElementById("remove_room").style.display="none";
		}
		
		document.getElementById("room_count").value = (RoomsCount + 1);
	}
}

function AddRoom()
{
	if(RoomsCount>=3)
	{
		alert(lc_JsManyRooms);
	}
	else
	{
		RoomsCount += 1;
		document.getElementById("remove_room").style.display = "";
		var container = document.getElementById("room_types");
		var elNew;
		var oOption;
		
		// INPUT or SELECTION
		if (DisplayTextBox=="true")
		{
			elNew = document.createElement("INPUT");
			elNew.setAttribute("type","text");
			elNew.setAttribute("id","room_type_id_" + RoomsCount);
			elNew.setAttribute("name","room_type_id_" + RoomsCount);
			elNew.style.width = "160px";
			elNew.style.marginRight = "5px";
			elNew.style.marginTop = "3px";
			container.appendChild(elNew);
		}
		else
		{
			elNew = document.createElement("SELECT");
			elNew.setAttribute("id","room_type_id_" + RoomsCount);
			elNew.setAttribute("name","room_type_id_" + RoomsCount);
			elNew.style.marginRight = "5px";
			elNew.style.marginTop = "3px";
			for(var j=1;j<RoomTypes.length;j++)
			{
				oOption = document.createElement("OPTION");	
				oOption.text = RoomTypes[j];
				oOption.innerText = RoomTypes[j];
				oOption.value = RoomTypes[j];	
				elNew.appendChild(oOption);
			}
			container.appendChild(elNew);
		}
	
		if(AskDetails=="true")
		{
			// ADULTS
			elNew = document.createElement("SELECT");
			elNew.setAttribute("id","adults_" + RoomsCount);
			elNew.setAttribute("name","adults_" + RoomsCount);
			elNew.style.marginRight = "5px";
			for(var j=1;j<=5;j++)
			{
				oOption = document.createElement("OPTION");	
				oOption.text = j;
				oOption.innerText = j;
				oOption.value = j;	
				if(j==2)
				{
					oOption.selected = true;
				}
				elNew.appendChild(oOption);
			}
			container.appendChild(elNew);
			
			// CHILDREN
			elNew = document.createElement("SELECT");
			elNew.setAttribute("id","children_" + RoomsCount);
			elNew.setAttribute("name","children_" + RoomsCount);
			elNew.style.marginRight = "5px";
			for(var j=0;j<=4;j++)
			{
				oOption = document.createElement("OPTION");	
				oOption.text = j;
				oOption.innerText = j;
				oOption.value = j;	
				if(j==0)
				{
					oOption.selected = true;
				}
				elNew.appendChild(oOption);
			}
			container.appendChild(elNew);
		}
		else
		{
			// GUESTS
			elNew = document.createElement("SELECT");
			elNew.setAttribute("id","guests_" + RoomsCount);
			elNew.setAttribute("name","guests_" + RoomsCount);
			elNew.style.marginRight = "5px";
			for(var j=1;j<=5;j++)
			{
				oOption = document.createElement("OPTION");	
				oOption.text = j;
				oOption.innerText = j;
				oOption.value = j;	
				if(j==2)
				{
					oOption.selected = true;
				}
				elNew.appendChild(oOption);
			}
			container.appendChild(elNew);			
		}				
		
		
		elNew = document.createElement("IMG");
		elNew.style.display="none";
		elNew.setAttribute("id","NoRoomTypeSelected_" + RoomsCount);
		elNew.style.marginLeft = "5px";
		elNew.style.cursor = "pointer";
		elNew.src = "/images/error_provider.gif";
		if (DisplayTextBox=="true")
		{
			elNew.setAttribute("alt",lc_NoRoomTypeInserted);
			container.appendChild(elNew);	
		}
		else
		{
			elNew.setAttribute("alt",lc_NoRoomTypeSelected);
			container.appendChild(elNew);	
		}	
		
		
		document.getElementById("room_count").value = (RoomsCount + 1);		
	}
}
	
var MyWin;
function EnlargeImage(url,wid,heg)
{
	wid = 260;
	heg = 200;
	if(MyWin!=null)
	{
		MyWin.close;
	}
				
	MyWin=window.open(url,'images',"height=" + (heg + 200) + ",width=" + (wid + 100) + ",status=no,toolbar=no,menubar=no,location=no,titlebar=no,resizable=no");
	MyWin.moveTo(5,5);
	MyWin.focus();
}

function SendFriend()
{
	var wid = 390;
	var heg = 380;
	var url = window.location.href.toString();
	url = url.replace(/&/,"@");
	url = "/SendToFriend.asp?page=" + url;
	if(MyWin!=null)
	{
		MyWin.close;
	}				
	MyWin=window.open(url,'images',"height=" + heg + ",width=" + wid + ",status=no,toolbar=no,menubar=no,location=no,titlebar=no,resizable=no");
	MyWin.focus();
}

function CurrencyConverter()
{

	var wid = 250;
	var heg = 290;
	var url = window.location.href.toString();
	url = url.replace(/&/,"@");
	url = "/CurrencyConverter.asp?page=" + url;
	if(MyWin!=null)
	{
		MyWin.close;
	}				
	MyWin=window.open(url,'images',"height=" + heg + ",width=" + wid + ",status=no,toolbar=no,menubar=no,location=no,titlebar=no,resizable=yes");
	MyWin.focus();
}

function insertAfter(parent, node, referenceNode) 
{
  parent.insertBefore(node, referenceNode.nextSibling);
}

function DisplayConverter()
{
	if(document.getElementById("main_description"))
	{
		var el = document.getElementById("main_description")
		var Tbl = el.getElementsByTagName("TABLE");			
		for(var i=0;i<Tbl.length;i++)
		{
			if(Tbl[i].className == "Pricelist")
			{			
				var elNEW = document.getElementById("CurrencyLink");
				elNEW.style.display = "block";
				insertAfter(Tbl[i].parentNode,elNEW,Tbl[i]);
				
				/*if(Tbl[i].parentNode.nodeName != "DIV")
				{
					insertAfter(Tbl[i].parentNode,elNEW,Tbl[i]);
				}
				else
				{
					insertAfter(el,elNEW,Tbl[i]);
				}*/
			}
		}
	}
}

function ResizeGallery()
{
	if(document.getElementById("PhotoAlbum"))
	{
		
		var el = document.getElementById("PhotoAlbum");
		var col = el.getElementsByTagName("DIV");
		var max_height=0;
		for(var i=0;i<col.length;i++)
		{
			if(col[i].className == "photo_album_item")
			{
				if(parseInt(col[i].clientHeight) > max_height)
				{
					max_height=parseInt(col[i].clientHeight);
				}
			}
		}
		
		
		for(var i=0;i<col.length;i++)
		{
			if(col[i].className == "photo_album_item")
			{
				col[i].style.height = max_height + "px";		
			}
		}	
		
	}
}


function ClearTable()
{
	if(document.getElementById("main_description"))
	{
		var el = document.getElementById("main_description")
		var Tbl = el.getElementsByTagName("TABLE")
		
		for(var i=0;i<Tbl.length;i++)
		{
			if(Tbl[i].id != "CurrencyConverter" && Tbl[i].id != "ReservationTable" && Tbl[i].className != "StaticTable")
			{
				ClearAttibutes(Tbl[i],"TABLE");
				Tbl[i].className = "Pricelist";
			}
		}
	}		
}		

function ClearAttibutes(elem,current_tag)
{
	elem.style.width = "auto";
	elem.style.height = "auto";
	//elem.style.border = "0px solid #FF0000";
	elem.setAttribute("align","");	
	elem.setAttribute("border","0");
	elem.style.fontSize = "11px";
	if (current_tag=="TD")		
	{
		elem.setAttribute("valign","top");
	}
	
	var newCollection;
	var newTAG;
	if (current_tag=="TABLE")
	{
		// CLEAR TBODY
		newCollection = elem.getElementsByTagName("TBODY");
		newTAG = "TBODY"; 
		if (newCollection.length == 0)
		{
			newCollection = elem.getElementsByTagName("TR");
			newTAG = "TR"; 
		}
		if (newCollection)
		{			
			for(var i=0;i<newCollection.length;i++)
			{
				ClearAttibutes(newCollection[i], newTAG);
			}	
		}	
		
		// CLEAR THEAD
		newCollection = elem.getElementsByTagName("THEAD");
		newTAG = "THEAD"; 
		if (newCollection.length == 0)
		{
			newCollection = elem.getElementsByTagName("TR");
			newTAG = "TR"; 
		}
		if (newCollection)
		{			
			for(var i=0;i<newCollection.length;i++)
			{
				ClearAttibutes(newCollection[i], newTAG);
			}	
		}	
		
	}
	else if (current_tag=="TBODY" || current_tag=="THEAD")
	{
		// CLEAR TR
		newCollection = elem.getElementsByTagName("TR");
		newTAG = "TR"; 
		if (newCollection)
		{			
			for(var i=0;i<newCollection.length;i++)
			{
				ClearAttibutes(newCollection[i], newTAG);
			}	
		}	
	}			
	else if (current_tag=="TR")
	{
		// CLEAR TD
		newCollection = elem.getElementsByTagName("TD");
		newTAG = "TD"; 
		if (newCollection)
		{			
			for(var i=0;i<newCollection.length;i++)
			{
				ClearAttibutes(newCollection[i], newTAG);
			}	
		}	
		
		// CLEAR TH
		newCollection = elem.getElementsByTagName("TH");
		newTAG = "TH"; 
		if (newCollection)
		{			
			for(var i=0;i<newCollection.length;i++)
			{
				ClearAttibutes(newCollection[i], newTAG);
			}	
		}	
	}		
}


function PrinterFriendly()
{
	var wid = 630;
	var heg = 600;
	//var page = new PageQuery(window.location.search);
	var qString = window.location.search.substring(1);
	if(qString != "")
	{
		qString = "?" + qString;
	}
	url = "/PrinterFriendly.asp" + qString;
	if(MyWin!=null)
	{
		MyWin.close;
	}				
	MyWin=window.open(url,'images',"height=" + heg + ",width=" + wid + ",status=no,toolbar=no,menubar=no,location=no,titlebar=no,resizable=no,scrollbars=yes");
	MyWin.focus();		
}

function ValidateCarReserveForm()
{
	var valid = true;
	var CustomerFirstName = Trim(document.getElementById("customer_first_name").value);
	var CustomerLastName = Trim(document.getElementById("customer_last_name").value);
	var CustomerMail = Trim(document.getElementById("customer_mail").value);
	var CustomerCountry = Trim(document.getElementById("customer_country").value);
	
	document.getElementById("NotProvidedMail").style.display = "none";
	document.getElementById("NotValidMail").style.display = "none";
	document.getElementById("NotProvidedLastName").style.display = "none";
	document.getElementById("NotProvidedFirstName").style.display = "none";
	document.getElementById("NotProvidedCountry").style.display = "none";
	
	var CustomerTelephone = Trim(document.getElementById("customer_telephone").value);
	var CustomerCity = Trim(document.getElementById("customer_city").value);
	document.getElementById("NotProvidedTelephone").style.display = "none";
	document.getElementById("NotProvidedCity").style.display = "none";
	document.getElementById("NotValidTelephone").style.display = "none";

	if(CustomerTelephone == "")
	{
		document.getElementById("NotProvidedTelephone").style.display = "";
		valid = false;
	}
	else if(CustomerTelephone.length<10)
	{
		document.getElementById("NotValidTelephone").style.display = "";
		valid = false;
	}
	
	if(CustomerCity == "")
	{
		document.getElementById("NotProvidedCity").style.display = "";
		valid = false;
	}
	
	if(CustomerMail == "")
	{
		document.getElementById("NotProvidedMail").style.display = "";
		valid = false;
	}
	else if(!validateEmail(CustomerMail))
	{
		document.getElementById("NotValidMail").style.display = "";
		valid = false;
	}
	
	if(CustomerLastName == "")
	{
		document.getElementById("NotProvidedLastName").style.display = "";
		valid = false;
	}
	
	if(CustomerFirstName == "")
	{
		document.getElementById("NotProvidedFirstName").style.display = "";
		valid = false;
	}
	
	if(CustomerCountry == "0")
	{
		document.getElementById("NotProvidedCountry").style.display = "";
		valid = false;
	}
	
	
	if(valid==true)
	{
		document.getElementById("submit").disabled = true;
		document.getElementById("GlobalError").style.display = "none";		
	}
	else
	{		
		document.getElementById("GlobalError").style.display = "";
	}
	return valid;

}

function ValidateReserveForm()
{
	var valid = true;
	var CustomerFirstName = Trim(document.getElementById("customer_first_name").value);
	var CustomerLastName = Trim(document.getElementById("customer_last_name").value);
	var CustomerMail = Trim(document.getElementById("customer_mail").value);
	var CustomerCountry = Trim(document.getElementById("customer_country").value);	
	
	document.getElementById("NotProvidedMail").style.display = "none";
	document.getElementById("NotValidMail").style.display = "none";
	document.getElementById("NotProvidedLastName").style.display = "none";
	document.getElementById("NotProvidedFirstName").style.display = "none";
	document.getElementById("NotProvidedCountry").style.display = "none";
	
	var CustomerTelephone = Trim(document.getElementById("customer_telephone").value);
	var CustomerCity = Trim(document.getElementById("customer_city").value);
	document.getElementById("NotProvidedTelephone").style.display = "none";
	document.getElementById("NotProvidedCity").style.display = "none";
	document.getElementById("NotValidTelephone").style.display = "none";

	if(CustomerTelephone == "")
	{
		document.getElementById("NotProvidedTelephone").style.display = "";
		valid = false;
	}
	else if(CustomerTelephone.length<10)
	{
		document.getElementById("NotValidTelephone").style.display = "";
		valid = false;
	}
	
	if(CustomerCity == "")
	{
		document.getElementById("NotProvidedCity").style.display = "";
		valid = false;
	}
	
	if(CustomerMail == "")
	{
		document.getElementById("NotProvidedMail").style.display = "";
		valid = false;
	}
	else if(!validateEmail(CustomerMail))
	{
		document.getElementById("NotValidMail").style.display = "";
		valid = false;
	}
	
	if(CustomerLastName == "")
	{
		document.getElementById("NotProvidedLastName").style.display = "";
		valid = false;
	}
	
	if(CustomerFirstName == "")
	{
		document.getElementById("NotProvidedFirstName").style.display = "";
		valid = false;
	}
	
	if(CustomerCountry == "0")
	{
		document.getElementById("NotProvidedCountry").style.display = "";
		valid = false;
	}
	
	for(var i=0;i<=RoomsCount;i++)
	{
		document.getElementById("NoRoomTypeSelected_" + i).style.display = "none";
		if(document.getElementById("room_type_id_" + i).value == "")
		{			
			document.getElementById("NoRoomTypeSelected_" + i).style.display = "";
			valid = false;
		}
	}
	
	if(document.getElementById("NoBoardSelected"))
	{
		document.getElementById("NoBoardSelected").style.display = "none";
		var CustomerBoard = Trim(document.getElementById("board").value);
		if(CustomerBoard == "")
		{		
			document.getElementById("NoBoardSelected").style.display = "";
			valid = false;
		}
	}
	
	if(valid==true)
	{
		document.getElementById("submit").disabled = true;
		document.getElementById("GlobalError").style.display = "none";		
	}
	else
	{		
		document.getElementById("GlobalError").style.display = "";
	}
	return valid;
}


//Various Useful Functions
function validateEmail(theAddress)
{
	var returnValue = true;
	var AtSym       = theAddress.indexOf('@');
	var Period      = theAddress.lastIndexOf('.');
	var Space       = theAddress.indexOf(' ');
	var Length      = theAddress.length - 1;  // Array is from 0 to length-1

	// '@' cannot be in first position, Must be at least one valid char btwn '@' and '.'
	// Must be at least one valid char after '.', No empty spaces permitted
	if((AtSym < 1) || (Period <= AtSym+1) || (Period == Length ) || (Space  != -1))
		returnValue = false;

	return returnValue;
}

function Trim(str)
{
   return str.replace(/^\s*|\s*$/g,"");
}


/*################ Slider ######################### */
var currentDisplayed=0;	
var goingUp = 0
var lastUp = 0
var speed = 3;
var timerUp;
var timerDown;
var StopAnything = false;

function MoveMe(id)
{
	if(currentDisplayed!=id)
	{
		try
		{
			clearTimeout(timerUp);
			clearTimeout(timerDown);
		}
		catch(e)
		{
		
		}			
		goingUp = id;
		MoveUp();
		MoveDown();
	}
}
	
function MoveDown()
{
	var el;
	var stop1 = 0;
	for(j=1;j<6;j++)
	{
		if(j!=goingUp)
		{
			if(document.getElementById("atm" + j))
			{
				el = document.getElementById("atm" + j)
				temp = parseInt(el.style.top);	
				if((temp + speed)<0)
				{
					el.style.top = (temp + speed) + "px";
				}
				else
				{
					el.style.top = "0px";
					stop1 += 1;
				}
			}
		}
	}
	timerDown=setTimeout("MoveDown();",10);	
	
}
	
function MoveUp()
{
	var el;
	if(document.getElementById("atm" + goingUp))
	{
		el = document.getElementById("atm" + goingUp)
		temp = parseInt(el.style.top);	
		if((temp - speed)>-142)
		{
			el.style.top = (temp - speed) + "px";
			timerUp=setTimeout("MoveUp();",10);	
		}
		else
		{
			el.style.top = "-142px";
			//Κλείνω timers
			clearTimeout(timerUp);
			clearTimeout(timerDown);
			//Επαναφέρω τα υπόλοιπα tiles στην θέση τους
			for(j=1;j<6;j++)
			{
				if(j!=goingUp)
				{
					if(document.getElementById("atm" + j))
					{
						el = document.getElementById("atm" + j);
						el.style.top = "0px";
					}
				}
			}
		}
	}	
}

function ForceNewForecast()
{
	if(document.getElementById("weather_table"))
	{
		var el = document.getElementById("weather_table");
		var tds = el.getElementsByTagName("TD");
		if(tds.length==0)
		{
			window.location.href = window.location.href + "&rtr=1";			
		}	
	}
}
