var url_site = "http://yar-net.ru";
var sitetitle = "Электронный Ярославль. Всё о Ярославле и Ярославской области";

function rate_comment (id, value, module) {
	$.getJSON(url_site + "/rate.php?id=" + id + "&value=" + value + "&module=" + module + "&jsoncallback=?", function(json){
		$("#ratecomment_"+id).html("");
		$("#ratecomment_"+id).append(json.value);
	});
}

function yn_load() {
	jQuery("#breadCrumb").jBreadCrumb({easing:'swing'});
//	$.historyInit(pageload);
	
//	$("a[rel=ajax]").click(function() {
//		var hash = this.href;
//		hash = hash.replace(/^http\:\/\/yar-net.ru*/i, "");
//		$.historyLoad(hash);
//		return false;
//	})


/*
	var loading = $('#loading');
	$('#loading').loading({
	 loadprocess_loading: function() {
	  loading.fadeIn(300);
	 },
	 loadprocess_loadend: function() {
	  loading.fadeOut(300);
	 }
	});
*/
	$('#smilies_block img').click(function () {
		value = $('textarea.form').val();
		$('textarea.form').val(value + this.id);
	});
	
	$('.quote_comm').click(function () {
		if (window.getSelection){
			txt = window.getSelection();
		}else if (document.getSelection){
			txt = document.getSelection();
		}else if (document.selection){
			txt = document.selection.createRange().text;
		}
		if(txt!="") {
			value = $('textarea.form').val();
			$('textarea.form').val(value + "[quote]" + txt + "[/quote]");
		}
		
	});

	$(".del_comm").click(function() {
		if(confirm('Вы действительно хотите удалить этот комментарий?')) {
			id_comm = this.id.split("_");
			$.getJSON("http://yar-net.ru/inc/del_comment.php?id="+id_comm[1]+"&format=json&jsoncallback=?",
	        function(data){
	        });
	        $('#comment-'+id_comm[1]).slideUp("slow");
        }
	})
	
	function upd_mess() {
		if(logged==1) {
			$.getJSON("http://yar-net.ru/inc/upd_mess.php?format=json&jsoncallback=?",
			function(data){
				$('.messages').html('&nbsp;');
				if(data.prop>0) {
				data.prop = "+"+data.prop;
				$('.messages').html(data.prop);
				}
			});
		}
	}
	setInterval(upd_mess, 60000);
}

function firm_search() {
var value = document.forms["search"].elements["iSearch"].value;
var count = document.forms["search"].elements["iSearch"].value.length;
if(count>2) {
makeRequest(url_site+'/firms/search.php?name='+value, 'firm_block');
document.getElementById('search_status').innerHTML = ''
}
else {
document.getElementById('search_status').innerHTML = 'не менее 3-х символов'
}
}

function set_search(link) {
	var y=document.getElementsByName("search");
      for(var i=0;i<y.length;i++){
		document.getElementById('linkbg-'+i).style.background= '#000';
		document.getElementById('link-'+i).style.textDecoration= 'underline';
        if (link==[i]) {
	        document.getElementById('linkbg-'+link).style.backgroundColor= '#f40000';
	        document.getElementById('linkbg-'+link).style.backgroundImage= 'url(/img/bg_grad.png)';
	        document.getElementById('linkbg-'+link).style.backgroundPosition="0px -157px"
	        document.getElementById('link-'+link).style.textDecoration= 'none';
	        document.getElementById('type').value= link;
	        setCookie("search_type", link, "Mon, 01-Jan-2010 00:00:00 GMT", "/");
		}
	}
}

function prof_spoiler(spoilerId) {
		if (document.getElementById('lid_'+spoilerId).className == 'infoline_none') {
			document.getElementById('lid_'+spoilerId).className = 'infoline_block';
		}
		else document.getElementById('lid_'+spoilerId).className = 'infoline_none';

		spoiler('infoid'+spoilerId);
	}


function spoiler(spoilerId) {
	if (document.getElementById(spoilerId).style.display == 'none') {
		setCookie(spoilerId, "block", "Mon, 01-Jan-2010 00:00:00 GMT", "/");
		document.getElementById(spoilerId).style.display = 'block';
	}
	else if (document.getElementById(spoilerId).style.display == 'block') {
		setCookie(spoilerId, "none", "Mon, 01-Jan-2010 00:00:00 GMT", "/");
		document.getElementById(spoilerId).style.display = 'none';
	}
}

function setCookie (name, value, expires, path, domain, secure) {
      document.cookie = name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}


function check_tag(text,div,divid) {
makeRequest(url_site+'/tags/input_tag.php?text='+text+'&div='+div, divid);
}
function set_tag(value2,div) {
document.getElementById(div).value=value2;
}
function add_tag(text,module,item) {
makeRequest(url_site+'/tags/add_tag.php?text='+text+'&module='+module+'&item='+item, 'tags_spisok_'+module+'_'+item);
document.getElementById('tag_name_'+module+'_'+item).value= '';
document.getElementById('tag_status_'+module+'_'+item).innerHTML = ''
}

function show_tags(module, item)
{
    if (document.getElementById('add_tag_'+module+'_'+item).style.display == 'none')
    {
        document.getElementById('add_tag_'+module+'_'+item).style.display = 'block';
    }
    else
    {
        document.getElementById('add_tag_'+module+'_'+item).style.display = 'none';
    }
}

function makeRequest(url,divid) {
var http_request = false;
if (window.XMLHttpRequest) { // Mozilla, Opera, ...
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
http_request.overrideMimeType('text/xml');
}
} else if (window.ActiveXObject) { // IE
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!http_request) {
alert('Ошибко');
return false;
}

http_request.onreadystatechange = function() { alertContents(http_request,divid); };

http_request.open('GET', url, true);
http_request.send(null);

}

function alertContents(http_request,divid) {

if (http_request.readyState == 1) {
document.getElementById(divid).innerHTML = '<img src="'+url_site+'/images/ajax-loading2.gif">'
}
if (http_request.readyState == 4) {
if (http_request.status == 200) {
document.getElementById(divid).innerHTML = http_request.responseText
} else {
	alert('Ошибка запроса');
//document.getElementById(divid).innerHTML = 'Ошибка запроса'

}
}
}

function pageload(hash) {
		if(hash) {
			$.getJSON(hash, {json: "yes"}, function(json){
				$("#content").html("");
				$("#content").append(json.content);
				document.title = json.title+" — "+sitetitle;
			});
		} else {
		}
}

//jquery history
jQuery.extend({historyCurrentHash:'/',historyCallback:undefined,historyInit:function(callback){jQuery.historyCallback=callback;var current_hash=location.hash;jQuery.historyCurrentHash=current_hash;if(jQuery.browser.msie){if(jQuery.historyCurrentHash==''){jQuery.historyCurrentHash='#'}$("body").prepend('<iframe id="jQuery_history" style="display: none;"></iframe>');var ihistory=$("#jQuery_history")[0];var iframe=ihistory.contentWindow.document;iframe.open();iframe.close();iframe.location.hash=current_hash}else if($.browser.safari){jQuery.historyBackStack=[];jQuery.historyBackStack.length=history.length;jQuery.historyForwardStack=[];jQuery.isFirst=true}jQuery.historyCallback(current_hash.replace(/^#/,''));setInterval(jQuery.historyCheck,100)},historyAddHistory:function(hash){jQuery.historyBackStack.push(hash);jQuery.historyForwardStack.length=0;this.isFirst=true},historyCheck:function(){if(jQuery.browser.msie){var ihistory=$("#jQuery_history")[0];var iframe=ihistory.contentDocument||ihistory.contentWindow.document;var current_hash=iframe.location.hash;if(current_hash!=jQuery.historyCurrentHash){location.hash=current_hash;jQuery.historyCurrentHash=current_hash;jQuery.historyCallback(current_hash.replace(/^#/,''))}}else if($.browser.safari){if(!jQuery.dontCheck){var historyDelta=history.length-jQuery.historyBackStack.length;if(historyDelta){jQuery.isFirst=false;if(historyDelta<0){for(var i=0;i<Math.abs(historyDelta);i++)jQuery.historyForwardStack.unshift(jQuery.historyBackStack.pop())}else{for(var i=0;i<historyDelta;i++)jQuery.historyBackStack.push(jQuery.historyForwardStack.shift())}var cachedHash=jQuery.historyBackStack[jQuery.historyBackStack.length-1];if(cachedHash!=undefined){jQuery.historyCurrentHash=location.hash;jQuery.historyCallback(cachedHash)}}else if(jQuery.historyBackStack[jQuery.historyBackStack.length-1]==undefined&&!jQuery.isFirst){if(document.URL.indexOf('#')>=0){jQuery.historyCallback(document.URL.split('#')[1])}else{var current_hash=location.hash;jQuery.historyCallback('')}jQuery.isFirst=true}}}else{var current_hash=location.hash;if(current_hash!=jQuery.historyCurrentHash){jQuery.historyCurrentHash=current_hash;jQuery.historyCallback(current_hash.replace(/^#/,''))}}},historyLoad:function(hash){var newhash;if(jQuery.browser.safari){newhash=hash}else{newhash='#'+hash;location.hash=newhash}jQuery.historyCurrentHash=newhash;if(jQuery.browser.msie){var ihistory=$("#jQuery_history")[0];var iframe=ihistory.contentWindow.document;iframe.open();iframe.close();iframe.location.hash=newhash;jQuery.historyCallback(hash)}else if(jQuery.browser.safari){jQuery.dontCheck=true;this.historyAddHistory(hash);var fn=function(){jQuery.dontCheck=false};window.setTimeout(fn,200);jQuery.historyCallback(hash);location.hash=newhash}else{jQuery.historyCallback(hash)}}});

//jquery thickbox
var tb_pathToImage = "/images/loadingAnimation.gif";
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('$(o).2S(9(){1u(\'a.18, 3n.18, 3i.18\');1w=1p 1t();1w.L=2H});9 1u(b){$(b).s(9(){6 t=X.Q||X.1v||M;6 a=X.u||X.23;6 g=X.1N||P;19(t,a,g);X.2E();H P})}9 19(d,f,g){3m{3(2t o.v.J.2i==="2g"){$("v","11").r({A:"28%",z:"28%"});$("11").r("22","2Z");3(o.1Y("1F")===M){$("v").q("<U 5=\'1F\'></U><4 5=\'B\'></4><4 5=\'8\'></4>");$("#B").s(G)}}n{3(o.1Y("B")===M){$("v").q("<4 5=\'B\'></4><4 5=\'8\'></4>");$("#B").s(G)}}3(1K()){$("#B").1J("2B")}n{$("#B").1J("2z")}3(d===M){d=""}$("v").q("<4 5=\'K\'><1I L=\'"+1w.L+"\' /></4>");$(\'#K\').2y();6 h;3(f.O("?")!==-1){h=f.3l(0,f.O("?"))}n{h=f}6 i=/\\.2s$|\\.2q$|\\.2m$|\\.2l$|\\.2k$/;6 j=h.1C().2h(i);3(j==\'.2s\'||j==\'.2q\'||j==\'.2m\'||j==\'.2l\'||j==\'.2k\'){1D="";1G="";14="";1z="";1x="";R="";1n="";1r=P;3(g){E=$("a[@1N="+g+"]").36();25(D=0;((D<E.1c)&&(R===""));D++){6 k=E[D].u.1C().2h(i);3(!(E[D].u==f)){3(1r){1z=E[D].Q;1x=E[D].u;R="<1e 5=\'1X\'>&1d;&1d;<a u=\'#\'>2T &2R;</a></1e>"}n{1D=E[D].Q;1G=E[D].u;14="<1e 5=\'1U\'>&1d;&1d;<a u=\'#\'>&2O; 2N</a></1e>"}}n{1r=1b;1n="1t "+(D+1)+" 2L "+(E.1c)}}}S=1p 1t();S.1g=9(){S.1g=M;6 a=2x();6 x=a[0]-1M;6 y=a[1]-1M;6 b=S.z;6 c=S.A;3(b>x){c=c*(x/b);b=x;3(c>y){b=b*(y/c);c=y}}n 3(c>y){b=b*(y/c);c=y;3(b>x){c=c*(x/b);b=x}}13=b+30;1a=c+2G;$("#8").q("<a u=\'\' 5=\'1L\' Q=\'1o\'><1I 5=\'2F\' L=\'"+f+"\' z=\'"+b+"\' A=\'"+c+"\' 23=\'"+d+"\'/></a>"+"<4 5=\'2D\'>"+d+"<4 5=\'2C\'>"+1n+14+R+"</4></4><4 5=\'2A\'><a u=\'#\' 5=\'Z\' Q=\'1o\'>1l</a> 1k 1j 1s</4>");$("#Z").s(G);3(!(14==="")){9 12(){3($(o).N("s",12)){$(o).N("s",12)}$("#8").C();$("v").q("<4 5=\'8\'></4>");19(1D,1G,g);H P}$("#1U").s(12)}3(!(R==="")){9 1i(){$("#8").C();$("v").q("<4 5=\'8\'></4>");19(1z,1x,g);H P}$("#1X").s(1i)}o.1h=9(e){3(e==M){I=2w.2v}n{I=e.2u}3(I==27){G()}n 3(I==3k){3(!(R=="")){o.1h="";1i()}}n 3(I==3j){3(!(14=="")){o.1h="";12()}}};16();$("#K").C();$("#1L").s(G);$("#8").r({Y:"T"})};S.L=f}n{6 l=f.2r(/^[^\\?]+\\??/,\'\');6 m=2p(l);13=(m[\'z\']*1)+30||3h;1a=(m[\'A\']*1)+3g||3f;W=13-30;V=1a-3e;3(f.O(\'2j\')!=-1){1E=f.1B(\'3d\');$("#15").C();3(m[\'1A\']!="1b"){$("#8").q("<4 5=\'2f\'><4 5=\'1H\'>"+d+"</4><4 5=\'2e\'><a u=\'#\' 5=\'Z\' Q=\'1o\'>1l</a> 1k 1j 1s</4></4><U 1W=\'0\' 2d=\'0\' L=\'"+1E[0]+"\' 5=\'15\' 1v=\'15"+1f.2c(1f.1y()*2b)+"\' 1g=\'1m()\' J=\'z:"+(W+29)+"p;A:"+(V+17)+"p;\' > </U>")}n{$("#B").N();$("#8").q("<U 1W=\'0\' 2d=\'0\' L=\'"+1E[0]+"\' 5=\'15\' 1v=\'15"+1f.2c(1f.1y()*2b)+"\' 1g=\'1m()\' J=\'z:"+(W+29)+"p;A:"+(V+17)+"p;\'> </U>")}}n{3($("#8").r("Y")!="T"){3(m[\'1A\']!="1b"){$("#8").q("<4 5=\'2f\'><4 5=\'1H\'>"+d+"</4><4 5=\'2e\'><a u=\'#\' 5=\'Z\'>1l</a> 1k 1j 1s</4></4><4 5=\'F\' J=\'z:"+W+"p;A:"+V+"p\'></4>")}n{$("#B").N();$("#8").q("<4 5=\'F\' 3c=\'3b\' J=\'z:"+W+"p;A:"+V+"p;\'></4>")}}n{$("#F")[0].J.z=W+"p";$("#F")[0].J.A=V+"p";$("#F")[0].3a=0;$("#1H").11(d)}}$("#Z").s(G);3(f.O(\'37\')!=-1){$("#F").q($(\'#\'+m[\'26\']).1T());$("#8").24(9(){$(\'#\'+m[\'26\']).q($("#F").1T())});16();$("#K").C();$("#8").r({Y:"T"})}n 3(f.O(\'2j\')!=-1){16();3($.1q.35){$("#K").C();$("#8").r({Y:"T"})}}n{$("#F").34(f+="&1y="+(1p 33().32()),9(){16();$("#K").C();1u("#F a.18");$("#8").r({Y:"T"})})}}3(!m[\'1A\']){o.21=9(e){3(e==M){I=2w.2v}n{I=e.2u}3(I==27){G()}}}}31(e){}}9 1m(){$("#K").C();$("#8").r({Y:"T"})}9 G(){$("#2Y").N("s");$("#Z").N("s");$("#8").2X("2W",9(){$(\'#8,#B,#1F\').2V("24").N().C()});$("#K").C();3(2t o.v.J.2i=="2g"){$("v","11").r({A:"1Z",z:"1Z"});$("11").r("22","")}o.1h="";o.21="";H P}9 16(){$("#8").r({2U:\'-\'+20((13/2),10)+\'p\',z:13+\'p\'});3(!(1V.1q.2Q&&1V.1q.2P<7)){$("#8").r({38:\'-\'+20((1a/2),10)+\'p\'})}}9 2p(a){6 b={};3(!a){H b}6 c=a.1B(/[;&]/);25(6 i=0;i<c.1c;i++){6 d=c[i].1B(\'=\');3(!d||d.1c!=2){39}6 e=2a(d[0]);6 f=2a(d[1]);f=f.2r(/\\+/g,\' \');b[e]=f}H b}9 2x(){6 a=o.2M;6 w=1S.2o||1R.2o||(a&&a.1Q)||o.v.1Q;6 h=1S.1P||1R.1P||(a&&a.2n)||o.v.2n;1O=[w,h];H 1O}9 1K(){6 a=2K.2J.1C();3(a.O(\'2I\')!=-1&&a.O(\'3o\')!=-1){H 1b}}',62,211,'|||if|div|id|var||TB_window|function||||||||||||||else|document|px|append|css|click||href|body||||width|height|TB_overlay|remove|TB_Counter|TB_TempArray|TB_ajaxContent|tb_remove|return|keycode|style|TB_load|src|null|unbind|indexOf|false|title|TB_NextHTML|imgPreloader|block|iframe|ajaxContentH|ajaxContentW|this|display|TB_closeWindowButton||html|goPrev|TB_WIDTH|TB_PrevHTML|TB_iframeContent|tb_position||thickbox|tb_show|TB_HEIGHT|true|length|nbsp|span|Math|onload|onkeydown|goNext|Esc|или|закрыть|tb_showIframe|TB_imageCount|Close|new|browser|TB_FoundURL|Key|Image|tb_init|name|imgLoader|TB_NextURL|random|TB_NextCaption|modal|split|toLowerCase|TB_PrevCaption|urlNoQuery|TB_HideSelect|TB_PrevURL|TB_ajaxWindowTitle|img|addClass|tb_detectMacXFF|TB_ImageOff|150|rel|arrayPageSize|innerHeight|clientWidth|self|window|children|TB_prev|jQuery|frameborder|TB_next|getElementById|auto|parseInt|onkeyup|overflow|alt|unload|for|inlineId||100||unescape|1000|round|hspace|TB_closeAjaxWindow|TB_title|undefined|match|maxHeight|TB_iframe|bmp|gif|png|clientHeight|innerWidth|tb_parseQuery|jpeg|replace|jpg|typeof|which|keyCode|event|tb_getPageSize|show|TB_overlayBG|TB_closeWindow|TB_overlayMacFFBGHack|TB_secondLine|TB_caption|blur|TB_Image|60|tb_pathToImage|mac|userAgent|navigator|of|documentElement|Prev|lt|version|msie|gt|ready|Next|marginLeft|trigger|fast|fadeOut|TB_imageOff|hidden||catch|getTime|Date|load|safari|get|TB_inline|marginTop|continue|scrollTop|TB_modal|class|TB_|45|440|40|630|input|188|190|substr|try|area|firefox'.split('|'),0,{}))
