function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function getBodyScrollTop()
{
	return self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop);
}

function getBodyScrollLeft()
{
	return self.pageXOffset || (document.documentElement && document.documentElement.scrollLeft) || (document.body && document.body.scrollLeft);
}

function getClientWidth()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
}

function getClientHeight()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
}

function getClientCenterX()
{
		var arrayPageSize = getPageSize();
		var hei=arrayPageSize[1];
		var wid=document.body.scrollWidth;

	return parseInt(wid/2);
}

function getClientCenterY()
{
		var arrayPageSize = getPageSize();
		var hei=arrayPageSize[1];
		var wid=document.body.scrollWidth;

	return parseInt(hei/2)+getBodyScrollTop();
}


function resetHeight(){
		var arrayPageSize = getPageSize();
			var detect = navigator.userAgent.toLowerCase();
			if(detect.indexOf("opera")==-1)  {
			var pageheight=arrayPageSize[4];
			}
		
		var newh=document.getElementById('allwrap').clientHeight;
		document.getElementById('backgroundLower').style.height="";
		document.getElementById('backgroundLower').style.height=newh+"px";

		document.getElementById('bottom-creative').style.height="";
		document.getElementById('bottom-creative').style.height=newh+"px";

		document.getElementById('bottom-creative-help').style.height="";
		document.getElementById('bottom-creative-help').style.height=newh+"px";

}

function resetNewsHeight(){
//		alert(document.getElementById('right-column-position').clientHeight);
		document.getElementById('threeblocks').style.height="";
		document.getElementById('rightblock').style.height=document.getElementById('right-column-position').clientHeight+"px";
		document.getElementById('rightblock').style.height=document.getElementById('middleblock').clientHeight+"px";

}

function fixHeight(){
		resetNewsHeight();
	
			var arrayPageSize = getPageSize();
			var detect = navigator.userAgent.toLowerCase();

			if(detect.indexOf("opera")==-1)  {
			var pageheight=arrayPageSize[3];
			}

	if(document.getElementById('rightblock').style.display!='none') {


		var dh=document.getElementById('threeblocks').clientHeight;
		var nh=document.getElementById('rightblock').clientHeight;
				document.getElementById('rightblock').style.height="";
				document.getElementById('rightblock').style.height=dh+"px";
	}



		var dataheight=document.getElementById('allwrap').clientHeight;
		if(pageheight<dataheight) { var myh=dataheight+0; } else { var myh=pageheight; }


		document.getElementById('backgroundLower').style.height="";
		document.getElementById('backgroundLower').style.height=myh+"px";

		document.getElementById('bottom-creative').style.height="";
		document.getElementById('bottom-creative').style.height=myh+"px";

		document.getElementById('bottom-creative-help').style.height="";
		document.getElementById('bottom-creative-help').style.height=myh+"px";


}

function setStyles(page){

var newsVisibles=new Array();

newsVisibles['home']=1;
newsVisibles['contacts']=1;
newsVisibles['newsitem']=1;

	if(newsVisibles[page]==1) document.getElementById('rightblock').style.display="block";	 else document.getElementById('rightblock').style.display="none";


	document.getElementById('homemenu').className='menu-element-off';
	document.getElementById('productsmenu').className='menu-element-off';
	document.getElementById('aboutmenu').className='menu-element-off';
	document.getElementById('contactsmenu').className='menu-element-off';

	if(page.indexOf('prod')!=-1 || page=='blackteas' || page=='fitoteas' || page=='greenteas' || page=='leafteas') { 
		var page2='products'; 
	} else var page2=page;

	if(document.getElementById(page2+'menu')) {
		document.getElementById(page2+'menu').className='menu-element-on';
	}

// vars

	var bgImagesHigher=Array();
	var bgImagesLower=Array();
	var bgImagesCreatives=Array();
	var bgImagesCreativesHelp=Array();
	var bgPositionsHigher=Array();
	var bgPositionsLower=Array();
	var bgPositionsCreatives=Array();
	var bgPositionsCreativesHelp=Array();
	var footerPoses=Array();


	bgImagesHigher['home']="img/image-bg-1-home.jpg";
	bgImagesHigher['newsitem']="img/image-bg-1-home.jpg";
	bgImagesHigher['about']="img/image-bg-1-home.jpg";
	bgImagesHigher['contacts']="img/image-bg-1-home.jpg";
	bgImagesHigher['products']="img/image-bg-1-prod.jpg";
	bgImagesHigher['blackteas']="img/image-bg-1-home.jpg";
	bgImagesHigher['fitoteas']="img/image-bg-1-home.jpg";
	bgImagesHigher['leafteas']="img/image-bg-1-home.jpg";
	bgImagesHigher['greenteas']="img/image-bg-1-prod.jpg";

	bgImagesLower['home']="img/newbg/new_lower_home.jpg";
	bgImagesLower['newsitem']="img/newbg/new_lower_home.jpg";
	bgImagesLower['about']="img/newbg/new_lower_home.jpg";
	bgImagesLower['contacts']="img/newbg/new_lower_home.jpg";
	bgImagesLower['products']="img/newbg/new_lower_prod.jpg";
	bgImagesLower['blackteas']="img/newbg/new_lower_home.jpg";
	bgImagesLower['fitoteas']="img/newbg/new_lower_prod_fito.jpg";
	bgImagesLower['leafteas']="img/newbg/new_lower_prod_leaf.jpg";
	bgImagesLower['greenteas']="img/newbg/new_lower_prod_green.jpg";

	bgImagesCreatives['home']="img/bg-creative-run2-home.png";
	bgImagesCreatives['newsitem']="img/bg-creative-run2-home.png";
	bgImagesCreatives['about']="img/bg-creative-run2-home.png";
	bgImagesCreatives['contacts']="img/bg-creative-run2-home.png";
	bgImagesCreatives['products']="img/bg-creative-run2-prod.png";
	bgImagesCreatives['blackteas']="img/bg-creative-run2-prod.png";
	bgImagesCreatives['fitoteas']="img/bg-creative-run2-prod-fito-help.png";
	bgImagesCreatives['leafteas']="img/bg-creative-run2-prod-listovie-help.png";
	bgImagesCreatives['greenteas']="img/bg-creative-run2-prod-zelenie.png";

	bgImagesCreativesHelp['fitoteas']="img/bg-creative-run2-prod-fito.png";
	bgImagesCreativesHelp['leafteas']="img/bg-creative-run2-prod-listovie.png";


	bgPositionsHigher['home']='center top';
	bgPositionsHigher['newsitem']='center top';
	bgPositionsHigher['products']='center top';
	bgPositionsHigher['blackteas']='center top';
	bgPositionsHigher['fitoteas']='center top';
	bgPositionsHigher['leafteas']='center top';
	bgPositionsHigher['greenteas']='center top';
	bgPositionsHigher['about']='center top';
	bgPositionsHigher['contacts']='center top';

	bgPositionsLower['home']='center bottom';
	bgPositionsLower['newsitem']='center bottom';
	bgPositionsLower['products']='center bottom';
	bgPositionsLower['blackteas']='center bottom';
	bgPositionsLower['fitoteas']='center bottom';
	bgPositionsLower['leafteas']='center bottom';
	bgPositionsLower['greenteas']='center bottom';
	bgPositionsLower['about']='center bottom';
	bgPositionsLower['contacts']='center bottom';


	bgPositionsCreatives['home']='center bottom';
	bgPositionsCreatives['newsitem']='center bottom';
	bgPositionsCreatives['products']='center bottom';
	bgPositionsCreatives['blackteas']='center bottom';
	bgPositionsCreatives['fitoteas']='bottom left';
	bgPositionsCreatives['leafteas']='center top';
	bgPositionsCreatives['greenteas']='center bottom';
	bgPositionsCreatives['about']='center bottom';
	bgPositionsCreatives['contacts']='center bottom';

	bgPositionsCreativesHelp['fitoteas']='bottom left';
	bgPositionsCreativesHelp['leafteas']='top center';

	footerPoses['home']=90;
	footerPoses['products']=100;
	footerPoses['fitoteas']=90;
	footerPoses['leafteas']=90;
	footerPoses['greenteas']=100;
	footerPoses['about']=90;
	footerPoses['contacts']=90;

// end of vars

	if(bgImagesHigher[page]) {
        newImage = "url("+bgImagesHigher[page]+")";
        document.getElementById('mainbody').style.backgroundImage = newImage;
	document.getElementById('mainbody').style.backgroundPosition=bgPositionsHigher[page];
	document.getElementById('mainbody').style.backgroundRepeat='no-repeat';
	}

	if(bgImagesLower[page]) {
	newImage = "url("+bgImagesLower[page]+")";
	document.getElementById('backgroundLower').style.backgroundImage = newImage;
	document.getElementById('backgroundLower').style.backgroundPosition=bgPositionsLower[page];
	document.getElementById('backgroundLower').style.backgroundRepeat='no-repeat';
	}


/*
	if(bgImagesCreatives[page]) {
	newImage = "url("+bgImagesCreatives[page]+")";
	document.getElementById('bottom-creative').style.backgroundImage = newImage;
	document.getElementById('bottom-creative').style.backgroundPosition=bgPositionsCreatives[page];
	document.getElementById('bottom-creative').style.backgroundRepeat='no-repeat';
	}
*/


	if(bgImagesCreativesHelp[page]) {
	newImage = "url("+bgImagesCreativesHelp[page]+")";
	document.getElementById('bottom-creative-help').style.backgroundImage = newImage;
	document.getElementById('bottom-creative-help').style.backgroundPosition=bgPositionsCreativesHelp[page];
	document.getElementById('bottom-creative-help').style.backgroundRepeat='no-repeat';
	} else document.getElementById('bottom-creative-help').style.backgroundImage = "";

}


function openArticleLong(num){
	if(document.getElementById('article_'+num)) {
	if(articles[num]==0)
		{
	articles[num]=1;
 	document.getElementById('article_'+num).style.display="block";
		} else closeArticleLong(num);
	}
	fixHeight();
}


function closeArticleLong(num){

	if(document.getElementById('article_'+num)) {
 	document.getElementById('article_'+num).style.display="none";
	articles[num]=0;
	}
}

	function openAssortiment(id){
	 	var obj=document.getElementById("subsel-"+id+"-on");
		var obj2=document.getElementById("subsel-"+id+"-off");
		var data=document.getElementById("subsel-"+id+"-data");

		if(obj) {
		 	obj.style.display="none";
			obj2.style.display="block";
		}

		if(data) {
			data.style.display="block";
		}

		fixHeight();

	}

	function closeAssortiment(id){
	 	var obj=document.getElementById("subsel-"+id+"-on");
		var obj2=document.getElementById("subsel-"+id+"-off");
		var data=document.getElementById("subsel-"+id+"-data");

		if(obj) {

		 	obj.style.display="block";
			obj2.style.display="none";
		}

		if(data) {
			data.style.display="none";
		}

		fixHeight();
	}


	function openVideo(){


		var width=532;
		var height=389;
		var arrayPageSize = getPageSize();
		var hei=arrayPageSize[1];
		var wid=screenSize().w;   //document.body.scrollWidth;

		var half_width=width/2;
		var half_height=height/2;

		document.getElementById('shaded').style.height=hei+"px";
		document.getElementById('shaded').style.width=wid+"px";

		var tp=(screenSize().h/2)-half_height;

		document.getElementById('infoiframe_div').style.top=tp+"px";
		document.getElementById('infoiframe_div').style.left=((screenSize().w/2)-half_width)+"px";

		document.getElementById('infoiframe_div').style.width=width+"px";
		document.getElementById('infoiframe_div').style.height=height+"px";

		document.getElementById('shaded').className="shaded_vis";

		document.getElementById('infoiframe_div').className='infoiframe_visible';
	}


function screenSize() {
    var w, h; // Объявляем переменные, w - длина, h - высота
    w = (window.innerWidth ? window.innerWidth : (document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.offsetWidth));
    h = (window.innerHeight ? window.innerHeight : (document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.offsetHeight));
    return {w:w, h:h}; 
}


	function closepopup()
		{
			killsound();
			document.getElementById('shaded').className="shaded_hid";
			document.getElementById('infoiframe_div').className="infoiframe_hidden";

		}



function killsound() {
               var ie = navigator.appName.indexOf("Microsoft") != -1;
		if(document.getElementById('video'))
	               var flashAudioPlayer = document.getElementById('video');

//               flashAudioPlayer = (ie) ? parent.frames[0]['video'] : parent.frames[0].document.getElementById('video');

		if(flashAudioPlayer)
	               flashAudioPlayer.toPause();
          }


