
	function lightBox_init() {
		var imgContainer = document.getElementById('imgGallery');
		window.onresize = changePos;
		window.onscroll = changePos;
		cookieValue = get_cookie("represent");
		themeSwitch(cookieValue ? cookieValue : 'cloud')

/*		if ( document.addEventListener ) {
			imgContainer.addEventListener("click", onClick, false);
		} else if ( document.attachEvent ) {
			imgContainer.attachEvent("onclick", onClick);
		} else {
			alert("Your browser will not work for this example.");
		}
*/
	}

	// убрать классы
	function faultCss () {
		var menu = document.getElementById('rubricator_nav').childNodes;
		for (var i=0; i<menu.length; i++) {
			if (menu[i].tagName == 'A') {
				menu[i].className = ''
			}
		}
	}
	
	// переключение между облаком и списком
	function themeSwitch(what) {
		faultCss();
		document.getElementById(what).className = 'active';
		if (what == 'list') {
			set_cookie('represent','list')
			oThemeList.className = ''
			oThemeList.className = 'list'
			showCount(1)
		}
		else {
			set_cookie('represent','cloud')
			oThemeList.className = ''
			oThemeList.className = 'clouds'
			showCount(0)
		}
	}
	
	// показать/спрятать количество фоток при режиме список/облако
	function showCount(sign) {
		coll = oThemeList.getElementsByTagName('DIV')
		for (j = 0; j < coll.length; j ++) {
			span = coll[j].lastChild;
			if (span.tagName == 'SPAN')	span.style.display = sign ? "inline" : "none"
		}
	}
	
	
/*	function onClick(e) {
		var el = window.event ? window.event.srcElement : e.target;
		if (el.src) {
			bigDiv.style.display = 'block';
			divBg.style.display = 'block';
			//shadowDiv.style.display = 'block';
			//shadowDiv.style.opacity = 3/10;
			//shadowDiv.style.filter = 'alpha(opacity=' + 3*10 + ')';
			// подгружаем большую картинку
			document.getElementById('bigImg').src = el.src + 'big.gif';
			var coll = bigDiv.childNodes;
			var count = 0;
			//for ( var i=0; i<coll.length; i++) {
			//	count += coll[i].offsetHeight;
			//	shadowDiv.style.height = count;
			//}
		}
	}
*/
	var index='';
	var card_pos='';
	function showCard( ind_card, pos )
	{
	   if ( ind_card == '' && pos == '' ) {
		;
	   } else {
		if ( ind_card != '' ) {
			index = ind_card;
		}
		else {
			index = posar[pos].pos;
		}
		if ( pos != '' ) {
			card_pos = pos;
		} else {
			for (var i=0; i<posar.length; i++) {
				if (ind_card == posar[i].pos) {
					card_pos = i;
					break;
				}
			}
		}
		setReadyState( null, null, null, setCard );
		url = '/include/dynamic/photogallery/cards/' +  photoar[index] + '.shtml';
		sendRequest(null, url, null, null, 'text/plain;charset=windows-1251');
	   }
	}

	function setCard()
	{
		data = req.responseText;
		document.getElementById('info').innerHTML = data;

		var doc_url = 'http://photo.autonews.ru/' + url;
/*		var i = new Image();
		i.src = "http://counter.yadro.ru/hit?t44.6;r"+
			escape(document.referrer)+((typeof(screen)=="undefined")?"":
			";s"+screen.width+"*"+screen.height+"*"+(screen.colorDepth?
			screen.colorDepth:screen.pixelDepth))+";u"+escape(doc_url)+
			";"+Math.random();*/
		bigDiv.style.display = 'block';
		divBg.style.display = 'block';
		var id = card_pos * 1 + 1 + step;
		if ( pages == 1 ) {
			max_photo = arsize;
		}

		id_prev = '';
		if ( id > 1 ) id_prev = card_pos * 1 - 1;
		url_prev = "javascript:showCard('', '" + id_prev + "');";

		id_next = '';
		if ( id < max_photo ) id_next = card_pos * 1 + 1;
		url_next = "javascript:showCard('', '" + id_next + "');";
		// формирование ссылки на предыдующую страницу
		if ( curr_page > 1 && card_pos == 0 && id_prev ) {
			cnt_from = (curr_page - 2) * 48;
			cnt_to = (curr_page - 1) * 48;
			url_prev = '/photogallery/list.shtml?rubric=' + rubric + '&card=1&n1=' + cnt_from + '&n2=' + cnt_to;
		}
		// формирование ссылки на след.страницу
		if ( curr_page < pages && card_pos == (arsize-1) && id_next ) {
			cnt_from = curr_page * 48;
			cnt_to = (curr_page + 1) * 48;
			url_next = '/photogallery/list.shtml?rubric=' + rubric + '&card=2&n1=' + cnt_from + '&n2=' + cnt_to;
		}
		document.getElementById('count').innerHTML = id + ' из ' + max_photo;
		document.getElementById('prev').href = url_prev;
		document.getElementById('next').href = url_next;
		
		var bodyCorr = document.documentElement ? document.documentElement : document.body;
		
		bigDiv.style.top = (bodyCorr.scrollTop + bodyCorr.clientHeight/2 - 205) + 'px';
		bigDiv.style.left = (bodyCorr.clientWidth/2 - bigDiv.clientWidth/2) + 'px';
	}
	
	function hideDiv () {
		bigDiv.style.display = 'none';
		divBg.style.display = 'none';
		//shadowDiv.style.display = 'none';
	}

	function getPageSize(){
		
		var yScroll;
		
		if (window.innerHeight && window.scrollMaxY) {	
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			yScroll = document.body.scrollHeight;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			yScroll = document.body.offsetHeight;
		}
		
		var windowHeight;
		if (self.innerHeight) {	// all except Explorer
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowHeight = document.body.clientHeight;
		}	
		
		// for small pages with total height less then height of the viewport
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else { 
			pageHeight = yScroll;
		}
	
		return pageHeight;
	}

function changePos() {
	var bodyCorr = document.documentElement ? document.documentElement : document.body;
	bigDiv.style.top = (bodyCorr.scrollTop + bodyCorr.clientHeight/2 - 205) + 'px';
	bigDiv.style.left = (bodyCorr.clientWidth/2 - bigDiv.clientWidth/2) + 'px';
}
