function pics(img,ref)
{
	document.getElementById(img).src = ref;
}

function openwin(img,w,h,title)
{
 var hWnd;
 if(hWnd!=null) hWnd.close();
 hWnd=window.open(img,"","toolbar=no,location=no,directories=no,resizable=yes,scrollbars=yes,left=100,top=100,width="+w+",height="+h);
 hWnd.document.open();
 hWnd.document.write("<html><head><title>"+title+"</title></head><body topmargin=0 leftmargin=0 marginwidth=0 marginheight=0>");
 hWnd.document.write("<img src=\""+img+"\" width="+w+" height="+h+">");
 hWnd.document.write("</body></html>");
 hWnd.document.close();
}

function obj_info(text)
{
 var hWnd;
 if(hWnd!=null) hWnd.close();
 hWnd=window.open("","","toolbar=no,location=no,directories=no,scrollbars=yes,left=100,top=100,width=600,height=500");
 hWnd.document.open();
 hWnd.document.write("<html><head><title>Информация</title><link href='/inc/css.css' type='text/css' rel='stylesheet'/></head><body topmargin=0 leftmargin=0 marginwidth=0 marginheight=0 style='padding:30px;'>");
 hWnd.document.write(text);
 hWnd.document.write("</body></html>");
 hWnd.document.close();
}

function IEPngFix( pngimg, gifimg, width, height, unique_name )
{
	var code = '<img src="'+ gifimg +'" width="' + width + '" height="' + height + '" border="0" id="'+ unique_name +'" style="background:url('+pngimg+') no-repeat 0px 0px;" alt="'+unique_name+'"/>';
	if( navigator.userAgent.indexOf("Opera") > 1 ) document.write(code);
	else
		if( navigator.userAgent.indexOf("MSIE 6") > 1 ) document.write('<img src="'+gifimg+'" width="' + width + '" height="' + height + '" border="0" alt="'+unique_name+'" id="'+ unique_name +'" style="filter: progid:DXImageTransform.Microsoft.AlphaImageLoader (src=' + pngimg + ' , sizingMethod=crop );"/>');
		else
			if(navigator.userAgent.indexOf("MSIE 5") != -1) document.write(code);
			else document.write(code);
}

function switch_head_bg(bg)
{
	document.getElementById("head_pic").style.backgroundImage = "url("+bg+")";
}


function get_price()
{
	document.getElementById("countprice").value = 1;
	document.of.submit();
}


function addFileInput(cont_id)
{
	$cont = $('#' + cont_id);
	//для фото
	name = 	$('input[type=file]:first', $cont).attr('name');
	$input = $('input[type=file]:last', $cont);
	$last_text = $('input[type=file]:last', $cont);
	$new_input = $input.clone(true);
	new_name = name + ($('input[type=file]', $cont).length + 1);
	$new_input.attr('name', new_name);
	$new_input.val('');
	$new_input.insertAfter($last_text);

	return false;
}


$(document).ready(function(){
	$('a').each(function(){
		link = $(this).attr('href');
		if( ($(this).attr("target")) && ( (link.indexOf('.jpg') > 0) || (link.indexOf('.JPG') > 0) ) )
		{
//			$(this).prettyPhoto();
//			$(this).lightbox();
//			$(this).fancybox();
		}
	});

		jQuery("a[rel^='prettyPhoto']").prettyPhoto({theme:'facebook'});



	//удал. фото
	$('.del_flats_pic').click(function(){
			num = $(this).attr('num');
			$(this).parent().parent().css({"display":"none"});
			$.ajax({
				url: "/inc/del_flats_pic.php?id="+num
			});
			return false;
	});
	$('.del_buildings_pic').click(function(){
			num = $(this).attr('num');
			$(this).parent().parent().css({"display":"none"});
			$.ajax({
				url: "/inc/del_buildings_pic.php?id="+num
			});
			return false;
	});
	$('.del_commerce_pic').click(function(){
			num = $(this).attr('num');
			$(this).parent().parent().css({"display":"none"});
			$.ajax({
				url: "/inc/del_commerce_pic.php?id="+num
			});
			return false;
	});
	$('.del_dacha_pic').click(function(){
			num = $(this).attr('num');
			$(this).parent().parent().css({"display":"none"});
			$.ajax({
				url: "/inc/del_dacha_pic.php?id="+num
			});
			return false;
	});
	$('.del_hotels_pic').click(function(){
			num = $(this).attr('num');
			$(this).parent().parent().css({"display":"none"});
			$.ajax({
				url: "/inc/del_hotels_pic.php?id="+num
			});
			return false;
	});
	$('.del_houses_pic').click(function(){
			num = $(this).attr('num');
			$(this).parent().parent().css({"display":"none"});
			$.ajax({
				url: "/inc/del_houses_pic.php?id="+num
			});
			return false;
	});
	$('.del_lots_pic').click(function(){
			num = $(this).attr('num');
			$(this).parent().parent().css({"display":"none"});
			$.ajax({
				url: "/inc/del_lots_pic.php?id="+num
			});
			return false;
	});
	$('.del_rooms_pic').click(function(){
			num = $(this).attr('num');
			$(this).parent().parent().css({"display":"none"});
			$.ajax({
				url: "/inc/del_rooms_pic.php?id="+num
			});
			return false;
	});


});