var NS4DOM = document.layers ? true:false;
var IEDOM = document.all ? true:false;
var W3CDOM = document.getElementById ? true:false;

function getObject (id) 
{
	if (W3CDOM) return document.getElementById(id);
	else if (IEDOM) return document.all[id];
	else if (NS4DOM) return document[id];
	return false;
}

function season_switch (href, season)
{
	var seasons = 'spring;summer;autumn;winter'.split(';');
	getObject('flash').className = 'flash_' + seasons[season];
	
	getObject('summer').className = 'summer';
	getObject('autumn').className = 'autumn';
	getObject('winter').className = 'winter';
	getObject('spring').className = 'spring';
	
	document.cookie = ('season=' + season);

	href.className = href.className + '_active';
	
	return false;
}

function firstpage_switch (action)
{
	if (getObject('news_button')) getObject('news_button').className = getObject('news_button').className.replace (' selected', '');
	getObject('consulting_button').className = getObject('consulting_button').className.replace (' selected', '');
	getObject('objects_button').className = getObject('objects_button').className.replace (' selected', '');
	getObject('about_button').className = getObject('about_button').className.replace (' selected', '');

	getObject(action + '_button').className = getObject(action + '_button').className + ' selected';
	
	if (getObject("fp_content").fleXcroll) 
	{
		getObject("fp_container").innerHTML = getObject(action).innerHTML
		getObject("fp_content").scrollUpdate ();
	}

	return false;
}

function setbigpicture (id, image, zoom)
{
	theComment = '';

	szoomdiv = ''
	if (zoom==1) szoomdiv = '<div class="zoom_icon"><img src="/files/image/design/clear.gif" width="300" height="250" alt=""  onclick="winopen (\'/files/image/objects/' + id + '_2.jpg\', \'width=500,height=0\');" /></div>';
	if (image.title) theComment = '<div class="comment">' + image.title + '</div>';
	getObject('zoomer').innerHTML = '<img src="/files/image/objects/' + id + '_1.jpg" width="300" height="250" alt="" />' + theComment + szoomdiv;
}

function setbigpictureAlt (id, rnd, image, zoom)
{
	theComment = '';

	szoomdiv = ''
	if (zoom==1) {
            szoomdiv = '<div class="zoom_icon" onclick="winopen (\'/img/images/' + id + '_' + rnd + '_super_big.jpg\', \'width=500,height=0\');"><img src="/files/image/design/clear.gif" width="300" height="250" alt="" /></div>';
        }
	if (image.title) theComment = '<div class="comment">' + image.title + '</div>';
	getObject('zoomer').innerHTML = '<img src="/img/images/' + id + '_' + rnd + '_big.jpg" width="300" height="250" alt="" />' + theComment + szoomdiv;
}

function winopen (img, size) 
{
	pic = img;
	picwin = window.open ('', 'picture', 'toolbar=no,scrollbars=no, status=no,titlebar=no,directories=no,resizable=no,menubar=no, hotkeys=no, innerHeight=0, innerWidth=0, outerHeight=0,'+size);
	picwin.onLoad = set_img (picwin, pic);
}	

function set_img (win, pic)  
{
	var i_close = new Image ();
	i_close.src = "/img/ph_close.gif";
	win.document.body.style.backgroundColor = "#FFFFFF";
	win.document.body.style.padding = "0px";
	win.document.body.style.margin = "0px";
	win.document.body.innerHTML = '<div style="text-align: center; background: url(/img/b-01.jpg) fixed;" ><div style="text-align: right; background-color: #999999;"><img src="http://coms.z.office/img/ph_close.gif" width="75" height="22" border="0" alt="Закрыть" id="close" name="close" onclick="window.close ()" /></div><img style="margin: 0px; padding: 0px; border-top: 3px solid #FFFFFF; " src="http://'+location.host+pic+'" onLoad="window.resizeTo (this.width + 10, this.height + 60); window.focus();" id=""picture"" /></div>';
}

function switchThumbs (href, id)
{
	$("dt").each(function() {
		$(this).find("a").removeClass("active");
	})
	href.className = "active";
	if (getObject("thumbnails").fleXcroll) 
	{
		getObject('thumbnails_content').innerHTML = getObject('thumbs' + id).innerHTML;
		getObject('thumbnails').scrollUpdate();
	}
}

moz=document.getElementById&&!document.all
mozHeightOffset=20

function checkBrowserWidth() {
	var theHeight = getBrowserHeight();

	getObject('shadow').style.display = (getBrowserWidth() >= 1030) ? 'block' : 'none';
	getObject('shadow').style.height = (theHeight <= 900) ? '900px' : theHeight + 'px';
	getObject('footer').style.height = (theHeight <= 900) ? '141px' : theHeight - 738 - 21 + 'px';
	getObject('bottom').style.height = (theHeight <= 900) ? '162px' : theHeight - 738 + 'px';

	return true;
}

function getBrowserWidth() {
	if (window.innerWidth) return window.innerWidth;
	else if (document.documentElement && document.documentElement.clientWidth != 0) return document.documentElement.clientWidth;
	else if (document.body) return document.body.clientWidth;
	return 0;
}

function getBrowserHeight() {
	if (window.innerHeight) return window.innerHeight;
	else if (document.documentElement && document.documentElement.clientHeight != 0) return document.documentElement.clientHeight;
	else if (document.body) return document.body.clientHeight;
	return 0;
}

onload = checkBrowserWidth;
onresize = checkBrowserWidth;
