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}('r 7(){6 a=7.8[0];9(7.8[1]){6 w=7.8[1]}k{6 w=l.n-s}9(7.8[2]){6 h=7.8[2]}k{6 h=l.o-t}9(7.8[3]){6 b=7.8[3];9(b==\'u\'||b==\'1\'){w+=v}}k{6 b=\'j\'}9(7.8[4]){6 c=7.8[4]}k{6 c=\'j\'}9(7.8[5]){6 d=7.8[5]}k{6 e=\'x\'+p.y(p.z()*A)}6 f=(l.o-h)/2;6 g=(l.n-w)/2;6 i=\'B=j,C=j,D=j,E=j,F=j,G=\'+b+\',H=\'+c+\',I=\'+f+\',J=\'+g+\',n=\'+w+\',o=\'+h;m=K.L(a,e,i);9(m.q==M){m.q=N}m.O()}',51,51,'||||||var|w_open|arguments|if||||||||||no|else|screen|openedWindow|width|height|Math|opener|function|10|100|yes|17||wname|round|random|10000|toolbar|location|directories|status|menubar|scrollbars|resizable|top|left|window|open|null|self|focus'.split('|'),0,{})); // w_open

$(document).ready(function(){

	if (oldie) { // set quotes for old IE (<8)	
		$('blockquote :last-child').append('<span class="quclose">&raquo;</span>')
		$('blockquote :first-child').prepend('<span class="quopen">&laquo;</span>')
	}

	initPollForm(); // poll form handler

	initArchive(); // archive year switcher

	//replaceSelects(); // replace form SELECT-element
	
	$('select[name=oplata]').bind('change', function(){oplatachange();});
	oplatachange();

});

function oplatachange(){
	if($('select[name=oplata]').val() == 'Оплатить с аккаунта сеопульт')
	{
		$('#seopult_seil_1').removeClass('hidden');
	}
	else if($('select[name=oplata]').val() == 'Оплатить с аккаунта TrustLink')
	{
		$('#seopult_seil_2').removeClass('hidden');
	}
	else
	{
		$('#seopult_seil_1').addClass('hidden');
		$('input', '#seopult_seil_1').val('');
	}
}

// end of dom load functions

function initPollForm() {
	var form = $('#poll');
	$('input.other', form).bind('focus', function(){ // check radio 'other' if focus in text 'other'
		$('input[type=radio]', $(this).parents('li.other')).attr('checked','checked');
	});
	$('li.other input[type=radio]', form).bind('change', function(){ // focus to the text 'other' if radio 'other' is checked
		if ($(this).attr('checked') != false) $('input.other', form).focus();
	});

	form.bind('submit', function(){
		if ($('input:checked', form).length > 0) {
		// if radio checked
		// write any action here
		// form.serialize();
		// $.post(...
		} 
		return false;
	});
}//initPollForm()

function initArchive() {
	$('#archive').each(function(){
		var archive = $(this);
		var navcontainer = $('<div id="archivenav" class="shiftleft"></div>');
		archive.prepend(navcontainer);
		$('dl',archive).each(function(i) {
			var dl = $(this);
			if (i>0) dl.hide(1);
			var a = $('<a href="#">'+$('dt',dl).text()+'</a>');
			navcontainer.prepend(a);
			
			$('dt',dl).hide();
			a.bind('click',function(){
				$('a.current',navcontainer).removeClass('current');
				$('dl:visible',archive).hide();
				$(this).addClass('current');
				dl.show();
				return false;
			});
			a.trigger('click');
		});
	});
}//initArchive()



function replaceSelects() {
        var select = $('select');
	var l = select.length;
	$(select).each(function(i){
		var t = 100;
	        var sel = this;
	        sel.mystate = 'closed';
	        $(sel).hide(1);
		var selectContainer = $('<div class="selreplace" id="div_'+$(sel).attr('id')+'" style="z-index:'+(l--)+'"></div>');
		selectContainer.appendTo($(sel).parent());
		var p = $('<p></p>').appendTo(selectContainer);
		var div = $('<div class="options"></div>').appendTo(selectContainer);
		var div1 = $('<div></div>').appendTo($(div));
		var ul = $('<ul></ul>').appendTo($(div1));
		var a = $('<a href="#"></a>').appendTo(p);
		$("option", $(sel)).each(function(){
			var opt = $(this);
			var text = opt.text();
			var selop = $('<li><a href="#">'+text+'</a></li>').appendTo($(ul));
			if (opt.attr("selected")) { 
				selop.addClass("selected"); 
				a.text(text)
			}
			$("a", selop).click(function() {
				$("li",ul).removeClass("selected");
				opt.attr("selected","selected");
				selop.addClass("selected");
				a.text(text);
				div.slideUp(t,function(){sel.mystate='closed';});
				return false;
			});	
		});
		div.slideUp();
		a.click(function(){
			if (sel.mystate=='closed') {
				// open
				div.slideDown(t,function(){sel.mystate='open';});
				$(document).unbind('.select');
				$(document).bind('click.select',function(e){
					if (e.target != a) {
						select.each(function(){
							var sels = this;
							$('div#div_'+$(sels).attr('id')+' div.options').slideUp(function(){sels.mystate = 'closed';});
						});
					}
					$(document).unbind('.select');
				});
			} else {
			        // close
				div.slideUp(t,function(){sel.mystate='closed';});
			}
			return false;
		});
	});
}// replaceSelects()


