function SubmitSearchForm( ) {

	if ( document.searchLeft.text.value != 'Поиск' && document.searchLeft.text.value != '' ) {
		document.searchLeft.submit( );
	}

}

function fcheck(obj){
	mask=0;
	if(obj.author.value=='') {mask=1; obj.author.focus();}
	if(obj.post.value==''&&mask!=1){mask=1; obj.post.focus();}

	if(mask==1){
		alert('Пожалуйста, заполните все обязательные поля!');
		return false;
	}
}

function wo(link,ww,hh,title,scrollbars, resize) {

	if ( !hh ) {
		wh = screen.height-'100px';
	}
	else {
		wh = parseInt(hh)+24;
	}

	w=window.open(link,'',(ww ? 'width='+ww+',' : '')+(wh ? 'height='+wh+',' : '')+'toolbar=0,scrollbars='+scrollbars+', '+(resize>=0 ? 'resizable='+resize : 'resizable'));
	if (link.indexOf('.html')==-1) {
		if (document.layers) title='';
		w.document.open();
		w.document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><title>'+title+'</title><meta http-equiv=Content-Type content="text/html; charset=windows-1251"></head>');
		w.document.write('<style type="text/css">.print {text-align:right; margin:3px 5px 2px 0;} .print a {text-decoration:none; font-family:Arial; color: #0080B0; font-size:11px}</style><style type="text/css" media="print">.print {visibility: hidden; display: none;}</style> <body style="margin:0; padding:0; height:100%; width:100%; background-color:#FFFFFF;"><table style=" width:100%; border-collapse:collapse; padding:0;"><tr align="center" valign="middle"><td><img src='+link+' width='+ww+' height='+hh+' border=0 alt="'+title+'" /></td></tr></table><div class="print"><a href="?print=1" onclick="self.print(); return false;"><img src="/i/print.gif" alt="Распечатать" title="Распечатать" border="0" /> Распечатать</a></div></body>');
		//w.document.write('<script type="text/javascript">var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");document.write(unescape("%3Cscript src=\'" + gaJsHost + "google-analytics.com/ga.js\' type=\'text/javascript\'%3E%3C/script%3E"));</script><script type="text/javascript">var pageTracker = _gat._getTracker("UA-2583103-1");pageTracker._initData();pageTracker._trackPageview();</script>');
		w.document.write('</html>');
		w.document.close();
	}
	w.focus();
}

function ObjInfo( link, title) {
	
	wo( link,'750', '500', title, '1');
	return false;

}

var user_agent = null;

switch(true)
{
	case navigator.userAgent.indexOf("Opera")>-1 :
		user_agent = "Opera";
		break;
	case navigator.userAgent.indexOf("MSIE")>-1 :
		user_agent = "IE";
		break;
	case navigator.userAgent.indexOf("Gecko")>-1 :
		user_agent = "Gecko";
		break;
}

function initXMLHTTPRequest( ){
	var xReq = null;

	if ( window.XMLHttpRequest ) {
		xReq = new XMLHttpRequest( );
	} 
	else if ( window.ActiveXObject ) {
		xReq = new ActiveXObject( "Microsoft.XMLHTTP" );
	}
	return xReq;
}

function SetNewsVisites( link, id, index ) {

	var myid = id.match(/(\d+)/g);
	var myindex = index.match(/(\d+)/g);
	var externalLink = link.match(/(diva.by)|(moda.by)/g);

	req = initXMLHTTPRequest( );
	
	if ( req ) {

		req.onreadystatechange = function( ) {

			if ( req.readyState == 4 ){

				if ( externalLink != null ) {

					window.location = link;

				}
				return true;

			}
			else {
			
				return false;
			
			}

		}
		req.open('GET', AppPath+'include/news_visites.php4?action=incrementNewsVisites&id='+myid+'&index='+myindex, true);
		req.send('');

	}

}

function TitleNewsHover() {
	var newsDiv = $('newsRight');
	var newsLinks = $C('nl', newsDiv, 'a');
	newsLinks.each(function(link, index){
		link.onmouseover = function() {
			link.lastChild.src = link.lastChild.src.replace(/\_hover.gif$/, ".gif");
			return false;
		}
		link.onmouseout = function() {
			link.lastChild.src = link.lastChild.src.replace(/\.gif$/, "_hover.gif");
			return false;
		}
	
	});
}

function MenuSubmenuGenerate() {

	var submenuDiv = $T('a', $('mainMenu') );

	submenuDiv.each(function(link, index){

		link.onmouseover = function() {
			over();
		}
		
		link.onmouseout = function() {
			out();
		}
	
	});

}

function ShowHide( elementId ) {
	var elem = $( elementId );

	if ( elem.style.display == 'none' || elem.style.display == '' ) {
		elem.style.display = 'block';
	}
	else {
		elem.style.display = 'none';
	}
}

function ShowHideMore( link ) {

	var shortTab = $('short');
	var fullTab = $('full');

	if ( link.href.match(/(#short)/g) ) {
		shortTab.style.display = "block";
		$('sdiv').className = "here";
		fullTab.style.display = "none";
		$('fdiv').className = "";
	}
	else {
		fullTab.style.display = "block";
		$('fdiv').className = "here";
		shortTab.style.display = "none";
		$('sdiv').className = "";
	}

	return false;
}

function getCalendar( monthId, yearId ) {

	var localMonthId = monthId.match(/(\d+)/g);
	var localYearId = yearId.match(/(\d+)/g);

	req = initXMLHTTPRequest( );

	if ( req ) {
		req.onreadystatechange = function( ) {
			if (req.readyState == 4){
				if (req.status == 200){
					try
					{
						var d = $("calendar");
						d.innerHTML = req.responseText;
					}
					catch (e) {}
				}
			}
		}
		req.open('GET', AppPath+'include/news_calendar.php4?action=getNewsByMonth&monthId='+localMonthId+'&yearId='+localYearId, true);
		req.send('');
	}
}

function SetTimer( func, time ) {
	timeOn = setTimeout( func, time );
}

function HideElement( elementName ) {
	$(elementName).style.display = 'none';
	clearTimeout( timeOn );
}

var theOpacity = 1;
var theIncrement = 0.01;

function HideWithOpacity( elementName ) {
	theOpacity -= theIncrement;
	$(elementName).style.opacity = theOpacity;
	if((theOpacity % 100) <= 0) {
		$(elementName).style.display = 'none';
		clearTimeout( timeOn );
	}
	else {
		setTimeout("HideWithOpacity( '"+elementName+"' )", 10);
	}
}

function CheckGlamReg( form ) {

	if ( form.sname.value == '' || form.name.value == ''
		|| form.mname.value == '' || form.bday.value == ''
		|| form.bmonth.value == '' || form.byear.value == ''
		|| form.city.value == '' || form.street.value == ''
		|| form.house.value == '' || form.flat.value == ''
		|| form.email.value == '' || form.zip.value == ''
		) {
		alert ('Пожалуйста, заполните все обязательные поля');
		return false;
	}

}

function glamQuestionWnd( ) {
	
	var glamWnd = window.open( AppPath + 'glamour/glam-code/?action=form', '', 'width=580,height=280' );
	glamWnd.focus();
	
}
