function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function addFavorites(fav){
			switch(fav){
				case 'fb': window.open('http://www.facebook.com/share.php?u='+encodeURIComponent(location.href)); break;
				case 'vk': window.open('http://vkontakte.ru/share.php?url='+location.href); break;
				case 'lj': 
					var this_text = 'http://www.livejournal.com/update.bml?subject='+encodeURIComponent(this_title)+'&event='+encodeURIComponent(document.getElementById('content').innerText);
					text_array = this_text.split('%20');
					new_text = new String(); i=0;
					text_add = encodeURIComponent('<br/><br/><a href="'+location.href+'">Подробнее</a>');
					while(i<text_array.length && (new_text+text_array[i]+text_add).length < 2048){
						new_text += text_array[i]+'%20';
						i++;
					}
					new_text += '...'+text_add;
					
					window.open(new_text); break;
				case 'tw': window.open('http://twitter.com/home/?status='+location.href+'+-+'+encodeURIComponent(this_title)); break;
				case 'mm': window.open('http://connect.mail.ru/share?share_url='+location.href); break;
				default: break;
			}
		}		
			
		function printFavorites(){
			var favs_array = new Array('fb','tw','lj','vk','mm');
			var titles_array=new Array('Facebook','Twitter','LiveJournal','В контакте',"Мой Мир");
			// bgcolor="#51525A"
			document.write('<table cellpadding="10" cellspacing="0" style="color:#EEEEEE;"><tr valign="middle"><!--td nowrap>Отправить:</td--><td nowrap>');
			for(i=0; i<favs_array.length; i++){
				document.write('<a title="'+titles_array[i]+'" style="float:left; background:URL(favorites/'+favs_array[i]+'.gif) no-repeat; cursor:pointer; padding:2px 7px 0 7px; margin-left:5px;" onclick="addFavorites(\''+favs_array[i]+'\')">&nbsp;</a>');
			}
			document.write('</td></tr></table>');
		}

monthNames = new Array("января","февраля","марта","апреля","мая","июня","июля","августа","сентября","октября","ноября","декабря");

function showTime () {
	if(document.getElementById) {
	nowtime = new Date()
	if (parseInt(nowtime.getHours()) > 9) { var nowtimeHours = nowtime.getHours()} else { var nowtimeHours = '0' + nowtime.getHours() }
	if (parseInt(nowtime.getMinutes()) > 9) { var nowtimeMinutes = nowtime.getMinutes()} else { var nowtimeMinutes = '0' + nowtime.getMinutes() }
	if (parseInt(nowtime.getSeconds()) > 9) { var nowtimeSeconds = nowtime.getSeconds()} else { var nowtimeSeconds = '0' + nowtime.getSeconds() }

	year = (navigator.appName.search("Microsoft") >= 0)? nowtime.getYear() : nowtime.getYear()+1900;

	var TimeString = nowtime.getDate() + ' ' + monthNames[nowtime.getMonth()] + ' ' + year + ' (' +  nowtimeHours + ':' + nowtimeMinutes + ':' + nowtimeSeconds + ')';
	if(document.getElementById('ShowTime')) {
		document.getElementById('ShowTime').innerHTML = TimeString;
		setTimeout("showTime()", 1000);
	}                                      	
	}
}

 function Pic(Width,Height,Path,Name) {
	Height2=Height+50;
	WinFeatures = "top=100,left=100,width="+Width+",height="+Height2+",Status=no,toolbar=no,menubar=no,location=no,directories=no,scrollbars=yes";
	BigW = window.open("","PictureWindow",WinFeatures);
	BigW.document.open();
	BigW.document.write("<head><title>"+Name+"</title></head>");
	BigW.document.write("<body bgcolor='#ffffff' leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'><IMG src='"+Path+"' height='"+Height+"' width='"+Width+"' alt='"+Name+"'><p <p align='center' style='margin:10px;'>"+Name+"</p></body>"); 
	BigW.document.close();
   }
   
  function formValid(form) {
	f1 = document.forms[form].name.value;
	f2 = document.forms[form].mail.value;
	f3 = document.forms[form].text.value;
	
	if (f1 == "") {
		alert("Введите, пожалуйста, Ваше имя");
		return false;
	}
 	else if (f3 == "") {
		alert("Введите, пожалуйста, Ваше сообщение");
		return false;
	}
	else return true;
}

function createPrintWindow(Num,Title)
{
	_content=document.getElementById('content').innerHTML;
	//Распечатать статью
	_content = _content.replace ("Распечатать статью"," ");
	_location = this.location;
	var p = Math.ceil(Math.random()*10000);
	var q = Math.ceil(Math.random()*p);
	windowName = p+'X'+p+q;
	WinFeatures = "top=100,left=100,width=780,height=600,Status=no,toolbar=no,menubar=no,location=no,directories=no,scrollbars=yes";
	w = window.open("",windowName,WinFeatures);
	w.document.open();
	w.document.write('<html><head><title>Газета журналистских расследований "ДЕЛО №" '+Num+' / '+Title+'</title><meta http-equiv="Content-Type" content="text/html; charset=windows-1251"></head>');
	//w.document.write('<body onload="window.print()"><p><small>Адрес статьи: '+_location+'</small></p><h2>Газета журналистских расследований "ДЕЛО №" '+Num+'</h2><h3>'+Title+'</h3>'+_content+'</body></html>'); 
	w.document.write('<body onload="window.print()"><p><small>Адрес статьи: '+_location+'</small></p>'+_content+'</body></html>'); 

	w.document.close();
}

