<!--
	siteURL = "http://www.astromyth.ru"
	
	var Constellations = {
		"SciurusVolans": "Белка-летяга",
		"SceptrumBrandenburgicum": "Бранденбургский Скипетр",
		"Ramus": "Ветвь Яблони",
		"Globus": "Воздушный Шар",
		"Volta": "Вольтова Батарея",
		"Col": "Голубь",
		"CVn": "Гончие Псы",
		"Menalus": "Гора Менала",
		"Anser": "Гусь",
		"Pomum": "Держава Императора",
		"Robur": "Дуб Карла",
		"Mon": "Единорог",
		"Pic": "Живописец",
		"Cam": "Жираф",
		"Gru": "Журавль",
		"Zeus": "Зевс Громовержец",
		"Dor": "Золотая Рыба",
		"LeoPalatinus": "Императорский Лев",
		"Ind": "Индеец",
		"Car": "Киль",
		"Pyx": "Компас",
		"Pup": "Корма",
		"CoronaFirmiana": "Корона Фирмиана",
		"Felies": "Кошка",
		"Funis": "Лаг",
		"Vol": "Летучая Рыба",
		"Lilium": "Лилия",
		"Linum": "Линь",
		"Vul": "Лисичка",
		"Psalterium": "Лютня Георга",
		"LMi": "Малый Лев",
		"CancerMinor": "Малый Рак",
		"TriMi": "Малый Треугольник",
		"Malus": "Мачта",
		"Gladii": "Мечи Курфюрста Саксонского",
		"Mic": "Микроскоп",
		"MarmorSculptile": "Мраморная Скульптура",
		"Mus": "Муха",
		"Ant": "Насос",
		"Nor": "Наугольник",
		"Norma": "Нилометр",
		"Noctua": "Ночная Сова",
		"Turdus": "Одинокий Дрозд",
		"Oct": "Октант",
		"Cervus": "Олень",
		"Pav": "Павлин",
		"Vel": "Паруса",
		"Mimidae": "Пересмешник",
		"Gallus": "Петух",
		"For": "Печь",
		"Velo": "Плат Вероники",
		"Aps": "Райская Птица",
		"Cae": "Резец",
		"Fluvius": "Реки Иордан и Тигр",
		"FluviusJordanis": "Река Иордан",
		"FluviusTigris": "Река Тигр",
		"Rose": "Роза",
		"Rhomb": "Ромб",
		"Lyn": "Рысь",
		"Vespa": "Северная Муха",
		"Tarandus": "Северный Олень",
		"Sex": "Секстант",
		"CorCaroli": "Сердце Карла",
		"Ret": "Сетка",
		"Sceptrum": "Скипетр и Рука Правосудия",
		"Scl": "Скульптор",
		"Honores": "Слава Фридриха II",
		"Manipulus": "Сноп",
		"Hills": "Созвездия Хилла",
		"Solarium": "Солнечные Часы",
		"Quadrans": "Стенной Квадрант",
		"Men": "Столовая Гора",
		"Polophylax": "Страж Полюса",
		"Tel": "Телескоп",
		"Telescopium": "Телескопы Гершеля",
		"TaurusPoniatovii": "Телец Понятовского",
		"OfficinaTypographica": "Типографский Станок",
		"Tuc": "Тукан",
		"Phaethon": "Фаэтон",
		"Phe": "Феникс",
		"Cha": "Хамелеон",
		"Messium": "Хранитель Урожая",
		"Cerberus": "Цербер",
		"Cir": "Циркуль",
		"Hor": "Часы",
		"Testudo": "Черепаха",
		"Sct": "Щит",
		"MachinaElectra": "Электрическая Машина",
		"Hyi": "Южная Гидра",
		"SagittaAustralis": "Южная Стрела",
		"Cru": "Южный Крест",
		"TrA": "Южный Треугольник",
		"Lac": "Ящерица",
		"And": "Андромеда",
		"Antinous": "Антиной",
		"Gem": "Близнецы",
		"UMa": "Большая Медведица",
		"CMa": "Большой Пес",
		"Lib": "Весы",
		"Aqua": "Вода",
		"Aqr": "Водолей",
		"Aur": "Возничий",
		"Lup": "Волк",
		"Boo": "Волопас",
		"Com": "Волосы Вероники",
		"Crv": "Ворон",
		"Her": "Геркулес",
		"Hya": "Гидра",
		"Gorgona": "Голова Медузы",
		"Vir": "Дева",
		"Del": "Дельфин",
		"Dra": "Дракон",
		"Ara": "Жертвенник",
		"Lep": "Заяц",
		"Oph": "Змееносец",
		"Ser": "Змея",
		"Zodii": "Зодиак",
		"Bruno": "Изгнание торжествующего зверя",
		"Cas": "Кассиопея",
		"Cet": "Кит",
		"Cap": "Козерог",
		"Haedus": "Козлята",
		"Argo": "Корабль Арго",
		"Cyg": "Лебедь",
		"Leo": "Лев",
		"Lyr": "Лира",
		"Arcus": "Лук",
		"UMi": "Малая Медведица",
		"Equ": "Малый Конь",
		"CMi": "Малый Пес",
		"Ari": "Овен",
		"Aql": "Орел",
		"Ori": "Орион",
		"Peg": "Пегас",
		"Per": "Персей",
		"Pleada": "Плеяды и Гиады",
		"OrionsWidgets": "Пояс и Меч Ориона",
		"Cnc": "Рак",
		"Psc": "Рыбы",
		"CrB": "Северная Корона",
		"Sco": "Скорпион",
		"Weigel": "Созвездия Вейгеля",
		"Schiller": "Созвездия Шиллера",
		"Sge": "Стрела",
		"Sgr": "Стрелец",
		"Tau": "Телец",
		"Tri": "Треугольник",
		"Cen": "Центавр",
		"Cep": "Цефей",
		"Crt": "Чаша",
		"Eri": "Эридан",
		"CrA": "Южная Корона",
		"PsA": "Южная Рыба",
		"Siren": "Сирена",
		"Ceneus": "Кеней"		
	}

	function setTransparent(imgName,lvl){
		if (IsIE()){
			var img = document.images(imgName);
					
			if (navigator.appName.indexOf("Netscape") != -1){
				img.style.MozOpacity = lvl / 100
			}else if (navigator.appName.indexOf("Microsoft") != -1){
				if (lvl == 100) {
					img.filters.alpha.opacity = lvl
				}else{
					img.filters.alpha.opacity = img.filters.alpha.opacity - 1;
					if (img.filters.alpha.opacity > lvl) {
						setTimeout("setTransparent('"+imgName+"',50);", 10);
					}
				}
			}
		}
	}
	
	function getConstellationTitle(strFile){
		var strName;
		
		try {
			strName = Constellations[strFile];
		}catch (e) {
    		return "?";
    	}

		return strName;
	}


	function locationHost(){
		return "W:/T(WWW)-tau-site.www/AstroMyth"
	}
	
	function getLocation(path){
		return location.hostname == "" ? locationHost() + "/" + path : location.hostname + "/" + path;
	}
	
	var TEXT = "";
	function prt2(txt) {
		TEXT = TEXT + txt;
	}
	
	function push(){
		document.write(TEXT);
	}
	
	function getTEXT(){
		return TEXT;
	}

	function replace_string(txt, cut_str, paste_str){ 
		var f = 0;
		var ht = '';
		ht = ht + txt;
		f = ht.indexOf(cut_str);
		while (f != -1){ 
			//цикл для вырезания всех имеющихся подстрок 
			if (f > 0){
				ht = ht.substr(0, f) + paste_str + ht.substr(f + cut_str.length);
			}else{
				ht = paste_str + ht.substr(cut_str.length);
			};
			f = ht.indexOf(cut_str);
		};
		return ht
	};

	function normalize_string(str){
		str = replace_string(str, '%26', '&');
		str = replace_string(str, '%20', ' ');
		str = replace_string(str, '[', '<');
		str = replace_string(str, ']', '>');
		return str;
	}

	function popupWindow(title, text){
		tauWindow = open("", "popup");
		tauWindow.document.open();

		tauWindow.document.write("<html>");
			tauWindow.document.write("<head>");
				tauWindow.document.write("<title>");
					tauWindow.document.write(title);
				tauWindow.document.write("</title>");
			tauWindow.document.write("</head>");
			
			tauWindow.document.write("<body>");
					tauWindow.document.write(text);
			tauWindow.document.write("</body>");
		tauWindow.document.write("</html>");


		tauWindow.document.close();
	}
	
	function showImageWindow(srcName){
		return showImageAndDescriptionWindow(srcName, srcName, srcName);
	}
	
	function showImageWindowExt(srcName, descr, src){
		var scr = 'yes';
		_src = '';
		
		winwidth = 0;
		winheight = 0;
		
		if (srcName != '') {
    		img = new Image;
	  		img.src = srcName;
			
			Shower = (location.hostname == "") ? locationHost() + '/images/show_image.html' : '/images/show_image.html';
			strParm = Shower + '?' + srcName + '&' + descr + '&' + _src;

			win = window.open(strParm, 'atlasimagefull', 'menubar=no, status=no, location=no, scrollbars=' + scr + ', fullscreen=no,directories=no,resizable=no');	

			resizeImageWindow(win);
			win.window.focus();
		}
		
		return false ;  
	}
	
	function resizeImageWindow(win){
		if (win.document.readyState == 'complete') {
			var NS = (navigator.appName == "Netscape") ? true : false;
			dW = 20;
			dH = 112;

			img = win.document.images[0];
			
			iWidth = (NS) ? win.innerWidth : win.document.body.clientWidth; 
       		iHeight = (NS) ? win.innerHeight : win.document.body.clientHeight; 
       		
       		iWidth = win.document.images[0].width - iWidth + dW; 
       		iHeight = win.document.images[0].height - iHeight + dH; 
       		
       		win.resizeBy(iWidth, iHeight); 
		}else{
			setTimeout("resizeImageWindow(win)", 200);
		}
	}
	
	function getWindowSize() {
	    var myWidth = 0, myHeight = 0;
	    	    
	    if( typeof( window.innerWidth ) == 'number' ) {
	        //Non-IE
	        myWidth = window.innerWidth;
	        myHeight = window.innerHeight;
	    } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	        //IE 6+ in 'standards compliant mode'
	        myWidth = document.documentElement.clientWidth;
	        myHeight = document.documentElement.clientHeight;
	    } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	        //IE 4 compatible
	        myWidth = document.body.clientWidth;
	        myHeight = document.body.clientHeight;
	    }
	}
	
	function viewNode(node){
		prt2(node);

		var childnodes = node.childNodes.length;

		result_str+=" "+node.nodeName+"<br/>";
		for(var i=0;i<childnodes;i++){
			viewNode(node.childNodes.item(i));
		}
	}
	
	function findNodeByName(node, name){
		for (var i = 0; i < node.childNodes.length; i++){
			var item = node.childNodes.item(i);
			
			if (IsIE()) {
				if (item.attributes.getNamedItem("nm").nodeValue == name) {
					return node.childNodes.item(i);
				}
			}else{
				if (item.hasAttributes()){
					if (item.attributes.getNamedItem("nm").nodeValue == name) {
						return node.childNodes.item(i);
					}
				}
			}
		}
		return false;
	}
	
	function inQuotes(str){
		return '"' + str + '"';
	}
	
	function getLink2Constellation(item){
    	strConstallation = item.attributes.getNamedItem("nm").nodeValue;
    	strLink = item.attributes.getNamedItem("fl").nodeValue;

    	if (strConstallation == ""){
    		strConstallation = getConstellationTitle(strLink);
    	}
    	if (strConstallation != ""){
	    	if (strLink != ""){
		    	strLink = "../Constellations/" + strLink;
				prt2('<a href="' + strLink + '.htm">');
			}
			prt2(strConstallation);
	    	if (strLink != ""){
				prt2('</a>');
			}
			prt2("<br>");
    	}
	}
	
	function showImage(image, pathImage, person, section){
		var shortName = image.attributes.getNamedItem("fl").nodeValue;
		var strImg = pathImage + shortName + ".jpg";
		var strImg_small = pathImage + shortName + "_small.jpg";
		var strImg_full = pathImage + shortName + "_full.jpg";

		var strCaption = image.attributes.getNamedItem("cpt").nodeValue;
		var strDscr = image.attributes.getNamedItem("dsc").nodeValue;
		var strSrc = image.attributes.getNamedItem("src").nodeValue;

		if (section != null){
			sectionCaption = section.attributes.getNamedItem("cpt").nodeValue;
			sectionDescription  = section.attributes.getNamedItem("dsc").nodeValue;
			sectionSource = section.attributes.getNamedItem("src").nodeValue;

			if (sectionCaption != ""){
				if (strCaption != ""){
					strCaption = "<br>" + strCaption;
				}
				strCaption = sectionCaption + strCaption;
			}
			
			if (sectionDescription != ""){
				if (strDscr != ""){
					strDscr = "<br>" + strDscr;
				}
				strDscr = sectionDescription + strDscr;
			}
			
			if (strSrc == "" && sectionSource != ""){
				strSrc = sectionSource;
			}
		}
		
		strCaption = normalize_string(strCaption);
		strDscr = normalize_string(strDscr);
		strSrc = normalize_string(strSrc);		

		prt2("<a href='#showimage' onClick='showImageWindowExt(" + inQuotes(strImg) + "," + inQuotes(strCaption) + "," + inQuotes(strSrc) + ")'>");
			prt2("<img border=1 src='");
			prt2(strImg_small);
			prt2("' alt='" + strCaption + "'");
			prt2(" name='" + shortName + "'");
			prt2(); // caption
			if (IsIE()){
				prt2(' style="filter:alpha(opacity=50);-moz-opacity:0.5" ');
			}else{
				prt2(' style="-moz-opacity:0.5" ');
			}
			prt2(' onMouseover = "setTransparent(this.name, 100)" onMouseout = "setTransparent(this.name, 50)" ');
			prt2(">");
		prt2("</a>");
		getSrcImage(strSrc);

		if (strDscr != ""){
			prt2("<p><font size=2>" + strDscr);
			if (person != "") {
				prt2('&nbsp;&nbsp;<a href="../History/' + person + '.htm" title="История">');
				prt2(">>>");
				prt2('</a>');
			}
			prt2("</font></p>");
		}
		
		if (person == ""){
			var item;
			prt2('<p align="right"><font size=2>');
			for (var i = 0; i < image.childNodes.length; i++){
				item = image.childNodes.item(i);
			    if (item.nodeName  == "cns") {
			    	getLink2Constellation(item);
			    }
			}
			prt2("</font></p>");
		}
	}
	
	function getSrcImage(strSrc){
		if (strSrc != ""){
			prt2("<a href='../History/Links.htm'>");
				prt2("<img border=0  align=top src='");
				prt2("../images/Q.gif");
				prt2("' alt='");
				prt2("Источник: " + strSrc); // caption
				prt2("'>");
			prt2("</a>");
		}
	}
	
	var isGalleryTitle = false;		
	var xml = null;
	var nc = 5; // число столбцов в таблице
	
	function createXML() {
		if (xml == null){
			if (IsIE()){
				xml = new ActiveXObject("Microsoft.XMLDOM");
			}else{
				xml = document.implementation.createDocument("","",null);
			}
			xml.async = false;
		}
	} 

	function getXMLPath(strURL){
		var path = location.pathname;
		var pos = path.lastIndexOf('/');
		path = path.substring(1, pos);

// формирование корректного пути XML
		urlXML = path + "/" + strURL;
		urlXML = location.hostname == "" ? urlXML : "http://" + getLocation(urlXML);	
		
		return urlXML;
	}
	
	function printTytle(strTytle){
		if (strTytle == "") {
//			if (!isGalleryTitle){
//				prt2("<h4>" + "Изображения" + "</h4>");
//			}
		}else{
			prt2("<h5>" + strTytle + "</h5>");
		}
		isGalleryTitle = true;
	}
	
	function getPage(strPage){
		var page = strPage;
		
		if (page == "") {
			var str = document.URL;
			page = str;
			page = page.substring(page.lastIndexOf('/')+1);
			page = page.substring(page.lastIndexOf('\\')+1);
			page = page.substring(0, page.indexOf('.'));
		}
		return page;
	}
	
	function showGallery(strURL, strPerson){
		createXML();
		urlXML = getXMLPath(strURL);
		strPerson = getPage(strPerson);
		
// загрузка XML 
		xml.load(urlXML);
		
// корень		
		var root = xml.childNodes.item(0);
		
// раздел
		var person = findNodeByName(root, strPerson);
		if (!person){
			return false;
		}
		
		prt2('<a name="gallery">');

		var tytle = person.attributes.getNamedItem("tl").nodeValue;
		printTytle(tytle);

		var description = person.attributes.getNamedItem("dsc").nodeValue;
		description = normalize_string(description);
		prt2("<p>" + description + "</p>");
		
		var image;
		var section = null;
		var pathImage = root.nodeName + "/" + person.attributes.getNamedItem("nm").nodeValue;
 		pathImage = ((location.hostname == "") ? locationHost() + '/images/' : '/images/') + pathImage  + "/";
 		
		prt2("<table cellspacing=8 id='gallery'>");
		var cnt = -1;
		for (var i = 0; i < person.childNodes.length; i++){
		    if (person.childNodes.item(i).nodeName  == "scn") {
				section = person.childNodes.item(i);
		    }
		    if (person.childNodes.item(i).nodeName  == "img") {
				cnt++;
				if (cnt % nc == 0 && i){
					prt2("</tr>");
				}
				if (cnt % nc == 0){
					prt2("<tr>");
				}
					
				prt2("<td align='center' valign='top'>");
					image = person.childNodes.item(i);
					showImage(image, pathImage, "", section );
				prt2("</td>");
		    }
		    
		}
		prt2("</table>");
		
		push();
	}

	var cnt = -1;
	function showConstellationGalleries(strGallery){
		createXML();

		printTytle("");
		
		cnt = -1;
		prt2("<table cellspacing=8 id='gallery'>");
		prt2("<tr>");
		
		if (strGallery){
			showConstellationGallery(strGallery, "");
		}else{
			showConstellationGallery("../History/images_Prehistoric.xml", "");
			showConstellationGallery("../History/images0Antic.xml", "");
			showConstellationGallery("../History/images1MiddleAges.xml", "");
			showConstellationGallery("../History/images2Renaissance.xml", "");
			showConstellationGallery("../History/images3AgeOfDiscovery.xml", "");
			showConstellationGallery("../History/images4inFolio.xml", "");
			showConstellationGallery("../History/images5Monarches.xml", "");
			showConstellationGallery("../History/images6SoMind.xml", "");
			showConstellationGallery("../History/images7March.xml", "");
			showConstellationGallery("../History/images8Now.xml", "");	
		}
		prt2("</table>");
		
//		push();
	}
	
	function showConstellationGallery(strURL, strConstellation){
		createXML();
		urlXML = getXMLPath(strURL);

		printTytle("");
		
		strConstellation = getPage(strConstellation);
// загрузка XML 
		xml.load(urlXML);

// корень		
		var root = xml.childNodes.item(0);
		var atlas;
		var image;
		var section = null;
		var imConstellation;
		var prePath = ((location.hostname == "") ? locationHost() + '/images/' : '/images/') ;

// цикл по атласам
//		document.write(root.nodeName + "<br>");
		for (var i = 0; i < root.childNodes.length; i++){
			atlas = root.childNodes.item(i);			
			if (atlas.nodeName == "prs"){
				section = null;
// цикл по картинкам
//				document.write(">" + atlas.nodeName + "<br>");
				for (var j = 0; j < atlas.childNodes.length; j++){
					image = atlas.childNodes.item(j);			
				    if (image.nodeName  == "scn") {
						section = image;
				    }
					if (image.nodeName == "img"){
// цикл по созвездиям на картинке
//						document.write(">>" + image.nodeName + "<br>");
						for (var k = 0; k < image.childNodes.length; k++){
							imConstellation = image.childNodes.item(k);			
							if (imConstellation.nodeName == "cns"){
// найдено 
//								document.write(">>>" + imConstellation.nodeName + ":" + imConstellation.attributes.getNamedItem("fl").nodeValue + "<br>");
								if (imConstellation.attributes.getNamedItem("fl").nodeValue == strConstellation){
									cnt++;
									if (cnt % nc == 0){
										prt2("</tr>");
									}
									if (cnt % nc == 0){
										prt2("<tr>");
									}									
					
									prt2("<td align='center' valign='top'>");
										var pathImage = root.nodeName + "/" + atlas.attributes.getNamedItem("nm").nodeValue;
								 		pathImage = prePath + pathImage  + "/";

										showImage(image, pathImage, atlas.attributes.getNamedItem("nm").nodeValue, section);
									prt2("</td>");
								}
							}
						}
					}
				}
			}
		}
	}
//-->

