function coords_gcenter_margin(Id,From)
{
	WidthFrom = document.getElementById(From).offsetWidth;
	WidthId = document.getElementById(Id).offsetWidth;
	
	Result = Number(WidthFrom) - Number(WidthId);
	
	Result = Result/2;

	document.getElementById(Id).style.marginLeft = Result + "px";

}
function bottom_it(Id)
{
	if(document.getElementById("addrealty"))
	{
	if(document.getElementById("addrealty").style.marginLeft > 0)
		document.getElementById("footer").style.marginTop = '300px';
	}

}
function normal_it(Id)
{

	document.getElementById("footer").style.marginTop = '-100px';

}
function position($Type,$Object)
{
	if(!Object) return false;
	$Left=$Object.offsetLeft;
    $Top=$Object.offsetTop;

    for (var parent = $Object.offsetParent; parent; parent = parent.offsetParent)
    {
        $Left += parent.offsetLeft;
        $Top += parent.offsetTop;
    }

    if($Type=="Left")	return $Left;
    if($Type=="Top") return $Top;
}

function locateit($Container,$Left,$Top)
{

	if($Top) $Container.style.marginTop=$Top+"px";
    if($Left)
    {
    	$Container.style.marginLeft=$Left+"px";
    }
}



function widthmaker()
{
	$Width=document.getElementById("body").offsetWidth;
	
	$Width2=$Width*(25/100);
	$Width=$Width*(35/100);

	if(document.getElementById("widthmaker")) document.getElementById("widthmaker").style.width=$Width+"px";
	if(document.getElementById("widthmaker2")) document.getElementById("widthmaker2").style.width=$Width2+"px";
}

function coords_xCenter(coordsInput_Id)
{
	objectWidth = document.getElementById(coordsInput_Id).style.width;
	bodyWidth = document.getElementById("body").offsetWidth;

	if(objectWidth.match('%'))
	{
		objectWidth = Number(objectWidth.replace('%',""));
		objectWidth = bodyWidth * (objectWidth / 100);
	}
	else
	{
		objectWidth = objectWidth.replace("px","");
	}
		
	x = Math.round((bodyWidth - objectWidth) / 2);
	
	return x + ";" + objectWidth + ";" + bodyWidth;
}

function center(Id,From)
{
	
	if(From!="body")
	{
		if(!document.getElementById(From)) return false;
		var Obj = document.getElementById(From);
		var Left = position("Left",Obj);
		var Top = position("Top",Obj);
		document.getElementById(Id).style.top = Top + "px";
		document.getElementById(Id).style.left = Left + "px";
	}
	
	centerTop(Id,From);	
	centerLeft(Id,From);


	
}
center_correct_cLeft=0;
center_correct_cTop=0;

function center_correct(Id,From,cLeft,cTop)
{
	center_correct_cLeft=cLeft;
	center_correct_cTop=cTop;
	centerTop(Id,From);	
	centerLeft(Id,From);
	center_correct_cLeft=0;
	center_correct_cTop=0;	
}

function centerTop(Id,From)
{
	var scrtop = 0;
	if(From!="body")
	{
		HeighthFrom = document.getElementById(From).offsetHeight;
		HeightId = document.getElementById(Id).offsetHeight;
		HeighthFrom = HeighthFrom - HeightId;
		HeighthFrom = Number(HeighthFrom)/2;
		document.getElementById(Id).style.marginTop = HeighthFrom + "px";
		return 1;
	}
	else
	{
		HeighthFrom = getWindowHeight();
		HeighthFrom = Number(HeighthFrom);
	
		scrtop=document.documentElement.scrollTop;
	}
	
	if(scrtop=="0") 
		scrtop=document.body.scrollTop;

	
	HeighthFrom = HeighthFrom /2;
	
	if(document.getElementById(Id))
	HeightId = document.getElementById(Id).offsetHeight;
	else HeightId = 0;
	HeightId = HeightId /2;

	
	HResult = Number(HeighthFrom) - Number(HeightId);
	scrtop = getScrollXY();
	
	if(From=="body")
	{
		Itog = HResult + scrtop;
		Itog=Itog+center_correct_cTop
		if(Itog <20) Itog = 20 + scrtop;
	}
	Itog = Itog;
	if(document.getElementById(Id))
	document.getElementById(Id).style.marginTop = Itog + "px";	
}


function centerLeft(Id,From)
{
	WidthFrom = document.getElementById(From).offsetWidth;

	if(document.getElementById(Id))
	WidthId = document.getElementById(Id).offsetWidth;
	else WidthId = 0;

	
	Result = Number(WidthFrom) - Number(WidthId);

	
	Result = Result/2;

	Result=Result+center_correct_cLeft
	if(document.getElementById(Id))
	document.getElementById(Id).style.marginLeft = Result + "px";	

}

function getWindowHeight()
{
	 var windowHeight = 0;
	 if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	 }
	 else {
		if (document.documentElement && document.documentElement.clientHeight) {
		   windowHeight = document.documentElement.clientHeight;
		}
		else {
		   if (document.body && document.body.clientHeight) {
			  windowHeight = document.body.clientHeight;
		   }
		}
	 }
	 return windowHeight;
  }
  
  
function getPosition(e) {
    e = e || window.event;
    var cursor = {x:0, y:0};
    if (e.pageX || e.pageY) {
        cursor.x = e.pageX;
        cursor.y = e.pageY;
    } 
    else {
        var de = document.documentElement;
        var b = document.body;
        cursor.x = e.clientX + 
            (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
        cursor.y = e.clientY + 
            (de.scrollTop || b.scrollTop) - (de.clientTop || 0);
    }
	
    return cursor;
}
  
function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return scrOfY;
} 
  
smoothScroll={}

smoothScroll.Top = 0;
smoothScroll.TopStart = 0;
smoothScroll.TopStart2 = 0;
smoothScroll.Speed = 1;
smoothScroll.toObject=function(Object)
{
	Object = document.getElementById(Object);
	smoothScroll.Top = position("Top",Object);
	
	smoothScroll.TopStart = getScrollXY();
	smoothScroll.TopStart2 = smoothScroll.TopStart;
	
	smoothScroll.Scrolling();
	
}

smoothScroll.Scrolling = function()
{
	smoothScroll.Speed=smoothScroll.Speed+5;
	if(smoothScroll.TopStart<smoothScroll.Top)
	{
		smoothScroll.TopStart2=smoothScroll.TopStart2+smoothScroll.Speed;
		if(smoothScroll.TopStart2>smoothScroll.Top)
		{	
			smoothScroll.Speed =1;
			smoothScroll.TopStart2=0;
			window.scrollTo( 0, smoothScroll.Top);
			onscrollcontroller();
			return false;
		}		
	}
	else
	{
		smoothScroll.TopStart2=smoothScroll.TopStart2-smoothScroll.Speed;
		if(smoothScroll.TopStart2<smoothScroll.Top)
		{	
			smoothScroll.Speed =1;
			smoothScroll.TopStart2=0;
			window.scrollTo( 0, smoothScroll.Top);
			onscrollcontroller();
			return false;
		}		
	}

	
    window.scrollTo( 0, smoothScroll.TopStart2);
	setTimeout("smoothScroll.Scrolling();","2");
}


function TopScreen(Id)
{
	var ScrollTop = getScrollXY();
	if(document.getElementById(Id))
	document.getElementById(Id).style.marginTop = ScrollTop+"px";
}


function BottomScreen(Id)
{
	var ScrollTop = getScrollXY();
	var ScreenHeight = getWindowHeight();
	
	Result = ScreenHeight=(ScreenHeight-46)+Number(ScrollTop);
	if(document.getElementById(Id))
	document.getElementById(Id).style.marginTop = ScreenHeight+"px";
}


function black_cover_show(Status)
{
	if(Status == "1")
	{

		var bHeight = getWindowHeight();
		bHeight = bHeight + document.getElementById("Content").offsetHeight;
		bHeight = Number(bHeight) + document.getElementById("body").offsetHeight;
		
		document.getElementById("black_cover").style.height = Number(bHeight) +20 + "px";			
		document.getElementById("black_cover").style.display = "block";
	}
	else if(Status =="0")
		document.getElementById("black_cover").style.display = "none";
		
}// In "Global Works" Section functions for all: days, months, years.


