Time=new Date();N=0;col="Color";Hshift=0;Vshift=0;
FP="document.getElementById('";LP="').";LPS="').style.";window.onresize=Resize;window.onload=FirstTime;

function ScrollSize()
{
	h = document.body.clientHeight - 86;
	if(h < 100)h = 100;

	if(navigator.appName=="Netscape"||window.opera)
	{
		h = window.innerHeight-109;
		if(h < 100)h = 100;
		w = window.innerWidth;
		if(w<785){h=h-15}
	}

	eval(FP+"sc"+LPS+"height='" + h + "px'");
}

function CreateSubMenu(number){if(eval(FP+"s"+number+LPS+"visibility=='visible'")){return};N=number;if(window.opera){FirstTime()};if(eval(FP+"s"+number+LPS+"visibility =='visible'")){return};number=number.toString();eval(FP+"a"+number+LPS+"color='yellow'");eval(FP+"s"+number+LPS+"visibility ='visible'")}
function Disable(number){if(eval(FP+"s"+number+LPS+"visibility=='hidden'")){return};N=number;number=number.toString();eval(FP+"a"+number+LPS+"color='white'");eval(FP+"s"+number+LPS+"visibility='hidden'")}
function DisableAll(){if(N!=0){Disable(N);N=0}}
function FirstTime()
{
for(number=1;number<5;number++)
{
if(navigator.appName=="Netscape"){eval("Hshift=6+"+FP+"all"+LP+"offsetLeft");Vshift=4}
else{eval("Hshift=5+"+FP+"all"+LP+"offsetLeft");Vshift=3};
if(!window.crypto&&navigator.appName=="Netscape"&&!window.opera)
{eval("Hshift=6+"+FP+"all"+LP+"offsetLeft");Vshift=4};
if(window.opera)
{eval("Hshift=6+"+FP+"all"+LP+"offsetLeft");col=""};
if(window.opera&&sc.innerHTML){eval("Hshift=5+"+FP+"all"+LP+"offsetLeft");Vshift=2;col=""};eval("w="+FP+"m"+number+LP+"offsetWidth");eval(FP+"s"+number+LPS+"width='"+w+"px'");eval(FP+"s"+number+LPS+"width='"+w+"px'");eval("x="+FP+"m"+number+LP+"offsetLeft");x=x+Hshift;y=59+Vshift;eval(FP+"s"+number+LPS+"left='"+x+"px'");{eval(FP+"s"+number+LPS+"top='"+y+"px'")}
}
}
function Resize(){ScrollSize();FirstTime()}
function Search(){if (navigator.appName=="Microsoft Internet Explorer"&&!window.opera){var r,i,s=document.selection.createRange().text;if(!s) s=window.showModalDialog("ToFind.htm",[],"dialogHeight:150px;dialogWidth:400px;help=no;status=no;scroll=no;resizable=no");if(s){r=document.body.createTextRange();for(i=0;r.findText(s[0]);i++){r.execCommand('BackColor','','yellow');r.collapse(false)};alert('Найдено: '+i+' слово(а)')}}else{alert('Воспользуйтесь комбинацией клавиш Ctrl+F')}}



function StatusString(index,tx,flag)
{
	if(index==0)
		document.getElementById("IndexHolder").style.display="none";

	NTime=new Date();
	FTime=new Date(NTime-Time);
	S=FTime.getSeconds();
	M=FTime.getMinutes();
	H=FTime.getHours()+FTime.getTimezoneOffset()/60;
	if (M==0&&H==0){text=S};
	if(M>0&&H==0){text=M+" мин. "+S};
	if(H>0){text=H+" час. "+M+" мин. "+S};

	ix = Math.round(index*100);
	document.getElementById("IndexHolder").innerHTML = ix + "%";
	
	if(index<=60)
	{
		document.getElementById("IndexHolder").style.backgroundColor="#FF4C4C";
		document.getElementById("IndexHolder").style.color="#fff";
	}

	if(flag)
		{
			DepF="Ваше занятие длится "+text+" сек."
		}
	    else{
			document.getElementById("IndexHolder").title = "Ваш индекс успеваемости: " + index + "% \n" + tx; 
			return;
		};

	document.getElementById("IndexHolder").title = "Ваш индекс успеваемости: " + index + "% \n" + tx + " \n" + DepF;
	Nindex=index;
	Ntx = tx;

	setTimeout("StatusString(Nindex,Ntx,true)",10000);
}


function ShowHidden(obj,tp)
{
j=i=0;

if(tp)
{
	if(document.getElementById(obj+'v0')==null&&document.getElementById(obj+'h0')==null)return;
	if(document.getElementById(obj+"p").style.display=="none")
	{st="";document.getElementById(obj+"vv").src="img/minus.gif";}
	else
	{st="none";document.getElementById(obj+"vv").src="img/plus.gif";}
	do{if(document.getElementById(obj+"v"+i)!=null){document.getElementById(obj+"v"+i).style.display=st;i++;}else break;}while(true);
	if(st=="none")do{if(document.getElementById(obj+"h"+j)!=null){document.getElementById(obj+"h"+j).style.display=st;j++;}else break;}while(true);
	document.getElementById(obj+"p").style.display=st;
	if(j>0)document.getElementById(obj+"hh").src="img/plus.gif";
}
else
{
	if(document.getElementById(obj+'h0')==null)return;
	if(document.getElementById(obj+"h0").style.display=="none")
	{st="";document.getElementById(obj+"hh").src="img/minus.gif";}
	else
	{st="none";document.getElementById(obj+"hh").src="img/plus.gif";}
	do{if(document.getElementById(obj+"h"+i)!=null){document.getElementById(obj+"h"+i).style.display=st;i++;}else break;}while(true);
}

}

function ShowSubj(obj)
{
if(document.getElementById(obj).style.display=="none")
{
	document.getElementById(obj).style.display="";
	//document.getElementById('p'+obj).innerHTML="-";
	document.getElementById('p'+obj).src="img/minus.gif";
}
else
{
 	document.getElementById(obj).style.display="none";
	//document.getElementById('p'+obj).innerHTML="+";
	document.getElementById('p'+obj).src="img/plus.gif";
}
}

function e(x)
{
	s = window.showModalDialog("feedbackform.aspx?sid="+SubjID+"&lid="+LessonID+"&linkid="+x,[],"dialogHeight:230px;dialogWidth:400px;help=no;status=no;scroll=no;resizable=no");

	if(s!=2)
	{
		if(s==1)alert("Сообщение отправлено!");else alert("Ошибка!");
	}
}
function m(x)
{
	s = window.showModalDialog("feedbackform.aspx?mes=1&sid="+SubjID+"&lid="+LessonID+"&linkid="+x,[],"dialogHeight:230px;dialogWidth:400px;help=no;status=no;scroll=no;resizable=no");

	if(s!=2)
	{
		if(s==1)alert("Сообщение отправлено!");else alert("Ошибка!");
	}
}

function l(x)
{
	txt = document.getElementById("d"+x).innerText;
	if(txt.length>70) txt = txt.slice(0,67) + "...";
	s = window.showModalDialog("addbookmarkform.aspx?sid="+SubjID+"&lid="+LessonID+"&linkid="+x+"&nm="+escape(txt),[],"dialogHeight:150px;dialogWidth:400px;help=no;status=no;scroll=no;resizable=no");

	if(s!=2)
	{
		if(s==1)alert("Закладка успешно добавлена!");else alert("Ошибка при добавлении закладки!");
	}
}

function ex(x)
{
	if(!confirm('Вы уверенны, что хотите закончить работу с системой?\nПри следующем входе в систему Вы сможете продолжить обучение с этого места.'))return;
	window.location="exit.aspx?linkid="+x;
}

function ToolBarClose()
{
	document.getElementById('toolbar').style.display="none";
	document.getElementById('toolbar0').style.display="block";
}
function ToolBarOpen()
{
	document.getElementById('toolbar').style.display="block";
	document.getElementById('toolbar0').style.display="none";

}

function ToolBarOver(x)
{
	x.style.background='#ccc';
	x.style.borderBottomColor = "#546543";
	x.style.borderRightColor = "#546543";
}

function ToolBarOut(x)
{
	x.style.background='#eee';
	x.style.borderBottomColor = "#A4B998";
	x.style.borderRightColor = "#A4B998";
}

function SendMes(type, url)
{
	s = window.showModalDialog("feedbackform.aspx?mes="+type+"&url="+url,[],"dialogHeight:230px;dialogWidth:400px;help=no;status=no;scroll=no;resizable=no");

	if(s!=2)
	{
		if(s==1)alert("Сообщение отправлено!");else alert("Ошибка!");
	}
}