/*
dialog(text)  вывести текста
dialog_status(text)  вывести текста, без кнопки закрыть
dialog_error(text)  вывести текста, без кнопки закрыть
dialog_close()   закрыть
dialog_image(src) для изображений
dialog_flv(src) Для flash роликов
dialog_swf(src)  для
dialog_mp3(src)  для вставки музыки
dialog_iframe(src)
*/
///////////////////////////////
var dialogplayerdir="/dialog/players";
/////////////////
document.write("<div id='okno'><table id='tdialog'><tr><td class='ul'></td><td class='uc'><div onclick='dialog_close()' id='dialog_clos'>&nbsp;</div></td><td class='ur'></td></tr><tr><td class='ml'></td><td class='mc' id='dialog_content'>124234</td><td class='mr'></td></tr><tr><td class='bl'></td><td class='bc'></td><td class='br'></td></tr></table></div><table id='moveokno' class='blacktdialog'><tr><td class='ul'></td><td class='uc'></td><td class='ur'></td></tr><tr><td class='ml'></td><td class='mc' id='move_content'>124234</td><td class='mr'></td></tr><tr><td class='bl'></td><td class='bc'></td><td class='br'></td></tr></table>");
//////////////////
var prozrachnost=0;
function dialog(text){
         document.getElementById("dialog_clos").style.display="block";
         dialog_status(text);
}
function dialog_status(text){
         prozrachnost=0;
         document.getElementById("okno").style.display="block";
         document.getElementById("dialog_content").innerHTML=text;
         shirina=document.documentElement.clientHeight;
         vnutren=document.getElementById("tdialog").offsetHeight;
         tmargin=Math.floor((shirina-vnutren)/2);
         tmargin=tmargin-20;
         if(tmargin<20){
         tmargin=20;
         }
         document.getElementById("tdialog").style.marginTop=tmargin+"px";
         setTimeout("opacity(1)",10);
}
function dialog_close(){
         document.getElementById("dialog_clos").style.display="none";
         prozrachnost=100;
         setTimeout("opacity(0)",10);
}
////////
function opacity(x){
         dob=10;
         if(x==0){
         dob=dob*(-1);
         }
         prozrachnost=prozrachnost+dob;
         if(prozrachnost<0){
         prozrachnost=0;
         document.getElementById("dialog_content").innerHTML="";
         }
         if(prozrachnost>100){
         prozrachnost=100;
         }
         if(prozrachnost==0){
         document.getElementById("okno").style.display="none";
         document.getElementById("dialog_content").innerHTML="";
         }
         prozrachnostfloor=prozrachnost/100;
         document.getElementById("okno").style.opacity=prozrachnostfloor;
         document.getElementById("okno").style.filter="alpha(opacity:" +prozrachnost +")";
         if((prozrachnost>0)&&(x==0)){
         setTimeout("opacity(0)",50);
         }
         if((prozrachnost<100)&&(x==1)){
         setTimeout("opacity(1)",50);
         }
}
//////////////
var cashimg=[0];
var cashix=[0];
var cashiy=[0];
function dialog_image(adres){
dlina=cashimg.length;
position=-1;
for(var i=0;i<dlina;i++){
if(cashimg[i]==adres){
position=i;
}
}
if(position>=0){
dialog_load_image(adres,cashix[position],cashiy[position]);
}
//////
if(position<0){
dialog('<div class="loadingdialog"><nobr>Загрузка изображения</nobr><div id="dialogoverflow"><img id="dialogimage" src="'+adres+'"/></div></div>');
document.getElementById("dialogimage").onload=function(){
heightimg=document.getElementById("dialogimage").offsetHeight;
widthimg=document.getElementById("dialogimage").offsetWidth;
adres=document.getElementById("dialogimage").getAttribute("src");
position=cashimg.length;
cashix[position]=widthimg;
cashiy[position]=heightimg;
cashimg[position]=adres;
dialog_load_image(adres,widthimg,heightimg);
}
}
//
}
//
function dialog_load_image(adres,x,y){
nvisot=document.documentElement.clientHeight-100;
nshir=document.documentElement.clientWidth-200;
zmy=y;
zmx=x;
if(y>nvisot){
zmy=nvisot;
zmx=x*zmy/y;
}
if(zmx>nshir){
zmy=zmy*nshir/zmx;
zmx=nshir;
}
dialog('<img src="'+adres+'" style="width:'+zmx+'px; height:'+zmy+'px"/>');
}
///////////////////
function code_flv(adres){
txt='<object id="player_api" style="width:100%; height:100%" type="application/x-shockwave-flash" data="'+dialogplayerdir+'/flowplayer.swf"><param value="true" name="allowfullscreen"/><param value="always" name="allowscriptaccess"/><param value="high" name="quality"/><param value="false" name="cachebusting"/><param value="#000000" name="bgcolor"/><param value=\'config={"clip":{"url":"'+adres+'"},"playlist":[{"url":"'+adres+'"}]}\' name="flashvars"/></object>';
return txt;
}
///////////////////
function code_mp3(adres){
zagolovok=adres;
if(zagolovok.indexOf("/")>-1){
razd=zagolovok.split("/");
kolr=razd.length-1;
zagolovok=razd[kolr];
}
txt='<embed src="'+dialogplayerdir+'/mp3.swf?mp3url='+adres+'&#038;txt='+zagolovok+'&#038;bgcolor=#ffffff" quality="high" bgcolor="#ffffff" wmode="opaque" style="width:290px; height:50px" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"/>';
return txt;
}
//////////////////////////
function dialog_error(infname){
dialog_status(infname+'<div style="clear:both"><input value="Закрыть" onclick="dialog_close()" type="button" style="width:100px; margin:10px auto; display:block; cursor:pointer"/></div>');
}
///////////////////////
function dialog_flv(adres){
dialog("<div style='width:400px; height:300px'>"+code_flv(adres)+"</div>");
}
///////////////////
function dialog_mp3(adres){
dialog(code_mp3(adres));
}
///////////////
function dialog_swf(adres){
dialog('<embed src="'+adres+'" style="width:640px; height:480px"/>');
}
//////////////////////
function dialog_iframe(src){
dialog("<table><tr><td><div id='resize_dialog'><iframe src='"+src+"' APPLICATION=yes style='width:100%; height:100%' frameborder=0 scrolling=auto></iframe></td></tr><tr><td><div onmousedown='dialog_resize()' ondrag='return false' class='resize'></div></td></tr></table>");
}
///////////////////
var mousepoloj=0;
var polojenmousex=0;
var polojenmousey=0;
var tekpositionx=0;
var tekpositiony=0;
document.onmousemove=function(e){
var x = 0, y = 0;
    if (!e) e = window.event;
    if (e.pageX || e.pageY){
        x = e.pageX;
        y = e.pageY;
    } else if (e.clientX || e.clientY){
        x = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
        y = e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop;
    }
polojenmousex=x;
polojenmousey=y;
if(mousepoloj==1){
shirina=document.getElementById("resize_dialog").offsetWidth;
visota=document.getElementById("resize_dialog").offsetHeight;
raznx=shirina+(polojenmousex-tekpositionx)*2;
razny=visota+(polojenmousey-tekpositiony)*2;
document.getElementById("resize_dialog").style.height=razny+"px";
document.getElementById("resize_dialog").style.width=raznx+"px";
tekpositionx=polojenmousex;
tekpositiony=polojenmousey;
///
shirina=document.documentElement.clientHeight;
vnutren=document.getElementById("tdialog").offsetHeight;
tmargin=Math.floor((shirina-vnutren)/2);
tmargin=tmargin-20;
if(tmargin<20){
tmargin=20;
}
document.getElementById("tdialog").style.marginTop=tmargin+"px";
}
//
}
document.onmouseup=function(){
mousepoloj=0;
}
function dialog_resize(){
mousepoloj=1;
tekpositionx=polojenmousex;
tekpositiony=polojenmousey;
}
///////////////
function dialog_move(obj){
tt=document.getElementById("moveokno");
tt.style.display="block";
/////////////////////
txt="";
el=obj.getElementsByTagName("*");
ellength=el.length;
for(var i=0;i<ellength;i++){
if(el[i].className=="hidedialog"){
txt=el[i].innerHTML;
}
}
document.getElementById("move_content").innerHTML=txt;
/////////////
el=document.getElementById("move_content").getElementsByTagName("*");
ellength=el.length;
for(var i=0;i<ellength;i++){
el[i].setAttribute("id", "");
}
////////////////
visota=tt.offsetHeight;
shirina=tt.offsetWidth;
//////////
x=polojenmousex;
y=polojenmousey;
///////////////////
mx=x+10;
my=y-visota-10;
shirinawindows=document.documentElement.clientWidth;
dopustiomost=shirinawindows-shirina;
if(mx>dopustiomost){
mx=dopustiomost;
}
if(my<0){
my=0;
}
//////////////////
tt.style.left=mx+"px";
tt.style.top=my+"px";
//////////////////
}
function dialog_moveclos(){
document.getElementById("moveokno").style.display="none";
document.getElementById("move_content").innerHTML="";
}
////////////////////////////////////
$(document).ready(function(){
setTimeout("sem()",50);
});
//////////////////////////
function sem(){
var mainobg=document.body;
var el=document.body.getElementsByTagName("a");
for(var d=0;d<el.length;d++){
tempclass=el[d].getAttribute("class");
if(tempclass=="files"){
adres=el[d].getAttribute("href");
if(adres.indexOf('.')>-1){
razd=adres.split('.');
posled=razd.length-1;
ras=razd[posled];
ras=ras.toLowerCase();
if(ras=="flv" || ras=="mp3"){
////////////
el[d].setAttribute("class", "filesmedia");
var temptitle=el[d].getAttribute("title");
if(temptitle=="" || temptitle==null){
var temptitle=el[d].innerHTML;
el[d].setAttribute("title", temptitle);
}
if(temptitle.indexOf('/')>-1){
razdtitle=temptitle.split('/');
posled=razdtitle.length-1;
temptitle=razdtitle[posled];
}
if(temptitle.indexOf(ras)>-1){
dlina=ras.length+1;
temptitle=temptitle.substr(0,temptitle.length-dlina);
}
if(temptitle.length>20){
temptitle=temptitle.substr(0,17)+"...";
}
el[d].innerHTML="<span><u>"+ras+"</u>"+temptitle+"</span>";
///////////-----------------
el[d].onclick=function(){
if(mainobg!=this){
//--------
for(var s=0;s<el.length;s++){
if(el[s]!=this){
tempclass=el[s].getAttribute("class");
if(tempclass=="filesmedia"){
ras="";
temptitle=el[s].getAttribute("href");
if(temptitle.indexOf(".")>-1){
razd=temptitle.split('.');
posled=razd.length-1;
ras=razd[posled];
ras=ras.toLowerCase();
}
temptitle=el[s].getAttribute("title");
if(temptitle.indexOf('/')>-1){
razdtitle=temptitle.split('/');
posled=razdtitle.length-1;
temptitle=razdtitle[posled];
}
if(temptitle.indexOf(ras)>-1){
dlina=ras.length+1;
temptitle=temptitle.substr(0,temptitle.length-dlina);
}
if(temptitle.length>20){
temptitle=temptitle.substr(0,17)+"...";
}
el[s].innerHTML="<span><u>"+ras+"</u>"+temptitle+"</span>";

}
}
}
//--
adres=this.getAttribute("href");
razd=adres.split('.');
posled=razd.length-1;
ras=razd[posled];
ras=ras.toLowerCase();
txt="";
if(ras=="flv"){
txt=code_flv(adres);
txt="<div style='width:320px; height:240px'>"+txt+"</div>";
}
if(ras=="mp3"){
txt=code_mp3(adres)
}
this.innerHTML="<i>"+txt+"</i><div class='clearfix'></div>";


mainobg=this;
//--------
}
return false;
}
/////////-------------------------
}
}
}


}
}
///////////////////////////////////////
















