function sendErrorWnd(){
}

sendErrorWnd.prototype = {
	openWnd :	function(){
					var t=this;
					var al = document.getElementById('sendErrorWnd');
					var h = "";
					if (!al) {
						var impWnd = document.createElement('div');
						impWnd.id = "sendErrorWnd";
						impWnd.className = "sendErrorWnd";
						document.getElementById('mainLayout').appendChild(impWnd);
					}
					

					h += '<div class="header"><span>www.rockbaby.ru/' + location.hash + '</span><a class="close" href="javascript:;"></a></div>';
					h += '<div class="content">';
					h += '<textarea></textarea>';
						
					h += '<span  class="choose" style="float:left;">';
					h += '<input id="type_err" type="radio" name="errtype" checked value="ошибка">';
					h += '<label for="type_err">Ошибка</label>';
					h += '</span>';
						
					h += '<span  class="choose" style="float:left;">';
					h += '<input id="type_unpr" type="radio" name="errtype" value="неточность"> ';
					h += '<label for="type_unpr">Неточность</label>';
					h += '</span>';
						
					h += '<span class="choose" style="float:left;">';
					h += '<input id="type_wish" type="radio" name="errtype" value="пожелание"> ';
					h += '<label for="type_wish">Пожелание</label>';
					h += '</span>';
					h += '<a href="javascript:;" class="profileButton sendErrorButt">Отправить</a>';
					h += '</div>';
					$('#sendErrorWnd').html(h);
					$('#sendErrorWnd').css('display', 'block');
					
					$('#sendErrorWnd .header .close').bind('click', function(){
						t.closeWnd();
					});
					
					$('#sendErrorWnd input').checkBox();
					
					$('#sendErrorWnd .sendErrorButt').bind('click', function(){
						h = '';
						h += $('#sendErrorWnd textarea').val();
						var type = '';
						if(h == '')
							return;
						$(this).after('<br clear="All"/><img style="margin-top:15px;margin-left:135px;" src="/media/images/ajax-loader.gif"/>');
						$(this).remove();
						var radios = $('#sendErrorWnd input');
						for(i=0;i<radios.length;i++){
							if(radios[i].checked)
								type = radios[i].value;						
						}
						$.post('/user/send_error_message', {
							text : h,
							type : type,
							location : 'http://www.rockbaby.ru/' + location.hash,
							browser : navigator.appName
						}, function(data){
							$('#sendErrorWnd .content').html('<span style="font-size:12pt;padding-left:1px;font-weight:bold;text-align:center;float:left;margin-top:70px;background-color:#615f5e;">Ваше сообщение успешно отправлено. Спасибо за помощь.</span>');
							setTimeout(function(){
								t.closeWnd();
							}, 3000);
						});
					});

				},
	closeWnd :	function(){
					if ($('#sendErrorWnd').css('display') == 'block') {
						$('#sendErrorWnd button').unbind('click');
						$('#sendErrorWnd').css('display', 'none');
					    $('#sendErrorWnd .close').unbind("click");
					}
				}
};

var sendErrorWnd = new sendErrorWnd();
