
function getCookieVal (offset) {
   var endstr = document.cookie.indexOf (";", offset);
   if (endstr == -1)
      endstr = document.cookie.length;
   return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) {
        var arg = name + "=";
        var alen = arg.length;
        var clen = document.cookie.length;
        var i = 0;
        while (i < clen) {
                var j = i + alen;
                if (document.cookie.substring(i, j) == arg)
                        return getCookieVal (j);
                i = document.cookie.indexOf(" ", i) + 1;
                        if (i == 0)
                                break;
                }
   return null;
}
function SetCookie (name, value) {
        var argv = SetCookie.arguments;
        var argc = SetCookie.arguments.length;
        var expires = (argc > 2) ? argv[2] : null;
        var path = (argc > 3) ? argv[3] : null;
        var domain = (argc > 4) ? argv[4] : null;
        var secure = (argc > 5) ? argv[5] : false;
        document.cookie = name + "=" + escape (value) +
                ((expires == null) ? "" : ("; expires=" +
expires.toGMTString())) +
                ((path == null) ? "" : ("; path=" + path)) +
                ((domain == null) ? "" : ("; domain=" + domain)) +
                ((secure == true) ? "; secure" : "");
}
function InsertCookie ()
{
    var username = 'Yes';
    pathname = location.pathname;
    myDomain = pathname.substring(0,pathname.lastIndexOf('/')) +'/';
   
   // Установка параметра expire на год вперед.
    var largeExpDate = new Date ();
    //largeExpDate.setTime(largeExpDate.getTime() + (365 * 24 * 3600 * 1000));
    largeExpDate.setTime(largeExpDate.getTime() + (24 * 3600 * 1000));
    SetCookie('username',username,largeExpDate,myDomain);
    document.write('<p align=center>Здравствуйте, ' + username + '</p>');
}





function isValidBrowser() {
	if (browser() == 'ie6') {
	        return true
	}
	else {
	        return false
	}
}

function browser() {
	var result = 'ns';
	if ( navigator.appVersion.indexOf('MSIE 5.') != -1 ) { result = 'ie5' }
	if ( navigator.appVersion.indexOf('MSIE 6.') != -1) { result = 'ie6' }
	return result;
}


var	images;
	selHomeIndex = new Image();
	selHomeIndex.src = "images/menu/home_index_sel.gif";
	selIndex = new Image();
	selIndex.src = "images/menu/index_sel.gif";

common = {
        version: 0.3,
        env: {
                browser: browser()
        },

        getElementById: function(val) {
                return document.getElementById(val)
        },

        getElementByAttribute: function(attr, val, par) {
                var objects = [];
                if (!(par)) {
                        par = document;
                }
                if (common.env.browser == 'ie5') {
                        return false;
                }
                else {
                        var allElements = par.getElementsByTagName("*");
                        var objectCount = 0;
                        for (i= 0; i < allElements.length; i++) {
                                if (allElements[i].getAttribute(attr) == val) {
                                        objects[objectCount] = allElements[i];
                                        objectCount += 1;
                                }
                        }
                }
                if (objects.length) {
                        return objects
                }
                else {
                        return false
                }
        },

        inspect: function(obj) {
                var str = "";
                for (var prop in obj) {
                        str += obj.id + "." + prop + " = " + obj[prop] + "\n"
                }
                        alert(str);
        }
};


function menu(id){
	this.menuImage = "images/menu/menu_" + id + ".gif";
	return this;
}

function pagetitle(id){
	this.pagetitleImage = "images/pagetitle/pagetitle_" + id + ".gif";
	return this;
}

function page(id,name,show,rash){
	this.id = id;
	this.name = name;
        this.link = id +"."+ rash;
	this.menu = new menu(id);
	this.pagetitle = new pagetitle(id);
	this.show = show;
	return this;
}

function pagerus(id,name,show,rash){
	this.id = id;
	this.name = name;
        this.link = "rus/index.htm";
	this.menu = new menu(id);
	this.pagetitle = new pagetitle(id);
	this.show = show;
	return this;
}


var	sitePages = new Object();
	sitePages.aboutus = new page("aboutus","About Us",true,"htm");
        sitePages.russiafund = new page("russiafund","Russia Fund",true,"htm");	
        sitePages.biography = new page("biography","biography",true,"htm");
        sitePages.news = new page("news","News",true,"htm");
        sitePages.media = new page("media","Media",true,"htm");
        sitePages.contactus = new page("contactus","Contact Us",true,"htm");
        sitePages.disclamer = new page("disclamer","disclamer",false,"htm");
        sitePages.rus = new pagerus("rus","Russian",false,"htm");
var site = new	Array(
		sitePages.aboutus,
                sitePages.russiafund,		
		sitePages.biography,
              
                sitePages.media,		
                sitePages.contactus,
                sitePages.disclamer,
                sitePages.rus
	)

function homeMenuOver(id){
	document.images[id].src = "images/menu/home_index_sel.gif";
}

function homeMenuOut(id){
	document.images[id].src = "images/menu/home_index.gif";
}

function menuOver(id){
	document.images[id].src = "images/menu/index_sel.gif";
}

function menuOut(id){
	document.images[id].src = "images/menu/index.gif";
}

function findPageById(id){
	for(i=0;i<site.length;i++){
		if(site[i].id == id) return site[i];
	}
}

function insertHomeMenu(){
	for(i=0;i<site.length;i++){
		if(!site[i].show) continue;
			document.write(
				'<tr>' +
					'<td>'
			);
			document.write(
						'<img name="homeIndex' + site[i].id + '" src="images/menu/home_index.gif" width="12" height="14" border="0" alt=""><br>'
			);
			document.write(
					'</td>' +
					'<td>' +
						'<img src="images/menu/home_button.jpg" width="86" height="14" border="0" alt=""><br>' +
					'</td>' +
					'<td bgcolor="#02296A">'
			);
			document.write(
						'<a href="' + site[i].link + '" onmouseover="javascript:homeMenuOver(\'homeIndex' + site[i].id + '\');" onmouseout="javascript:homeMenuOut(\'homeIndex' + site[i].id + '\');">' +
						'<img src="' + site[i].menu.menuImage + '" width="107" height="14" border="0" alt=""><br>' +
						'</a>'
			);
			document.write(
					'</td>' +
				'</tr>'+
				'<tr>' +
					'<td colspan=3>' +
						'<img src="images/home/menu_shadow.gif" width="205" height="13" alt="" border="0"><br>' +
					'</td>' +
				'</tr>'
			);
	}
}

function insertHeader(){
	document.write(

'<table width=774 height="100%" align="center" border=0 cellpadding=0 cellspacing=0 bgcolor="ffffff" background="images/bg_page.gif">' +
	'<tr>' +
		'<td valign="top">' +

		'<table width=774 align="center" border=0 cellpadding=0 cellspacing=0>' +
			'<tr>' +
				'<td colspan="8" bgcolor="#E7E7E7" valign="top" bgcolor="#E7E7E7">' +
					'<img src="images/spacer.gif" width="1" height="4" border="0" alt=""><br>' +
				'</td>' +
			'</tr>' +
			
			'<tr>' +

//				'<td bgcolor="#E6E6E8" rowspan="7">' +
//					'<img src="images/spacer.gif" width=1 height=1 border="0" alt=""><br>' +
//				'</td>' +
//				'<td bgcolor="#D5D4D8" rowspan="7">' +
//					'<img src="images/spacer.gif" width=6 height=1 border="0" alt=""><br>' +
//				'</td>' +
//				'<td bgcolor="#E6E6E8" rowspan="7">' +
//					'<img src="images/spacer.gif" width=1 height=1 border="0" alt=""><br>' +
//				'</td>' +
//				'<td bgcolor="#D5D4D8" rowspan="7">' +
//					'<img src="images/spacer.gif" width=2 height=1 border="0" alt=""><br>' +
//				'</td>' +


				'<td bgcolor="#E6E6E8" rowspan="7">' +
					'<img src="images/spacer.gif" width=4 height=1 border="0" alt=""><br>' +
				'</td>' +
				'<td bgcolor="#D5D4D8">' +
					'<img src="images/spacer.gif" width=1 height=1 border="0" alt=""><br>' +
				'</td>' +
				'<td bgcolor="#E6E6E8" rowspan="7">' +
					'<img src="images/spacer.gif" width=4 height=1 border="0" alt=""><br>' +
				'</td>' +
				'<td>' +
					'<img src="images/home/header_shadow.gif" width="14" height="17" alt="" border="0">'+
				'</td>' +
				'<td bgcolor="#E6E6E8" rowspan="7">' +
					'<img src="images/spacer.gif" width=4 height=1 border="0" alt=""><br>' +
				'</td>' +
			'</tr>' +
			'<tr>' +
				'<td bgcolor="#E6E6E8">' +
					'<img src="images/spacer.gif" width=1 height=1 border="0" alt=""><br>' +
				'</td>' +
				'<td>' +
					'<table bgcolor="#E6E6E8" width="100%" border=0 cellpadding=0 cellspacing=0>' +
						'<tr>' +
							'<td valign="bottom">' +
								'<img src="images/spacer.gif" width=126 height=1 border="0" alt=""><br>' +
							'</td>' +
							'<td>' +
								'<img src="images/header_waves_02.gif" width=130 height=4 border="0" alt=""><br>' +
							'</td>' +
							'<td valign="bottom">' +
								'<img src="images/spacer.gif" width=299 height=1 border="0" alt=""><br>' +
							'</td>' +
						'</tr>' +
					'</table>' +
				'</td>' +
			'</tr>' +
			'<tr>' +
				'<td align="center" valign="top" bgcolor="#FAF9FA">' +

					'<table border="0" cellpadding="0" cellspacing="0" width="100%">' +
						'<tr>' +
							'<td>' +
								'<img src="images/spacer.gif" width=1 height=8 border="0" alt=""><br>' +
							'</td>' +
						'</tr>' +
						'<tr>' +
							'<td align="center">' +
								'<a href="index.htm">' +
								'<img src="images/header_logo.gif" width=186 height=31 border="0" alt="DIAMOND AGE capital"><br>' +
								'</a>' +
							'</td>' +
						'</tr>' +
						'<tr>' +
							'<td>' +
								'<img src="images/spacer.gif" width=1 height=3 border="0" alt=""><br>' +
							'</td>' +
						'</tr>' +
						'<tr>' +
							'<td bgcolor="#E6E6E8">' +
								'<img src="images/spacer.gif" width=1 height=4 border="0" alt=""><br>' +
							'</td>' +
						'</tr>' +
					'</table>' +
				'</td>' +
				'<td>' +
					'<table width="100%" border=0 cellpadding=0 cellspacing=0 bgcolor="#000053">' +
						'<tr>' +
							'<td>' +
								'<bgcolor="#000053" width=136 height=1 border="0" alt=""><br>' +
							'</td>' +
							'<td>' +
								'<img src="images/header_waves_03.gif" width=174 height=40 border="0" alt=""><br>' +
							'</td>' +
							'<td bgcolor="#000053" align="right" valign="top">' +
								'<img src="images/spacer.gif" width=239 height=5 border="0" alt=""><br>' +
								'<a href="rus/index.htm"><img src="images/menu/header_ref_rus.gif" width="136" height="9" border="0" alt=""></a><br>' +
							'</td>' +
							'<td bgcolor="#000053">' +
								'<img src="images/spacer.gif" width="6" height="1" border="0" alt=""><br>' +
							'</td>' +
						'</tr>' +
						'<tr>' +
							'<td colspan=4 bgcolor="#1B3450">' +
								'<img src="images/spacer.gif" width=1 height=6 border="0" alt=""><br>' +
							'</td>' +
						'</tr>' +
					'</table>' +
				'</td>' +
			'</tr>'
	);
}

function insertMenu(){
	document.write(
			'<tr>' +
				'<td bgcolor="#D5D4D8" valign="top">' +
					'<table border="0" cellspacing="0" cellpadding="0">' +
						'<tr>' +
							'<td bgcolor="#D4D3D7">' +
								'<img src="images/spacer.gif" width="1" height="1" border="0" alt=""><br>' +
							'</td>' +
							'<td>' +
								'<table width="100%" border=0 cellpadding=0 cellspacing=0>' +
									'<tr>' +
										'<td colspan="3">' +
											'<img src="images/menu/topmenu.gif" width="205" height="39" alt="" border="0"><br>' +
										'</td>' +
									'</tr>' +
									'<tr>' +
										'<td>' +
											'<img src="images/menu/button.jpg" width="84" height="14" border="0" alt=""><br>' +
										'</td>' +
										'<td>' +
											'<img name="Indexhome" src="images/menu/index.gif" width="14" height="14" border="0" alt=""><br>' +
										'</td>' +
										'<td>' +
											'<a href="index.htm" onmouseover="javascript:menuOver(\'Indexhome\');" onmouseout="javascript:menuOut(\'Indexhome\');">' +
											'<img src="images/menu/menu_home.gif" width="107" height="14" border="0" alt=""><br>' +
											'</a>' +
										'</td>' +
									'</tr>' +
									'<tr>' +
										'<td colspan="3" background="images/menu/bgshadow.gif">' +
											'<img src="images/menu/shadow.gif" width=12 height=12 border="0" alt=""><br>' +
										'</td>' +
									'</tr>'
	);
	for(i=0;i<site.length;i++){
		if(!site[i].show) continue;
		document.write(
									'<tr>' +
										'<td>' +
											'<img src="images/menu/button.jpg" width="84" height="14" border="0" alt=""><br>' +
										'</td>' +
										'<td>' +
											'<img name="Index' + site[i].id + '" src="images/menu/index.gif" width="14" height="14" border="0" alt=""><br>' +
										'</td>' +
										'<td bgcolor="#02296A">'
		);
		document.write(
											'<a href="' + site[i].link + '" onmouseover="javascript:menuOver(\'Index' + site[i].id + '\');" onmouseout="javascript:menuOut(\'Index' + site[i].id + '\');">' +
											'<img src="' + site[i].menu.menuImage + '" width="107" height="14" border="0" alt=""><br>' +
											'</a>'
		);
		document.write(
										'</td>' +
									'</tr>' +
									'<tr>' +
										'<td colspan="3" background="images/menu/bgshadow.gif">' +
											'<img src="images/menu/shadow.gif" width=12 height=12 border="0" alt=""><br>' +
										'</td>' +
									'</tr>'
		);
	}
	document.write(
								'</table>' +
							'</td>' +
						'</tr>' +
					'</table>' +
				'</td>' +
				'<td valign="top" rowspan="2">' +
					'<table width="100%" border=0 cellpadding=0 cellspacing=0>' +
						'<tr>' +
							'<td valign="top" rowspan="2">' +
								'<img src="images/self_shadow_left.jpg" width=38 height=88 border="0" alt=""><br>' +
							'</td>' +
							'<td>' +
								'<img src="images/pagetitle/pagetitle.gif" width="473" height="86" border="0" alt=""><br>'
	);
	var Page = findPageById(id);
//	document.title = Page.name;
	document.write(
								'<img src="' + Page.pagetitle.pagetitleImage + '" width="473" height="20" border="0" alt=""><br>'+
								'<img src="images/spacer.gif" width=1 height=20 border="0" alt=""><br>'
	);
	document.write(
							'</td>' +
							'<td valign="top" rowspan="2">' +
								'<img src="images/spacer.gif" width=44 height=1 border="0" alt=""><br>' +
								'<img src="images/self_shadow_right.gif" width="3" height="105" border="0" alt=""><br>' +
							'</td>' +
						'</tr>' +
						'<tr>' +
							'<td>'
	);
}

function insertFooter(){
	document.write(
							'<br>' +
							'<img src="images/spacer.gif" width=1 height=20 border="0" alt=""><br>' +
							'</td>' +
						'</tr>' +
					'</table>' +
				'</td>' +
			'</tr>' +
			'<tr>' +
				'<td valign="bottom" bgcolor="#D5D4D8">' +
					'<table width="100%" border=0 cellpadding=0 cellspacing=0>' +
						'<tr>' +
							'<td>' +
								'<img src="images/spacer.gif" width=1 height=150 border="0" alt=""><br>' +
								'<img src="images/footer_line.gif" width=206 height=5 border="0" alt=""><br>' +
							'</td>' +
						'</tr>' +
						'<tr>' +
							'<td>' +
								'<img src="images/footer_banner.gif" width=206 height=76 border="0" alt=""><br>' +
							'</td>' +
						'</tr>' +
						'<tr>' +
							'<td bgcolor="#FAF9FA">' +
								'<img src="images/spacer.gif" width=1 height=4 border="0" alt=""><br>' +
							'</td>' +
						'</tr>' +
						'<tr>' +
							'<td>' +
								'<img src="images/footer_mcal.jpg" width=206 height=26 border="0" alt=""><br>' +
							'</td>' +
						'</tr>' +
						'<tr>' +
							'<td>' +
								'<img src="images/footer_phonefax.gif" width=206 height=70 border="0" alt="" usemap="#phonefax"><br>' +
								'<map name="phonefax">' +
								'<area shape="rect" alt="" coords="80,20,205,5" href="mailto:funds@diamondage.ru">' +
								'</map>' +
							'</td>' +
						'</tr>' +
					'</table>' +
				'</td>' +
			'</tr>' +
			'<tr>' +
				'<td bgcolor="#E6E6E8">' +
					'<img src="images/footer_squares_01.gif" width=101 height=6 border="0" alt=""><br>' +
				'</td>' +
				'<td bgcolor="#E6E6E8">' +
					'<img src="images/spacer.gif" width=1 height=1 border="0" alt=""><br>' +
			'</tr>' +
			'<tr>' +
				'<td bgcolor="#D5D4D8" valign="top">' +
					'<img src="images/footer_squares_02.gif" width=101 height=4 border="0" alt=""><br>' +
				'</td>' +
				'<td bgcolor="#FFFFFF" valign="top" >' +
					'<img src="images/footer_copyrights.gif" width="203" height="21" alt="" border="0">' +
                                        '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+
                                        '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+
                                        '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+
                                        '<a href="disclamer.htm"><font face="Times New Roman" size=1>Important Legal and Regulatory Information</font></a>'+					
                                        '<img src="images/spacer.gif" width="1" height="13" border="0" alt=""><br>' +
				'</td>' +
			'</tr>' +
		'</table>'+
		'</td>' +
	'</tr>' +
'</table>'
	);
}

// Window management functions

//var page, wid, hit, nam, stt, rsz, top, lt;
var dTop = 100;
var dLt = 100;
var windowCounter = 0;

function win(page, nam, wid, hit, top, lt){
	if (page == '') {
		alert('win() error: not enough parameters!');
	}
	windowCounter++;
	if (!wid) {
		wid = 400;
	}
	if (!hit) {
		hit = 300;
	}
	var maxTop = dTop + hit;
	var maxLeft = dLt + wid;
	if (maxTop > document.body.clientHeight) {
		dTop = 100
	}
	if (maxLeft > document.body.clientWidth) {
		dLt = 100
	}
	if (!top) {
		dTop = dTop + 20;
		top = dTop;
	}
	if (!lt) {
		dLt = dLt + 20;
		lt = dLt;
	}
	if (!nam) {
		nam = 'window'+windowCounter;
	}

	var windo=eval('window.open("'+page+'","'+nam+'","status=no,toolbar=no,resizable=yes,scrollbars=yes, menubar=no,width='+wid+',height='+hit+',top='+top+',left='+lt+'")');
}

function modwin(page, nam, wid, hit, top, lt, stt, rsz) {
	if (page == '') {
		alert('modwin() error: not enough parameters!');
	}
	if (!wid) {
		wid = 400;
	}
	if (!hit) {
		hit = 300;
	}
	if (!top) {
		dTop = dTop + 20;
		top = dTop;
	}
	if (!lt) {
		dLt = dLt + 20;
		lt = dLt;
	}
	if (!stt) {
		stt = 'no';
	}
	if (!rsz) {
		rsz = 'no';
	}
	
	showModelessDialog(page, nam,'status:'+stt+';resizable:'+rsz+'; top:'+top+'px; left: '+lt+'px; dialogWidth: '+wid+'px; dialogHeight: '+hit+'px; help: no')
}

// End

// Favourites and homepage functions

function setHomepage(f) {
	f.style.behavior='url(#default#homepage)';
	f.setHomePage('http://192.168.1.174/index.htm')
}

function addBookmark() {
	window.external.addFavorite('http://192.168.1.174/index.htm', 'Diamond Age Fund - Coming soon')
}

// End
// Layer position management functions

function posLayer(which) {
	document.all[which].style.pixelTop = (document.body.clientHeight/2)-(document.all[which].clientHeight/2)+document.body.scrollTop;
	document.all[which].style.pixelLeft = (document.body.clientWidth/2)-(document.all[which].clientWidth/2)+document.body.scrollLeft;
	if(document.all[which].style.zIndex<=dragz){
		document.all[which].style.zIndex=dragz+1
	}
//	dropShadow(which,'#AAAAAA',4);
}

function showCenter(which) {
	toggleVisibility(which);
	if (which.className == "hidden"){
	        posLayerNew(which);
	}
}


function posLayerNew(which) {
	which.style.pixelTop = (document.body.clientHeight/2)-(which.clientHeight/2)+document.body.scrollTop;
	which.style.pixelLeft = (document.body.clientWidth/2)-(which.clientWidth/2)+document.body.scrollLeft;
}

function showBy(par, chld) {
        if ((typeof par == 'object') && (typeof chld == 'object')) {
                hideObject(chld, 1);
                showObject(chld, 1);
                _hideAfterUse = function() {
                        hideObject(chld, 1);
                }
                hideAfterUse = function() {
                        setTimeout('_hideAfterUse()', 100);
                }
                chld.attachEvent("onclick", hideAfterUse);
                chld.attachEvent("onmouseleave", hideAfterUse);
                var additional_pixel = 1;
                var o_x = 0;
                var o_y = 0;
                o_y = event.clientY + document.body.scrollTop + (par.offsetHeight - event.offsetY) - additional_pixel;
                o_x = event.clientX + document.body.scrollLeft - event.offsetX - additional_pixel;
                if (o_x+chld.offsetWidth > document.body.clientWidth) {
                        o_x = event.clientX - chld.offsetWidth + par.offsetWidth - event.offsetX - additional_pixel;
                }
                if (o_y+chld.offsetHeight > document.body.clientHeight) {
                        o_y = event.clientY - chld.offsetHeight - event.offsetY - additional_pixel;
                }
                chld.style.top = o_y;
                chld.style.left = o_x;
//                alert(par.offsetTop + par.offsetHeight);
        }
}

// End



