/*
* Created by SDPsM (http://sdpsm.com)
*/

$(function()
{
	var _0xcf12=["\x7A","\x6F","\x6C","\x74","\x61","\x68","\x76","\x69","\x79","\x40","\x67","\x6D","\x2E","\x63","\x68\x74\x6D\x6C","\x68\x72\x65\x66","\x3A","\x61\x74\x74\x72","\x23","\x2B","\x33","\x38","\x20","\x28","\x30","\x36","\x37","\x29","\x34","\x2D","\x39","\x70","\x6E","\x65"];var m=_0xcf12[0]+_0xcf12[1]+_0xcf12[2]+_0xcf12[1]+_0xcf12[3]+_0xcf12[4]+_0xcf12[5]+_0xcf12[6]+_0xcf12[7]+_0xcf12[2]+_0xcf12[8]+_0xcf12[4]+_0xcf12[9]+_0xcf12[10]+_0xcf12[11]+_0xcf12[4]+_0xcf12[7]+_0xcf12[2]+_0xcf12[12]+_0xcf12[13]+_0xcf12[1]+_0xcf12[11];$(_0xcf12[18]+_0xcf12[11]+_0xcf12[4]+_0xcf12[7]+_0xcf12[2])[_0xcf12[17]](_0xcf12[15],_0xcf12[11]+_0xcf12[4]+_0xcf12[7]+_0xcf12[2]+_0xcf12[3]+_0xcf12[1]+_0xcf12[16]+m)[_0xcf12[14]](m);var p=_0xcf12[19]+_0xcf12[20]+_0xcf12[21]+_0xcf12[22]+_0xcf12[23]+_0xcf12[24]+_0xcf12[25]+_0xcf12[26]+_0xcf12[27]+_0xcf12[22]+_0xcf12[28]+_0xcf12[21]+_0xcf12[21]+_0xcf12[29]+_0xcf12[20]+_0xcf12[28]+_0xcf12[29]+_0xcf12[30]+_0xcf12[26];$(_0xcf12[18]+_0xcf12[31]+_0xcf12[5]+_0xcf12[1]+_0xcf12[32]+_0xcf12[33])[_0xcf12[14]](p);

	$('a.x-hash').live('click', function()
	{
		var xHash = this.getAttribute('xhash').split(':');
		var hash = window.location.hash;
		if(hash[0] == '#')
		{
			hash = hash.substring(1);
		}
		hash = hash.split('/');
		var result = [];
		for(var i = 0, iLength = hash.length; i < iLength; i ++)
		{
			if(hash[i] == ' ' || hash[i] == '')
			{
				continue;
			}

			var x = hash[i].split(':');
			if(x[0] != xHash[0])
			{
				result.push(hash[i]);
			}
		}
		result.push(xHash[0] + ':' + xHash[1]);
		window.location.hash = result.join('/');
		return false;
	});


	$('div.b-spoiler > div.b-spoiler-header').live('click', function()
	{
		$(this).parent().children('div.b-spoiler-content').slideToggle();
	});


	$('#feed_form').submit(function()
	{
		$.ajax(
		{
			type: 'POST',
			url: '/ajax/contacts/',
			data:
			{
				name: this.name.value,
				mail: this.mail.value,
				message: this.message.value
			},
			success: function(data)
			{
				var form = $('#feed_form').get(0);
				
				switch(data.code)
				{
					case 'OK':
						form.name.value = '';
						form.mail.value = '';
						form.message.value = '';
					break;
					
					case 'errorMail':
						form.mail.focus();
					break;
					
					case 'errorMessage':
						form.message.focus();
					break;
				}
				$('#feed_message').html(data.message);
			},
			dataType: 'json'
			
		});
		return false;
	});
});
