function clearform(which)
{
		which.value='';
		which.style.color='#999999';
}

function searchtxt(which)
{
if (which.value=="")
{
	if (which.name=="search")
	{
		which.value='Поиск...';
		which.style.color='#999';
	}
	if (which.name=="uid")
	{
		which.value='Логин';
		which.style.color='#999';
	}
	if (which.name=="pwd")
	{
		which.value='Пароль';
		which.style.color='#999';
	}
}
}

function togglesize(id, maxsize)
{	
	if(document.getElementById(id).className == '' && maxsize < document.getElementById(id).width)
	{
		document.getElementById(id).className = 'resizedimg';
	}
	else
	{
		document.getElementById(id).className = '';
	}
}

function initSpoilers(context)
{
	$('div.sp-body', context).each(function(){
		var $sp_body = $(this);
		var name = $.trim(this.title) || 'скрытый текст';
		this.title = '';
		var $sp_head = $('<div class="sp-head folded clickable">'+ name +'</div>');
		$sp_head.insertBefore($sp_body).click(function(e){
			if (!$sp_body.hasClass('inited')) {
				initPostImages($sp_body);
				var $sp_fold_btn = $('<div class="sp-fold clickable">[свернуть]</div>').click(function(){
					$.scrollTo($sp_head, { duration:200, axis:'y', offset:-200 });
					$sp_head.click().animate({opacity: 0.1}, 500).animate({opacity: 1}, 700);
				});
				$sp_body.prepend('<div class="clear"></div>').append('<div class="clear"></div>').append($sp_fold_btn).addClass('inited');
			}
			if (e.shiftKey) {
				e.stopPropagation();
				e.shiftKey = false;
				var fold = $(this).hasClass('unfolded');
				$('div.sp-head', $($sp_body.parents('td')[0])).filter( function(){ return $(this).hasClass('unfolded') ? fold : !fold } ).click();
			}
			else {
				$(this).toggleClass('unfolded');
				$sp_body.slideToggle('fast');
			}
		});
	});
}
jQuery(document).ready(function() {
	if (jQuery('#iconator')) jQuery('#shrsb-networks').sortable({ 
		delay:        250,
		cursor:      'move',
		scroll:       true,
		revert:       true, 
		opacity:      0.7
	});
	if (jQuery('.shrsb-bookmarks')) { jQuery('#shrsb-sortables').sortable({ 
		handle:      '.box-mid-head',
		delay:        250,
		cursor:      'move',
		scroll:       true,
		revert:       true, 
		opacity:      0.7
	});

	//Select all icons upon clicking
	jQuery('#sel-all').click(function() {
		jQuery('#shrsb-networks').each(function() {
			jQuery('#shrsb-networks input').attr('checked', 'checked');
		});
	});

	//Deselect all icons upon clicking
	jQuery('#sel-none').click(function() {
		jQuery('#shrsb-networks').each(function() {
			jQuery('#shrsb-networks input').removeAttr('checked');
		});
	});

	//Select most popular icons upon clicking
	jQuery('#sel-pop').click(function() {
		jQuery('#shrsb-networks').each(function() {
			jQuery('#shrsb-networks input').removeAttr('checked');
		});
		jQuery('#shrsb-networks').each(function() {
			jQuery('#shr-digg').attr('checked', 'checked');
			jQuery('#shr-reddit').attr('checked', 'checked');
			jQuery('#shr-delicious').attr('checked', 'checked');
			jQuery('#shr-stumbleupon').attr('checked', 'checked');
			jQuery('#shr-mixx').attr('checked', 'checked');
			jQuery('#shr-comfeed').attr('checked', 'checked');
			jQuery('#shr-twitter').attr('checked', 'checked');
			jQuery('#shr-technorati').attr('checked', 'checked');
			jQuery('#shr-misterwong').attr('checked', 'checked');
			jQuery('#shr-diigo').attr('checked', 'checked');
			jQuery('#shr-googlebuzz').attr('checked', 'checked');
		});
	});

	/* Select recommended icons upon clicking
	jQuery('#sel-pop').click(function() {
		jQuery('#shrsb-networks').each(function() {
			jQuery('#shr-digg').attr('checked', 'checked');
			jQuery('#shr-reddit').attr('checked', 'checked');
			jQuery('#shr-delicious').attr('checked', 'checked');
			jQuery('#shr-stumbleupon').attr('checked', 'checked');
			jQuery('#shr-mixx').attr('checked', 'checked');
			jQuery('#shr-comfeed').attr('checked', 'checked');
			jQuery('#shr-twitter').attr('checked', 'checked');
			jQuery('#shr-technorati').attr('checked', 'checked');
			jQuery('#shr-misterwong').attr('checked', 'checked');
			jQuery('#shr-???').attr('checked', 'checked');
			jQuery('#shr-???').attr('checked', 'checked');
			jQuery('#shr-???').attr('checked', 'checked');
			jQuery('#shr-???').attr('checked', 'checked');
			jQuery('#shr-???').attr('checked', 'checked');			
		});
	}); */

	//Swap enabled/disabled between donation options onclick
	jQuery('#preset-amounts').parent('label').click(function() {
		jQuery('#custom-amounts').attr('disabled', 'disabled').css({'cursor':'none'});
		jQuery('#preset-amounts').removeAttr('disabled');
	});

	//Swap enabled/disabled between donation options onclick
	jQuery('#custom-amounts').parent('label').click(function() {
		jQuery('#preset-amounts').attr('disabled', 'disabled').css({'cursor':'none'});
		jQuery('#custom-amounts').removeAttr('disabled');
	});

	// Handle tiny form submission upon selecting option to hide sponsor messages
	jQuery('#hide-sponsors').click(function() {
		jQuery('#no-sponsors').submit();
	});

	// Create a universal click function to close status messages...
	jQuery('.del-x').click(function() {
		jQuery(this).parent('div').parent('div').fadeOut();
	});

	// if checkbox isn't already checked, open warning message...
	jQuery("#custom-mods").click(function() {
		if(jQuery(this).is(":not(:checked)")) {
			jQuery("#custom-mods-notice").css("display", "none");
		}
		else {
			jQuery("#custom-mods-notice").fadeIn("fast");
			jQuery("#custom-mods-notice").css("display", "table");
		}
	});

	// close custom mods warning when they click the X
	jQuery(".custom-mods-notice-close").click(function() {
		jQuery("#custom-mods-notice").fadeOut('fast');
	});

	// Apply "smart options" to BG image
	jQuery('#bgimg-yes').click(function() {
		if(jQuery(this).is(':checked')) {
			jQuery('#bgimgs').fadeIn('slow');
		}
		else {
			jQuery('#bgimgs').css('display', 'none');
		}
	});

	// Apply "smart options" to Yahoo! Buzz
	jQuery('#shr-yahoobuzz').click(function() {
		if (jQuery(this).attr('checked')) {
			jQuery('#ybuzz-defaults').fadeIn('fast');
		}
		else {
			jQuery('#ybuzz-defaults').fadeOut();
		}
	});

	// Apply "smart options" to Twittley
	jQuery('#shr-twittley').click(function() {
		if (jQuery(this).attr('checked')) {
			jQuery('#twittley-defaults').fadeIn('fast');
		}
		else {
			jQuery('#twittley-defaults').fadeOut();
		}
	});

	// Apply "smart options" to Twitter
	jQuery('#shr-twitter').click(function() {
		if (jQuery(this).attr('checked')) {
			jQuery('#twitter-defaults').fadeIn('fast');
		}
		else {
			jQuery('#twitter-defaults').fadeOut();
		}
	});

	jQuery('#shorty').change(function() {
		jQuery('#shortyapimdiv-bitly').fadeOut('fast');
		jQuery('#shortyapimdiv-trim').fadeOut('fast');
		jQuery('#shortyapimdiv-snip').fadeOut('fast');
		jQuery('#shortyapimdiv-tinyarrow').fadeOut('fast');
		jQuery('#shortyapimdiv-cligs').fadeOut('fast');
		jQuery('#shortyapimdiv-supr').fadeOut('fast');
		if(this.value=='trim'){
			jQuery('#shortyapimdiv-trim').fadeIn('fast');
		}
		else if(this.value=='bitly'){
			jQuery('#shortyapimdiv-bitly').fadeIn('fast');
		}
		else if(this.value=='snip'){
			jQuery('#shortyapimdiv-snip').fadeIn('fast');
		}
		else if(this.value=='tinyarrow'){
			jQuery('#shortyapimdiv-tinyarrow').fadeIn('fast');
		}
		else if(this.value=='cligs'){
			jQuery('#shortyapimdiv-cligs').fadeIn('fast');
		}
		else if(this.value=='supr'){
			jQuery('#shortyapimdiv-supr').fadeIn('fast');
		}
	});

	jQuery('#shortyapichk-trim').click(function() {
		if (this.checked) {
			jQuery('#shortyapidiv-trim').fadeIn('fast');
		}
		else {
			jQuery('#shortyapidiv-trim').fadeOut('fast');
		}
	});

	jQuery('#shortyapichk-tinyarrow').click(function() {
		if (this.checked) {
			jQuery('#shortyapidiv-tinyarrow').fadeIn('fast');
		}
		else {
			jQuery('#shortyapidiv-tinyarrow').fadeOut('fast');
		}
	});

	jQuery('#shortyapichk-cligs').click(function() {
		if (this.checked) {
			jQuery('#shortyapidiv-cligs').fadeIn('fast');
		}
		else {
			jQuery('#shortyapidiv-cligs').fadeOut('fast');
		}
	});

	jQuery('#shortyapichk-supr').click(function() {
		if (this.checked) {
			jQuery('#shortyapidiv-supr').fadeIn('fast');
		}
		else {
			jQuery('#shortyapidiv-supr').fadeOut('fast');
		}
	});

	jQuery('#position-above').click(function() {
		if (jQuery('#info-manual').is(':visible')) {
			jQuery('#info-manual').fadeOut();
		}
	});

	jQuery('#position-below').click(function() {
		if (jQuery('#info-manual').is(':visible')) {
			jQuery('#info-manual').fadeOut();
		}
	});

	jQuery('#position-manual').click(function() {
		if (jQuery('#info-manual').is(':not(:visible)')) {
			jQuery('#info-manual').fadeIn('slow');
		}
	});

	jQuery('.dtags-info').click(function() {
		jQuery('#tag-info').fadeIn('fast');
	});

	jQuery('.dtags-close').click(function() {
		jQuery('#tag-info').fadeOut();
	});

	jQuery('.shebang-info').click(function() {
		jQuery('#info-manual').fadeIn('fast');
	});

	jQuery('#clearShortUrls').click(function() {
		if (jQuery('#clearShortUrls').is(':checked')) {
			this.checked=jQuery('#clear-warning').fadeIn('fast');
		}else{
			this.checked=jQuery(this).is(':not(:checked)');
		}
		this.checked=jQuery(this).is(':not(:checked)');
	});

	jQuery('#warn-cancel').click(function() {
		this.checked=jQuery('#clear-warning').fadeOut();
		this.checked=jQuery(this).is(':not(:checked)');
	});

	jQuery('#warn-yes').click(function() {
		this.checked=jQuery('#clear-warning').fadeOut();
		this.checked=jQuery('#clearShortUrls').attr('checked', 'checked');
		this.checked=!this.checked;
	});



	jQuery('#shrsbresetallwarn-cancel').click(function() {
		jQuery('#shrsbresetallwarn').fadeOut();
	});

	jQuery('#shrsbresetallwarn-yes').click(function() {
		this.checked=jQuery('#shrsbresetallwarn').fadeOut();
		this.checked=jQuery('#resetalloptionsaccept').submit();
		this.checked=!this.checked;
	});


	


// Load character count and tweet output demo onload
	var dfaultload = 0;
	var dfaulttitle = 8;
	var dfaulturl = 13;
	if(jQuery("#tweetconfig").val().indexOf('${title}')!=-1) {
		dfaultload = Math.floor(dfaultload + dfaulttitle);
	}
	if(jQuery("#tweetconfig").val().indexOf('${short_link}')!=-1) {
		dfaultload = Math.floor(dfaultload + dfaulturl);
	}
	var mathdoneload = Math.floor(jQuery('#tweetconfig').val().length - dfaultload);
	if(mathdoneload >= 50) {
		jQuery('#tweetcounter span').addClass('error');
	}
	else {
		jQuery('#tweetcounter span').removeClass();
	}
	jQuery('#tweetcounter span').html(mathdoneload);
	var endvalueload = jQuery('#tweetconfig').val();
	endvalueload = endvalueload.replace('${title}', 'Some fancy post title');
	endvalueload = endvalueload.replace('${short_link}', 'http://b2l.me/a4Dc1');
	var endtweetload = endvalueload;
	jQuery('#tweetoutput span').html(endtweetload);



	jQuery('#tweetconfig').keyup(function() {
		var dfaults = 0;
		var title = 8;
		var url = 13;

		if(jQuery("#tweetconfig").val().indexOf('${title}')!=-1) {
			dfaults = Math.floor(dfaults + title);
		}
		if(jQuery("#tweetconfig").val().indexOf('${short_link}')!=-1) {
			dfaults = Math.floor(dfaults + url);
		}

		var mathdone = Math.floor(jQuery(this).val().length - dfaults);

		if(mathdone >= 50) {
			jQuery('#tweetcounter span').addClass('error');
			alert("You need to leave room for the short URL and/or post title...");
			return false;
		}
		else {
			jQuery('#tweetcounter span').removeClass();
		}
		jQuery('#tweetcounter span').html(mathdone);
		
		var endvalue = jQuery(this).val();

		endvalue = endvalue.replace('${title}', 'Some fancy post title');
		endvalue = endvalue.replace('${short_link}', 'http://b2l.me/a4Dc1');

		var endtweet = endvalue;

		jQuery('#tweetoutput span').html(endtweet);

	});

}});
jQuery(document).ready(function(){jQuery(".shr-bookmarks a.external").attr("target","_blank");var c=jQuery(".shr-bookmarks").height(),d=jQuery(".shr-bookmarks ul.socials").height();d>c&&jQuery(".shr-bookmarks-expand").hover(function(){jQuery(this).animate({height:d+"px"},{duration:400,queue:false})},function(){jQuery(this).animate({height:c+"px"},{duration:400,queue:false})});if(jQuery(".shr-bookmarks-center")||jQuery(".shr-bookmarks-spaced")){var a=jQuery(".shr-bookmarks").width(),b=jQuery(".shr-bookmarks:first ul.socials li").width(), e=jQuery(".shr-bookmarks:first ul.socials li").length,f=Math.floor(a/b);b=Math.min(f,e)*b;if(jQuery(".shr-bookmarks-spaced").length>0){a=Math.floor((a-b)/(Math.min(f,e)+1));jQuery(".shr-bookmarks ul.socials li").css("margin-left",a+"px")}else if(jQuery(true)){a=(a-b)/2;jQuery(".shr-bookmarks-center").css("margin-left",a+"px")}}});