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 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 backtoform()
{
	document.getElementById("save").value = 0;
	document.previewform.submit();
}


function show_div(id)
{
	var div;
	div = document.getElementById(id);
	if ( div.style.display == "none" ) div.style.display = "block";
		else div.style.display = "none";
}

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(){
	//удал. фото

	$('.del_file').click(
		function(){
			num = $(this).attr('num');
			$(this).parent().parent().css({"display":"none"});
			$.ajax({
				url: "/inc/del_file.php?id="+num
			});
			return false;
		}
	);
});