function dCA(num)
{
	var d=document.getElementById('d'+num);
	var t=document.getElementById('t'+num);
	var a=document.getElementById('a'+num);
	var l=document.getElementById('l'+num);
	var m=document.getElementById('m'+num);
	
	var current=document.getElementById('current-object');
	
	t.className='';
	m.className='';
	a.className='object2';
	l.style.display='none';
	
	current.value='';
}

function CA(num)
{
	var d=document.getElementById('d'+num);
	var t=document.getElementById('t'+num);
	var a=document.getElementById('a'+num);
	var l=document.getElementById('l'+num);
	var m=document.getElementById('m'+num);
	
	var current=document.getElementById('current-object');
	
	if(current.value!='')
	{
		document.getElementById('t'+current.value).className='';
		document.getElementById('m'+current.value).className='';
		document.getElementById('a'+current.value).className='object2';
		document.getElementById('l'+current.value).style.display='none';
	}
	
	t.className='act';
	m.className='act';
	a.className='object2-act';
	l.style.display='block';
	
	current.value=num;
}

function Init()
{
	if(window.addEventListener) 
	{
		window.addEventListener('resize', ReplacePhoto, false);
		window.addEventListener('resize', PositionShadow, false);
	} 
	else if (window.attachEvent) 
	{
		window.attachEvent('onresize', ReplacePhoto);
		window.attachEvent('onresize', PositionShadow);
	}
}

function ReplacePhoto()
{
	if(document.getElementById('photo-is-active') && document.getElementById('photo-is-active').value!=0)
	{
		PositionPhoto();
	}
}

function HeightObj()
{
	var height=parseFloat(document.getElementById('photo-td').style.height.substr(0,3));
	var w=document.getElementById('photo-width').value;
	var h=document.getElementById('photo-height').value;
	var nn=document.getElementById('photo-is-active').value;

	if(height < h - 100)
	{
		document.getElementById('photo-td').style.height=height + 100;
	}
	else
	{
		if(height >= h - 100 && height < h - 10)
		{
			document.getElementById('photo-td').style.height=height + 10;
		}
		else
		{
			if(height >= h - 10 && height <= h)
			{
				document.getElementById('photo-td').style.height=height + 1;
			}
		}
	}

	if(height!=h) setTimeout('HeightObj()', 0.5);
	
	if(height==h)
	{
		document.getElementById('photo-td').innerHTML=document.getElementById('img'+nn).innerHTML;
		//document.getElementById('img'+nn).innerHTML='';
	}
}

function WidthObj()
{
	var width=parseFloat(document.getElementById('photo-td').style.width.substr(0,3));
	var w=document.getElementById('photo-width').value;
	var h=document.getElementById('photo-height').value;

	if(width < w - 100)
	{
		document.getElementById('photo-td').style.width=width + 100;
	}
	else
	{
		if(width >= w - 100 && width <= w - 10)
		{
			document.getElementById('photo-td').style.width=width + 10;
		}
		else
		{
			if(width >= w - 10 && width <= w)
			{
				document.getElementById('photo-td').style.width=width + 1;
			}
		}
	}

	if(width!=w) setTimeout('WidthObj()', 0.5);

	if(width==w) HeightObj();
}

function PositionPhoto()
{
	var x=(window.innerWidth)?window.innerWidth:((document.all)?document.body.offsetWidth:null);
	var y=(window.innerHeight)?window.innerHeight:((document.all)?document.body.offsetHeight:null);
	
	var w=document.getElementById('photo-width').value;
	var h=document.getElementById('photo-height').value;

	PositionShadow();
	
	document.getElementById('photo').style.top=document.body.scrollTop + ((y / 2) - h / 2 - 10);
	document.getElementById('photo').style.left=x / 2 - w / 2 - 30;
	document.getElementById('photo').style.display='block';
}

function ShowBigPhoto(w,h,nn)
{
	document.getElementById('photo-is-active').value=nn;
	document.getElementById('photo-width').value=w;
	document.getElementById('photo-height').value=h;

	document.getElementById('shadow').style.display='block';
	PositionPhoto();

	document.getElementById('photo-td').style.width=0;
	document.getElementById('photo-td').style.height=100;
	
	if(document.getElementById('type')) document.getElementById('type').style.display='none';

	WidthObj();
}

function CloseBigPhoto(nn)
{
	document.getElementById('shadow').style.display='none';
	document.getElementById('photo-is-active').value=0;		
	document.getElementById('photo-width').value=0;
	document.getElementById('photo-height').value=0;
	
	document.getElementById('photo').style.top=0;
	document.getElementById('photo').style.left=0;
	document.getElementById('photo').style.display='none';

	document.getElementById('photo-td').style.width='0px';
	document.getElementById('photo-td').style.height='0px';

	document.getElementById('img'+nn).innerHTML=document.getElementById('photo-td').innerHTML;
	document.getElementById('photo-td').innerHTML='';
	
	if(document.getElementById('type')) document.getElementById('type').style.display='block';
	
}

function pngdisplay(image, width, height, cl) 
{
	if(navigator.appName=='Microsoft Internet Explorer') 
	{ 
		document.write('<img src="images/empty.gif" style="width: ' + width + '; height: ' + height + '; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=' + image + ', sizingMethod=scale)" class="' + cl + '">');
	} 
	else 
	{
		document.write('<img src="' + image + '" style="width: ' + width + '; height: ' + height + ';" class="' + cl + '">');
	}
}

var div_delta=798;

function Buttons(param)
{
	if(param==1)
	{
		document.getElementById("nextbtn").disabled=true;
		document.getElementById("prevbtn").disabled=true;
	}

	if(param==0)
	{
		document.getElementById("nextbtn").disabled=false;
		document.getElementById("prevbtn").disabled=false;
	}
}

function RollStage(direction)
{
	var stage=document.getElementById("stage");
	var current_stage=document.getElementById("current-stage");	
	var current_stage_value=parseFloat(current_stage.value);

	if(direction==1 && current_stage_value!=2)
	{
		Buttons(1);

		ScrollStage(current_stage_value, direction, 100);
	}

	if(direction==1 && (current_stage_value + 1==2 || current_stage_value==2)) document.getElementById("nextbtn").src=p22.src;
	else document.getElementById("nextbtn").src=p2.src;
	
	if(direction==-1 && current_stage_value!=0) 
	{
		Buttons(1);
		
		ScrollStage(current_stage_value, direction, 100);
	}
	
	if(direction==-1 && (current_stage_value - 1==0 || current_stage_value==0)) document.getElementById("prevbtn").src=p11.src;
	else document.getElementById("prevbtn").src=p1.src;
}

function RollStageGesko(direction)
{
	var stage=document.getElementById("stage");
	var currentstage=document.getElementById("current-stage");
	
	if(currentstage)
	{
		var current_stage_value=parseFloat(currentstage.value);

		if(direction==1 && current_stage_value!=3)
		{
			stage.innerHTML=document.getElementById('st'+ (current_stage_value+1)).innerHTML;
			currentstage.value=current_stage_value+1;
		}
	
		if(direction==1 && (current_stage_value + 1==3 || current_stage_value==3)) document.getElementById("nextbtn").src=p22.src;
		else document.getElementById("nextbtn").src=p2.src;
	
		if(direction==-1 && current_stage_value!=1) 
		{
			stage.innerHTML=document.getElementById('st'+ (current_stage_value-1)).innerHTML;
			currentstage.value=current_stage_value-1;
		}
		
		if(direction==-1 && (current_stage_value - 1==1 || current_stage_value==1)) document.getElementById("prevbtn").src=p11.src;
		else document.getElementById("prevbtn").src=p1.src;
	}
}

function ScrollStage(current_stage_value, direction, delta)
{
	var stage=document.getElementById("stage");
	var d_l=div_delta * (current_stage_value + direction);
	var d_f=div_delta * (current_stage_value + direction);

	stage.scrollLeft=stage.scrollLeft + (delta * direction);	

	var scl=stage.scrollLeft;	

	if(direction==1)
	{
		if(scl < d_l - 100)
		{
			setTimeout("ScrollStage("+current_stage_value+", "+direction+", 100);", 50);
		}
		else
		{
			if(scl < d_l - 10)
			{
				setTimeout("ScrollStage("+current_stage_value+", "+direction+", 10);", 1);
			}
			else
			{
				if(scl!=d_l)
				{
					setTimeout("ScrollStage("+current_stage_value+", "+direction+", 1);", 1);
				}
				else
				{
					var current_stage=document.getElementById("current-stage");	
					var current_stage_value=parseFloat(current_stage.value);

					current_stage.value=current_stage_value+1;
					
					Buttons(0);
				}
			}
		}
	}

	if(direction==-1)
	{
		if(scl > d_l + 100)
		{
			setTimeout("ScrollStage("+current_stage_value+", "+direction+", 100);", 50);
		}
		else
		{
			if(scl > d_l + 10)
			{
				setTimeout("ScrollStage("+current_stage_value+", "+direction+", 10);", 1);
			}
			else
			{
				if(scl!=d_f)
				{
					setTimeout("ScrollStage("+current_stage_value+", "+direction+", 1);", 1);
				}
				else
				{
					var current_stage=document.getElementById("current-stage");	
					var current_stage_value=parseFloat(current_stage.value);

					current_stage.value=current_stage_value - 1;
					
					Buttons(0);
				}
			}
		}
	}	
}

function ShowArenda(obj)
{
	var o=document.getElementById('h'+obj);
	var current=document.getElementById('current-object');
	
	if(current.value!='') document.getElementById('h'+current.value).style.display='none';
	
	if(current.value!=obj)
	{
		o.style.display='block';
		current.value=obj;
	}
	else current.value='';
}

function ShowArenda2(obj)
{
	var o=document.getElementById(obj);
	
	if(o.style.display=='block') o.style.display='none';
	else o.style.display='block';
}

var map;
var rg;
var cg;
var marker;

function ShowGoogle(param)
{
	document.getElementById('shadow').style.display='block';
	PositionShadow();

	var x=parseFloat((window.innerWidth)?window.innerWidth:((document.all)?document.body.offsetWidth:null))- 20;

	document.getElementById('google').style.width=x;
	document.getElementById('google').style.display='block';
	EjectMap(param);
}

function EjectMap(param)
{
	var h=-1;
	var height=parseFloat(document.getElementById('google').style.top);

	if(height < h - 100)
	{
		document.getElementById('google').style.top=height + 100;
	}
	else
	{
		if(height >= h - 100 && height <= h - 10)
		{
			document.getElementById('google').style.top=height + 10;
		}
		else
		{
			if(height >= h - 10 && height <= h)
			{
				document.getElementById('google').style.top=height + 1;
			}
		}
	}

	if(height!=h) setTimeout('EjectMap('+param+')', 1);
	
	if(height==h)
	{
		load2();
	}
}

function HideGoogle2()
{
	document.getElementById('shadow').style.display='none';
	unEjectMap();
}

function unEjectMap()
{
	var h=-431;
	var height=parseFloat(document.getElementById('google').style.top);

	if(height >= h + 100)
	{
		document.getElementById('google').style.top=height - 100;
	}
	else
	{
		if(height >= h + 10)
		{
			document.getElementById('google').style.top=height - 10;
		}
		else
		{
			if(height >= h)
			{
				document.getElementById('google').style.top=height - 1;
			}
		}
	}

	if(height!=h) setTimeout('unEjectMap()', 1);

	if(height==h)
	{
		document.getElementById('google').style.display='none';
		GUnload();
	}
}

function load2() 
{
	if(GBrowserIsCompatible())
	{
		if(document.getElementById('map'))
		{
			map=new GMap2(document.getElementById('map'));
		
			map.setCenter(new GLatLng(lat,lng), zoom);
			map.enableScrollWheelZoom();
			map.addControl(new GSmallMapControl());
			//map.addControl(new GMapTypeControl());
			map.disableDoubleClickZoom();

			PlaceMarker(lat,lng,'');
		}
	}
} 

function PlaceMarker(lat,lng,point)
{
	if(point!='')
	{
		lat=point.lat();
		lng=point.lng();
	}
	
	map.clearOverlays();
	map.addOverlay(new GMarker(new GLatLng(lat,lng)));
	map.panTo(new GLatLng(lat,lng));
	
	if(document.getElementById('lat-temp')) document.getElementById('lat-temp').value=lat;
	if(document.getElementById('lng-temp')) document.getElementById('lng-temp').value=lng;
	if(document.getElementById('lat-sp')) document.getElementById('lat-sp').innerHTML=lat;
	if(document.getElementById('lng-sp')) document.getElementById('lng-sp').innerHTML=lng;
	if(document.getElementById('zoom-temp')) document.getElementById('zoom-temp').value=map.getZoom();
}

function PositionShadow()
{
	if(document.getElementById('shadow') && document.getElementById('shadow').style.display=='block')
	{
		var arrayPageSize=getPageSize();

		document.getElementById('shadow').style.height=arrayPageSize[1];
		document.getElementById('shadow').style.width=arrayPageSize[0];
	}
}

function getPageSize()
{
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) 
	{	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} 
	else if (document.body.scrollHeight > document.body.offsetHeight)
	{ 
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} 
	else 
	{ 
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	
	if (self.innerHeight) 
	{	
		if(document.documentElement.clientWidth)
		{
			windowWidth = document.documentElement.clientWidth; 
		} 
		else 
		{
			windowWidth = self.innerWidth;
		}
		
		windowHeight = self.innerHeight;
	} 
	else if (document.documentElement && document.documentElement.clientHeight) 
	{ 
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} 
	else if (document.body) 
	{ 
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	if(yScroll < windowHeight)
	{
		pageHeight = windowHeight;
	} 
	else 
	{ 
		pageHeight = yScroll;
	}

	if(xScroll < windowWidth)
	{	
		pageWidth = xScroll;		
	} 
	else 
	{
		pageWidth = windowWidth;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 

	return arrayPageSize;
}