function ShowAdPhoto(link)
{
	var overlay = document.getElementById('overlay');
	var vew_photo = document.getElementById('vew_photo');
	var y = self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop);
	vew_photo.style.top = y + 'px';
	vew_photo.innerHTML = '<div><img src="' + link + '" border = "1"></img></div><div><a href="javascript:void(0);" onclick="CloseShowPhoto();" style="color:#FFFFFF;font-weight:bold;">Закрыть</a></div>';
	vew_photo.style.width = '100%';
	overlay.style.display = 'block';
	vew_photo.style.display = 'block';
}
function CloseShowPhoto(id)
{
	var overlay = document.getElementById('overlay');
	var vew_photo = document.getElementById('vew_photo');

	overlay.style.display = 'none';
	vew_photo.style.display = 'none';
}
function Events(event)
{
	CloseShowPhoto();
}

function onkp()
{
	var max = 600;
	var c = document.getElementById('c1');
	var t = document.getElementById('message');
	c.innerHTML='Вы ввели: <b>' + t.value.length + '</b> симв.<br>Максимально допустимое кол-во символов: <b>' + max + '</b>';
	if(t.value.length>=max)
	{
		t.value=t.value.substring(0,max);
		c.style.color = '#FF0000';
		c.innerHTML='Вы ввели: <b>' + t.value.length + '</b> симв.<br>Максимально допустимое кол-во символов: <b>' + max + '</b>';
	}else{
		c.style.color = '#006600';
	}
}

function show_podparam(id)
{
	
	var text = document.getElementById('text_' + id);
	var show = document.getElementById('all_params_' + id);	

	if(show.style.display == 'block'){
		show.style.display = 'none';
		text.innerHTML = text.innerHTML.replace(/-/,"+");
	}else{
		show.style.display = 'block';
		text.innerHTML = text.innerHTML.replace(/\+/,"-");
	}
}

function show_params_all(){
	var show = document.getElementById('show');
	var hide = document.getElementById('hide');
	var value = 0;
	
	if(show.style.display == 'none'){
		show.style.display = 'block';
		hide.style.display = 'none'; 
	}else{
		show.style.display = 'none';
		hide.style.display = 'block';
		value = 1;
	}

	
	var expiresDate = new Date();
	expiresDate.setTime(expiresDate.getTime() + 365 * 24 * 60 * 60 * 1000);
	var expires = expiresDate.toGMTString();
	document.cookie = "show_params_all=" + value + "; path=/; expires=" + expires + ";";
}
function send_mass_ajax(selector,aid,id_obj)
{
	SubmitLink('/admin/ad/new_cat.php?id=' + selector.options[selector.selectedIndex].value,'child_cat');
	SubmitLink('/admin/ad/change_ad_list.php?top=' + selector.options[selector.selectedIndex].value+'&id=' + aid + '&id_obj=' + id_obj ,'ad_list');
	
}
function changeproperty(aim,action,param,child)
{	
	switch(action){
		case 'create_property':{
			$(document).ready(function(){
			var propname=$("#newpropname").val();	
			
			$.get('/admin/board_new/actions/core.php',{action:"create_property",param:param,name_param:propname},function(data){
				$(aim).html(data);			
			});	
			});
			break;
		}
		case 'update_property':{
			$(document).ready(function(){
			var propname=$("#property"+child).val();	
		//	alert(propname);
			$.get('/admin/board_new/actions/core.php',{action:"update_property",param:param,name_param:propname,child:child},function(data){
				$(aim).html(data);			
			});		
			});	
			break;	
		}
		default:{
			$(document).ready(function(){
				$.get('/admin/board_new/actions/core.php',{action:action,param:param,child:child},function(data){
					$(aim).html(data);
				});		
			});
			break;	
		}
	}
}
function changecategory(aim1,aim2,selector,adv_id,type,user)
{
	$(document).ready(function(){
		var param=selector.options[selector.selectedIndex].value;
		$.get('/admin/board_new/actions/core.php',{action:"select_category",param:param},function(data){
			$(aim1).html(data);
		});
		$.get('/admin/board_new/actions/core.php',{action:"get_ad_list",param:param,adv_id:adv_id,type:type,user:user},function(data){
			$(aim2).html(data);
		});
	});
}
function userban(action,type,user,name)
{
	var reason = prompt('причина бана:','');
	if(reason){
		location.href="/admin/board_new/actions/core.php?action=" + action + "&type=" + type + "&user=" + user + "&name=" + name + "&reason=" + reason;
	}	
}
function add_proposition2(action,id,aim)
{
	$(document).ready(function(){
		var text=$('#'+id).val();
		$.get('/admin/board_new/actions/core.php',{action:action,text:text},function(data){
			$('#'+aim).html(data);
		});
		
	});
}
function add_proposition(action,id,aim,mode)
{
	$(document).ready(function(){
		switch(mode){
			case 1:{
				var text=$('#'+id).val();
				var type=$("#type_gen_search").attr("checked");
				if(type==true)
					type=1;
				else type=0;
				$.get('/admin/board_new/actions/core.php',{action:action,text:text,type:type},function(data){
					$('#'+aim).html(data);
				}); 
				break;
			}
			case 2:{ 
				var param=$("select#"+id).val();
				var category=$("select#prop_cat").val();
				$.get('/admin/board_new/actions/core.php',{action:action,param:param,category:category},function(data){
					$('#'+aim).html(data);
				});
				break;
			}
		}
		
	});
}
function mode_proposition(action,aim1,aim2,mode)
{
	$(document).ready(function(){
		
		switch(mode){
		case 1:{
			var category=$("select#"+aim1).val();
		
			$.get('/admin/board_new/actions/core.php',{action:action,category:category},function(data){
				$("#"+aim2).html(data);
			});
			break;
			}
		case 2:{
			var param=$("select#"+aim1).val();
			var category=$("select#prop_cat").val();
			$.get('/admin/board_new/actions/core.php',{action:action,param:param,category:category},function(data){
				$("#"+aim2).html(data);
			});
			break;
			}
		case 3:{
			var param=$("select#"+aim1).val();
			$.get('/admin/board_new/actions/core.php',{action:action,param:param},function(data){
				$("#"+aim2).html(data);
			});
			break;
			}
		}
	});
}

function utils_act(action,obj)
{
	var id=obj.id;
	$(document).ready(function(){
		switch(action){
			case 1: {
				$.get('/admin/board_new/actions/core.php',{action:'count_advert'},function(){
					$("#"+id).animate({
						marginLeft:20
					}, 200 );
					$("#"+id).animate({
						marginLeft:0
					}, 250);
				});
				break;
			}
			case 2: {
				$.get('/admin/board_new/actions/core.php',{action:'drop_advert'},function(data){
					$("#"+id).animate({
						marginLeft:20
					}, 200 );
					$("#"+id).animate({
						marginLeft:0
					}, 250);
				}
				
				);
				break;
			}
			case 3:{
				$.get('/admin/board_new/actions/core.php',{action:'clear_history'},function(data){
				
					$("#"+id).animate({
						marginLeft:20
					}, 200 );
					$("#"+id).animate({
						marginLeft:0
					}, 250);
				}
				
				);
				break;
			}
		}
	});
}
function modComment()
{
	$("#user_comment").toggle();
	$("#edit_ucom").toggle();
	$("#moducom").toggle();
	$("#saveucom").toggle();
	
}
function saveComment(uid)
{
	var comment=$.trim($("#edit_ucom > textarea").val());
	$.post("/admin/ad/ucom_add_.php",{uid:uid,comment:comment},function(data){
		
		$("#user_comment").text(data).toggle();
		$("#edit_ucom").toggle();
		$("#edit_ucom > textarea").val(data).toggle();
		$("#moducom").toggle();
		$("#saveucom").toggle();
	});
	


}
function mail(id)
{
	window.location.href="http://www.u-mama.ru/gmail/index.php?p=new_msg&receiver="+id;
}
function uinfo(id)
{
	window.open("http://www.u-mama.ru/users/index.php?mode=info&user="+id,'','width=800,height=600,history=yes,resizable=yes,status=yes,scrollbars=yes,toolbar=yes,location=yes,menubar=yes');
}
