var ie=(document.all && document.all.item && !window.opera)?1:0;

var objCount = 1;
pics = new Array();

function preload(img) {
	pics[objCount] = new Image();
	pics[objCount].src = img;
	objCount++;
}

function RollImage(id, n, act_id, n1, todo)
{
	if(id == act_id) return false;

	if(todo=='over')
	{
		/*if(act_id!='')
		{
			document.images[act_id].src = pics[n1].src;
			if(n1==1 || n1==2)
				document.all["td"+act_id].style.backgroundImage = "url(images/grayp.gif)";
			else
				document.all["td"+act_id].style.backgroundImage = "url(images/cell_menu_bg.gif)";
		}*/

		document.images[id].src = pics[n].src;
		document.all["td"+id].style.backgroundImage = "url(images/orangep.gif)";
	}
	else
	{
		/*if(act_id!='')
		{
			document.images[act_id].src = pics[n1].src;
			document.all["td"+act_id].style.backgroundImage = "url(images/orangep.gif)";			
		}*/

		document.images[id].src = pics[n].src;
		
		if(n==1 || n==2)
			document.all["td"+id].style.backgroundImage = "url(images/grayp.gif)";
		else
			document.all["td"+id].style.backgroundImage = "url(images/cell_menu_bg.gif)";
	}
}

function RollImageSub(id, act_id, todo)
{
	if(id == act_id) return false;

	if(todo=='over')
	{
		/*if(document.images[act_id])
		{
			document.images[act_id].src = pics[5].src;
			document.all["td"+act_id].style.backgroundImage = "url(images/subgrayd.gif)";
		}*/
		document.images[id].src = pics[6].src;
		document.all["td"+id].style.backgroundImage = "url(images/subgrayl.gif)";
	}
	else
	{
		/*if(document.images[act_id])
		{
			document.images[act_id].src = pics[6].src;
			document.all["td"+act_id].style.backgroundImage = "url(images/subgrayl.gif)";
		}*/
		document.images[id].src = pics[5].src;
		document.all["td"+id].style.backgroundImage = "url(images/subgrayd.gif)";
	}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function ShowHideDirs(id) {
	if(!ie) return true;
	if(!document.all["dir"+id]) return true;

	dir = document.all["dir"+id];
	if (dir.className == 'BlShow') {
		dir.className = 'BlHide';
	} else {
		dir.className = 'BlShow';
	}
	return false;
}

function HideAllDirs() {
	var i,id, args = HideAllDirs.arguments;
	if(!ie) return true;
	for(i=0; i<args.length; i++)
	{
		id = args[i];
		if(document.all["dir"+id])
		{
			dir = document.all["dir"+id];
			dir.className = 'BlHide';
		}
	}
	return true;
}

function openImage(image,title) {
	window.open("/popup.php?img="+image+"&title="+title, "popupimage", "scrollbars=1, resizable=0, width=520, height=450").focus();
}

function openImageg(image,title) {
	window.open("/npopup.php?img="+image+"&title="+title, "popupimage", "scrollbars=1, resizable=0, width=520, height=450").focus();
}

function openImagen(id,num) {
	window.open("/gallery/"+id+"/"+num, "popupimage", "scrollbars=1, status=0, resizable=1, width=520, height=450, top=10").focus();
}

function openPrint(page) {
	window.open("/txt"+page, "printpopup", "scrollbars=1, location=1, menubar=1, resizable=1, width=730, height=600").focus();
}

function PrintPage()
{
	window.print();
}

function ShowHCombo(id) {
	if(!ie) return true;
	
	if(!document.all["comb"+id]) return true;
    
	comb = document.all["comb"+id];
	if (comb.className == 'BlShow') {
		comb.className = 'BlHide';
	} else {
		comb.className = 'BlShow';
	}
	return false;
}

function SetHiddenVar(variable,val) {
	var forma = document.forms['Search'];
	forma.elements[variable].value = val;
	forma.submit();
	return false;
}

function SetHolidays(sel) {
	var forma = document.forms['take_tour'];
	sel_d = forma.elements['fld['+sel+'_day]'];
	sel_m = forma.elements['fld['+sel+'_month]'];
	sel_y = forma.elements['fld['+sel+'_year]'];
	month = sel_m.options[sel_m.selectedIndex].value;
	year = sel_y.options[sel_y.selectedIndex].value;
	dateObj = new Date(year, month, 0);
	last_d = dateObj.getDate();
	for (i=0;i<31;i++) {
		option = sel_d.options[i]
		dateObj = new Date(year, (month-1), option.value);
		colr = 'Black';
		if (i>=last_d) 
			colr = '#808080';
		else if (dateObj.getDay()==6 || dateObj.getDay()==0)
			colr = '#CF1315';
		option.style.color = colr; 
	}
}

function AddFavor(url)
{
	window.external.AddFavorite(url, 'ÑîþçÊóðîðò')
}

function ShowRightMenu()
{
	var timeout = 300;
	var t = 0;

	if( document.all['rmt_subdir'] )
		setTimeout("document.all['rmt_subdir'].className = 'showitem'", timeout);
	if( document.all['right_menu_table'] )
		setTimeout("document.all['right_menu_table'].className = 'showitem'",  timeout);
	
	var i=0;
	while( document.all['dir_'+i] )
	{
		t++;
		setTimeout("document.all['dir_"+i+"'].className = 'showitem'", timeout*(t+1));
		setTimeout("document.all['separ_"+i+"'].className = 'showitem'", timeout*(t+1));
	
		if( document.all['submenu_'+i] )
		{
			setTimeout("document.all['submenu_"+i+"'].className = 'showitem'", timeout*(t+1));
		
			var k=0;
			while( document.all['subdir_'+k] )
			{
				t++;
				setTimeout("document.all['subdir_"+k+"'].className = 'showitem'", timeout*(t+1));
				setTimeout("document.all['subsepar_"+k+"'].className = 'showitem'", timeout*(t+1));
				k++;
			}
		}

		i++;
	}
	
	t++;
	if( document.all['last_tr_id'] )
		setTimeout("document.all['last_tr_id'].className = 'showitem'",  timeout*(t+1));
}

function ShowMail(user, domain1, domain2) {
	var email = user+'&#64;'+domain1+'&#46;'+domain2;
	if (ShowMail.arguments[3]) name = ShowMail.arguments[3];
	else name = email;
	document.writeln('<a href="mailto:'+email+'">'+name+'</a>');
}