$(document).ready(function()
{	
	$('.multy_images').each(function(){
		var obg = $(this);
		if (swfobject.getFlashPlayerVersion().major === 0)
		{
			obg.parent().html('You need flashplayer!!!<br><a href="http://get.adobe.com/flashplayer/">adobe flashplayer</a>');
		}
		else
		obg.uploadify({
			'uploader' : '/images/style/uploadify/uploadify.swf',
			'cancelImg' : '/images/backend/button_delete.png',
			'buttonImg' : '/images/style/uploadify/button.jpg',
			'script' : '/uploadify.php',
			
			'fileExt' : '*.jpg;*.png;*.gif;*.bmp;',
			'fileDesc' : ' ',
			'auto' : true,
			'displayData' : 'speed',
			'height' : 24,
			'width' : 100,
			'method' : 'post',
			'multi' : true,
			'onComplete'  : function(event,ID,fileObj,response_name_file,data)
			{
				//$('<input type="hidden" name="photos[]" value="'+response_name_file+'">').appendTo( '.upload' );
				obg.parent().append('<input type="hidden" name="photos[]" value="'+response_name_file+'">');
			},
			'onAllComplete' : function(event,data)
			{
				obg.parents('form').filter(':last').submit();
			},
	
			'onError' : function (event,ID,fileObj,errorObj)
			{
				alert(errorObj.type + ' Error: ' + errorObj.info);
			}
				
		});	
	});
	
	$('#product_multy_images').each(function(){
		var obg = $(this);
		if (swfobject.getFlashPlayerVersion().major === 0)
		{
			obg.parent().html('You need flashplayer!!!<br><a href="http://get.adobe.com/flashplayer/">adobe flashplayer</a>');
		}
		else
		obg.uploadify({
			'uploader' : '/images/style/uploadify/uploadify.swf',
			'cancelImg' : '/images/backend/button_delete.png',
			'buttonImg' : '/images/style/uploadify/button.jpg',
			'script' : '/uploadify.php',
			
			'fileExt' : '*.jpg;*.png;*.gif;*.bmp;',
			'fileDesc' : ' ',
			'auto' : true,
			'displayData' : 'speed',
			'height' : 24,
			'width' : 100,
			'method' : 'post',
			'multi' : true,
			'onComplete'  : function(event,ID,fileObj,response_name_file,data)
			{
				obg.parent().append('<input type="hidden" name="photos_array[]" value="'+response_name_file+'"><b>'+response_name_file+'</b>');
			},
			'onAllComplete' : function(event,data){},
			'onError' : function (event,ID,fileObj,errorObj){alert(errorObj.type + ' Error: ' + errorObj.info);}	
		});	
	});
	
	$('.produkt_image').each(function(){
		var obg = $(this);
		if (swfobject.getFlashPlayerVersion().major === 0)
		{
			obg.parent().html('You need flashplayer!!!<br><a href="http://get.adobe.com/flashplayer/">adobe flashplayer</a>');
		}
		else
		obg.uploadify({
			'uploader' : '/images/style/uploadify/uploadify.swf',
			'cancelImg' : '/images/backend/button_delete.png',
			'buttonImg' : '/images/style/uploadify/button1.jpg',
			'script' : '/uploadify.php',
			'fileExt' : '*.jpg;*.png;*.gif;*.bmp;',
			'fileDesc' : ' ',
			'auto' : true,
			'displayData' : 'speed',
			'height' : 24,
			'width' : 92,
			'method' : 'post',
			'multi' : false,
			'onComplete'  : function(event,ID,fileObj,response_name_file,data)
			{
				obg.parent().find('input[type="hidden"]').val(response_name_file);
				obg.parent().find('input[type="file"]').change();
				$('.msg'+obg.attr('rel')).html('Выбран файл<br><b>'+response_name_file+'</b>');
			},
			'onSelect' : function(event,ID,fileObj) {obg.parent().find('input[type="file"]').change();},
			'onAllComplete' : function(event,data){},
			'onError' : function (event,ID,fileObj,errorObj){alert(errorObj.type + ' Error: ' + errorObj.info);}
		});	
	});
	
	$('.any_file_auto').each(function(){
		var obg = $(this);
		if (swfobject.getFlashPlayerVersion().major === 0)
		{
			obg.parent().html('You need flashplayer!!!<br><a href="http://get.adobe.com/flashplayer/">adobe flashplayer</a>');
		}
		else
		obg.uploadify({
			'uploader' : '/images/style/uploadify/uploadify.swf',
			'cancelImg' : '/images/backend/button_delete.png',
			'buttonImg' : '/images/style/uploadify/button1.jpg',
			'script' : '/uploadify.php',
			'auto' : true,
			'displayData' : 'speed',
			'height' : 24,
			'width' : 92,
			'method' : 'post',
			'multi' : false,
			'onComplete' : function(event,ID,fileObj,response_name_file,data)
			{
				obg.parent().find('input[type="hidden"]').val(response_name_file);
				obg.parent().find('input[type="file"]').change();
				rel = obg.attr('rel');
				$('.msg'+rel).html('Выбран файл<br><b>'+response_name_file+'</b>');
			},
			'onAllComplete' : function(event,data)
			{
				obg.parents('form').filter(':last').submit();
			},
			'onSelect' : function(event,ID,fileObj) {obg.parent().find('input[type="file"]').change();},
			'onError' : function (event,ID,fileObj,errorObj){alert(errorObj.type + ' Error: ' + errorObj.info);}
		});	
	});

	$('.any_file').each(function(){
		var obg = $(this);
		if (swfobject.getFlashPlayerVersion().major === 0)
		{
			obg.parent().html('You need flashplayer!!!<br><a href="http://get.adobe.com/flashplayer/">adobe flashplayer</a>');
		}
		else
		obg.uploadify({
			'uploader' : '/images/style/uploadify/uploadify.swf',
			'cancelImg' : '/images/backend/button_delete.png',
			'buttonImg' : '/images/style/uploadify/button1.jpg',
			'script' : '/uploadify.php',
			'auto' : true,
			'displayData' : 'speed',
			'height' : 24,
			'width' : 92,
			'method' : 'post',
			'multi' : false,
			'onComplete' : function(event,ID,fileObj,response_name_file,data)
			{
				obg.parent().find('input[type="hidden"]').val(response_name_file);
				obg.parent().find('input[type="file"]').change();
				rel = obg.attr('rel');
				$('.msg'+rel).html('Выбран файл<br><b>'+response_name_file+'</b>');
			},
			'onSelect' : function(event,ID,fileObj) {obg.parent().find('input[type="file"]').change();},
			'onError' : function (event,ID,fileObj,errorObj){alert(errorObj.type + ' Error: ' + errorObj.info);}
		});	
	});

	$('.one_image').each(function(){
		var obg = $(this);
		if (swfobject.getFlashPlayerVersion().major === 0)
		{
			obg.parent().html('You need flashplayer!!!<br><a href="http://get.adobe.com/flashplayer/">adobe flashplayer</a>');
		}
		else
		obg.uploadify({
			'uploader' : '/images/style/uploadify/uploadify.swf',
			'cancelImg' : '/images/backend/button_delete.png',
			'buttonImg' : '/images/style/uploadify/button1.jpg',
			'script' : '/uploadify.php',
			'fileExt' : '*.jpg;*.png;*.gif;*.bmp;',
			'fileDesc' : ' ',
			'auto' : true,
			'displayData' : 'speed',
			'height' : 24,
			'width' : 92,
			'method' : 'post',
			'multi' : false,
			'onComplete'  : function(event,ID,fileObj,response_name_file,data)
			{
				obg.change();
				obg.parent().find('input[type="hidden"]').val(response_name_file);
				rel = obg.attr('rel');
				$('.msg'+rel).html('Выбран файл<br><b>'+response_name_file+'</b>');
			},
			'onAllComplete' : function(event,data){},
			'onSelect' : function(event,ID,fileObj) {obg.parent().find('input[type="file"]').change();},
			'onError' : function (event,ID,fileObj,errorObj){alert(errorObj.type + ' Error: ' + errorObj.info);}
		});	
	});
	
	
	$('.one_image_auto').each(function(){
		var obg = $(this);
		if (swfobject.getFlashPlayerVersion().major === 0)
		{
			obg.parent().html('You need flashplayer!!!<br><a href="http://get.adobe.com/flashplayer/">adobe flashplayer</a>');
		}
		else
		obg.uploadify({
			'uploader' : '/images/style/uploadify/uploadify.swf',
			'cancelImg' : '/images/backend/button_delete.png',
			'buttonImg' : '/images/style/uploadify/button1.jpg',
			'script' : '/uploadify.php',
			'fileExt' : '*.jpg;*.png;*.gif;*.bmp;',
			'fileDesc' : ' ',
			'auto' : true,
			'displayData' : 'speed',
			'height' : 24,
			'width' : 92,
			'method' : 'post',
			'multi' : false,
			'onComplete'  : function(event,ID,fileObj,response_name_file,data)
			{
				obg.change();
				obg.parent().find('input[type="hidden"]').val(response_name_file);
				rel = obg.attr('rel');
				$('.msg'+rel).html('Выбран файл<br><b>'+response_name_file+'</b>');
			},
			'onAllComplete' : function(event,data)
			{
				obg.parents('form').filter(':last').submit();
			},
			'onSelect' : function(event,ID,fileObj) {obg.parent().find('input[type="file"]').change();},
			'onError' : function (event,ID,fileObj,errorObj){alert(errorObj.type + ' Error: ' + errorObj.info);}
		});	
	});
	
	
	$('.one_video').each(function(){
		var obg = $(this);
		if (swfobject.getFlashPlayerVersion().major === 0)
		{
			obg.parent().html('You need flashplayer!!!<br><a href="http://get.adobe.com/flashplayer/">adobe flashplayer</a>');
		}
		else
		obg.uploadify({
			'uploader' : '/images/style/uploadify/uploadify.swf',
			'cancelImg' : '/images/backend/button_delete.png',
			'buttonImg' : '/images/style/uploadify/button1.jpg',
			'script' : '/uploadify.php',
			'fileExt' : '*.mp4;*.flv;*.mov;*.f4v;*.ogv;*.webm;*.3gp;*.3g2;*.mp3;*.vaac;*.m4a;*.swf;',
			'fileDesc' : ' ',
			'auto' : true,
			'displayData' : 'speed',
			'height' : 24,
			'width' : 92,
			'method' : 'post',
			'multi' : false,
			'onComplete'  : function(event,ID,fileObj,response_name_file,data)
			{
				obg.change();
				obg.parent().find('input[type="hidden"]').val(response_name_file);
				rel = obg.attr('rel');
				$('.msg'+rel).html('Выбран файл<br><b>'+response_name_file+'</b>');
			},
			'onAllComplete' : function(event,data){},
			'onSelect' : function(event,ID,fileObj) {obg.parent().find('input[type="file"]').change();},
			'onError' : function (event,ID,fileObj,errorObj){alert(errorObj.type + ' Error: ' + errorObj.info);}
		});	
	});
	
	$('.one_flash').each(function(){
		var obg = $(this);
		if (swfobject.getFlashPlayerVersion().major === 0)
		{
			obg.parent().html('You need flashplayer!!!<br><a href="http://get.adobe.com/flashplayer/">adobe flashplayer</a>');
		}
		else
		obg.uploadify({
			'uploader' : '/images/style/uploadify/uploadify.swf',
			'cancelImg' : '/images/backend/button_delete.png',
			'buttonImg' : '/images/style/uploadify/button1.jpg',
			'script' : '/uploadify.php',
			'fileExt' : '*.swf;',
			'fileDesc' : ' ',
			'auto' : true,
			'displayData' : 'speed',
			'height' : 24,
			'width' : 92,
			'method' : 'post',
			'multi' : false,
			'onComplete'  : function(event,ID,fileObj,response_name_file,data)
			{
				obg.change();
				obg.parent().find('input[type="hidden"]').val(response_name_file);
				rel = obg.attr('rel');
				$('.msg'+rel).html('Выбран файл<br><b>'+response_name_file+'</b>');
			},
			'onAllComplete' : function(event,data)
			{
				obg.parents('form').filter(':last').submit();
			},
			
			'onSelect' : function(event,ID,fileObj) {obg.parent().find('input[type="file"]').change();},
			'onError' : function (event,ID,fileObj,errorObj){alert(errorObj.type + ' Error: ' + errorObj.info);}
		});	
	});
	
	
	$('.one_mp3').each(function(){
		var obg = $(this);
		if (swfobject.getFlashPlayerVersion().major === 0)
		{
			obg.parent().html('You need flashplayer!!!<br><a href="http://get.adobe.com/flashplayer/">adobe flashplayer</a>');
		}
		else
		obg.uploadify({
			'uploader' : '/images/style/uploadify/uploadify.swf',
			'cancelImg' : '/images/backend/button_delete.png',
			'buttonImg' : '/images/style/uploadify/button1.jpg',
			'script' : '/uploadify.php',
			'fileExt' : '*.mp3',
			'fileDesc' : ' ',
			'auto' : true,
			'displayData' : 'speed',
			'height' : 24,
			'width' : 92,
			'method' : 'post',
			'multi' : false,
			'onComplete'  : function(event,ID,fileObj,response_name_file,data)
			{
				obg.change();
				obg.parent().find('input[type="hidden"]').val(response_name_file);
				rel = obg.attr('rel');
				$('.msg'+rel).html('Выбран файл<br><b>'+response_name_file+'</b>');
			},
			'onAllComplete' : function(event,data){},
			'onSelect' : function(event,ID,fileObj) {obg.parent().find('input[type="file"]').change();},
			'onError' : function (event,ID,fileObj,errorObj){alert(errorObj.type + ' Error: ' + errorObj.info);}
		});	
	});
	
	$('.one_font_file').each(function(){
		var obg = $(this);
		if (swfobject.getFlashPlayerVersion().major === 0)
		{
			obg.parent().html('You need flashplayer!!!<br><a href="http://get.adobe.com/flashplayer/">adobe flashplayer</a>');
		}
		else
		obg.uploadify({
			'uploader' : '/images/style/uploadify/uploadify.swf',
			'cancelImg' : '/images/backend/button_delete.png',
			'buttonImg' : '/images/style/uploadify/button.jpg',
			'script' : '/uploadify.php',	
			'fileExt' : '*.otf;*.ttf',
			'fileDesc' : ' ',
			'auto' : true,
			'displayData' : 'speed',
			'height' : 24,
			'width' : 100,
			'method' : 'post',
			'multi' : false,
			'onComplete'  : function(event,ID,fileObj,response_name_file,data)
			{
				obg.parent().find('input[type="hidden"]').val(response_name_file);
				obg.parent().find('input[type="file"]').change();
				rel = obg.attr('rel');
				$('.msg'+rel).html('Выбран файл<br><b>'+response_name_file+'</b>');
			},
			'onAllComplete' : function(event,data){},
			'onSelect' : function(event,ID,fileObj) {obg.parent().find('input[type="file"]').change();},
			'onError' : function (event,ID,fileObj,errorObj){alert(errorObj.type + ' Error: ' + errorObj.info);}
		});	
	});
	
	
	$('.one_csv_file').each(function(){
		var obg = $(this);
		if (swfobject.getFlashPlayerVersion().major === 0)
		{
			obg.parent().html('You need flashplayer!!!<br><a href="http://get.adobe.com/flashplayer/">adobe flashplayer</a>');
		}
		else
		obg.uploadify({
			'uploader' : '/images/style/uploadify/uploadify.swf',
			'cancelImg' : '/images/backend/button_delete.png',
			'buttonImg' : '/images/style/uploadify/button.jpg',
			'script' : '/uploadify.php',	
			'fileExt' : '*.csv;',
			'fileDesc' : ' ',
			'auto' : true,
			'displayData' : 'speed',
			'height' : 24,
			'width' : 100,
			'method' : 'post',
			'multi' : false,
			'onComplete'  : function(event,ID,fileObj,response_name_file,data)
			{
				obg.parent().find('input[type="hidden"]').val(response_name_file);
				obg.parent().find('input[type="file"]').change();
				rel = obg.attr('rel');
				$('.msg'+rel).html('Выбран файл<br><b>'+response_name_file+'</b>');
			},
			'onAllComplete' : function(event,data){},
			'onSelect' : function(event,ID,fileObj) {obg.parent().find('input[type="file"]').change();},
			'onError' : function (event,ID,fileObj,errorObj){alert(errorObj.type + ' Error: ' + errorObj.info);}
		});	
	});

	
	$('.slovar_file').each(function(){
		var obg = $(this);
		if (swfobject.getFlashPlayerVersion().major === 0)
		{
			obg.parent().html('You need flashplayer!!!<br><a href="http://get.adobe.com/flashplayer/">adobe flashplayer</a>');
		}
		else
		obg.uploadify({
			'uploader' : '/images/style/uploadify/uploadify.swf',
			'cancelImg' : '/images/backend/button_delete.png',
			'buttonImg' : '/images/style/uploadify/button.jpg',
			'script' : '/uploadify.php',
			'fileExt' : '*.txt;',
			'fileDesc' : ' ',
			'auto' : true,
			'displayData' : 'speed',
			'height' : 24,
			'width' : 100,
			'method' : 'post',
			'multi' : false,
			'onComplete'  : function(event,ID,fileObj,response_name_file,data)
			{
				obg.parent().find('input[type="hidden"]').val(response_name_file);
				obg.parent().find('input[type="file"]').change();
				rel = obg.attr('rel');
				$('.msg'+rel).html('Выбран файл<br><b>'+response_name_file+'</b>');
			},
			'onAllComplete' : function(event,data){},
			'onSelect' : function(event,ID,fileObj) {obg.parent().find('input[type="file"]').change();},
			'onError' : function (event,ID,fileObj,errorObj){alert(errorObj.type + ' Error: ' + errorObj.info);}
		});	
	});

	
	
	
	
	
});

