// JavaScript Document

/* sezione per fare il rollover delle immagini per vendita/realizzazioni */
var __CURRENT_ING_INDEX = 0;
var __SWAPPING_IMG_INDEX = 0;
var __CURRENT_FADE = 0;
var __FADE_STEP = 10;
var __SWAP_MILLI = 50;
var __MAX_SCROLL_AREA = 571;

function swapImage(newIndex)
{
	if(newIndex != __CURRENT_ING_INDEX && newIndex != __SWAPPING_IMG_INDEX && (__CURRENT_FADE == 0 || __CURRENT_FADE > 100))
	{
		__SWAPPING_IMG_INDEX = newIndex;
		__CURRENT_FADE = 0;
		var elem = document.getElementById("imgcasa"+newIndex);
		if(elem)
		{
			elem.style.opacity = (100 - __CURRENT_FADE)/100;
			elem.style.filter = "progid:DXImageTransform.Microsoft.Alpha (style=0, opacity=0);";
			elem.style.display = "block";
			doSwap();
		}
	}
}

function doSwap()
{
	if(__CURRENT_FADE <= 100)
	{
		__CURRENT_FADE += __FADE_STEP;
		var elem = document.getElementById("imgcasa"+__CURRENT_ING_INDEX);
		if(elem)
		{
			elem.style.opacity = (100 - __CURRENT_FADE)/100;
			elem.style.filter = "progid:DXImageTransform.Microsoft.Alpha (style=0, opacity="+(100 - __CURRENT_FADE)+");"
		}
		elem = document.getElementById("imgcasa"+__SWAPPING_IMG_INDEX);
		if(elem)
		{
			elem.style.opacity = (__CURRENT_FADE)/100;
			elem.style.filter = "progid:DXImageTransform.Microsoft.Alpha (style=0, opacity="+(__CURRENT_FADE)+");"
		}
		setTimeout("doSwap()",__SWAP_MILLI);
	}
	else
		__CURRENT_ING_INDEX = __SWAPPING_IMG_INDEX;
}


var __PREV_Y;
var __IS_MOVING_DOWN = false;
var __IS_MOVING = false;
var __START_SCROLL = false;

function setCoords(e)
{
	var tempY;
	if (IE)
		tempY = event.clientY;
	else 
		tempY = e.pageY;
	if(__PREV_Y)
	{
		if(__PREV_Y < tempY)
		{
			__IS_MOVING = true;
			__IS_MOVING_DOWN = true;
		}
		else if(__PREV_Y > tempY)
		{
			__IS_MOVING = true;
			__IS_MOVING_DOWN = false;
		}
	}
	__PREV_Y = tempY;
}

function startScroll()
{
	__START_SCROLL = true;
	scrollIt();
}

function stopScroll()
{
	__START_SCROLL = false;
	__IS_MOVING = false;
}

function startMove()
{
	__IS_MOVING = true;
}

function scrollIt()
{
	var elem = document.getElementById("scrollArea");
	if(elem && __IS_MOVING)
	{
		if(!elem.style.top)
		{
			elem.style.top = 0;
			elem.style.myTop = 0;
		}
		var scrollBy = 0;
		if(!__IS_MOVING_DOWN)
		{
			if(elem.style.myTop > (__MAX_SCROLL_AREA - elem.offsetHeight))
				scrollBy = -10;
		}
		else
		{
			if(elem.style.myTop < 0)
				scrollBy = 10;
		}
		if(scrollBy != 0)
		{
			elem.style.myTop += scrollBy;
			elem.style.top = elem.style.myTop+"px";
		}
	}
}

var IE = document.all?true:false;
if (!IE) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = setCoords;


function searchOverlay()
{
}

function showStanza(id,file) {
    if (jQuery("#divplanimetria").css("display") != "none") {
        if (jQuery("#" + id).length == 0)
            jQuery("#containerPlaniUbi").append("<div id='" + id + "' class='tipoHover'><img src='" + file + "' /></div>")
        else
            jQuery("#" + id).css("display", "block");
    }
}

function hideStanza(id)
{
	if(jQuery("#"+id).length > 0)
		jQuery("#"+id).css("display","none");
}

function playVideo(src)
{
	jQuery(body).append("<div style='text-align: right;'><a href='javascript:void(0)' onclick='hideVideo(this)'>chiudi</a></div><div class='videoPlayer' onclick='close(this)'><OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0' WIDTH='550' HEIGHT='400' id='myMovieName'><PARAM NAME=movie VALUE='"+src+"'><PARAM NAME=quality VALUE=high><PARAM NAME=bgcolor VALUE=#FFFFFF><EMBED href='"+src+"' quality=high bgcolor=#FFFFFF WIDTH='550' HEIGHT='400' NAME='myMovieName' ALIGN='' TYPE='application/x-shockwave-flash' PLUGINSPAGE='http://www.macromedia.com/go/getflashplayer'></EMBED></OBJECT> </div>");
}

function hideVideo(ctrl)
{
	jQuery(ctrl).parent.detach();
}


function GoUbic() {
	if(document.getElementById("divubicazione"))
	    document.getElementById("divubicazione").style.display = 'block';
	if(document.getElementById("divplanimetria"))
    	document.getElementById("divplanimetria").style.display = 'none';
	if(document.getElementById("divabbattibili"))
	    document.getElementById("divabbattibili").style.display = 'none';    
    SetAdd();
}

function GoPlan() {
	if(document.getElementById("divubicazione"))
    	document.getElementById("divubicazione").style.display = 'none';
	if(document.getElementById("divplanimetria"))
    	document.getElementById("divplanimetria").style.display = 'block';
	if(document.getElementById("divabbattibili"))
    	document.getElementById("divabbattibili").style.display = 'none';
}

function GoAbbattibili() {
	if(document.getElementById("divubicazione"))
    	document.getElementById("divubicazione").style.display = 'none';
	if(document.getElementById("divplanimetria"))
    	document.getElementById("divplanimetria").style.display = 'none';
	if(document.getElementById("divabbattibili"))
    	document.getElementById("divabbattibili").style.display = 'block';
}

function setMuro(img, nodeid) {
    var display = jQuery("#imgAbbattibile" + nodeid).css("display");
    if (display == "none") {
        jQuery("#imgAbbattibile" + nodeid).css("display", "block");
        jQuery(img).removeClass("iconaMuroAbbattibileRed");
        jQuery(img).addClass("iconaMuroAbbattibile");
    }
    else {
        jQuery("#imgAbbattibile" + nodeid).css("display", "none");
        jQuery(img).removeClass("iconaMuroAbbattibile");
        jQuery(img).addClass("iconaMuroAbbattibileRed");
    }
}

function printScheda()
{
  GoPlan();
  self.print()
}
