var FPS = 25;

function ExpandDiv(obj, To,Duration, Step,Where) {
	var CurrentHeight = parseFloat(obj.style.height);
	if(Duration == null)
		Duration = 1000;

	if(Step == null || Step == undefined)
	{
		Step = (CurrentHeight - To) / (Duration/1000*FPS);
		if(Step < 0)
			Step = Step * -1;
	}
	
	if(Where == null || Where == undefined) 
	{
		if(CurrentHeight < To)
		{
			Where = 1;
			obj.setAttribute("expanding","1");
		}
		if(CurrentHeight > To)
		{
			Where = -1;
			obj.setAttribute("collapsing","1");
		}
	}
	if(Where == 1) 
	{
		if(CurrentHeight < To) {
			obj.style.height = CurrentHeight + Step + "px";
			if(obj.getAttribute("expanding") == 1)
				setTimeout(function() {ExpandDiv(obj, To,Duration, Step,Where), FPS
			});
		} else {
			obj.setAttribute("expanding",0);
			obj.style.height = To + "px";
		}
	}
	
	if(Where == -1) {
		if(CurrentHeight > To) {
			obj.style.height = CurrentHeight - Step + "px";
			if(obj.getAttribute("expanding") == 1)
				obj.setAttribute("expanding",0);
			if(obj.getAttribute("collapsing") == 1)
				setTimeout(function() {ExpandDiv(obj, To,Duration, Step,Where), FPS
			});
		} else {
			obj.style.height = To + "px";
			obj.setAttribute("collapsing",0);
		}
	}
	
}



function ShowImage(URL)
{
   var Form = ShowForm({'Page':encodeURI('?page=Hotel.ShowImage&blank=1&Path='+URL+'&width='+Window.Width*0.8+'&height='+Window.Height*0.8),'OnClick':function() {Form.Close();},'AddCloseIcon':'false'});Form.Form.style.cursor='pointer';setTimeout(function(){Form.Relocate();},2000);
}

AttachEvent(window,"load",function()
{
    var imgs = document.getElementsByTagName("img"); 
    for(var i = 0;i<imgs.length;i++){
        //alert(imgs[i].getAttribute("onclick")  + " && " +imgs[i].parentNode.tagName );
        if(imgs[i].getAttribute("onclick") == null && imgs[i].parentNode.tagName != "A")
        {                      
            //imgs[i].style.cursor = "pointer";        
            AttachEvent(imgs[i],"click",function() 
            {
                var src = this.src.substring(this.src.indexOf(document.location.pathname) + document.location.pathname.length);
                if(src.indexOf("ImageViewer.php") > -1){
                    src = src.substring(src.indexOf("Path=") + 5);
                    src = src.substring(0,src.indexOf("&"));
                }         
                //ShowImage(src);
            },true);      
        }
    }                        
},true);
