
// Javascript to handle the menus, etc

var menuCount = 10;
var itemCount = 37;

function sizeme()
{
    // window size stuff
    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;
    }

    // resize the content to fill most of the height
    // resize the frame to maximise space with the right aspect ratio (0.75)

    var content = document.getElementById('content');
    var ifrm = document.getElementById('ifrm');

    content.style.height = (myHeight - 115) + 'px';

    var AR = 0.75;  // the aspect ratio that we want

    var hmax = myHeight - 115 - 30;

    ifrm.style.height = hmax + 'px';

}



function toggle_list(id, lang)
{
    var menu = 'menu' + id;
    var maps = ' Maps';

    // hide all sub-menus

    for (var i = 1; i <= menuCount; i++) {
	document.getElementById('submenu' + i).style.display = 'none';
	//document.getElementById('menu' + i).style.backgroundColor = '#084c8e';
	//document.getElementById('menu' + i).style.border = '0px solid #084c8e';
	document.getElementById('menu' + i).style.fontWeight = 'normal';
    }

    // show the selected sub-menu and highlight menu

    //document.getElementById(menu).style.backgroundColor = '#2b85bb';
    //document.getElementById(menu).style.border = '2px solid #ef0780';
    document.getElementById('submenu' + id).style.display = 'block';
    document.getElementById(menu).style.fontWeight = 'bold';

    // set the chapter heading to be the tile attribute of the menu link
    
    var title = document.getElementById(menu).getAttribute('title');
    document.getElementById('chapter_heading').innerHTML = title;
    var thetitle = '';
    var subtitle = '';

    // load the content

    //toggle_content(menu);

    switch (id) {
    case '1':                 // Demographic

	if (lang == 'RU')
	  thetitle = 'Демографические карты';
	else
	  thetitle = title + maps;
	break;

    case '2':                 // Education

	if (lang == 'RU')
	  thetitle = 'Карты Образования';
	else
	  thetitle = title + maps;
	break;

    case '3':                  // Health
	
	if (lang == 'RU') {
	  thetitle = 'Карты Здоровья';
	  subtitle = 'Примечание к подсчету данного показателя<br><br>Для того, чтобы оценить уровень смертности среди детей моложе 5 лет, необходима информация о количестве смертей и  о размере населения, подверженного риску смерти. Количество смертей  получено из регистрационной системы демографии населения, тогда как размер населения оценивается переписью. Однако во многих странах информация, необходимая для оценки уровня смертности, часто ошибочна из-за заниженных сведений, полученных из регистрационной системы демографии населения. Таким образом, уровень смертности среди населения  моложе 5 лет, высчитанный на основе регистрационных данных, гораздо ниже, чем предполагаемый уровень, основанный на данных опроса населения. Обсуждение методов оценки настоящего уровня смертности в данный момент незакончено.<br>Уровень смертности среди детей моложе 5 лет, представленный в данном Атласе, был получен путем метода косвенной  оценки и с использованием данных переписи населения о рожденных и выживших детях. Мы предоставляем рассчитанные уровни смертности среди детей моложе 5 лет в сельских регионах на районном уровне и в городских регионах на областном уровне, а также в городе Душанбе. Метод косвенной оценки, используемый нами для этих расчетов, был разработан Вильамом Брассом в 1960 году. Данный метод позволяет оценить возможность смерти между моментом рождения и до определенного возраста 5 лет.';
	} else {
	  thetitle = title + maps;
          subtitle = 'NOTE ON THE CALCULATION OF THE INDICATOR<br><br>In order to estimate the Under 5 Mortality Rate (U5MR), it is necessary to have information on both the number of deaths and the size of the population at risk of dying. The former is usually derived from vital registration system and the latter from the census. However, in many countries the information which allows deriving direct estimates of mortality are often subject to errors due to the underreporting in the vital registration system. Hence, the estimates of U5MR which come from the vital registration system produce mortality levels which are well below survey estimate. The debate on where the true U5MR lie is still ongoing.<br>The U5MR presented in this Atlas has been produced using a indirect estimation technique and information on children ever born and children surviving available in the last Census. We provide estimates of U5MR for rural area at Rayon level and for urban area at the oblast level plus Dushanbe. This indirect estimation technique was developed by William Brass in the 1960s. This method provides estimations of the probability of dying between birth and exact age 5.';	}
	break;

    case '4':                  // Household Amenities

	if (lang == 'RU')
	  thetitle = 'Карты Бытовых условий';
	else
	  thetitle = title + maps;
	break;

    case '5':                  // Economic

	if (lang == 'RU')
	  thetitle = 'Экономические Карты';
	else
	  thetitle = title + maps;
	break;

    case '6':                  // Poverty

	if (lang == 'RU') {
	  subtitle = 'Примечание по методологии<br><br>Следующие показатели бедности были расcчитаны на основе совместных данных Всеобщей Переписи Населения 2000 года и Оценки Уровня Жизни Таджикистана (ТОУЖ) 2003 года, используя статистический метод картографии бедности разработанный работниками Всемирного Банка - Элберсом и Ладжау.<br>Более детальная информация доступна на сайте:<br><A HREF="http://www.s3ri.soton.ac.uk/publications/applications.php" target="_blank">“Technical Note: Creating a Poverty Map for Tajikistan” Baschieri A. and Falkingham J. (2005)</A><br><br>В данном Атласе используются два показателя бедности:<ul><li>По душевое потребление (общее сводное потребление)<li>По душевое продовольственное потребление</ul>В данных картах также испульзуются две черты бедности:<ul><li>Абсолютная черта бедности 47,06 сомони ($2,15 ППС)<li>Относительная черта бедности – указатель 40-го процентиля</ul>';
	  thetitle = 'Карты Бедности';
	} else {
	  thetitle = title + maps;
	  subtitle = 'METHODOLOGICAL NOTE<br><br>The following poverty indicators have been estimated by combining the 2000 Census of Tajikistan and the 2003 Tajikistan Living Standard Survey, through the application of the statistical poverty mapping technique developed by Elbers and Lanjouw from the World Bank.<br>For more details see: <br><A HREF="http://www.s3ri.soton.ac.uk/publications/applications.php" target="_blank">Technical Note: Creating a Poverty Map for Tajikistan Baschieri A. and Falkingham J. (2005)</A><br><br>Two poverty indicators are available:<ul><li>Per capita consumption (total consumption aggregated)<li>Per capita food consumption</ul>Two poverty lines are available:<ul><li>Absolute poverty line 47.06 Somoni ($2.15PPP)<li>Relative poverty line 40th percentile point</ul>';
	}
	break;

    case '7':                 // Land Cover Maps

	if (lang == 'RU')
	  thetitle = 'Карты Земного покрытия';
	else
	  thetitle = title + maps;
	break;

    case '8':                  // Relief

	if (lang == 'RU')
	  thetitle = 'Карты Рельефа';
	else
	  thetitle = title + maps;
	break;

    case '9':                  // Infrastructure

	if (lang == 'RU')
	  thetitle = 'Карты Инфраструктур';
	else
	  thetitle = title + maps;
	break;

    case '10':                  // Contextual

	if (lang == 'RU')
	  thetitle = 'Общие географические карты';
	else
	  thetitle = title + maps;
	break;

    default: 
	var subtitle = id;
    }
	
    menupage(thetitle, subtitle, lang);
}




function toggle_content(page, id)
{
    // load an html page into the content frame
    // ./content/<id>.html

    // normal face on all menu links

    for (var i = 1; i <= itemCount; i++) {
	document.getElementById('p' + i).style.fontWeight = 'normal';
    }

    // bold the selected link

    document.getElementById('p' + page).style.fontWeight = 'bold';

    // load the web page

    parent.frames["ifrm"].location = 'content/' + id + '.html';

}





function menupage(title, subtitle, lang)
{
    // load a nice looking page into the content part

    var ifrm = parent.frames["ifrm"].document;

    var langlinktext = '';
    var heading1 = 'Socio-Economic Atlas of Tajikistan 2005';

    if (lang == 'UK' || lang == '') { // already in English, switch to Russian

	langlinktext = '<a href="index_ru.html" target="_top"><img src="images/flag_ru.gif" border=0 align=middle></a>&nbsp;&nbsp;<a href="index_ru.html" target="_top" class="link">На русском языке</a>';

    }
    else if (lang == 'RU') { // in Russian, switch to English

	langlinktext = '<a href="index.html" target="_top"><img src="images/flag_uk.gif" border=0 align=middle></a>&nbsp;&nbsp;<a href="index.html" target="_top" class="link">English version</a>';
	heading1 = 'СОЦИАЛЬНО-ЭКОНОМИЧЕСКИЙ АТЛАС ТАДЖИКИСТАНА 2005';

    }

    ifrm.open("text/html");
    ifrm.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' +
	       '<html xmlns="http://www.w3.org/1999/xhtml">' +
	       '<head>' +
	       '<meta http-equiv="content-type" content="text/html; charset=utf-8" />' +
	       '<style type="text/css" media="screen">' +
	       '.link { text-decoration: none; color: #084c8e; }' +
	       '.link:hover { text-decoration: underline; }' +
	       '</style>' +
	       '</head>' +
	       '<body style="margin: 0; padding: 30px; background-color: #fff; color: #555; font-family: Arial, Helvetica, sans-serif;">' +
	       '<div style="text-align: center">' +
	       '<h1 style="font-size: 24pt; font-weight: normal; margin: 20px 0; color: #084c8e;">' + heading1 + '</h1>' +
	       '<img src="images/World_bank.PNG" title="World Bank" alt="World Bank Logo" align="middle" />' +
	       '<img src="images/TJ_government.png" hspace=40 title="Tajikistan Government" alt="Tajikistan Logo" align="middle" />' +
	       '<img src="images/DFID.png" title="DFID" alt="DFID Logo" align="middle" />' +
      	       '<h2 style="font-size: 16pt; font-weight: normal; padding: 0; margin: 20px 0 15px 0;">' + title + '</h2>' +
	       '<h2 style="font-size: 10pt; font-weight: normal; padding: 0; margin: 15px 0 40px; 0; text-align: left;">' + subtitle + '</h2>' + 
	       '<div  style="margin-bottom: 30px;"><img src="images/geodata_logo.gif" title="GeoData Institute" alt="GeoData Logo" align="middle" />' +
	       '<img src="images/soton.gif" hspace=40 title="University of Southampton" alt="Southampton University Logo" align="middle" />' +
	       '<img src="images/s3ri.png" title="s3ri" alt="s3ri Logo" align="middle" /></div>' +
	       langlinktext +
	       '</div>' +
	       '</body>');
    ifrm.close();
    
}

