var textarray= new Array();
var catalogImages=new Array();
var catalogImagesPics=new Array();



function ChangePic(imgName,imgFile) {
	document.images[imgName].src=imgFile;
	}

function ShowMenu(divid) {


		if (document.getElementById(divid)){

			if (document.getElementById(divid).innerHTML!="")

				document.getElementById(divid).style.visibility="visible";

		}
	}

function HideMenu(divid) {
		if (document.getElementById(divid))
			document.getElementById(divid).style.visibility="hidden";
	}





var divs=new Array();

function InitialPositioning() {
//alert(navigator.appName);
var picX;
var picY;

//позиция картинки
picX= getForIeX(document.getElementById('menu'));
picY= getForIeY(document.getElementById('menu'));

//alert(picX);
//позиционирование текста в галерее товаров
if(document.getElementById("text0")){
		document.getElementById("text0").style.left=picX-257+"px";
		document.getElementById("text0").style.top=picY-276+"px";
	}
//позиционирование кнопок в галерее товаров
if(document.getElementById("buttons")){
		document.getElementById("buttons").style.left=picX-100+"px";
		document.getElementById("buttons").style.top=picY-70+"px";
	}
//позиция меню 1 уровня
document.getElementById('mainmenu').style.left=picX-97+"px";
document.getElementById('mainmenu').style.top=picY+"px";

	//позиционируем выпадающие меню
	for(var i=0; i<divs.length; i++){
			divWidth=0;

			divWidth=document.getElementById(divs[i]).offsetWidth;

		document.getElementById(divs[i]).style.left=document.getElementById(divs[i]).style.left-divWidth+"px";
	}



	//загружаем первую картинку и первый текст в каталог

	if (textarray.length!=0){
	document.getElementById("text0").innerHTML=	textarray[0][0];
	document.getElementById("catalogimage").src=textarray[0][1];

	}

}

function loadImages(){

	if (catalogImages.length!=0){

		for(i=0; i<catalogImages.length; i++){

			catalogImagesPics[i] = document.createElement("IMG");
			catalogImagesPics[i].src=catalogImages[i];

		}

	}

}

var currentPosition=0;

function changeCatalogImage(val){

		currentPosition=currentPosition+val;
		if (currentPosition<0)
			currentPosition=textarray.length-1;
		if (currentPosition>textarray.length-1)
			currentPosition=0;

	//alert(navigator.userAgent);
		document.getElementById("text0").innerHTML=	textarray[currentPosition][0];
		if (navigator.appName=="Microsoft Internet Explorer" && navigator.userAgent.indexOf("MSIE 7.0")!=-1) //
			catalogimage.filters[0].Apply();
			//DecreaseOpacity(100,0,1);
		document.getElementById("catalogimage").src=textarray[currentPosition][1];
		if (navigator.appName=="Microsoft Internet Explorer" && navigator.userAgent.indexOf("MSIE 7.0")!=-1)//
			catalogimage.filters[0].Play();
			//IncreaseOpacity(0,100,1);
			//alert(navigator.userAgent);

}


function IncreaseOpacity(currentOpacity, finishlevel, step){

			//alert("!!!!");

			document.getElementById('text').filters.alpha.opacity=currentOpacity;

			currentOpacity=currentOpacity+step;

			if (currentOpacity<finishlevel)

				timerID=setTimeout("IncreaseOpacity("+currentOpacity+", "+finishlevel+", "+step+")",20);

			else clearTimeout(timerID);

	}


	function DecreaseOpacity(currentOpacity, finishlevel, step){

			//alert("!!!!");

			document.getElementById('text').filters.alpha.opacity=currentOpacity;

			currentOpacity=currentOpacity-step;

			if (currentOpacity>finishlevel)

				timerID=setTimeout("DecreaseOpacity("+currentOpacity+", "+finishlevel+", "+step+")",20);

			else clearTimeout(timerID);

	}

function getForIeX(El) {
	  var X = 0;

	 do {
		X += El.offsetLeft;

		} while ((El = El.offsetParent) != null);
	  return X;
	}

	function getForIeY(El) {
	  var Y = 0;
	  do { Y += El.offsetTop } while ((El = El.offsetParent) != null);
	  return Y;
	}

function submit(form)
{
	document.forms[form].submit();
}











function popup(name)
{ alert(name);
	document.getElementById(name).style.display='block';
	document.getElementById(name).style.pixelTop=document.body.scrollTop + document.body.clientHeight;
}

function views(url,name)
{
	foto=window.open('/images/view.php?foto='+url+'&name='+name,'foto','width=300,height=300');
	foto.focus();
}
function view(url,name)
{
	foto=window.open('/images/view.php?foto='+url+'&name='+name,'foto','width=300,height=300');
	foto.focus();
}
function view_hist(url,name)
{
	foto=window.open('/images/view2.php?foto='+url+'&name='+name,'foto','width=800,height=600, scrollbars=yes');
	foto.focus();
}
function sub(){
  if (confirm("Вы уверены?")) { document.F.submit; return true; } else { return false;  }
}

function del(ref){
  if (confirm("Вы действительно хотите удалить?")) { document.F.submit; return true; } else { return false;  }
}



function off(mode)
{   /*if (mode!=1)
    {document.getElementById('inv1').style.display='none';}*/
	if (mode!=2)
    {document.getElementById('inv2').style.display='none';}
	if (mode!=3)
    {document.getElementById('inv3').style.display='none';}
	if (mode!=4)
    {document.getElementById('inv4').style.display='none';}
	if (mode!=5)
    {document.getElementById('inv5').style.display='none';}
	if (mode!=6)
    {document.getElementById('inv6').style.display='none';}


}

function on(id)
{  /* if (id!=inv1)
    {document.getElementById('inv1').style.display='none';}*/
	if (id!=2)
    {document.getElementById('inv2').style.display='none';}
	if (id!=3)
    {document.getElementById('inv3').style.display='none';}
	if (id!=4)
    {document.getElementById('inv4').style.display='none';}
	if (id!=5)
    {document.getElementById('inv5').style.display='none';}
	if (id!=6)
    {document.getElementById('inv6').style.display='none';}

	document.getElementById(id).style.display='block';
}





function off_eng(mode)
{   /*if (mode!=1)
    {document.getElementById('inv1').style.display='none';}*/
	if (mode!=2)
    {document.getElementById('inv2').style.display='none';}
	if (mode!=3)
    {document.getElementById('inv3').style.display='none';}
	if (mode!=4)
    {document.getElementById('inv4').style.display='none';}
    if (mode!=5)
    {document.getElementById('inv5').style.display='none';}
	/*if (mode!=3)
    {document.getElementById('invs3').style.display='none';}
	if (mode!=4)
    {document.getElementById('invs4').style.display='none';}
	if (mode!=5)
    {document.getElementById('invs5').style.display='none';}
	if (mode!=6)
    {document.getElementById('invs6').style.display='none';}
			if (mode!=7)
    {document.getElementById('invs7').style.display='none';}*/

}

function on_eng(id)
{  /* if (id!=invs1)
    {document.getElementById('inv1').style.display='none';}*/
	if (id!=2)
    {document.getElementById('inv2').style.display='none';}
	if (id!=3)
    {document.getElementById('inv3').style.display='none';}
	if (id!=4)
    {document.getElementById('inv4').style.display='none';}
    if (id!=5)
    {document.getElementById('inv5').style.display='none';}

	 if (id!=0)
	{document.getElementById(id).style.display='block';}
}

function off_it(mode)
{   /*if (mode!=1)
    {document.getElementById('invs1').style.display='none';}*/
	if (mode!=2)
    {document.getElementById('invs2').style.display='none';}
	if (mode!=3)
    {document.getElementById('invs3').style.display='none';}
	if (mode!=4)
    {document.getElementById('invs4').style.display='none';}
    if (mode!=5)
    {document.getElementById('invs5').style.display='none';}

}

function on_it(id)
{  /* if (id!=invs1)
    {document.getElementById('invs1').style.display='none';}*/
	if (id!=2)
    {document.getElementById('invs2').style.display='none';}
	if (id!=3)
    {document.getElementById('invs3').style.display='none';}
	if (id!=4)
    {document.getElementById('invs4').style.display='none';}
    if (id!=5)
    {document.getElementById('invs5').style.display='none';}

	 if (id!=0)
	{document.getElementById(id).style.display='block';}
}





function windowOpener(windowHeight, windowWidth, windowName, windowUri)
{
var centerWidth=(window.screen.width-windowWidth)/2;
var centerHeight=(window.screen.height-windowHeight)/2;

newWindow=window.open(windowUri, windowName,'fullscreen=0,toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0,width='+windowWidth+',height='+windowHeight);
newWindow.blur();
newWindow.moveTo(centerWidth, centerHeight);
newWindow.focus();
return newWindow.name;
}

function openwin(string,w,h)
 {
  param='width='+w+',height='+h;
  foto=window.open(string,'foto',param);
   }

/*if (document.body.clientWidth < 800) {
document.write('2');
}
else if (document.body.clientWidth  > 1200) {
document.write('222222');
}*/


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 getbrows()
{
	if (navigator.appName == 'Microsoft Internet Explorer'){
	document.getElementById('flajok').style.marginTop = '-327px';
	}
}

 //мигающий текст

  // function flashit()
//{
//if (!document.all)return;
//if (myexample.style.color=="#ff0000")myexample.style.color="#002ba5";
//else myexample.style.color="#ff0000"}setInterval("flashit()", 500)