var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
var singleInterFlag=0;
var singleInterShowed=0;
var singleButtonShowed=0;
var singlaArray=[];
var singlaPointer=1;
var singlaMax=1;
var canshow=0;
var sss=document.location.href;
var totplit=0;
var stukflag=0;
var plitid=[];
var staticTip=0;
var ntercount=0;
var notntercount=0;




var mouseX, mouseY;
	myns4 = (document.layers)? true:false
	myie4 = (document.all)? true:false
	if (myns4) {document.captureEvents(Event.MOUSEMOVE);}
	document.onmousemove=mousemove;
function mousemove(e) {
	if (myns4) {mouseX=e.pageX;mouseY=e.pageY}
	if (myie4) {mouseX=event.x;mouseY=event.y}
}

function bigMe(targ,bigurl,smallurl){
}

function smallMe(targ,bigurl,smallurl){
}


function setTop(loc){
	//надо сделать #top в конце, причём тока один
	if(loc.indexOf('#')>0){
		loc=loc.substring(0,loc.indexOf('#'));
	}
	loc=''+loc+'#top';
//	alert(loc);
	return loc;
}

// rub, hormenu_recall,  - три обьекта сцуконах..

function rubFUCK09fs_DoFSCommand(command, args) {
  var rubFUCK09fsObj = InternetExplorer ? rubFUCK09fs : document.rubFUCK09fs;
//  alert("function call = opening " add sss);
  if(command=="getInter"){
	  si(args); //срабатывает
  }else{
	  window.document.rubFUCK09fs.SetVariable("curURL",sss);
  }
}

function si(intr){
  if(typeof(interoHere)!='undefined'){
     if((intr!='')&&(intr!='#')){
	  window.document.intero1.SetVariable('urulli',intr);
     }
  }
}

if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && 
        navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<SCRIPT LANGUAGE=VBScript\> \n');
	document.write('on error resume next \n');
	document.write('Sub rubFUCK09fs_FSCommand(ByVal command, ByVal args)\n');
	document.write('  call rubFUCK09fs_DoFSCommand(command, args)\n');
	document.write('end sub\n');
	document.write('</SCRIPT\> \n');
}

function starta(){ 
  //сообщаем верхушке, где мы находимся..
  //  var hormenu_recallObj = InternetExplorer ? hormenu_recall : document.hormenu_recall;
  //  window.document.hormenu_recall.SetVariable('urla',sss);
}



function myChangaInta(){
	singlaPointer--;
	if(singlaPointer==0)singlaPointer=singlaMax;
	document.getElementById('singlaInter').src=singlaArray[singlaPointer];
	document.getElementById('changIntP').src='/images/spacer.gif';
	document.getElementById('changIntP').src='/tpl/clocks.gif';
	setTimeout('myChangaInta()',6000);
}

function myChangaInta000(){
	singlaPointer--;
	if(singlaPointer==0)singlaPointer=singlaMax;
	document.getElementById('singlaInter').src=singlaArray[singlaPointer];
	document.getElementById('changIntP').src='/images/spacer.gif';
	document.getElementById('changIntP').src='/tpl/clocks.gif';
	//setTimeout('myChangaInta()',6000);
}



function checkperenoso(typo){
	if(masscountero==typo){
	}else{
		document.write('</div><div style="clear:left">');//перенос 
		masscountero=typo; 
	}
}




function showOne(myWx,myWy,myName,myMinPic,myBigPic,myType,myParent,myHref){
	myWx=myWx/10;
	myWy=myWy/10;
	//вычисляем высоту изображения
	var imgHo=0;
	var imgWo=0;
	if(myWx*myWy){
		//всё ненулевое - пробуем напрямую зарядить размеры исходя из пропорции 33=100
		imgWo=120*myWx/33;
		imgHo=120*myWy/33;
	}
	if(myWx==44){
		imgWo=160;
	}
	if(myWx==33.3){
		imgWo=120;
	}
	if(myWx==33){
		imgWo=120;
	}
	if(myWx==30){
		imgWo=108;
	}
	if(myWx==25){
		imgWo=90;
	}
	if(myWx==20){
		imgWo=72;
	}
	if(myWx==11){
		imgWo=40;
	}
	if(myWx==10){
		imgWo=36;
	}

	//высота вычисляется после ширины
	if(myWy==44){
		imgHo=160;
	}
	if(myWy==33.3){
		imgHo=120;
	}
	if(myWy==33){
		imgHo=120;
	}
	if(myWy==30){
		imgHo=108;
	}
	if(myWy==25){
		imgHo=90;
	}
	if(myWy==20){
		imgHo=72;
	}
	if(myWy==11){
		imgHo=40;
	}
	if(myWy==10){
		imgHo=36;
	}
	if(myWy==7){
		imgHo=25;
	}
	if(myWy==5){
		imgHo=18;
	}
	if(myWy==3){
		imgHo=11;
	}
	//допущения для специальных размеров...внутри разных коллекций разные размеры.
	if(imgHo*imgWo){
		singleInterShowed=1;
		//оба ненулевые... ставим их.
		document.write('<img src="'+myMinPic+'" alt="керамическая плитка - '+myType+' '+myName+'" width='+imgWo+' height='+imgHo+'>');
		//document.write('<br>'+imgWo+'px*'+imgHo+'px ');
	}else if(imgHo*imgWo){
		singleInterShowed=1;
		//оба размера ненулевые - ВОЗМОЖНО ЭТО И НЕ ПЛИТКА ВОВОСЕ!
		document.write('<div style="clear:left"></div><img style="border:1px solid #ffffff" src="'+myMinPic+'" alt="'+myName+'">');
	}else if(imgHo){
//		alert('нет ширины '+imgWo);
	}else if(imgWo){
//		alert('нет высоты');
	}else{
		//оба размера нулевые - ВОЗМОЖНО ЭТО И НЕ ПЛИТКА ВОВОСЕ!
		if(singleInterFlag){
			// ещё один интерьер. 
			// надо его сохранить в массив.
			singlaPointer++;
			singlaMax=singlaPointer;
			singlaArray[singlaPointer]=''+myMinPic;	
		}else{
			singleInterFlag=1;
			document.write('<img id="singlaInter" src="'+myMinPic+'" alt="'+myName+'" width=200 height=286>');
			if(location.href.indexOf('look')>0){
				// при поиске выдаются не один интерьер а все..
				singleInterFlag=0;
			}else{
				document.write('<br><a style="cursor:pointer" onClick="myChangaInta000();"><img src="/tpl/clocks.gif" name="changIntP" id="changIntP" border=0 style="border:0px" title="сменить интерьер" style="margin-top:-310px;margin-left:200px"></a>');
			}
			singlaArray[singlaPointer]=''+myMinPic;
			setTimeout('myChangaInta()',6000);
		}
	}

	if((myType.indexOf("рдюр")>0)||(myType.indexOf("екор")>0)||(myType.indexOf("анно")>0)||(myType.indexOf("авка")>0)||(myType.indexOf("андаш")>0)){
		stukflag=1;	
	}else{
		stukflag=0;
	}
}

function about(myid,myalias){
      window.open('/plitka/'+myalias+'/'+myid+'.html', '', 'scrollbars, resizable, width=720, height=550');
}


function newContent(link,target,stringo) {

	// link - URL адрес подгружаемой страницы
	// target - DIV в который мы подгружаем контент
	
	var contaner = document.getElementById(target);
	contaner.innerHTML = 'Загрузка ...';

	var resource = getRequest();
	if(resource){
		resource.open('post', link);
		resource.onreadystatechange = function (){
			// Получаем значение, указывающее текущее состояние элемента управления
			if(resource.readyState == 4){
				contaner.innerHTML = resource.responseText;
				//видимо это успех.. требуется jquery прохуячить..
			}
		}
		resource.send(null);
	}else{
		document.location = link;
	}
}




function newContent1(link,target,stringo) {
	// link - URL адрес подгружаемой страницы
	// target - DIV в который мы подгружаем контент
	var contaner = document.getElementById(target);
	contaner.innerHTML = 'Загрузка ...';
	var resource = getRequest();
	if(resource){
		resource.open('post', link);
		resource.onreadystatechange = function (){
			// Получаем значение, указывающее текущее состояние элемента управления
			if(resource.readyState == 4){
				contaner.innerHTML = resource.responseText;
				//видимо это успех.. требуется jquery прохуячить..
				jQuery(function() {jQuery("#tree").treeview({collapsed: true,animated: "fast",control:"#sidetreecontrol",persist: "location"});});
				document.getElementById('rubru').style.display='block';
			}
		}
		resource.send(null);
	}else{
		document.location = link;
	}
}



/* Функция для получения метода для работы с браузерами */

function getRequest(){
	try{return new XMLHttpRequest()}
	catch(e){
		try{return new ActiveXObject('Msxml2.XMLHTTP')}
		catch(e){
			try{return new ActiveXObject('Microsoft.XMLHTTP')}
			catch(e){return null;};
		}
	}
}

// это было в начале main.html

function tima(){
	if(timaflag){				
		hrtest.className = 'men';
		hrtest=0;
	}
}
timaflag=1;
hrtesto=0;
hrtest=0;
//возвращает все свойства объекта  
	
function showProperties(obj) 
{
  var result = "";
  for (var i in obj) {result += i + " = " + obj[i] + "\n";}
  return result;
}


function anchorecheck(){
  var s=''+location.href;
  if(s.indexOf('#')>0){
    // если к анкору допусано чёта - показываем фильтры. 
    // alert('показываем фильтры');
    document.getElementById("filterbut").style.display="none";
    document.getElementById("rubut1").style.display="block";
    document.getElementById("rubut2").style.display="block";
    document.getElementById("botfiltro").style.display="block";
    document.getElementById("filterform").style.display="block";
    document.getElementById("rubru").style.display="none";
  }else{
    // если к анкору ничего не дописано - показываем рубрикатор.
    // alert('показываем рубрикатор');
    document.getElementById('botfiltro').style.display='none';
    document.getElementById('filterbut').style.display='block';
    document.getElementById('filterform').style.display='none';
    document.getElementById('rubut1').style.display='none';
    document.getElementById('rubut2').style.display='none';
    document.getElementById('rubru').style.display='none';
    // если мы на заглавной странице - показываем рубрикатор не сразу..
    if((s=='http://all-tile.ru')||(s=='http://www.all-tile.ru')||(s=='http://all-tile.ru/')||(s=='http://www.all-tile.ru/')){
	    setTimeout("newContent1('/JQueryRubric.php','rubradiva','')",1000);
    }else{
	    newContent1('/JQueryRubric.php','rubradiva','');
    }
    //
  }
}

$(document).ready(function(){
    $(".lightbox").lightbox({
      fitToScreen: true,
      imageClickClose: false,
	  navBarSlideSpeed: 200,
	  resizeSpeed: 200,
	  fileLoadingImage: '/lightbox/images/loading.gif',
      fileBottomNavCloseImage: '/lightbox/images/closelabel.gif',
      strings:{
        prevLinkTitle: 'Предыдущий рисунок',
        nextLinkTitle: 'Следующий рисунок',
        prevLinkText: '&laquo; Назад',
        nextLinkText: 'Вперед &raquo;',
        closeTitle: 'Закрыть галерею',
        image: 'Рисунок ',
        of: ' из '
      }
    });
    setTimeout('anchorecheck()',500);
});

