/*/////////////////////////////////////////////////////
dialog(text)  вывести текста
dialog_close()   закрыть
dialog_status(text)  вывести текста, без кнопки закрыть
dialog_error(text)  вывести текста, без кнопки закрыть
dialog_image(src) для изображений
dialog_flv(src) Для flash роликов
dialog_swf(src)  для флешек
dialog_mp3(src)  для вставки музыки
dialog_iframe(src) для фреймов
dialog_gallery(this, 'group')//adres from href or src, +attribute group
//------------
dialog_move(this) dialog_moveclose() 
class='hidedialog'
///=========================================plus
addShadow(shadow, text, razmer)
setCookie(name, value)
getCookie(name)
code_flv(adres)
code_mp3(adres)
posLeft(obj) поучение координаты обьекта
posTop(obj)  поучение координаты обьекта
onReady(function(){}); загрузка дом дерева
printpage() //распечатать div c id='page'
toggle(id) //скрыть отобразить
return add_favorite(this); //добавить в избранное
intvalue(str) полчить только цифры
numreal(str) получить цену
comments(id, this)
random(min, max)
polojenmousex - положение мышки
polojenmousey - положение мышки
///----------------------
для включение слайдера 
<div id='slider' width='100' time='1000' playtime='15000' height='100' slider='opacity||slider' playbuttons='true'(скрывать при автоплее) button_top='true' button_down='true' arrows='true' play='true' autoplay='true' realname='true' resize='true'>
	<div title='ONE' realname='one'>1</div>
	<div>2</div>
</div>
для включение тени
<div shadow='shadow' razmer='100%'>....</div>
Для включение классов к файлам
<a hrer="/file.jpg" class='files'>file</a>
*/////////////////////////////////////////onready functions////////////////
function bindReady(handler){
  var called = false
  function ready() { // (1)
    if (called) return
    called = true
    handler()
  }
  if (document.addEventListener ) { // (2)
    document.addEventListener( "DOMContentLoaded", function(){
      document.removeEventListener( "DOMContentLoaded", arguments.callee, false)
      ready()
    }, false )
  } else if ( document.attachEvent ) {  // (3)
    if ( document.documentElement.doScroll && window == window.top ) {
      function tryScroll(){
        if (called) return
        try {
          document.documentElement.doScroll("left")
          ready()
        } catch(e) {
          setTimeout(tryScroll, 0)
        }
      }
      tryScroll()
    }
    document.attachEvent("onreadystatechange", function(){
      if ( document.readyState === "complete" ) {
        document.detachEvent( "onreadystatechange", arguments.callee )
        ready()
      }
    })
  }
    if (window.addEventListener)
        window.addEventListener('load', ready, false)
    else if (window.attachEvent)
        window.attachEvent('onload', ready)
}
readyList = []
function onReady(handler) {
  if (!readyList.length) {
    bindReady(function() {
      for(var i=0; i<readyList.length; i++) {
        readyList[i]()
      }
    })
  }
  readyList.push(handler)
}
///////////////////////////////
var dialogresize="resize.php";
//////////////////
el=document.getElementsByTagName("script");
var dialogplayerdir="";
for(var i=0;i<el.length;i++){
	tempsrc=el[i].getAttribute("src");
	if(tempsrc!=null && tempsrc!=""){
		if(tempsrc.indexOf("dialog")>=0){
			srazd=tempsrc.split("/");
			for(m=0;m<srazd.length-1;m++){
				dialogplayerdir=dialogplayerdir+"/"+srazd[m];
			}
			dialogplayerdir=dialogplayerdir.substr(1,dialogplayerdir.length-1);
		}
	}
}	
/////////////////
document.write("<iframe name='myfr' id='myfr' APPLICATION='yes' style='width:5px; height:5px; position:absolute; left:-100px; top:-100px' frameborder='0' scrolling='no'></iframe>");
document.write("<div id='shadow_dialog_bg' style='display:none'></div>");
document.write("<div id='okno' style='display:none'><div id='tdialog'>"+addShadow("shadow", "<div onclick='dialog_close()' id='dialog_clos'>&nbsp;</div><div id='dialog_content'>&nbsp;</div> ")+"</div></div>");
document.write("<div id='show_dialog_block' style='display:none'>"+addShadow("gray", "<span id='close_show_dialog' onclick=\"toggle('show_dialog_block')\">X</span><div id='show_dialog_content'></div>")+"</div>");
document.write("<div id='moveokno' style='display:none'>"+addShadow("gray", "<div id='move_content'></div>")+"</div>");
//////////////////
var elements_obj_dialog=[0];
function animate(t_obj,x1,x2,timer,tip_style){
	x1=intvalue(x1);
	x2=intvalue(x2);
	timer=intvalue(timer);
	if(x1!=x2){
		status_obj_style=0;
		if(document.getElementById(t_obj)){
			obj=document.getElementById(t_obj);
			status_obj_style=1;
		}
		if(!document.getElementById(t_obj)){
			if(t_obj){
				obj=t_obj;
				status_obj_style=1;
			}
		}
		if(status_obj_style==1){
			nowtime=new Date();
			nowsec=nowtime.getTime();
			objrandom=nowsec*1000000+Math.round(Math.random()*999999);
			elements_obj_dialog[objrandom]=obj;
			stimer=20;
			steps=Math.round(timer/stimer);		
			if(x2>x1){
				razn=x2-x1;
			}
			if(x1>x2){
				razn=x1-x2;
			}
			shag=Math.round(razn/steps);
			if(x2<x1){
				shag=shag*(-1);
			}
			for(i=1;i<=steps;i++){
				x1=x1*1+shag;
				if(i==steps){
					x1=x2;
				}
				steptime=stimer*i;
				setTimeout("setStyle("+objrandom+","+x1+", '"+tip_style+"')",steptime);
			}
		}
	}
}
function setStyle(id_el,pos_style,tip_style){
	obj=elements_obj_dialog[id_el];
	if(tip_style=="left"){
		obj.style.left=pos_style+"px";
	}
	if(tip_style=="top"){
		obj.style.top=pos_style+"px";
	}
	if(tip_style=="width"){
		obj.style.width=pos_style+"px";
	}
	if(tip_style=="height"){
		obj.style.height=pos_style+"px";
	}
	if(tip_style=="widthProcent"){
		obj.style.width=pos_style+"%";
	}
	if(tip_style=="heightProcent"){
		obj.style.height=pos_style+"%";
	}
	if(tip_style=="marginLeft"){
		obj.style.marginLeft=pos_style+"px";
	}
	if(tip_style=="marginTop"){
		obj.style.marginTop=pos_style+"px";
	}
	if(tip_style=="marginLeftProcent"){
		obj.style.marginLeft=pos_style+"%";
	}
	if(tip_style=="marginTopProcent"){
		obj.style.marginTop=pos_style+"%";
	}
	if(tip_style=="opacity"){
		razd_style=pos_style/100;
		obj.style.opacity=razd_style;
		obj.style.filter="alpha(opacity:"+pos_style+")";
	}
}
//////////////////////////////////////////////////
function dialog(text, navmenu){
        document.getElementById("dialog_clos").style.display="block";
        dialog_status(text, navmenu);
}
function dialog_status(text, navmenu){
	// prozrachnost=0;
	document.getElementById("okno").style.display="block";
	document.getElementById("dialog_content").innerHTML="<div id='dop_dialov_navmenu' class='none'></div>"+text;
	shirina=document.documentElement.clientHeight;
	vnutren=document.getElementById("tdialog").offsetHeight;
	tmargin=Math.floor((shirina-vnutren)/2);
	document.getElementById("tdialog").style.marginTop=tmargin+"px";
	//-----------------
	if(navmenu!=undefined){	
		mass_navmenu=navmenu.split("|");
		zmy=document.getElementById("dialog_content").offsetHeight;
		zmx=document.getElementById("dialog_content").offsetWidth;
		navtop=Math.floor(zmy/2)-20;
		document.getElementById("dop_dialov_navmenu").style.display="block";
		document.getElementById("dop_dialov_navmenu").innerHTML='<div class="navgallery" style="margin:'+navtop+'px 0 0; width:'+zmx+'px">'+mass_navmenu[1]+mass_navmenu[2]+'</div>';
	}
	window.onresize=function(){dialog_close();}	
	//
	browser=navigator.appVersion;
	if(browser.indexOf("MSIE")<0){
		proz=document.getElementById('shadow_dialog_bg').style.opacity;
		if(proz!=1){
			animate("shadow_dialog_bg",0,100,300,"opacity");
		}
	}
	setTimeout("document.getElementById('shadow_dialog_bg').style.display='block';",100);
}
function dialog_close(){
	document.getElementById("dialog_clos").style.display="none";
	document.getElementById("okno").style.display="none";
	document.getElementById("dialog_content").innerHTML="";
	document.getElementById("shadow_dialog_bg").style.display="none";
	browser=navigator.appVersion;
	if(browser.indexOf("MSIE")<0){
		proz=document.getElementById('shadow_dialog_bg').style.opacity="0";
	}	
}
//////////////
var cashimg=[0];
var cashix=[0];
var cashiy=[0];
function dialog_image(adres, navmenu){
	dlina=cashimg.length;
	position=-1;
	for(var i=0;i<dlina;i++){
		if(cashimg[i]==adres){
			position=i;
		}
	}
	if(position>=0){
		tempx=intvalue(cashix[position]);
		tempy=intvalue(cashiy[position]);
		if(tempx==0 || tempy==0){position=-1;}
		if(position>=0){dialog_load_image(adres,cashix[position],cashiy[position],navmenu);}
	}
	if(position<0){
		dialog('<div class="loadingdialog"><nobr>Загрузка изображения</nobr><div id="dialogoverflow"><img id="dialogimage" tempsrc="'+adres+'"/></div></div>');
		document.getElementById("dialogimage").onload=function(){
			heightimg=document.getElementById("dialogimage").offsetHeight;
			widthimg=document.getElementById("dialogimage").offsetWidth;
			position=cashimg.length;
			cashix[position]=widthimg;
			cashiy[position]=heightimg;
			cashimg[position]=adres;
			dialog_load_image(adres,widthimg,heightimg,navmenu);
		}
		document.getElementById("dialogimage").src=adres;
	}
}
//-------------------------------
var gallerymasive=[0];
var galleryadresm=[0];
var gallerytitle=[0];
var gallerystep=0;
var galleryvsego=0;
var gallerystatus=0;
function gallery_slider_razmer(){
	galleryheight=document.documentElement.clientHeight-100;
	gallerywidth=galleryheight*16/9;
	maxwidth=document.documentElement.clientWidth-200;
	maxwidth2=1200;
	if(gallerywidth>maxwidth){
		gallerywidth=maxwidth;
	}
	if(gallerywidth>maxwidth2){
		gallerywidth=maxwidth2;
	}
	maxheight=gallerywidth*9/16;
	maxheight2=675;
	if(galleryheight>maxheight){
		galleryheight=maxheight;
	}
	if(galleryheight>maxheight2){
		galleryheight=maxheight2;
	}
	elmassive=new Array(gallerywidth, galleryheight)
	return elmassive;
}
function gallery_slider(id){
	if(gallerystatus==0){
		rmasive=gallery_slider_razmer();
		gallerywidth=rmasive[0];
		galleryheight=rmasive[1];
		//
		gallerystep=id;
		gallerystatus=1;
		pos=id*gallerywidth*(-1);
		left=document.getElementById("movegalleryslider").style.left;
		for(i=0;i<=galleryvsego;i++){
			if(i!=id){
				document.getElementById("sliderfotogallery"+i).className="pointer";
				if(document.getElementById("sliderbigfoto"+i)){
					document.getElementById("sliderbigfoto"+i).style.height="50%";
				}
			}
		}
		document.getElementById("sliderfotogallery"+id).className="bgblack";
		if(document.getElementById("sliderbigfoto"+id)){
			setTimeout(function(){animate("sliderbigfoto"+id, 50, 100, 300, "heightProcent");},250);
		}
		animate("movegalleryslider", left, pos, 500, "left");
		animate("slidertitle", 0, 50, 250, "marginTop");
		setTimeout(function(){
			animate("slidertitle", 50, 0, 250, "marginTop");
			document.getElementById("slidertitle").innerHTML=gallerytitle[id];
		},300);
		
		
		if(document.getElementById("insliderfoto")){
			
				widthslidera=50;
				maxleft=(galleryvsego-4)*widthslidera;
				tekleft=(id-2)*widthslidera;
				if(tekleft>maxleft){tekleft=maxleft;}
				if(tekleft<0){tekleft=0;}
				tekleft=tekleft*(-1);
				tekposleft=document.getElementById("insliderfoto").style.left;
				animate("insliderfoto", tekposleft, tekleft, 500, "left");
			
		}
		setTimeout(function(){gallerystatus=0;},500);
	}
}
function gallery_slider_start(){
	rmasive=gallery_slider_razmer();
	gallerywidth=rmasive[0];
	galleryheight=rmasive[1];
	gallery_slider_image(gallerystep, gallerywidth, galleryheight);
	vpered=gallerystep
	nazad=gallerystep;
	go1=0;
	go2=0;
	while(vpered<=galleryvsego){
		vpered++;
		go1++;
		time1=go1*250;
		setTimeout("gallery_slider_image("+vpered+", "+gallerywidth+", "+galleryheight+")",time1);
	}
	while(nazad>=0){
		nazad--;
		go2++;
		time2=go2*250;
		setTimeout("gallery_slider_image("+nazad+", "+gallerywidth+", "+galleryheight+")",time2);
	}	
}
function gallery_slider_image(id, gallerywidth, galleryheight){
	document.getElementById("sliderfotoconteiner"+id).innerHTML="<img id='sliderbigfoto"+id+"' src='"+galleryadresm[id]+"' style='max-width:"+gallerywidth+"px; height:100%; max-height:"+galleryheight+"px'>";
}
function gallery_slider_play(znak){
	if(gallerystatus==0){
		next=gallerystep+znak;
		if(next<0){next=galleryvsego;}
		if(next>galleryvsego){next=0;}
		gallery_slider(next);
	}
}
function dialog_gallery(obj, group, tipgallery){
	if(tipgallery==undefined){
		tipgallery="full";
	}
	relagroup=group;
	if(group.length==0){
		group=Math.round(Math.random()*555555)+555555;
	}
	if(tipgallery=="foto"){
		rmasive=gallery_slider_razmer();
		gallerywidth=rmasive[0];
		galleryheight=rmasive[1];
		//--
		gallerymasive=[0];
		galleryadresm=[0];
		text="";
		bigtext="";
		gallerystep=-1;
		element=document.getElementsByTagName("*");
		vsegoimage=-1;
		for(var i=0;i<element.length;i++){
			vattr=element[i].getAttribute("onclick");
			if(vattr!=null && vattr!=""){
				vattr=vattr.toString();
				index=vattr.indexOf("dialog_gallery");
				if(index>=0){
					findid=vattr.substr(index,vattr.length-index);
					if(findid.indexOf(group)>=0){ 
						freturn=element[i].getAttribute("return");
						if(freturn==null || freturn!="false" || freturn==""){
							adres=element[i].getAttribute("link");
							if(adres==null || adres==""){
							  adres=element[i].getAttribute("href");
							}
							if(adres==null || adres==""){
							  adres=element[i].getAttribute("src");
							}
							ras=adres.split(".");
							ras=ras[ras.length-1].toLowerCase();
							if(ras=="jpg" || ras=="jpeg" || ras=="gif" || ras=="png"){
								vsegoimage++;
								gallerymasive[vsegoimage]=element[i];
								galleryadresm[vsegoimage]=adres;
								if(obj==element[i]){
									gallerystep=vsegoimage;
								}
								dtitle="";
								title_mouse="";
								title_hide="";
								if(element[i].getAttribute("alt")!=null || element[i].getAttribute("alt")==""){
									dtitle=element[i].getAttribute("alt");
								}
								if(element[i].getAttribute("title")!=null || element[i].getAttribute("title")==""){
									dtitle=element[i].getAttribute("title");
								}
								gallerytitle[vsegoimage]=dtitle;
								if(dtitle.length>0){
									title_mouse="onmousemove='dialog_move(this)' onmouseout='dialog_moveclose()'";
									title_hide="<div class='hidedialog'>"+dtitle+"</div>";
								}
								text=text+"<div onclick='gallery_slider("+vsegoimage+")' "+title_mouse+" class='pointer' id='sliderfotogallery"+vsegoimage+"' style='padding:5px; float:left; width:40px; height:32px'><img src='"+dialogresize+"?w=40&h=32&src="+adres+"'>"+title_hide+"</div>";
								bigtext=bigtext+"<div style='float:left; width:"+gallerywidth+"px; height:"+galleryheight+"px'><div id='sliderfotoconteiner"+vsegoimage+"' style='display:table-cell; text-align:center; vertical-align:middle; width:"+gallerywidth+"px; height:"+galleryheight+"px'></div></div>";
							}
						}
					}
				}	 
			}
		}
		if(vsegoimage>2){
			galleryvsego=vsegoimage;
			width=gallerywidth*(galleryvsego+1)+100;
			blockwidth=50;
			razmertop=blockwidth*(galleryvsego+1);
			if(vsegoimage<5){
				alltext="<div style='margin:20px auto; width:"+razmertop+"px'>"+text+"<div class='clearfix'></div></div>";
			}
			if(vsegoimage>=5){
				allwidth=blockwidth*5;
				alltext="<div style='margin:20px auto;'><table><tr><td class='vmiddle spadding_right'><span class='pointer' onmousedown=\"block_move('insliderfoto', 'outsliderfoto', 'left')\" onmouseup=\"block_move_stop('insliderfoto')\"><img src='"+dialogplayerdir+"/img_left.png' style='height:20px'></span></td><td><div id='outsliderfoto' style='position:relative; overflow:hidden; width:"+allwidth+"px'><div id='insliderfoto' style='position:relative; width:"+razmertop+"px'>"+text+"</div></div></td><td class='vmiddle spadding_left'><span class='pointer' onmousedown=\"block_move('insliderfoto', 'outsliderfoto', 'right')\" onmouseup=\"block_move_stop('insliderfoto')\"><img src='"+dialogplayerdir+"/img_right.png' style='height:20px'></span></td></tr></table><div class='clearfix'></div></div>";
			}
			
			
			
			dialog("<div style='position:absolute; z-index:100; width:"+gallerywidth+"px'>"+alltext+"</div><div class='clearfix'></div> <div style='width:"+gallerywidth+"px; height:"+galleryheight+"px; overflow:hidden; position:relative'><div id='movegalleryslider' style='position:relative; width:"+width+"px'>"+bigtext+"</div></div><div class='clearfix'></div><div style='margin:-50px 0 0 0; height:50px; overflow:hidden; width:"+gallerywidth+"px; position:absolute; z-index:100'><div id='slidertitle' style='display:tabble-cell; vertical-align:bottom; height:50px; padding:10px; text-shadow:1px 1px 2px #333333, -1px -1px 10px #ffffff; color:#ffffff'></div></div>", "|<a class='navleft' href='javascript:void(0)' onclick=\"gallery_slider_play(-1)\"></a>|<a class='navright' href='javascript:void(0)' onclick=\"gallery_slider_play(1)\"></a>");
			setTimeout("gallery_slider_start()",500);
			setTimeout("gallery_slider("+gallerystep+")",100);
			///
			document.onkeydown=function(event){
				event = event || window.event;
				if(event.keyCode == 0x25){
					gallery_slider_play(-1);
				}
				if(event.keyCode == 0x27){
					gallery_slider_play(1);
				}
			}
		}
		if(vsegoimage<=2){
			tipgallery="full";
		}
	}
	if(tipgallery=="full"){
		gallerymasive=[0];
		galleryadresm=[0];
		text="";
		tekid=-1;
		element=document.getElementsByTagName("*");
		vsegoimage=-1;
		for(var i=0;i<element.length;i++){
			vattr=element[i].getAttribute("onclick");
			if(vattr!=null && vattr!=""){
				vattr=vattr.toString();
				index=vattr.indexOf("dialog_gallery");
				if(index>=0){
					findid=vattr.substr(index,vattr.length-index);
					if(findid.indexOf(group)>=0){
					 
						freturn=element[i].getAttribute("return");
						if(freturn==null || freturn!="false" || freturn==""){
						vsegoimage++;
						
						adres=element[i].getAttribute("link");
						if(adres==null || adres==""){
						  adres=element[i].getAttribute("href");
						}
						if(adres==null || adres==""){
						  adres=element[i].getAttribute("src");
						}

						text=text+"\n"+adres;
						gallerymasive[vsegoimage]=element[i];
						galleryadresm[vsegoimage]=adres;
						if(obj==element[i]){
							tekid=vsegoimage;
						}
						}
					 }
				}	 
			}	
		}
		dtitle="";
		if(obj.getAttribute("alt")!=null || obj.getAttribute("alt")==""){
			dtitle=obj.getAttribute("alt");
		}
		if(obj.getAttribute("title")!=null || obj.getAttribute("title")==""){
			dtitle=obj.getAttribute("title");
		}
		if(tekid>=0){
			adres=galleryadresm[tekid];
		}
		navmenu="";
		if(vsegoimage>=1){
			dpred="";
			dnext="";
			if(tekid>0){
				pred=tekid-1;
				dpred="<a href='"+galleryadresm[pred]+"' class='navleft' return='false' onclick=\"return dialog_gallery(gallerymasive["+pred+"], '"+relagroup+"')\">&nbsp;</a>";
			}
			if(tekid<vsegoimage){
				next=tekid+1;
				dnext="<a href='"+galleryadresm[next]+"' class='navright' return='false' onclick=\"return dialog_gallery(gallerymasive["+next+"], '"+relagroup+"')\">&nbsp;</a>";
			}
			navmenu=dtitle+"|"+dpred+"|"+dnext;
			document.onkeydown=function(event){
				event = event || window.event;
				if(event.keyCode == 0x25){
					if(dpred.length>3){
						dialog_gallery(gallerymasive[pred], relagroup);
					}
				}
				if(event.keyCode == 0x27){
					if(dnext.length>3){
						dialog_gallery(gallerymasive[next], relagroup);
					}
				}
			}
		}
		tip_opane=0;
		if(adres!=null && adres!=""){
			ras=adres.split(".");
			ras=ras[ras.length-1].toLowerCase();
			if(ras=="jpg" || ras=="jpeg" || ras=="gif" || ras=="png"){
				dialog_image(adres, navmenu);
				tip_opane=1;
			}
			if(ras=="mp3"){
				dialog_mp3(adres, navmenu);
				tip_opane=1;
			}
			if(ras=="swf"){
				dialog_swf(adres, navmenu);
				tip_opane=1;
			}
			if(ras=="flv"){
				dialog_flv(adres, navmenu);
				tip_opane=1;
			}
		}
		if(tip_opane==0){
			text_el=obj.getElementsByTagName("TEXTAREA");
			temp_info="";
			if(text_el.length>0){
				for(i=0;i<text_el.length;i++){
					if(text_el[i].className=="hidedialog"){
						temp_info=text_el[i].innerHTML;
					}
				}
			}
			temp_info=temp_info.toString();
			temp_info=temp_info.replace(/&lt;/gi, '<');
			temp_info=temp_info.replace(/&gt;/gi, '>');
			dialog(temp_info, navmenu);
		}
	}
	return false;
}
//------------------------------
function dialog_load_image(adres,x,y,navmenu){
	nvisot=document.documentElement.clientHeight-200;
	nshir=document.documentElement.clientWidth-200;
	zmy=y;
	zmx=x;
	normal=0;
	if(y>nvisot){
		zmy=nvisot;
		zmx=x*zmy/y;
		normal=1;
	}
	if(zmx>nshir){
		zmy=zmy*nshir/zmx;
		zmx=nshir;
		normal=1;
	}
	fullexpand="";
	if(normal==1){
		fullexpand="<img id='fullexpandclick' onclick='fullsize("+x+","+y+")' src='"+dialogplayerdir+"/fullexpand.gif'/>";
	}
	if(navmenu==undefined){
		navmenu="";
	}	
	mass_navmenu=navmenu.split("|");
	info_image="";
	if(mass_navmenu[0].length>2){
		info_image='<div id="imageinfo" style="width:'+zmx+'px"><div id="out_imageinfo">'+mass_navmenu[0]+'</div></div>';
	
	}	
	dialog('<div style="overflow:hidden; width:'+zmx+'px; height:'+zmy+'px"><div class="main_img_block"><div id="fullexpand" style="overflow:hidden; width:'+zmx+'px; height:'+zmy+'px">'+fullexpand+'<img id="imagegalary" src="'+adres+'" style="width:'+zmx+'px; height:'+zmy+'px; opacity:0; filter:alpha(opacity=0)"/></div>'+info_image+'<div class="clearfix">&nbsp;</div></div></div>', navmenu);
	animate(document.getElementById("imagegalary"),0,100,200,"opacity");
}
///////////////////
function fullsize(x,y){
	max_x=window.screen.width;
	max_y=window.screen.height;
	zmx=x;
	zmy=y;
	if (gfotoshirina>max_y){
		zmy=max_y;
		zmx=gfotoshirina*zmy/gfotoshirina;
	}
	if (zmx>max_x){
		zmy=zmy*max_x/zmx;
		zmx=max_x;
	}
	x=zmx;
	y=zmy;
	/////////
	document.getElementById("fullexpandclick").style.display="none";
	document.getElementById("imagegalary").style.width=x+"px";
	document.getElementById("imagegalary").style.height=y+"px";
	document.getElementById("imagegalary").style.position="relative";
	document.getElementById("imagegalary").style.left="0px";
	document.getElementById("imagegalary").style.top="0px";
	document.getElementById("fullexpand").onmousemove=function(){
		mousemovefoto();
	}
	document.getElementById("fullexpand").onmouseout=function(){
		gfotoactionx=0;
		gfotoactiony=0;
	};
	zagrwidth(x,y);
}
//////////////////////////
var gfotoshirina=0;
var gfotovisota=0;
var gfotoxvidim=0;
var gfotoyvidim=0;
var gfotoxrazn=0;
var gfotoyrazn=0;
var gfotoxopred=0;
var gfotoyopred=0;
var gfotogox=0;
var gfotogoy=0;
var gfotoactionx=0;
var gfotoactiony=0;
var gfotoopredshiriny=90;
var gfotoxznak=1;
var gfotoyznak=1;
var grealshirina=0;
var grealvisota=0;
function zagrwidth(x,y){
	if(document.getElementById("imagegalary")){
		gfotoshirina=x;
		gfotovisota=y;
		gfotoxvidim=document.getElementById("fullexpand").offsetWidth;
		gfotoyvidim=document.getElementById("fullexpand").offsetHeight;
		gfotoxrazn=(gfotoshirina-gfotoxvidim)*(-1);
		gfotoyrazn=(gfotovisota-gfotoyvidim)*(-1);
		gfotoxopred=gfotoxvidim-gfotoopredshiriny;
		gfotoyopred=gfotoyvidim-gfotoopredshiriny;
		gfotogox=parseInt(gfotoxvidim/2)-parseInt(gfotoshirina/2);
		document.getElementById("imagegalary").style.left=gfotogox +"px";
		gfotogoy=parseInt(gfotoyvidim/2)-parseInt(gfotovisota/2);
		document.getElementById("imagegalary").style.top=gfotogoy +"px";
		grealshirina=gfotoshirina;
		grealvisota=gfotovisota;
		gfotoxopred=posLeft(document.getElementById("fullexpand"));
		gfotoshirina=gfotoxopred+gfotoxvidim-gfotoopredshiriny;
		gfotoxopred=gfotoxopred+gfotoopredshiriny;
		gfotoyopred=posTop(document.getElementById("fullexpand"));
		gfotovisota=gfotoyopred+gfotoyvidim-gfotoopredshiriny;
		gfotoyopred=gfotoyopred+gfotoopredshiriny;
	}
}
////////
function mousemovefoto(){
	if(document.getElementById("imagegalary")){
		x=polojenmousex;
		y=polojenmousey-(document.documentElement.scrollTop || document.body.scrollTop);
		gfotoactionx=0;
		if(x>gfotoshirina){gfotoxznak=-1; gfotoactionx=1;}
		if(x<gfotoxopred){gfotoxznak=1; gfotoactionx=1;}
		if(gfotoactionx==1){
			setTimeout("gmovoknox()",50);
		}
		gfotoactiony=0;
		if(y>gfotovisota){gfotoyznak=-1; gfotoactiony=1;}
		if(y<gfotoyopred){gfotoyznak=1; gfotoactiony=1;}
		if(gfotoactiony==1){
			setTimeout("gmovoknoy()",50);
		}
	}
}
/////////////
var sdvig_position=0.5;
browser=navigator.appVersion;
if(browser.indexOf("MSIE 7")>=0){
	sdvig_position=1.5;
}
function gmovoknox(){
	if(grealshirina>gfotoxvidim){
		gfotogox=gfotogox+gfotoxznak*sdvig_position;
		if(gfotogox<gfotoxrazn){gfotogox=gfotoxrazn; gfotoactionx=0;}
		if(gfotogox>0){gfotogox=0; gfotoactionx=0;}
		document.getElementById("imagegalary").style.left=gfotogox+"px";
		if(gfotoactionx==1){
			setTimeout("gmovoknox()",40);
		}
	}
}
function gmovoknoy(){
	if(grealvisota>gfotoyvidim){
		gfotogoy=gfotogoy+gfotoyznak*sdvig_position;
		if(gfotogoy>0){gfotogoy=0; gfotoactiony=0;}
		if(gfotogoy<gfotoyrazn){gfotogoy=gfotoyrazn; gfotoactiony=0;}
		document.getElementById("imagegalary").style.top=gfotogoy+"px";
		if(gfotoactiony==1){
			setTimeout("gmovoknoy()",40);
		}
	}
}
//----------------
function code_flv(adres){
	txt='<object id="player_api" style="width:100%; height:100%" type="application/x-shockwave-flash" data="'+dialogplayerdir+'/players/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"/><param name="wmode" value="opaque"/></object>';
	return txt;
}
//----------------
function code_swf(adres){
	txt='<embed style="width:100%; height:100%" src="'+adres+'" wmode="opaque">';
	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+'/players/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, navmenu){
	dialog("<div style='width:400px; height:300px'>"+code_flv(adres)+"</div>", navmenu);
}
///////////////////
function dialog_mp3(adres, navmenu){
	dialog("<div>"+code_mp3(adres)+"</div>", navmenu);
}
///////////////
function dialog_swf(adres, navmenu){
	dialog("<div style='width:400px; height:300px'>"+code_swf(adres)+"</div>", navmenu);
}
//////////////////////
function dialog_iframe(src, navmenu){
//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>");
	dialog("<iframe src='"+src+"' APPLICATION='yes' style='width:900px; height:500px' frameborder='0' scrolling='auto'></iframe>", navmenu);
}
//
function go_id(id){
	tekadres=location.href;
	razd=tekadres.split("#");
	location=razd[0]+"#"+id;
}
///////////////////
var polojenmousex=0;
var polojenmousey=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;
}
////////////////////////////////////////////////////
function dialog_show(obj, tip){
	this_id=obj.getAttribute("id");
	if(this_id==null || this_id==""){
		this_id="object"+random(100000,999999);
		obj.setAttribute("id", this_id);
	}
	if(!document.getElementById("out"+this_id)){
		shel=obj.childNodes;
		for(var i=0;i<shel.length;i++){
			if(shel[i].className=="hidedialog"){
				shel[i].setAttribute("id", "out"+this_id);
			}
		}
	}
	
	
	document.getElementById("show_dialog_content").innerHTML=document.getElementById("out"+this_id).innerHTML;
	document.getElementById("show_dialog_block").style.display="block"; 

	if(tip==undefined){
		document.getElementById("close_show_dialog").style.display="none"; 
		sh_left=polojenmousex-30;
		sh_top=polojenmousey-document.getElementById("show_dialog_block").offsetHeight;
	}
	if(tip=="add_close"){
		document.getElementById("close_show_dialog").style.display="block"; 
		sh_left=posLeft(document.getElementById(this_id))+Math.floor(document.getElementById(this_id).offsetWidth/3);
		sh_top=posTop(document.getElementById(this_id))-document.getElementById("show_dialog_block").offsetHeight+5;	
	}
	document.getElementById("show_dialog_block").style.display="block"; 
	document.getElementById("show_dialog_block").style.left=sh_left+"px";
	document.getElementById("show_dialog_block").style.top=sh_top+"px";
	
	//location="#show_dialog_block";
}
function dialog_show_close(){
	document.getElementById("show_dialog_block").style.display="none"; 
}
/////////////////////////////////////////////////////////////
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;
dopustimoisty=(document.documentElement.scrollTop || document.body.scrollTop);
if(mx>dopustiomost){
	mx=dopustiomost;
	if(y<(dopustimoisty+visota)){
		dopustimoisty=y+30;
	}
}
if(my<dopustimoisty){
	my=dopustimoisty;
}
//////////////////
tt.style.left=mx+"px";
tt.style.top=my+"px";
//////////////////
}
function dialog_moveclose(){
	document.getElementById("moveokno").style.display="none";
	document.getElementById("move_content").innerHTML="";
}
////////////////////////////////////
onReady(function(){
	loadfiles();
	proverkaforms();
	playDom();
	changefont();
	resizeimage();
});
/////////////////////
function resizeimage(){
	var el=document.body.getElementsByTagName("img");
	for(var i=0;i<el.length;i++){
		metka=el[i].className;
		if(metka=="IMGresize"){
			el[i].className="pointer";
			adres=el[i].getAttribute("src");
			el[i].setAttribute("adres", adres);
			width=intvalue(el[i].style.width);
			height=intvalue(el[i].style.height);
			dw="";
			dh="";
			if(width==0 && height==0){
				dw="&w=128";
				dh="&h=128";
			}
			if(width>0){
				dw="&w="+width;
			}
			if(height>0){
				dh="&h="+height;
			}
			el[i].setAttribute("src", "resize.php?src="+adres+dw+dh);
			el[i].onclick=function(){
				adres=this.getAttribute("adres");
				dialog_image(adres);
			};
		}
	}
}
/////////////////////
var mainobg;
function loadfiles(){
	var mainobg=null;
	var el=document.body.getElementsByTagName("a");
	teklocation=document.location;
	teklocation=teklocation.toString();
	razd=teklocation.split('/');
	var tek_url="";
	for(var i=0;i<razd.length-1;i++){
		tek_url=tek_url+"/"+razd[i];
	}
	tek_url=tek_url.substr(1,tek_url.length-1);
	var tek_url_strlen=tek_url.length;
	for(var d=0;d<el.length;d++){
		tempclass=el[d].className;
		if(tempclass=="files"){
			adres=el[d].getAttribute("href");
			adres=adres.toString();
			if(adres.indexOf("http://")>=0){
				adres=adres.substr(tek_url_strlen+1,adres.length-tek_url_strlen);
			}
			el[d].setAttribute("tempurl",adres);
			if(adres.indexOf('.')>-1){
				razd=adres.split('.');
				posled=razd.length-1;
				ras=razd[posled];
				ras=ras.toLowerCase();
				statusras=0;
				if(ras=="jpg" || ras=="gif" || ras=="png" || ras=="jpeg"){
					statusras=1;
					tekwidth=0;
					tekheight=0;
					twidth=el[d].getAttribute("width");
					dopadres="";
					if(twidth!=null && twidth!=""){
						tekwidth=twidth;
						dopadres=dopadres+"&w="+twidth;
					}
					theight=el[d].getAttribute("height");
					if(theight!=null && theight!=""){
						tekheight=theight;
						dopadres=dopadres+"&h="+theight;
					}
					if(tekwidth==0 && tekheight==0){
						dopadres="&w=128&h=128";
					}
					el[d].setAttribute("class", "filesimage");
					el[d].setAttribute("title", el[d].innerHTML);
					el[d].innerHTML="<img src='"+dialogresize+"?src="+adres+dopadres+"'>";
					el[d].onclick=function(){
						normaliz(this);
						adres=this.getAttribute("href");
						dialog_image(adres);
						return false;
					}
				}
				if(ras=="flv" || ras=="mp3" || ras=="swf"){
					statusras=1;
					el[d].className="filesmedia";
					var temptitle=el[d].innerHTML;
					realtemptitle=temptitle;
					if(temptitle.indexOf('/')>-1){
						razdtitle=temptitle.split('/');
						posled=razdtitle.length-1;
						temptitle=razdtitle[posled];
					}
					dlina=ras.length;
					endtemp=temptitle.substr(temptitle.length-dlina+1,dlina);
					if(endtemp==ras){
						temptitle=temptitle.substr(0,temptitle.length-dlina+1);
					}
					if(temptitle.length>20){
						temptitle=temptitle.substr(0,17)+"...";
					}
					el[d].setAttribute("title", realtemptitle);
					el[d].innerHTML="<span><u>"+ras+"</u>"+temptitle+"</span>";
					
					el[d].onclick=function(){
						if(mainobg!=this){
							normaliz(this);
							adres=this.getAttribute("href");	
							razd=adres.split('.');
							posled=razd.length-1;
							ras=razd[posled];
							ras=ras.toLowerCase();
							txt="";
							if(ras=="flv"){
								txt="<div style='width:300px; height:240px'>"+code_flv(adres)+"</div>";
							}
							if(ras=="mp3"){
								txt=code_mp3(adres);
							}
							if(ras=="swf"){
								txt="<div style='width:300px; height:240px'>"+code_swf(adres)+"</div>";
							}
							this.innerHTML="<div style='margin-bottom:40px'><a href='javascript:void(0)' onclick='location=\"download.php?f="+adres+"\"'>скачать</a>&nbsp;<a href='javascript:void(0)' onclick='normaliz(\"close\")' class='closefiles'>x</a><div class='clearfix'></div><i>"+txt+"</i></div>";
							mainobg=this;
						}
						return false;
					}
				}
				if(statusras==0){
					temptitle=el[d].innerHTML;
					el[d].className="filestype";
					el[d].setAttribute("href","download.php?f="+adres);
					el[d].innerHTML="<img src='"+dialogplayerdir+"/icons/"+ras+".gif' align='absmiddle'><span>"+temptitle+"</span>";
				}
			}
		}
	}
}
///////////////////////////////////////
function normaliz(obj){
    el=document.body.getElementsByTagName("a");
    for(var s=0;s<el.length;s++){
		if(el[s]!=obj){
			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];
				}
				dlina=ras.length;
				endtemp=temptitle.substr(temptitle.length-dlina+1,dlina);
				if(endtemp==ras){
					temptitle=temptitle.substr(0,temptitle.length-dlina+1);
				}
				if(temptitle.length>20){
					temptitle=temptitle.substr(0,17)+"...";
				}
				el[s].innerHTML="<span><u>"+ras+"</u>"+temptitle+"</span>";
			}
		}
    }
    if(obj=="close"){
		mainobg=null;
    }
}
////////////////////////////////
function clearfiles(){
    el=document.body.getElementsByTagName("a");
    for(var i=0;i<el.length;i++){
		classname=el[i].getAttribute("class");
		sos=0;
		if(classname=="filesmedia" || classname=="filesimage"){
			sos=1;
			el[i].innerHTML=el[i].getAttribute("title");
		}
		if(classname=="filestype"){
			sos=1;
			el[i].innerHTML=el[i].getElementsByTagName("span")[0].innerHTML;
		}
		if(sos==1){
			el[i].setAttribute("class","files");
			el[i].setAttribute("href",el[i].getAttribute("tempurl"));
			el[i].onclick=function(){
				return false;
			}
		}
    }
}
/////////////////
var posid=[0];
var skorost=5;
var zamokmenu=1;
function topmenu(id,group,tip){
  if(document.getElementById(id)){
    if(!document.getElementById("out"+id)){
      document.getElementById(id).innerHTML="<div id='out"+id+"'>"+document.getElementById(id).innerHTML+"</div>";
    }
    if(zamokmenu==1){
      zamokmenu=0;
      if(document.getElementById("out"+id)){
        document.getElementById(id).style.overflow="hidden";
        if(tip=="height" || tip==1){
          tekvisota=document.getElementById(id).offsetHeight;
        }
        if(tip=="width" || tip==0){
          tekvisota=document.getElementById(id).offsetWidth;
        }
        kolzapros=10;
        if(tekvisota==0){
          if(document.getElementById("top"+id)){
            document.getElementById("top"+id).className="topmenuselect";
          }
          document.getElementById(id).style.display="block";
          if(tip=="height" || tip==1){
            allvisota=document.getElementById("out"+id).offsetHeight;
          }
          if(tip=="width" || tip==0){
            allvisota=document.getElementById("out"+id).offsetWidth;
          }
          setTimeout("otobrazit('"+id+"','1')",0);
          part=Math.floor(allvisota/10);
          for(var i=1;i<=kolzapros;i++){
            time=i*40;
            rast=i*part;
            if(i==kolzapros){
              rast=allvisota;
              zamokmenu=1;
            }
            setTimeout("otobrazit('"+id+"','"+rast+"','"+tip+"')",time);
          }
        }
        if(tekvisota!=0){
          if(document.getElementById("top"+id)){
            document.getElementById("top"+id).className="topmenu";
          }
          if(tip=="height" || tip==1){
            allvisota=document.getElementById("out"+id).offsetHeight;
          }
          if(tip=="width" || tip==0){
            allvisota=document.getElementById("out"+id).offsetWidth;
          }
          part=Math.floor(allvisota/10);
          for(var i=1;i<=kolzapros;i++){
            time=i*40;
            rast=allvisota-i*part;
            if(i==kolzapros){
              rast=0;
              zamokmenu=1;
            }
            setTimeout("otobrazit('"+id+"','"+rast+"','"+tip+"')",time);
          }
        }
        if(document.getElementById(posid[group]) && posid[group]!=id){
          if(document.getElementById("top"+posid[group])){
            document.getElementById("top"+posid[group]).className="topmenu";
          }
          document.getElementById(posid[group]).style.overflow="hidden";
          ptekvisota=document.getElementById(posid[group]).offsetHeight;
          if(tip=="height" || tip==1){
            pallvisota=document.getElementById("out"+id).offsetHeight;
          }
          if(tip=="width" || tip==0){
            pallvisota=document.getElementById("out"+id).offsetWidth;
          }
          ppart=Math.floor(pallvisota/10);
          for(var i=1;i<=kolzapros;i++){
            time=i*40;
            rast=allvisota-i*part;
            if(i==kolzapros){
              rast=0;
              zamokmenu=1;
            }
            setTimeout("otobrazit('"+posid[group]+"','"+rast+"','"+tip+"')",time);
          }
        }
        posid[group]=id;
      }
    }
  }
  if(!document.getElementById(id)){
    alert("Не найден елемент с id='"+id+"'");
  }
}
//--
function otobrazit(id,rast,tip){
  if(rast==0){
    document.getElementById(id).style.display="none";
  }
  if(tip=="height" || tip==1){
    document.getElementById(id).style.height=rast+"px";
  }
  if(tip=="width" || tip==0){
    document.getElementById(id).style.width=rast+"px";
  }
}
///////////////////////////////
///////////////////////////////////////////////////////////////
//////////////////////////////////проверка форма///////////////////
//////////////////////////////////////////////////////////
////////////////////////
function intvalue(str, min, max){
	str += '';
	var rgx = /\d|\.|-/;
	var out = '';
	for( var i = 0; i < str.length; i++ ){ if( rgx.test( str.charAt(i) ) ){
		if( !( ( str.charAt(i) == '-' && out.length != 0 ) ) ){ out += str.charAt(i); } } 
	}
	if(out.substr(0,1)=="0" && out.length>1){
		out=out.substr(1,out.length-1);
	}
	if(out==''){
		out=0;
	}
	out=out*1;
	if(min>0 && out<min){
		out=min;
	}
	if(max>0 && out>max){
		out=max;
	}
	return out;
}
//////////////
function numreal(str){
	str=str.toString();
	cel=str;
	ost="00";
	if(str.indexOf('.')>-1){
		temp=str.split(".");
		temp[1]=temp[1].substr(0,2);
		if(temp[1]==""){
			temp[1]="0";
		}
	cel=temp[0].toString();
	ost=temp[1].toString();
	}
	dlina=cel.length;
	if(dlina>3){
		go=0;
		part="";
		dlina=dlina-1;
		for(var i=dlina;i>-1;i--){
			go=go+1;
			temp=cel.substr(i,1);
			razdelitel="";
			if((go%3==1)&&(go>1)){
				razdelitel="&nbsp;";
			}
			part=temp+razdelitel+part;
		}
		cel=part;
	}
	str=cel+"."+ost;
	return str;
}
//////////////////////
function proverkaforms(){
	var elems=document.getElementsByTagName("form");
	for(var i=0;i<elems.length;i++){
		returnmainproverka(elems[i]);
	}
}
////
function mainproverka(obj){
	sos=returnmainproverka(obj);
	if (sos==0){
		alert("Заполните выделенные поля");
		return false;
	}
	if (sos==1){
		return true;
	}
}
//----------
function returnmainproverka(obj){
	sos=1;
	var elems=obj.getElementsByTagName("*");
	for(var i=0;i<elems.length;i++){
		tempclass=elems[i].className;
		if((tempclass=="false")||(tempclass=="true")){
			elems[i].className="true";
			ttype=elems[i].getAttribute("type");
			if(ttype!="email"){
				dopttype=elems[i].getAttribute("proverka");
				if(ttype=="password" && dopttype!="false"){
					tproverka=elems[i].getAttribute("proverkathispassword");
					tname=elems[i].getAttribute("name");
					tekid=elems[i].getAttribute("id");
					if((tekid==null || tekid=="") && tname!=""){
						elems[i].setAttribute("id", "passwordid"+i);
						tekid="passwordid"+i;
						elems[i].value="";
					}
					if(tname!="" && tproverka!="false" && !document.getElementById("proverkathispassword"+tekid) && tekid.indexOf("proverkathispassword")==-1){
						tempshablons= elems[i].parentNode.innerHTML;
						tempvalue=elems[i].value;
						elems[i].parentNode.innerHTML=tempshablons+"<div>Для проверки пароля </div><input value='' class='false' onkeyup='proverkapass(this)' type='password' name='"+tekid+"' id='proverkathispassword"+tekid+"'/>";
						sos=0;
						elems[i].className="true";
						elems[i].value=tempvalue;
					}
					if(elems[i].value.length<5){
						sos=0;
						elems[i].className="false";
					}
					if(tekid.indexOf("proverkathispassword")>-1){
						tempvalue=document.getElementById(tname).value;
						if(tempvalue!=elems[i].value){
							sos=0;
							elems[i].className="false";
						}
					}
				}
				if(elems[i].value.length<2 && ttype!="password"){
					sos=0;
					elems[i].className="false";
				}
			}
			if(ttype=="email"){
				var obj_value=elems[i].value;
				var reg=/^[-0-9a-z_\.]+@[-0-9a-z\.]+\.[a-z]{2,3}$/i; 
				var result=reg.test(obj_value) ? "true" : "false";  
				elems[i].className=result;
				if(result!="true"){
					sos=0;	
				}
			}
		}
	}
	return sos;
}
////////////////////////////
function proverkapass(obj){
	obj.setAttribute("class", "true");
	tekid=obj.getAttribute("name");
	if(document.getElementById(tekid)){
		tempvalue=document.getElementById(tekid).value;
		if(obj.value == tempvalue){
			obj.className="true";
		}
		if(obj.value != tempvalue){
			obj.className="false";
		}
	}
}
//-------------------
function thisproverka(obj){
	kol=1;
	type=obj.getAttribute("type");
	if(type!="email"){
		if(type=="password"){
			kol=5;
		}
		if (obj.value.length>kol){
			obj.className="true";
		}
		else{
			obj.className="false";
		}
	}
	if(type=="email"){
		var obj_value=obj.value;
		var reg=/^[-0-9a-z_\.]+@[-0-9a-z\.]+\.[a-z]{2,3}$/i; 
		var result=reg.test(obj_value) ? "true" : "false";  
		obj.className=result;
	}
}
///////////////////////favorite//////////////////
function add_favorite(a){
  fav_title=document.title;
  fav_url=document.location;
  try {
    window.external.AddFavorite(fav_url, fav_title);
  }
  catch (e) {
    try {
      window.sidebar.addPanel(fav_title, fav_url, "");
    }
    catch (e) {
      if (window.opera) {
        a.rel="sidebar";
        a.title=fav_title;
        a.url=fav_url;
        return true;
      }
      else {
        alert('Нажмите Ctrl-D чтобы добавить страницу в закладки');
      }
    }
  }
  return false;
}
//////////////////////////////////////
function toggle(t_obj){
	status_obj_style=0;
	if(document.getElementById(t_obj)){
		obj=document.getElementById(t_obj);
		status_obj_style=1;
	}
	if(!document.getElementById(t_obj)){
		if(t_obj){
			obj=t_obj;
			status_obj_style=1;
		}
	}
	if(status_obj_style==1){
		if(obj.offsetWidth>0){
			obj.style.display="none";
		}
		else{
			obj.style.display="block";
		}
	}
}
//////////////////////print///////////////
function printpage(){
text=document.getElementById("page").innerHTML;
print_title=document.title;
blockscload="";
el=document.getElementsByTagName("link");
for(var i=0;i<el.length;i++){
	tempst=el[i].getAttribute("href");
	blockscload=blockscload+"<link rel=\"StyleSheet\" href=\""+tempst+"\" type=\"text/css\"/>";
}
view = window.open("", "view", "status=yes, toolbar=no, menubar=no, scrollbars=yes, location=no, width=800, height=600");
view.document.open();
view.document.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"xhtml11.dtd\">");
view.document.write("<html>");
view.document.write("<head>");
view.document.write("<title>"+print_title+"</title>");
view.document.write(blockscload);
view.document.write("<script>");
view.document.write("function clearlink(){");
view.document.write("var el=document.getElementsByTagName(\"a\");");
view.document.write("for(var i=0;i<el.length;i++){");
view.document.write("el[i].onclick=function(){return false;};");
view.document.write("}}");
view.document.write("</script>");
view.document.write("<style media=\"print\">#printlink{display:none}</style>");
view.document.write("</head>");
view.document.write("<body onload='clearlink()'>");
view.document.write("<div onmouseover=\"this.style.height='25px'\" onmouseout=\"this.style.height='1px'\" id=\"printlink\" style='z-index:3; position:absolute; height:1px; overflow:hidden; padding:5px 0px; text-align:right; display:block; cursor:pointer; color:#ffffff; background:#444444; font-weight:bold; width:100%;'><span onclick=\"print()\" style='margin:5px 0px; font-weight:bold; display:block; width:auto;'>распечатать</span></div>");
view.document.write("<div style='z-index:2; left:0px; top:0px; width:100%; height:100%; position:fixed'>&nbsp;</div><div style='z-index:1; left:0px; top:0px; position:absolute; margin:10px 0 0 0; width:100%' class=\"clear\" id=\"content\">" +text +"</div>");
view.document.write("</body></html>");
view.document.close();
}
//////////////////////shadow////////////////////////////
////на основе highslide/////////////////
var element_pl_block=[];
var element_pl_slider=[];
function playDom(){
	goblock=-1;
	goslider=-1;
	elements=document.getElementsByTagName("*");
	for(var b=0;b<elements.length;b++){
		tempshadow=elements[b].getAttribute("shadow");
		if(tempshadow!=null || tempshadow==""){
			temptext=elements[b].innerHTML;
			elements[b].style.background="none";
			elements[b].setAttribute("shadow","");
			razmershadow=elements[b].getAttribute("razmer");
			elements[b].innerHTML=addShadow(tempshadow, temptext, razmershadow);
		}
		//---
		tempplayblock=elements[b].getAttribute("playblock");
		if(tempplayblock=="true"){
			goblock++;
			element_pl_block[goblock]=elements[b];
		}
		//----
		tempplayblock=elements[b].getAttribute("slider");
		if(tempplayblock=="slider" || tempplayblock=="opacity"){
			goslider++;
			element_pl_slider[goslider]=elements[b];
		}
	}
	if(goblock>=0){
		playblocks();
	}
	if(goslider>=0){
		playslider();
	}
}
//---
var slider_link=[];
var slider_play=[];
function playslider(){
	for(i=0;i<element_pl_slider.length;i++){

		get_autoplay=element_pl_slider[i].getAttribute("autoplay");
		add_autoplay=0;
		if(get_autoplay=="true"){
			add_autoplay=1;
		}
		get_realname=element_pl_slider[i].getAttribute("realname");
		add_realname=0;
		if(get_realname=="true"){
			add_realname=1;
		}
		get_realname=element_pl_slider[i].getAttribute("click");
		clictable=1;
		if(get_realname=="false"){
			clictable=0;
		}
		get_position=element_pl_slider[i].getAttribute("button_top");
		add_button_top=0;
		if(get_position=="true"){
			add_button_top=1;
		}
		get_position=element_pl_slider[i].getAttribute("button_down");
		add_button_down=1;
		if(get_position=="false"){
			add_button_down=0;
		}
		get_arrow=element_pl_slider[i].getAttribute("arrows");
		add_arrow=0;
		if(get_arrow=="true"){
			add_arrow=1;
		}
		get_play=element_pl_slider[i].getAttribute("play");
		add_play=0;
		if(get_play=="true"){
			add_play=1;
		}
		get_resize=element_pl_slider[i].getAttribute("resize");
		add_resize=0;
		if(get_resize=="true"){
			add_resize=1;
		}
		tip=tek_id=element_pl_slider[i].getAttribute("slider");
		tek_id=element_pl_slider[i].getAttribute("id");
		if(tek_id==null || tek_id==""){
			tek_id=i;
		}
		slider_link[tek_id]=1;
		slider_play[tek_id]=0;
		element_pl_slider[i].setAttribute("id","slider_"+tek_id);
		tek_width=element_pl_slider[i].getAttribute("width");
		if(tek_width==null || tek_width==""){
			tek_width=element_pl_slider[i].offsetWidth;
			element_pl_slider[i].setAttribute("width", tek_width);
		}
		tek_width=tek_width.toString();
		if(tek_width.indexOf("px")>-1){
			tek_width=tek_width.substr(0,tek_width.length-2)*1;
		}
		tek_width=tek_width*1;
		tek_height=element_pl_slider[i].getAttribute("height");
		if(tek_height==null || tek_height==""){
			tek_height=300;
			element_pl_slider[i].setAttribute("height", tek_height);
		}
		tek_height=tek_height.toString();
		if(tek_height.indexOf("px")>-1){
			tek_height=tek_height.substr(0,tek_height.length-2)*1;
		}
		tek_height=tek_height*1;
		element_pl_slider[i].style.width=tek_width+"px";
		elements=element_pl_slider[i].childNodes;
		buttons_top="";
		buttons_down="";
		go=0;
		el=[];
		for(n=0;n<elements.length;n++){
			if(elements[n].nodeType == 1){
				go++;
				el[go]=elements[n];
			}
		}
		if(go>1){
			for(n=1;n<=go;n++){
				el[n].style.width=tek_width+"px";
				el[n].style.height=tek_height+"px";
				el[n].style.cssFloat="left";
				el[n].style.styleFloat="left";
				el[n].style.overflow="hidden";
				slider_title=el[n].getAttribute("title");
				el[n].setAttribute("title", "");
				slider_name=el[n].getAttribute("realname");
				el[n].innerHTML="<div id='slider_in_"+tek_id+"_"+n+"'>"+el[n].innerHTML+"<div style='height:10px; font-size:2px'>&nbsp;</div></div>";
				doptext="";
				dopmouse="";
				tname=n;
				if(slider_title!=null && slider_title!=""){
					dopmouse="onmouseout='dialog_moveclose()' onmousemove='dialog_move(this)'";
					doptext="<div class='hidedialog'>"+slider_title+"</div>";
				}
				if(add_realname==1){
					if(slider_title!=null && slider_title!=""){
						tname=slider_title;
					}
					if(slider_name!=null && slider_name!=""){
						tname=slider_name;
					}
				}
				if(tip=="opacity"){
					el[n].style.position="absolute";
				}
				if(tip=="opacity" && n>1){
					el[n].style.zIndex="1";
				}
				if(tip=="opacity" && n==1){
					el[n].style.zIndex="10";
				}
				sel="";
				if(n==1){
					sel="class='fav'";
				}
				addclick="";
				if(clictable==1){
					addclick="onclick=\"slider_"+tip+"('"+n+"','"+tek_id+"')\"";	
				}
				buttons_top=buttons_top+"<a "+sel+" id='slider_link_top_"+tek_id+"_"+n+"' "+dopmouse+" "+addclick+" href='javascript:void(0)'><span>"+tname+doptext+"</span><ins></ins></a>";
				buttons_down=buttons_down+"<a "+sel+" id='slider_link_down_"+tek_id+"_"+n+"' "+dopmouse+" "+addclick+" href='javascript:void(0)'><span>"+tname+doptext+"</span><ins></ins></a>";
				el[n].setAttribute("id", "slider_block_"+tek_id+"_"+n);
			}
			all_width=go*(tek_width+20);
			relativeblock="";
			if(tip=="slider"){
				relativeblock="position:relative; left:0px;";
			}
		
			display_arrow="";
			if(add_arrow==0){
				display_arrow="display:none";
			}
			display_play="";
			if(add_play==0){
				display_play="display:none";
			}
			display_buttons_top="";
			if(add_button_top==0){
				display_buttons_top="display:none";
			}
			display_buttons_down="";
			if(add_button_down==0){
				display_buttons_down="display:none";
			}
			tekbuttons_top="<div style='clear:both'></div><div class='slider_all_buttons' id='slider_all_buttons_up_"+tek_id+"' style='"+display_buttons_top+"'><span class='buttons' id='slider_buttons_top_"+tek_id+"'>"+buttons_top+"</span><a href='javascript:void(0)' onclick=\"slider_playstop('"+tek_id+"', '"+tip+"')\" class='play' style='"+display_play+"' id='slider_play_top_"+tek_id+"'>&nbsp;</a><a href='javascript:void(0)' class='arrow left' id='slider_left_top_"+tek_id+"' style='"+display_arrow+"' onclick=\"slider_arrow('"+tek_id+"', -1, '"+tip+"')\">&nbsp;</a><a onclick=\"slider_arrow('"+tek_id+"', 1, '"+tip+"')\" href='javascript:void(0)' class='arrow right' style='"+display_arrow+"' id='slider_right_top_"+tek_id+"'>&nbsp;</a></div><div style='clear:both'></div>";
			tekbuttons_down="<div style='clear:both'></div><div class='slider_all_buttons' id='slider_all_buttons_down_"+tek_id+"' style='"+display_buttons_down+"'><span class='buttons' id='slider_buttons_down_"+tek_id+"'>"+buttons_down+"</span><a href='javascript:void(0)' onclick=\"slider_playstop('"+tek_id+"', '"+tip+"')\" class='play' style='"+display_play+"' id='slider_play_down_"+tek_id+"'>&nbsp;</a><a href='javascript:void(0)' class='arrow left' id='slider_left_down_"+tek_id+"' style='"+display_arrow+"' onclick=\"slider_arrow('"+tek_id+"', -1, '"+tip+"')\">&nbsp;</a><a onclick=\"slider_arrow('"+tek_id+"', 1, '"+tip+"')\" href='javascript:void(0)' class='arrow right' style='"+display_arrow+"' id='slider_right_down_"+tek_id+"'>&nbsp;</a></div><div style='clear:both'></div>";
			
			element_pl_slider[i].innerHTML=tekbuttons_top+"<div id='slider_main_"+tek_id+"' style='position:relative; overflow:hidden; height:"+tek_height+"px; width:"+tek_width+"px'><div id='slider_moveblock_"+tek_id+"' style='"+relativeblock+"width:"+all_width+"px'>"+element_pl_slider[i].innerHTML+"</div></div>"+tekbuttons_down;
			
			if(add_autoplay==1){
				slider_playstop(tek_id, tip);
			}
			if(add_resize==1){
				main_height=document.getElementById("slider_in_"+tek_id+"_1").offsetHeight;	
			}
			setTimeout("slider_"+tip+"(1, '"+tek_id+"')",100);
		}
	}
}
//---
function slider_playstop(obj, tip){
	ntip=slider_play[obj];
	get_autoplay=document.getElementById("slider_"+obj).getAttribute("playbuttons");
	add_autoplay=1;
	if(get_autoplay=="false"){
		add_autoplay=0;
	}
	if(ntip==0){
		document.getElementById("slider_play_top_"+obj).className="stop";
		document.getElementById("slider_play_down_"+obj).className="stop";
		slider_play[obj]=1;
		if(add_autoplay==0){
			document.getElementById("slider_buttons_top_"+obj).style.display="none";
			document.getElementById("slider_left_top_"+obj).style.display="none";
			document.getElementById("slider_right_top_"+obj).style.display="none";
			document.getElementById("slider_buttons_down_"+obj).style.display="none";
			document.getElementById("slider_left_down_"+obj).style.display="none";
			document.getElementById("slider_right_down_"+obj).style.display="none";
		}
		setTimeout("slider_arrow('"+obj+"', '0', '"+tip+"')",5000);
	}
	if(ntip==1){
		document.getElementById("slider_play_top_"+obj).className="play";
		document.getElementById("slider_play_down_"+obj).className="play";
		if(add_autoplay==0){
			document.getElementById("slider_buttons_top_"+obj).style.display="inline-block";
			document.getElementById("slider_left_top_"+obj).style.display="inline-block";
			document.getElementById("slider_right_top_"+obj).style.display="inline-block";
			document.getElementById("slider_buttons_down_"+obj).style.display="inline-block";
			document.getElementById("slider_left_down_"+obj).style.display="inline-block";
			document.getElementById("slider_right_down_"+obj).style.display="inline-block";
		}
		slider_play[obj]=0;
	}
}
function slider_arrow(obj, znak, tip){
	if(document.getElementById("slider_moveblock_"+obj)){
		vsego=0;
		tek=0;
		elements=document.getElementById("slider_moveblock_"+obj).childNodes;
		for(n=0;n<elements.length;n++){
			if(elements[n].nodeType == 1){
				vsego++;
			}
		}
		for(n=1;n<=vsego;n++){
			if(document.getElementById("slider_link_top_"+obj+"_"+n)){
				tclass=document.getElementById("slider_link_top_"+obj+"_"+n).className;
				if(tclass=="fav"){
					tek=n;
				}
			}
		}
		if(znak!=0){
			tek=tek+znak;
			if(tek>vsego){
				tek=1;
			}
			if(tek<1){
				tek=vsego;
			}
			setTimeout("slider_"+tip+"('"+tek+"', '"+obj+"')", 10);
		}	
		if(znak==0){
			if(slider_play[obj]==1){
				tek++;
				if(tek>vsego){
					tek=1;
				}
				setTimeout("slider_"+tip+"('"+tek+"', '"+obj+"')", 10);
				tektime=document.getElementById("slider_"+obj).getAttribute("playtime");
				if(tektime==null || tektime==""){
					tektime=30000;
				}
				setTimeout("slider_arrow('"+obj+"', '0', '"+tip+"')",tektime);
			}
		}
	}
}
//==================================
function slider_slider(id, obj){
	if(slider_link[obj]==1 && document.getElementById("slider_moveblock_"+obj)){
		tektime=document.getElementById("slider_"+obj).getAttribute("time");
		if(tektime==null || tektime==""){
			tektime=500;
		}
		slider_link[obj]=0;
		vsego=0;
		elements=document.getElementById("slider_moveblock_"+obj).childNodes;
		for(n=0;n<elements.length;n++){
			if(elements[n].nodeType == 1){
				vsego++;
			}
		}
		for(i=1;i<=vsego;i++){
			if(document.getElementById("slider_link_top_"+obj+"_"+i)){
				tclass="";
				if(i==id){
					tclass="fav";
				}
				document.getElementById("slider_link_top_"+obj+"_"+i).className=tclass;
				document.getElementById("slider_link_down_"+obj+"_"+i).className=tclass;
			}
		}
		get_cirle=document.getElementById("slider_"+obj).getAttribute("circle");
		if(get_cirle=="false"){
			document.getElementById("slider_left_top_"+obj).style.display="";
			document.getElementById("slider_right_top_"+obj).style.display="";
			document.getElementById("slider_left_down_"+obj).style.display="";
			document.getElementById("slider_right_down_"+obj).style.display="";
			if(id==1){
				document.getElementById("slider_left_top_"+obj).style.display="none";
				document.getElementById("slider_left_down_"+obj).style.display="none";
			}
			if(id==vsego){
				document.getElementById("slider_right_top_"+obj).style.display="none";
				document.getElementById("slider_right_down_"+obj).style.display="none";
			}
		}
		
		
		left=document.getElementById("slider_moveblock_"+obj).style.left;
		left=intvalue(left);
		shag=0;
		if(document.getElementById("slider_main_"+obj)){
			shag=document.getElementById("slider_main_"+obj).offsetWidth;
			shag=shag*1;
		}
		if(shag>0){
			left2=shag*(id-1)*(-1);
			//---
			animate("slider_moveblock_"+obj,left,left2,tektime,"left");
			if(document.getElementById("slider_"+obj).getAttribute("resize")=="true"){
				main_height=document.getElementById("slider_main_"+obj).offsetHeight;
				pod_height=document.getElementById("slider_in_"+obj+"_"+id).offsetHeight;
				animate("slider_main_"+obj,main_height,pod_height,tektime,"height");
				animate("slider_block_"+obj+"_"+id,main_height,pod_height,tektime,"height");
			}
			
		}
		setTimeout(function(){slider_link[obj]=1;},tektime);
	}
}
//---------
function slider_opacity(id, obj){
	if(slider_link[obj]==1 && document.getElementById("slider_moveblock_"+obj)){
		tektime=document.getElementById("slider_"+obj).getAttribute("time");
		if(tektime==null || tektime==""){
			tektime=500;
		}
		slider_link[obj]=0;
		vsego=0;
		elements=document.getElementById("slider_moveblock_"+obj).childNodes;
		for(n=0;n<elements.length;n++){
			if(elements[n].nodeType == 1){
				vsego++;
			}
		}
		for(i=1;i<=vsego;i++){
			itempid="slider_block_"+obj+"_"+i;
			if(document.getElementById(itempid)){
				if(i==id){
					tclass="fav";
					zindex=10;
					setTimeout(function(){animate(itempid,0,100,tektime,"opacity");}, 10);
				}
				if(i!=id){
					tclass="";
					zindex=1;
					setTimeout(function(){animate(itempid,100,0,tektime,"opacity");}, 10);
				}
				document.getElementById(itempid).style.zIndex=zindex;
				document.getElementById("slider_link_top_"+obj+"_"+i).className=tclass;
				document.getElementById("slider_link_down_"+obj+"_"+i).className=tclass;
			}	
		}
		if(document.getElementById("slider_"+obj).getAttribute("resize")=="true"){
				main_height=document.getElementById("slider_main_"+obj).offsetHeight;
				pod_height=document.getElementById("slider_in_"+obj+"_"+id).offsetHeight;
				animate("slider_main_"+obj,main_height,pod_height,tektime,"height");
				animate("slider_block_"+obj+"_"+id,main_height,pod_height,tektime,"height");
		}
		setTimeout(function(){slider_link[obj]=1;},tektime);
	}
}
//--------------------------
function playblocks(){
	for(i=0;i<element_pl_block.length;i++){
		elements=element_pl_block[i].childNodes;
		var temp_obj=[];
		var temp_index=[];
		kol=-1;
		for(n=0;n<elements.length;n++){
			if(elements[n].nodeType == 1){
				kol++;
				temp_obj[kol]=elements[n];
				temp_index[kol]=kol;
			}
		}	
		temp_index=shuffle(temp_index);
		polovina=Math.round((kol+1)/2);
		for(n=0;n<=kol;n++){
			index=temp_index[n];
			if(n<polovina){
				$(temp_obj[index]).show(1500);
			}
			if(n>=polovina){
				$(temp_obj[index]).hide(1500);
			}
		}
	}
	setTimeout("playblocks()",60000);
}
//----------
function addShadow(tempshadow, text, razmer){
         block="<table style='width:"+razmer+"'><tr><td class='tl' style='border: medium none; margin: 0px; padding: 0px; background: transparent url("+dialogplayerdir+"/shadow/"+tempshadow+".png) repeat scroll 0px 0px; line-height: 0px; font-size: 0px; height: 20px; width: 20px;'>&nbsp;</td><td class='tm' style='border: medium none ; margin: 0px; padding: 0px; background: transparent url("+dialogplayerdir+"/shadow/"+tempshadow+".png) repeat scroll 0px -40px; line-height: 0px; font-size: 0px; height: 20px;'>&nbsp;</td><td class='tr' style='border: medium none ; margin: 0px; padding: 0px; background: transparent url("+dialogplayerdir+"/shadow/"+tempshadow+".png) repeat scroll -20px 0px; line-height: 0px; font-size: 0px; height: 20px; width: 20px;'>&nbsp;</td></tr><tr><td class='ml' style='border: medium none ; margin: 0px; padding: 0px; background: transparent url("+dialogplayerdir+"/shadow/"+tempshadow+".png) repeat scroll 0px -80px; line-height: 0px; font-size: 0px; height: 20px; width: 20px;'>&nbsp;</td><td class='mm' style='background:transparent url("+dialogplayerdir+"/shadow/"+tempshadow+"_bg.png)'>"+text+"</td><td class='mr' style='border: medium none ; margin: 0px; padding: 0px; background: transparent url("+dialogplayerdir+"/shadow/"+tempshadow+".png) repeat scroll -20px -80px; line-height: 0px; font-size: 0px; height: 20px; width: 20px;'>&nbsp;</td></tr><tr><td class='bl' style='border: medium none ; margin: 0px; padding: 0px; background: transparent url("+dialogplayerdir+"/shadow/"+tempshadow+".png) repeat scroll 0px -20px; line-height: 0px; font-size: 0px; height: 20px; width: 20px;'>&nbsp;</td><td class='bm' style='border: medium none ; margin: 0px; padding: 0px; background: transparent url("+dialogplayerdir+"/shadow/"+tempshadow+".png) repeat scroll 0px -60px; line-height: 0px; font-size: 0px; height: 20px;'>&nbsp;</td><td class='br' style='border: medium none ; margin: 0px; padding: 0px; background: transparent url("+dialogplayerdir+"/shadow/"+tempshadow+".png) repeat scroll -20px -20px; line-height: 0px; font-size: 0px; height: 20px; width: 20px;'>&nbsp;</td></tr></table>";
         return block;
}
///---------------------------------
function changefont(){
	if(document.getElementById("fontpage")){
		tipfont=getCookie("fontstyle");
		elements=document.getElementById("fontpage").getElementsByTagName("a");
		for(var b=0;b<elements.length;b++){
			temptip=elements[b].getAttribute("tip");
			if(temptip==tipfont){
			  elements[b].className="current";
			}
			elements[b].onclick=function(){
				el=document.getElementById("fontpage").getElementsByTagName("a");
				for(var g=0;g<el.length;g++){
					el[g].className="";
				}
				tip=this.getAttribute("tip");
				if(tip!=null || tip==""){
					this.className="current";
					document.getElementById("page").className=tip;
					setCookie("fontstyle", tip);
				}
				return false;
			}
		}
		if(tipfont==null){
			elements[1].className="current";
		}
		document.getElementById("page").className=tipfont;
	}
}
//////coocie///--------------------------------
function setCookie(name, value) {
      var valueEscaped = escape(value);
      var expiresDate = new Date();
      expiresDate.setTime(expiresDate.getTime() + 365 * 24 * 60 * 60 * 1000);
      var expires = expiresDate.toGMTString();
      var newCookie = name + "=" + valueEscaped + "; path=/; expires=" + expires;
      if (valueEscaped.length <= 4000) document.cookie = newCookie + ";";
}
// Получить куки
function getCookie(name) {
      var prefix = name + "=";
      var cookieStartIndex = document.cookie.indexOf(prefix);
      if (cookieStartIndex == -1) return null;
      var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length);
      if (cookieEndIndex == -1) cookieEndIndex = document.cookie.length;
      return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex));
}
//////////////-----определение координат обьекта------------------
function posLeft(obj){
  var curleft = 0;
  if (obj.offsetParent){
    while (obj.offsetParent){
      curleft += obj.offsetLeft
      obj = obj.offsetParent;
    }
  }
  else if (obj.x)
    curleft += obj.x;
  return curleft;
}
function posTop(obj){
  var curtop = 0;
  if (obj.offsetParent){
    while (obj.offsetParent){
      curtop += obj.offsetTop
      obj = obj.offsetParent;
    }
  }else if (obj.y)
    curtop += obj.y;
  return curtop;
}
//////////////////////////
function insert_tag(tag, obj_id) {
	if(document.getElementById(obj_id)){
		start="["+tag+"]";
		end="[/"+tag+"]";		
		element = document.getElementById(obj_id);
		if (document.selection) {
			element.focus();
			sel = document.selection.createRange();
			sel.text = start + sel.text + end;
		}
		else if(element.selectionStart || element.selectionStart == '0'){
			element.focus();
			var startPos = element.selectionStart;
			var endPos = element.selectionEnd;
			stop_tag=1;
			if(tag.indexOf(":")>=0 || tag.indexOf(")")>=0 || tag.indexOf("(")>=0){
				stop_tag=0;	
				element.value = element.value.substring(0, startPos) +" "+ tag +" "+element.value.substring(endPos, element.value.length);
			}
			if(stop_tag==1){	
				element.value = element.value.substring(0, startPos) + start + element.value.substring(startPos, endPos) + end + element.value.substring(endPos, element.value.length);
			}
		}
		else{
			element.value += start + end;
		}
	}
	if(!document.getElementById(obj_id)){	
		alert("Не найден обьект textarea с id="+obj_id);
	} 
	return false;
}
//////////////
function comments(id, obj){
	if(!document.getElementById("pod"+id)){
		obj.onclick=function(){
			return false;
		};
		obj.className="";
		text=bb_code(id);
		obj.innerHTML="<span id='pod"+id+"'><span class='fav pointer' onclick=\"toggle('tags"+id+"')\">панель</span><div id='tags"+id+"'><div>"+text+"</div></div></span>";
	}
}
function bb_code(id){
		masive_bb_code=new Array("b|B","i|I","u|U","s|S");
		text_bb="";
		for(var i=0;i<masive_bb_code.length;i++){
			razd=masive_bb_code[i].split("|");
			text_bb=text_bb+"<img style='height:18px' class='pointer' src='"+dialogplayerdir+"/smiles/bb_code/"+razd[0]+".png' onclick=\"return insert_tag('"+razd[0]+"','"+id+"')\">";
		}
		//
		text_smile="";
		browser=navigator.appVersion;
		if(browser.indexOf("MSIE")<0){
			smile_dir=dialogplayerdir+"/smiles/summer/";
			masive_smile_code=new Array("biggrin|:D","blink|:blink","cool|:cool","dry|:dry","huh|:P","laugh|:laugh","mad|:mad","ohmy|:ohmy","rolleyes|%)","sad|:(","smile|:)","tongue|:tongue","unsure|:unsure","wink|;)");
			for(var i=0;i<masive_smile_code.length;i++){
				razd=masive_smile_code[i].split("|");
				text_smile=text_smile+"<img class='pointer' alt='"+razd[1]+"' style='height:16px' onclick=\"insert_tag('"+razd[1]+"','"+id+"')\" src='"+smile_dir+razd[0]+".gif'>";
			}
		}
		return 	"<span class='code'>"+text_bb+"</span><span class='smile'>"+text_smile+"</span>";
}
///////
function random(x, y){
	d=Math.floor(Math.random() * (y - x + 1)) + x;
	return d;
}
/////////////
function to_bless(obj){
	text="выполнить данное дейсвие";
	attr=obj.getAttribute("title");
	if(attr!=null && attr!=""){
		text=attr;
	}
	if(window.confirm("Вы дейсвительно хотите \""+text+"\"?")){
		return true;
	}else {
		return false;
	}
}
///////////////////////
/*------------------------------------
<div id='out' style="border:1px solid #000000; margin:30px auto; position:relative; width:500px; height:100px; overflow:hidden;">
	<div id='in' style="width:3730px; position:relative">
		block
	</div>
</div>
<span onmousedown="block_move('in', 'out', 'up')" onmouseup="block_move_stop('in')">up</span>
<span onmousedown="block_move('in', 'out', 'down')" onmouseup="block_move_stop('in')">down</span>
<span onmousedown="block_move('in', 'out', 'left')" onmouseup="block_move_stop('in')">left</span>
<span onmousedown="block_move('in', 'out', 'right')" onmouseup="block_move_stop('in')">right</span>
---------------------------*/
var massive_obj_move_block=[0];
var razgon_move_block=0;
function block_move(obj_in, obj_out, tip, status){
	skorost=10;
	if(status==undefined){
		massive_obj_move_block[obj_in]=1;
	}
	if(document.getElementById(obj_in) && document.getElementById(obj_out))	{
		tobj_in=document.getElementById(obj_in);
		tobj_out=document.getElementById(obj_out);
		if(tip=="left" || tip=="right"){
			vout=tobj_out.offsetWidth;
			vin=tobj_in.offsetWidth;
			sdvig=tobj_in.style.left;
		}
		if(tip=="up" || tip=="down"){
			vout=tobj_out.offsetHeight;
			vin=tobj_in.offsetHeight;
			sdvig=tobj_in.style.top;
		}
		if(vin<=vout){
			massive_obj_move_block[obj_in]=0;
		}
		if(vin>vout){
			if(status==undefined){
				razgon_move_block=10;
				if(vin>1000){
					razgon_move_block=20;
				}
				if(vin>2000){
					razgon_move_block=30;
				}
				if(vin>3000){
					razgon_move_block=40;
				}
				if(vin>4000){
					razgon_move_block=50;
				}
			}
			if(razgon_move_block>0){
				razgon_move_block=razgon_move_block-2;
			}
			skorost=skorost+razgon_move_block;
			ts=0;
			if(sdvig=="" || sdvig==null){
				sdvig=0;
				ts=1;
			}
			if(ts==0){
				sdvig=sdvig.substr(0,sdvig.length-2);
				sdvig=sdvig*1;
			}
			if(tip=="right" || tip=="down"){
				predel=(vin-vout)*(-1);
				if(sdvig>predel){
					sdvig=sdvig-skorost;
				}
				if(document.getElementById(obj_in+"_right")){
					if(sdvig<predel){
						document.getElementById(obj_in+"_right").style.visibility="hidden";
						block_move_stop(obj_in);
					}
				}
				if(sdvig<0){
					if(document.getElementById(obj_in+"_left")){
						document.getElementById(obj_in+"_left").style.visibility="visible";
					}
				}
			}
			if(tip=="left" || tip=="up"){
				if(sdvig<0){
					sdvig=sdvig+skorost;
				}
				if(document.getElementById(obj_in+"_left")){
					if(sdvig==0){
						document.getElementById(obj_in+"_left").style.visibility="hidden";
						block_move_stop(obj_in);
					}
				}
				if(sdvig>predel){
					if(document.getElementById(obj_in+"_right")){
						document.getElementById(obj_in+"_right").style.visibility="visible";
					}
				}
			}
			if(tip=="left" || tip=="right"){
				tobj_in.style.left=sdvig+"px";
			}
			if(tip=="up" || tip=="down"){
				tobj_in.style.top=sdvig+"px";
			}
		}
	}
	if(massive_obj_move_block[obj_in]==1){
		setTimeout("block_move('"+obj_in+"', '"+obj_out+"', '"+tip+"', 1)",40);
	}
}
function block_move_stop(obj_in){
	massive_obj_move_block[obj_in]=0;
	razgon_move_block=0;
}
//////////////////////////////ajax/////////////////////////////////////////////
function sack(file) {
	this.xmlhttp = null;
	this.resetData = function() {
		this.method = "POST";
  		this.queryStringSeparator = "?";
		this.argumentSeparator = "&";
		this.URLString = "";
		this.encodeURIString = true;
  		this.execute = false;
  		this.element = null;
		this.elementObj = null;
		this.requestFile = file;
		this.vars = new Object();
		this.responseStatus = new Array(2);
  	};
	this.resetFunctions = function() {
  		this.onLoading = function() { };
  		this.onLoaded = function() { };
  		this.onInteractive = function() { };
  		this.onCompletion = function() { };
  		this.onError = function() { };
		this.onFail = function() { };
	};
	this.reset = function() {
		this.resetFunctions();
		this.resetData();
	};
	this.createAJAX = function() {
		try {
			this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e1) {
			try {
				this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e2) {
				this.xmlhttp = null;
			}
		}
		if (! this.xmlhttp) {
			if (typeof XMLHttpRequest != "undefined") {
				this.xmlhttp = new XMLHttpRequest();
			} else {
				this.failed = true;
			}
		}
	};
	this.setVar = function(name, value){
		this.vars[name] = Array(value, false);
	};
	this.encVar = function(name, value, returnvars) {
		if (true == returnvars) {
			return Array(encodeURIComponent(name), encodeURIComponent(value));
		} else {
			this.vars[encodeURIComponent(name)] = Array(encodeURIComponent(value), true);
		}
	}
	this.processURLString = function(string, encode) {
		encoded = encodeURIComponent(this.argumentSeparator);
		regexp = new RegExp(this.argumentSeparator + "|" + encoded);
		varArray = string.split(regexp);
		for (i = 0; i < varArray.length; i++){
			urlVars = varArray[i].split("=");
			if (true == encode){
				this.encVar(urlVars[0], urlVars[1]);
			} else {
				this.setVar(urlVars[0], urlVars[1]);
			}
		}
	}
	this.createURLString = function(urlstring) {
		if (this.encodeURIString && this.URLString.length) {
			this.processURLString(this.URLString, true);
		}
		if (urlstring) {
			if (this.URLString.length) {
				this.URLString += this.argumentSeparator + urlstring;
			} else {
				this.URLString = urlstring;
			}
		}
		this.setVar("rndval", new Date().getTime());
		urlstringtemp = new Array();
		for (key in this.vars) {
			if (false == this.vars[key][1] && true == this.encodeURIString) {
				encoded = this.encVar(key, this.vars[key][0], true);
				delete this.vars[key];
				this.vars[encoded[0]] = Array(encoded[1], true);
				key = encoded[0];
			}

			urlstringtemp[urlstringtemp.length] = key + "=" + this.vars[key][0];
		}
		if (urlstring){
			this.URLString += this.argumentSeparator + urlstringtemp.join(this.argumentSeparator);
		} else {
			this.URLString += urlstringtemp.join(this.argumentSeparator);
		}
	}
	this.runResponse = function() {
		eval(this.response);
	}
	this.runAJAX = function(urlstring) {
		if (this.failed) {
			this.onFail();
		} else {
			this.createURLString(urlstring);
			if (this.element) {
				this.elementObj = document.getElementById(this.element);
			}
			if (this.xmlhttp) {
				var self = this;
				if (this.method == "GET") {
					totalurlstring = this.requestFile + this.queryStringSeparator + this.URLString;
					this.xmlhttp.open(this.method, totalurlstring, true);
				} else {
					this.xmlhttp.open(this.method, this.requestFile, true);
					try {
						this.xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
					} catch (e) { }
				}
				this.xmlhttp.onreadystatechange = function() {
					switch (self.xmlhttp.readyState) {
						case 1:
							self.onLoading();
							break;
						case 2:
							self.onLoaded();
							break;
						case 3:
							self.onInteractive();
							break;
						case 4:
							self.response = self.xmlhttp.responseText;
							self.responseXML = self.xmlhttp.responseXML;
							self.responseStatus[0] = self.xmlhttp.status;
							self.responseStatus[1] = self.xmlhttp.statusText;
							if (self.execute) {
								self.runResponse();
							}
							if (self.elementObj) {
								elemNodeName = self.elementObj.nodeName;
								elemNodeName.toLowerCase();
								if (elemNodeName == "input"
								|| elemNodeName == "select"
								|| elemNodeName == "option"
								|| elemNodeName == "textarea") {
									self.elementObj.value = self.response;
								} else {
									self.elementObj.innerHTML = self.response;
								}
							}
							if (self.responseStatus[0] == "200") {
								self.onCompletion();
							} else {
								self.onError();
							}
							self.URLString = "";
							break;
					}
				};
				this.xmlhttp.send(this.URLString);
			}
		}
	};
	this.reset();
	this.createAJAX();
}
//var ajax = new sack();
///////////////////////////////////////////
//---------PHP to JS-----------------------------
function shuffle(inputArr){
	// *     example 1: massive=array(1,2,3); d=shuffle(massive);
    // *     returns 1: d=array(3,1,2)
	var valArr = [];
    var k = '', i = 0;
    for (k in inputArr) { 
        valArr.push(inputArr[k]);
        delete inputArr[k] ;
    }
    valArr.sort(function() {return 0.5 - Math.random();});
    for (i = 0; i < valArr.length; i++) {
        inputArr[i] = valArr[i];
    }
	return inputArr;
}
function addslashes(str) {
    // *     example 1: addslashes("kevin's birthday");
    // *     returns 1: 'kevin\'s birthday'
    return (str+'').replace(/([\\"'])/g, "\\$1").replace(/\0/g, "\\0");
}
////////////////////////
function pagetotop(){
	t=document.documentElement.scrollTop || document.body.scrollTop;
	l=document.documentElement.scrollLeft || document.body.scrollLeft;
	if(t>0){
		t=t-30;
	}
	if(t<0){
		t=0;
	}
	scroll(l,t);
	if(t>0){	
		setTimeout("pagetotop()",20);
	}
}












