var browser=navigator.userAgent.toLowerCase();
var isFF=((browser.indexOf('mozilla')!=-1) && (browser.indexOf('spoofer')==-1) && (browser.indexOf('compatible')==-1) && (browser.indexOf('opera')==-1) && (browser.indexOf('webtv')==-1) && (browser.indexOf('hotjava')==-1));
var isIE=((browser.indexOf("msie")!=-1) && (browser.indexOf("opera")==-1));
var isOP=(browser.indexOf("opera")!=-1);

/////////////////////////rollover
document.write("<div id=rollover class=rollover>");
document.write("</div>");
function rollover(aEvent, tekst, visible) {

var rollover=document.getElementById('rollover');
var myEvent = window.event ? window.event : aEvent;
_x=myEvent.clientX; 
_y=myEvent.clientY;
rollover.style.top=_y + document.body.scrollTop+20;
rollover.style.left=_x-10;
rollover.innerHTML=tekst;
rollover.style.visibility=visible;
}

/////////////////rollover


//--------------------------------
/* Создание нового объекта XMLHttpRequest для общения с Web-сервером */
var xmlHttp = false;
try {
  xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
  try {
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (e2) {
    xmlHttp = false;
  }
}
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
  xmlHttp = new XMLHttpRequest();
}
//---------------------------------------------------------

//-----------AJAX------poluchaem tekst soobschenija-----------

///////////vote
function showmessage(vote)
{
  var url = "hidden.php?vote="+vote;
  // Открыть соединение с сервером
  xmlHttp.open("GET", url, true);
  // Установить функцию для сервера, которая выполнится после его ответа
  xmlHttp.onreadystatechange =messageready;
  // SПередать запрос
  xmlHttp.send(null);
}

function messageready()
{
  if (xmlHttp.readyState == 4) 
 {
    var response = xmlHttp.responseText;

new_vote.style.visibility='visible';
new_vote.style.width=document.body.clientWidth;
new_vote.style.height=document.body.scrollHeight;

new_vote.innerHTML= response;

vote_size.style.top=document.body.scrollTop+50;
vote_size.style.left=document.body.clientWidth/3;

//vote_size.style.top=400;
//window.alert( id=vote_size.style.height);
div_load.style.visibility='hidden';
  }
//else {sstatus.innerText="processing...";}
}
///////////vote
///////////cover
function cover_load(vote)
{
  var url = vote;
  xmlHttp.open("GET", url, true);
  xmlHttp.onreadystatechange =cover_ready;
  xmlHttp.send(null);
}

function cover_ready()
{
  if (xmlHttp.readyState == 4) 
 {
    var response = xmlHttp.responseText;
//    alert(response);
acover.innerHTML= response;
load_cover.style.visibility='hidden';
//var cover_img=document.getElementById('cover_img').style;

size=document.body.scrollTop+((document.body.clientHeight-cover_img.height)/2);

if (size <  0) size=0;

cover_img.style.top=size;

cover_img.style.left=(document.body.clientWidth-cover_img.width)/2;

//window.alert(cover_img.style.top+' + ' +cover_img.style.left);
  }
}
///////////cover
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////// LOAD IMG /////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function loading_img(vote)
{
  var url = "hidden.php?img="+vote;
  xmlHttp.open("GET", url, true);
  xmlHttp.onreadystatechange =cover_ready;
  xmlHttp.send(null);
}

function Start_RevealTrans()
{
    if(isIE){
//img_revealtrans=document.getElementById('img_revealtrans');

img_revealtrans.style.visibility="hidden"
img_revealtrans.filters.item(0).Transition=24;
img_revealtrans.filters.item(0).Apply()
img_revealtrans.filters.item(0).Play()
img_revealtrans.style.visibility=""
setTimeout('Start_RevealTrans()', 20000);
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////

///////////news_img
function news_img(n_img) {
load_news_img.style.visibility='visible';
load_news_img.style.width=document.body.clientWidth;
load_news_img.style.height=document.body.scrollHeight;

load_news_img_i.style.top=document.body.scrollTop+((document.body.clientHeight-load_news_img_i.height)/2);
load_news_img_i.style.left=(document.body.clientWidth-load_news_img_i.width)/2;

n_n_img(n_img);
}

function n_n_img(img)
{
  var url = 'hidden.php?news='+img;
  xmlHttp.open("GET", url, true);
  xmlHttp.onreadystatechange =news_img_ready;
  xmlHttp.send(null);
}

function news_img_ready()
{
  if (xmlHttp.readyState == 4) 
 {
    var response = xmlHttp.responseText;
img_news.innerHTML= response;
//alert(response);
//var loaded_img=document.getElementById("loaded_img");

img_news.style.width=document.body.clientWidth;
img_news.style.height=document.body.scrollHeight;

//setTimeout('loaded_img.style.top=document.body.scrollTop+((document.body.clientHeight-loaded_img.height)/2)', 600);
//setTimeout('loaded_img.style.left=(document.body.clientWidth-loaded_img.width)/2', 600);

//setTimeout('img_news.style.visibility=\'visible\'', 700);
//setTimeout('load_news_img.style.visibility=\'hidden\'', 700);

img_news.style.visibility='visible';
load_news_img.style.visibility='hidden';

size=document.body.scrollTop+((document.body.clientHeight-loaded_img.height)/2);

if (size <  0) size=0;

loaded_img.style.top=size;
loaded_img.style.left=(document.body.clientWidth-loaded_img.width)/2;

//window.alert(loaded_img.style.top+' + ' + loaded_img.style.left);
  }
}

///////////news_img
//-----------end of AJAX------poluchaem tekst soobschenija-----------
xmlbusy=0;
var ajax_win_id=0;
///////////////// load_page
function load_page(get_url, post_url) {
//alert(get_url);
if (xmlbusy ==0) {
xmlHttp.open("POST", get_url+"&r="+Math.random(), true);
xmlHttp.onreadystatechange =loaded_page;
xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlHttp.send(post_url);
}
}
///////////////// load_page
///////////////// loaded page
function loaded_page () {
var show_load=document.getElementById("mywin_txt_"+ajax_win_id);
  if (xmlHttp.readyState == 4) 
 {
xmlbusy=0;
show_load.innerHTML="";
var response = xmlHttp.responseText;
show_load.innerHTML=response;

 }
else {
xmlbusy=1;
show_load.innerHTML="<br><br><center>Loading...<br><img src=img/load_45.gif></center>";
 }
}
////////////////////////////////////////////
function show_music (iid, dir, width) {
	var music_play=document.getElementById("music_play");
	var txt="";
	txt+="<object id=player type=\"application/x-shockwave-flash\" data=\""+dir+"music/player_mp3_maxi.swf\" width=\""+width+"\" height=\"17\">";
	txt+="<param name=\"movie\" value=\""+dir+"music/player_mp3_maxi.swf\" />";
	txt+="<param name=\"bgcolor\" value=\"#ffffff\" />";
	txt+="<param name=\"FlashVars\" value=\"mp3="+dir+"music/f1l3s/"+iid+".mp3&showvolume=1&height=17&width="+width+"&autoplay=1\" />";
	txt+="</object>";
	music_play.innerHTML=txt;
//	document.getElementById("player").SetVariable("player:jsPlay", "");
	music_play.style.display="inline";
	}
////////////////////////////////////////////
function radio_history() {
	var div_radio_history=document.getElementById("div_radio_history");
	var div_radio_vesti=document.getElementById("div_radio_vesti");
	if (div_radio_history.style.overflowY == "hidden") {
		div_radio_history.style.overflowY="auto";
		div_radio_history.style.height=200;
		div_radio_vesti.innerHTML="<b><u>Закрыть</u></b>&nbsp;&nbsp;";
		}
	else {
		div_radio_history.style.overflowY="hidden";
		div_radio_history.style.height=30;
		div_radio_vesti.innerHTML="<b><u>Архив</u></b>&nbsp;&nbsp;";
		}
	}
////////////////////////////////////////////
function anek_history() {
	var td_anek_distory=document.getElementById("td_anek_distory");
	var td_anek=document.getElementById("td_anek");
	if (td_anek_distory.style.display == "none") {
		td_anek_distory.style.display="block";
		td_anek.innerHTML="<b><u>Закрыть</u></b>&nbsp;&nbsp;";
		}
	else {
		td_anek_distory.style.display="none";
		td_anek.innerHTML="<b><u>Архив</u></b>&nbsp;&nbsp;";
		}
	}
////////////////////////////////////////////
function change_anekdoti(iid, img) {
	if (img != "") document.getElementById("anek_img").src="anekdoti/f1l3s/"+img;
	else document.getElementById("anek_img").src="img/anek_top.png";
	var anek_player=document.getElementById("anek_player");
	var txt="";
	txt+="<object id=player type=\"application/x-shockwave-flash\" data=\"anekdoti/player_mp3_maxi.swf\" width=\"160\" height=\"17\">";
	txt+="<param name=\"movie\" value=\"anekdoti/player_mp3_maxi.swf\" />";
	txt+="<param name=\"bgcolor\" value=\"#ffffff\" />";
	txt+="<param name=\"FlashVars\" value=\"mp3=anekdoti/f1l3s/"+iid+".mp3&showvolume=1&height=17&width=160&autoplay=1\" />";
	txt+="</object>";
	anek_player.innerHTML=txt;
	}
////////////// DROP DOWN LIST //////////////
function select_list(array, selected, name, extra) {
	var txt="<select name="+name+" id="+name+" "+extra+">";
	for ( var i in array ){
		var sel="";
		if (selected == i) sel="selected";
		txt+="<option value=\""+i+"\" "+sel+">"+array[i]+"</option>";
		}
	return txt;
}
////////////////////////////////////////////
function js_onchange_busline() {
	var change_bus=document.getElementById("change_bus").value;
	var change_holy=document.getElementById("change_holy").value;
	var div_close_bus=document.getElementById("div_close_bus");
	if (change_holy == 0) {
		if (change_bus == 0) {
			document.getElementById("bus_list").innerHTML="";
			document.getElementById("bus_list_to").innerHTML="";
			div_close_bus.style.display="none";
			}
		else { 
			document.getElementById("bus_list").innerHTML="<div style=\"background-color:white;border-left: solid white 4px;\">"+bus_lines[change_bus]+"</div>";
			document.getElementById("bus_list_to").innerHTML="<div style=\"background-color:white;\">"+bus_lines_to[change_bus]+"</div>";
			div_close_bus.style.display="block";
			}
		}
	else {
		if (change_bus == 0) {
			document.getElementById("bus_list").innerHTML="";
			document.getElementById("bus_list_to").innerHTML="";
			div_close_bus.style.display="none";
			}
		else {
			document.getElementById("bus_list").innerHTML="<div style=\"background-color:white;border-left: solid white 4px;\">"+bus_lines_holy[change_bus]+"</div>";
			document.getElementById("bus_list_to").innerHTML="<div style=\"background-color:white;\">"+bus_lines_to_holy[change_bus]+"</div>";
			div_close_bus.style.display="block";
			}
		}
	}
///////////////////////////////////////////////
function close_bus() {
	var change_bus=document.getElementById("change_bus");
	var change_holy=document.getElementById("change_holy");
	change_bus.options[0].selected=true;
	change_holy.options[0].selected=true;
	js_onchange_busline();
	}
////////////////////////////////////////////
function js_onchange_tramline() {
	var change_tram=document.getElementById("change_tram").value;
	var tram_change_holy=document.getElementById("tram_change_holy").value;
	var div_close_tram=document.getElementById("div_close_tram");
	if (tram_change_holy == 0) {
		if (change_tram == 0) {
			document.getElementById("tram_list").innerHTML="";
			document.getElementById("tram_list_to").innerHTML="";
			div_close_tram.style.display="none";
			}
		else { 
			document.getElementById("tram_list").innerHTML="<div style=\"background-color:white;border-left: solid white 4px;\">"+tram_lines[change_tram]+"</div>";
			document.getElementById("tram_list_to").innerHTML="<div style=\"background-color:white;\">"+tram_lines_to[change_tram]+"</div>";
			div_close_tram.style.display="block";
			}
		}
	else {
		if (change_tram == 0) {
			document.getElementById("tram_list").innerHTML="";
			document.getElementById("tram_list_to").innerHTML="";
			div_close_tram.style.display="none";
			}
		else {
			document.getElementById("tram_list").innerHTML="<div style=\"background-color:white;border-left: solid white 4px;\">"+tram_lines_holy[change_tram]+"</div>";
			document.getElementById("tram_list_to").innerHTML="<div style=\"background-color:white;\">"+tram_lines_to_holy[change_tram]+"</div>";
			div_close_tram.style.display="block";
			}
		}
	}
///////////////////////////////////////////////
function close_tram() {
	var change_tram=document.getElementById("change_tram");
	var tram_change_holy=document.getElementById("tram_change_holy");
	change_tram.options[0].selected=true;
	tram_change_holy.options[0].selected=true;
	js_onchange_tramline();
	}
///////////////////////////////////////////////
var videoteka_current=0;
function videoteka_move_left() {
	var videoteka_lmit=document.getElementById("videoteka_lmit").innerHTML;
	if (isIE) {
		document.getElementById('vide_right_img').filters[0].opacity=100;
		if (document.getElementById('videoteka_div').scrollLeft <= 200) document.getElementById('vide_left_img').filters[0].opacity=20;
		}
	if (isFF) {
		document.getElementById('vide_right_img').style.MozOpacity="1.0";
		if (document.getElementById('videoteka_div').scrollLeft <= 200) document.getElementById('vide_left_img').style.opacity="0.2";
		}
	document.getElementById('videoteka_div').scrollLeft-=167;
	videoteka_current--;
	}
///////////////////////////////////////////////
function videoteka_move_right() {
	videoteka_current++;
	var videoteka_lmit=document.getElementById("videoteka_lmit").innerHTML;
	if (isIE) {
		document.getElementById('vide_left_img').filters[0].opacity=100;
		if (videoteka_lmit == videoteka_current) document.getElementById('vide_right_img').filters[0].opacity="20";
		}
	if (isFF) {
		document.getElementById('vide_left_img').style.opacity="1.0";
		if (document.getElementById('videoteka_div').clientWidth <= (document.getElementById('videoteka_div').scrollLeft)+200) document.getElementById('vide_right_img').style.opacity="0.2";
		}
	document.getElementById('videoteka_div').scrollLeft+=167;
	}
///////////////////////////////////////////////
function setHomepage() { 
	if (document.all) { //For IE  
		document.body.style.behavior='url(#default#homepage)'; 
		document.body.setHomePage('http://dinaburg.eu'); 
		} 
	else if (window.sidebar) { 
		if(window.netscape) { 
			try { 
				netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
				} 
			catch(e){ 
				alert("This action was aviod by your browserif you want to enable please enter about:config in your address line,and change the value of signed.applets.codebase_principal_support to true"); 
				} 
			} 
		var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch); 
		prefs.setCharPref('browser.startup.homepage','http://dinaburg.eu'); 
		} 
	} 
///////////////////////////////////////////////
function CreateBookmarkLink() {
	title = "Газета \"Динабург вести\""; 
	url="http://dinaburg.eu/";
	// Blogger - Replace with <$BlogItemTitle$>
	// MovableType - Replace with <$MTEntryTitle$> url = "Webpage URL";
	// Blogger - Replace with <$BlogItemPermalinkURL$>
	// MovableType - Replace with <$MTEntryPermalink$>
	// WordPress - <?php bloginfo('url'); ?>
	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
		}
	else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title);
		}
	else if(window.opera && window.print) { // Opera Hotlist
		return true;
		} 
	}
//if (window.external) {  document.write('<a href =      "javascript:CreateBookmarkLink()");">Add to Favorites</a>');   } else  if (window.sidebar) {  document.write('<a href =     "javascript:CreateBookmarkLink()");">Bookmark Page</a>');  } else if (window.opera && window.print) {	   document.write('<a href =     "javascript:CreateBookmarkLink()");">Add Bookmark</a>'); }
///////////////////////////////////////////////
var last_mouseover_top_slide_news=new Array();
var last_mouseover_top_slide_auto=new Array();
function js_top_slide_news(iid, img_width, txt_width){
	last_mouseover_top_slide_news[iid]=-1;
	last_mouseover_top_slide_auto[iid]=-1;
	var content=document.getElementById(iid+"_content");
	var txt="";
	for (var i in array_top_news[iid]){
		txt+="<div id=\"main_"+iid+"_"+i+"\" style=\"width:"+txt_width+";margin-bottom:2px; padding:6px;padding-left:9px;padding-right:9px; cursor:pointer;\" onmouseover=\"js_top_slide_news_onmouseover('"+iid+"', '"+i+"');\">"+
			 "<a href=\""+array_top_news[iid][i]["click"]+"\" style=\"text-decoration:none;\">"+
			 "<b id=\"mainB_"+iid+"_"+i+"\" style=\"font-size:12pt;\">"+
//			 "<span style=\"color:white;font-size:20pt;\">&bull;</span>"+
			 "<img src=\"img/bullet.png\" border=0 id=\"bullet_"+iid+"_"+i+"\">"+
			 array_top_news[iid][i]["title"]+"</b></a>"+
			 " <a href=\""+array_top_news[iid][i]["commenti_click"]+"\" style=\"font-size:10pt;color:red;TEXT-DECORATION: none;\"><i><b>("+array_top_news[iid][i]["commenti"]+")</b></i></a>"+
			 "<div id=\"anotation_"+iid+"_"+i+"\" style=\"display:none;font-size:10pt;\"><a href=\""+array_top_news[iid][i]["click"]+"\" style=\"text-decoration:none;color:white;\">"+array_top_news[iid][i]["anotation"]+"</a></div>"+
			 ""+
			 "</div>";
		}
		txt="<table border=0 style=\"border: solid #73142C 0px;\" cellspacing=\"0\" cellpadding=\"0\">"+
			 "<tr>"+
			 "<td valign=top width="+img_width+" height=200><img src=\"\" id=img_"+iid+" height=192 style=\"border: solid #73142C 1px;\"></td>"+
			 "<td valign=top width="+txt_width+">"+txt+"</td>"+
			 "</tr>"+
			 "</table>";
	content.innerHTML=txt;
	//js_top_slide_news_onmouseover(iid, 0);
	js_top_slide_news_auto(iid);
	}
///////////////////////////////////////////////
function js_top_slide_news_onmouseover(iid, i){
//alert(iid+" - "+i);
	if (last_mouseover_top_slide_news[iid] != i) {
		if (last_mouseover_top_slide_news[iid] != -1) {
			document.getElementById("anotation_"+iid+"_"+last_mouseover_top_slide_news[iid]).style.display="none";
			document.getElementById("anotation_"+iid+"_"+last_mouseover_top_slide_news[iid]).style.color="black";
			document.getElementById("mainB_"+iid+"_"+last_mouseover_top_slide_news[iid]).style.color="black";
			document.getElementById("main_"+iid+"_"+last_mouseover_top_slide_news[iid]).style.backgroundImage="none";
			
			document.getElementById("bullet_"+iid+"_"+last_mouseover_top_slide_news[iid]).src="img/bullet.png";
			}
		last_mouseover_top_slide_news[iid]=i;
		document.getElementById("anotation_"+iid+"_"+i).style.display="block";
		document.getElementById("anotation_"+iid+"_"+i).style.color="white";
		document.getElementById("mainB_"+iid+"_"+i).style.color="white";
		document.getElementById("main_"+iid+"_"+i).style.backgroundImage="url('img/top_news_line.jpg')";
		
		document.getElementById("bullet_"+iid+"_"+i).src="img/bullet_white.png";
		
		var img=document.getElementById("img_"+iid).src=array_top_news[iid][i]["img"];
		}
	}
///////////////////////////////////////////////
function js_top_slide_news_auto(iid){
	if (last_mouseover_top_slide_auto[iid] >= 3) {
		last_mouseover_top_slide_auto[iid]=-1;
		//alert(last_mouseover_top_slide_auto[iid]);
		}
	last_mouseover_top_slide_auto[iid]++;
	js_top_slide_news_onmouseover(iid, last_mouseover_top_slide_auto[iid]);
	setTimeout("js_top_slide_news_auto('"+iid+"');",8000);
	//alert(last_mouseover_top_slide_news[iid]);
	}
////////////////// Chart Drow /////////////////
function chart_drow(id, width, height, swf_url, www_url) {

	var obj=document.getElementById(id);
	var txt="";
	txt+="<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\"";
	txt+="	codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\"";
	txt+="	width=\""+width+"\"";
	txt+="	height=\""+height+"\" id=\"graph-2\" align=\"middle\">";
	txt+="	<param name=\"flashvars\" value=\"data-file="+www_url+"\">";
	txt+="	<param name=\"allowScriptAccess\" value=\"sameDomain\" />";
	txt+="	<param name=\"movie\" value=\""+swf_url+"\" />";
	txt+="	<param name=\"quality\" value=\"high\" />";
	txt+="	<param name=\"wmode\" value=\"opaque\" />";	
	txt+="	<embed src=\""+swf_url+"\"";
	txt+="		flashvars=\"data-file="+www_url+"\"";
	txt+="		wmode=\"opaque\"";
	txt+="		quality=\"high\"";
	txt+="		bgcolor=\"#FFFFFF\"";
	txt+="		width=\""+width+"\"";
	txt+="		height=\""+height+"\"";
	txt+="		name=\"open-flash-chart\"";
	txt+="		align=\"middle\"";
	txt+="		allowScriptAccess=\"sameDomain\"";
	txt+="		type=\"application/x-shockwave-flash\"";
	txt+="		pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" />";
	txt+="	</object>";
	obj.innerHTML=txt;
	}
///////////////////////////////////////////////