 $(function() {
	MaxWidth=600-(1280-screen.width)/1.5;
	$("#galeryTable").css('width',MaxWidth);
	$(".ad-gallery").css('width',MaxWidth);
    var galleries = $('.ad-gallery').adGallery();
  });

function sendComment()
{
	var er=0;

		var name=$("#name").attr('value');
		var city=$("#city").attr('value');
		var comm_text=$("#comm_text").attr('value');
		var code=$("#code").attr('value');
		var sid=$("#sid").attr('value');
		var com=$("#com").attr('value');


	if(comm_text==""){
		alert("Нужно ввести текст");
		er=1;
	}
	else if(name==""){
		alert("Нужно ввести Имя");
		er=1;
	}

/*	else if(code==""){
		alert("Нужно ввести Защитный код");
		er=1;
	}*/
	else{
		$("#comment").html('<center><img src="../../img/loader.gif"></center>');
		$.post('../../inc/comm_img.php',{
			name:name,
			city:city,
			comm_text:comm_text,
			/*code:code,
			sid:sid,*/
			com:com,
			addcomment:1
		},function(data){$("#comment").html(data);});
	}

	if(er==1){return false;}

}

function vievComments()
{
	$("#comment").html('<img src="../../img/loader.gif">');
	$.post('../../inc/comm_img.php',{com: $("#imgNow").attr('value')},function(data){$("#comment").html(data);});
}

function upl(type)
{
	
	if(type!="delet" && $("#userfile").attr('value')!=""){
		var data = btoa(document.getElementById("userfile").files.item(0).getAsBinary());
		var fileName = btoa(document.getElementById("userfile").files.item(0).fileName);

	}
	else
	{
		var data="";
		var fileName="";

	}

	$("#progress1").html("<img src=\"../../img/loader.gif\"/>");
	$("#ed_im").css("display","none");
	$.post("../../inc/upload_img.php", {file_name: fileName, data: data,text: $("#imgtext1").attr('value'),type:type,iid: $("#imgNow").attr('value')},function(dat)
	{
			$("#progress1").html(dat);
			$("#ed_im").css("display","inline");
	});

}

function editImgForm()
{

	$("#comment").html('<img src="../../img/loader.gif">');
	$.post('../../inc/edit_img.php',{com: $("#imgNow").attr('value')},function(data)
	{
		$("#comment").html(data);
		
		$("#uploadify").uploadify({
			'uploader'       : window.globalHost+'js/scripts/uploadify.swf',
			'script'         : window.globalHost+'inc/upload_img.php',
			'cancelImg'      : window.globalHost+'js/scripts/cancel.png',
			'folder'         : 'uploads',
			'queueID'        : 'fileQueue',
			'auto'           : true,
			'multi'          : false,
			'onComplete':function(event, ID, fileObj, response, data){alert(response);}

		});
				

	});
}



