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 show_hide(objName,objName2) {
	curDrag = MM_findObj('cadiv_i1'); 
	curDrag2 = MM_findObj('cadiv_i2'); 	
	curDrag3 = MM_findObj('cadiv_i3'); 		
	curDrag.style.display = 'none';
	curDrag2.style.display = 'block';
	curDrag3.style.display = 'block';	
	return false;
}

//Проверка на валидность отзыва к статье
function CheckReply(frm) {
	regExp = /^[a-zA-Z0-9](([a-z0-9\-_\+\&]?)+[a-z0-9])?\@((\w([a-zA-Z0-9\-_\.]+\w)?\.[a-z]{2,4})|(([01]?\d\d|2[0-4]\d|25[0-5])\.([01]?\d\d|2[0-4]\d|25[0-5])\.([01]?\d\d |2[0-4]\d|25[0-5])\.([01]?\d\d|2[0-4]\d|25[0-5]))|(localhost))$/;

	var canGo = true;
	if (frm.Nick.value == "") canGo = false;
	if (frm.message.value == "") canGo = false;
	if (frm.Mail.value!="" && !regExp.test(frm.Mail.value)) canGo = false;
	
	if (canGo) frm.submit();
	else alert("Заполните все поля!");
	
}

//Отправка сообщения о спаме
function alarm(id,act) {
	f = document.forms["AlertSpam"];
	f.action.value = act;
	f.mes_id.value = id;
	f.submit();
}


function search_submit() {
	f = document.forms["sForm"];
	f.submit();
}

function send_var(form_name, val) {
	form_name.action = "RubricatorS.php";
	form_name.qq.value = val;
	form_name.qq.name = "cb_"+val;
	form_name.submit();
}

function ResortBy(field) {
	f = document.forms["rub_sel"];
	f.sort_field.value = field;
	f.submit();
}

function ShowVote(mode,id) {
	if (mode == 1) {
	  myWin= open("article_vote.php?art_id="+id, "", "width=450,height=350,status=no,toolbar=no,menubar=no,scrollbars=1");
	} else 
	if (mode == 2) {
	  myWin= open("article_vote.php?ShowRate="+id, "", "width=450,height=350,status=no,toolbar=no,menubar=no,scrollbars=1");
	}
}

function view(x,y,name) {
	newwin = window.open("","_blank","width=300,height=200,scrollbars=1",1);
	newwin.document.open();
	newwin.moveTo(0,0);
	newwin.document.write('<html><head><title>Screen</title></head>'+
						  '<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" align="center" bgcolor="#666666" style="overflow:auto;">'+
						  '<center><img src="'+name+'" style="margin-top:10px;" onload="window.resizeBy(this.width-document.body.clientWidth+15, this.height-document.body.clientHeight+15);" align=absmiddle></center>'+
						  '</body></html>');
	newwin.document.close();
}

function view_cover(x,y,name) {
	newwin = window.open("","_blank","width="+x+",height="+y);
	newwin.document.write('<html><head><title>Screen</title></head><body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0> <img src="'+name+'"> </body></html>');
}

function view_cover2(name) {
	// функция добавлена Дионисом 23.03.06 в рамках задачи уменьшения трафика через localhost
	newwin = window.open("","_blank","width=100,height=100");
	newwin.document.write('<html><head><title></title></head>'+
	'<body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0>'+
	'<img src="'+name+'" name="cover" onload="javascript:window.resizeBy(document.cover.width-document.body.clientWidth, document.cover.height-document.body.clientHeight); return true;">'+
	'</body></html>');
	return false;
}

// открытие баннеров в новом окне
function newwin(url) {
	newwin = window.open(url,"_blank");
	newwin.focus();
	return false;
}


function select_option(selector, val, mode) {
	//Проверяем есть ли необходимый СЕЛЕКТ
	if (!selector) 	return false;

	//устанавливаем значение
	if (mode == "text") {
		for(i=0; i<selector.length; i++) {
			if (selector[i].text == val) { 
				selector[i].selected = true;
				return true;
			}
		}
		return false;
	} else 
	if (mode == "value") {
		for(i=0; i<selector.length; i++) {
			if (selector[i].value == val) { 
				selector[i].selected = true;
				return true;
			}
		}
		return false;
	} 
	return false;
}
// Сворачивание или разворачивание блоков в меню
function show_hide_menu(obj) {
    curDrag = MM_findObj(obj);
    if (curDrag.style.display == 'block') {
        curDrag.style.display = 'none';
    }
    else {
        curDrag.style.display = 'block';
    }
    
    return false;
}

function ShowHint(w,h,path) {
  myWin= open(path, "", 
    "width="+w+",height="+h+",status=no,toolbar=no,menubar=no,scrollbars=1,resize=1");
}

//Кешируем картинки
mimg = new Image();
// mimg.src = "/images/global/menu_plashka_yellow.gif";
mimg2 = new Image();
// mimg2.src = "/images/global/menu_plashka_yellow1.gif";

d=document;
dim=d.images||false;
blankSrc="/images/null.gif";

marazm='DXImageTransform.Microsoft.AlphaImageLoader';
var IE=(d.all&&!window.opera&&navigator.platform=="Win32")||d.layers;
var IE5=IE&&/MSIE\s([\d\.]+)/.test(navigator.userAgent)&&5.5<=parseFloat(RegExp.$1);


function FullBrifNews(id) {
	if (document.getElementById("full_"+id).style.display == "none") {
		document.getElementById("full_"+id).style.display = "";
		document.getElementById("comand_"+id).innerHTML = "<<< коротко";
		if (document.getElementById("picts_"+id))
			document.getElementById("picts_"+id).style.display = "";
	} else {
		document.getElementById("full_"+id).style.display = "none";
		document.getElementById("comand_"+id).innerHTML = "прочитать полностью >>>";
		if (document.getElementById("picts_"+id))
			document.getElementById("picts_"+id).style.display = "none";
	}
}



function fuckIE() {
	if (dim && IE) {
		for(var i=0;i<dim.length;i++){
			IM=dim[i];
			if (/(.*)\.png/i.test(IM.src)) {
				if(IE5) { // поймать бы урода, который такое выдумал
					IM.style.filter="progid:"+marazm+"(src='"+IM.src+"',sizingMethod='image')";
					IM.src=blankSrc;
				}
			}
		}
	}
}

function noSpam(us_er,do_ma_in) {
	do_ma_in = (!do_ma_in)?'mirf.ru':do_ma_in;
	window.location = "mailto:" + us_er + "@" + do_ma_in;
}

function ShowRegForm() {
	show_hide_fr("f_reg");
}

function show_hide_fr(objName) {
	curDrag = MM_findObj(objName); 
	if (!curDrag) return false;
	if (curDrag.style.display != 'none') curDrag.style.display = 'none'; 
	else curDrag.style.display = 'block';
}

function set_display_mode(objName, mode) {
	curDrag = MM_findObj(objName); if (!curDrag) return false;
	curDrag.style.display = mode;
}

function GoToReminder() {
	window.location.href="http://forum.mirf.ru/login.php?do=lostpw";
}

function GoToRegister() {
	window.location.href="http://forum.mirf.ru/register.php";
}

