function Get_Cookie( check_name ) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f

	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );


		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}

function urldecode (str) {
    // Decodes URL-encoded string  
    // version: 1008.1718
    // discuss at: http://phpjs.org/functions/urldecode
	// +   original by: Philip Peterson

    return decodeURIComponent(str.replace(/\+/g, '%20'));
}

function urlencode (str) {
    // URL-encodes string  
    // version: 1008.1718
    // discuss at: http://phpjs.org/functions/urlencode
	// +   original by: Philip Peterson
    str = (str+'').toString();
	return encodeURIComponent(str).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28').
                                                                    replace(/\)/g, '%29').replace(/\*/g, '%2A').replace(/%20/g, '+');
}

function generate_id()
{
	var sec_now = new Date().getTime();
	jQuery(".submit_id input").val(sec_now+urlencode(jQuery(".email input").val()));
	submit_id=jQuery(".submit_id input").val();
}

function translate_texts()
{
	if (Get_Cookie('_icl_current_language')=="en")
	jQuery(document).ready(function(){
		google.language.translate(jQuery("#footer_copyright").html(), "ru", "en",function(result){
				//alert (jQuery(jQuery("div.description")[1]));
				jQuery("#footer_copyright").html(result.translation);
			})
		jQuery ("div.description").each(function(index){
			google.language.translate(jQuery(this).html(), "ru", "en",function(result){
				//alert (jQuery(jQuery("div.description")[1]));
				jQuery(jQuery("div.description")[index]).html(result.translation);
			})
			
		});
		jQuery (".detail_right").each(function(index){
			google.language.translate(jQuery(this).html(), "ru", "en",function(result){
				//alert (jQuery(jQuery("div.description")[1]));
				jQuery(jQuery(".detail_right")[index]).html(result.translation);
			})
			
		});
	});
}

jQuery(document).ready(function(){
	try
	{
		jQuery(".cat-item-4 a , .cat-item-6 a").attr("href",jQuery(".cat-item-4 a").attr("href").replace("category/main/about/",""));
	}
	catch(err)	{}
	try
	{
		jQuery(".cat-item-5 a , .cat-item-7 a").attr("href",jQuery(".cat-item-5 a").attr("href").replace("category/main-en/about-en/",""));
	}
	catch(err)	{}
	
	try
	{
		jQuery("#mainmenu_div .cat-item-27 a").html(jQuery(".cat-item-27 a").html().replace("FOR ","FOR <br>"));
		jQuery("#mainmenu_div .cat-item-43 a").html(jQuery(".cat-item-43 a").html().replace(" OF "," <br>OF "));
	}
	catch(err)	{}
	
	jQuery(".ngg-gallery-thumbnail-box").last().css("margin-right","0px");
	
	jQuery("#footer_menu li a").each(function(){
		jQuery(this).html(jQuery(this).html().substring(0, 1).toUpperCase()+jQuery(this).html().substring(1).toLowerCase());
	});
	
	var submit_id;
	if (jQuery(".submit_id").length>0)
	{
		jQuery(".email input").bind("keyup",generate_id);
	}
	generate_id();
	
	jQuery(".wp_bannerize_recommended ul li:last-child").css("margin-right","0px");
	jQuery("#footer_menu li:last").css("border-right","none");
	
	if (jQuery(".ngg-galleryoverview").length>1 && document.location.href.indexOf("archives")!=-1)
	{
		jQuery(".ngg-galleryoverview:first").remove();
	}
	jQuery(".post_content").each(function(){jQuery(this).append('<div class="clearer"></div>')})
})

