function viewart(file)
{	var path = file;
	$(window).scrollTop(0);
	$('#fon').css('height',$('#global').height());
	$('#fon').show();
	$("body").prepend('<div class="gallery" id="gallery" style="display:none;"><div class="all"><table cellpadding="0" cellspacing="0" id="img"><tr><td></td><td></td><td><img src="/img/x.gif" alt="X" onClick="close_art();" style="cursor:pointer;"></td></tr><tr><td>&nbsp;</td><td width="800" height="533" id="img_big"></td><td style="padding-left:10px;">&nbsp;</td></tr></table></div></div>');
  	$('#img_big').animate({opacity: 0},500,function(){
    	$(this).html('<img src="' + path + '" />').find('img').bind('load',function(){ $('#img_big').animate({opacity: 1},500); });
  	});
	$('#gallery').show();
}

function viewphoto(id)
{
	$(window).scrollTop(0);
	$('#fon').css('height',$('#global').height());
	$('#fon').show();
	var path = photo_list[id];
	now_element(id_photo_list,id);
  	$('#img_big').animate({opacity: 0},500,function(){
    	$(this).html('<img src="' + path + '" />').find('img').bind('load',function(){ $('#img_big').animate({opacity: 1},500); });
  	});
	$('#gallery').show();
}

function close_gal()
{
	$('#gallery').hide();	$('#fon').hide();
}

function close_comm()
{
	$('#addcomment_div').hide();
	$('#fon').hide();
}

function close_art()
{
	$('#fon').hide();
	$('#gallery').remove();
}

function next_photo()
{	photo_now = photo_now*1 + 1;
	this_photo = photo_now;
	if(id_photo_list.length <= photo_now) { this_photo = 0; photo_now = 0; }
	var path = photo_list[id_photo_list[this_photo]];
  	$('#img_big').animate({opacity: 0},500,function(){
    	$(this).html('<img src="' + path + '" />').find('img').bind('load',function(){ $('#img_big').animate({opacity: 1},500); });
  	});
}

function prev_photo()
{
	photo_now = photo_now*1 - 1;
	this_photo = photo_now;
	if(0 > photo_now) { this_photo = id_photo_list.length - 1; photo_now = id_photo_list.length - 1; }
	var path = photo_list[id_photo_list[this_photo]];
  	$('#img_big').animate({opacity: 0},500,function(){
    	$(this).html('<img src="' + path + '" />').find('img').bind('load',function(){ $('#img_big').animate({opacity: 1},500); });
  	});
}

function now_element(arr,el)
{	$.each(arr, function(n, val)
	{
		if(val == el)
		photo_now = n;
	});
}

function viewvideo(path)
{	$(window).scrollTop(0);
	$('#fon').css('height',$('#global').height());
	$('#fon').show();	$('#video_big').html('<embed height="360" width="604" flashvars="height=360&width=604&file=' + path + '&backcolor=0xacacac&frontcolor=0x000000&lightcolor=0xffffff&screencolor=0x000000&displayheight=340&displaywidth=604&showstop=true&showdownload=false&autoscroll=true" allowfullscreen="true" allowscriptaccess="always" src="/swf/mediaplayer.swf"/>');
	$('#video_gall').show();
}

function viewvideo2(path)
{
	$(window).scrollTop(0);
	$('#fon').css('height',$('#global').height());
	$('#fon').show();
	$('#video_big').html('<embed height="360" width="604" flashvars="height=360&width=463&file=' + path + '&backcolor=0xacacac&frontcolor=0x000000&lightcolor=0xffffff&screencolor=0x000000&displayheight=340&displaywidth=463&showstop=true&showdownload=false&autoscroll=true" allowfullscreen="true" allowscriptaccess="always" src="/swf/mediaplayer.swf"/>');
	$('#video_gall').show();
}

function close_video()
{
	$('#video_gall').hide();
	$('#fon').hide();
}

function addcom()
{	$(window).scrollTop(0);
	$('#fon').css('height',$('#global').height());
	$('#fon').show();
	$('#addcomment_div').show();
}

function voteresp(lngg)
{	var id_opros = $('#opros_id').val();
	var inputs = $('table.vopros :radio:checked').val();
	var otvet_text = $('#otvet_text').val();
    var error = 0;

	if(!inputs) {		error = 1;
		alert('Âèáåð³òü â³äïîâ³äü');
	}

	if(inputs == 'your_ans' && otvet_text == '') {
		error = 1;
		alert('Âêàæ³òü Âàøó â³äïîâ³äü');
	}

	if(error == 0) {		$.ajax({
   			type: "POST",
   			url: "/response/voteresp.php",
   			data: "id_opros=" + id_opros + "&inputs=" + inputs + "&lang=" + lngg + "&otvet_text=" + otvet_text,
   			success: function(msg){
     			$('#opros_res').html(msg);
     			$(window).scrollTop(0);
				$('#fon').css('height',$('#global').height());
				$('#fon').show();
				$('#opros_div').show();
   			}
 		});
 	}
}

function auth(lng)
{	$.ajax({
		type: "POST",
		url: "/response/authresp.php",
		data: "lng=" + lng,
		success: function(msg){			$('#fon').css('height',$('#global').height());
			$('#fon').show();			$("body").prepend(msg);
			$(window).scrollTop(0);
   		}
 	});
}

function go_auth()
{var lng = $('#log_a').val();
var ps = $('#pas_a').val();
	$.ajax({
		type: "POST",
		url: "/response/user-resp.php",
		data: "log=" + lng + "&ps=" + ps,
		success: function(msg){
			if(msg == 0){            	$('#auth_form').submit();
			} else {				$('#error_a').show();
			}
   		}
 	});
}

function close_opros()
{
	$('#opros_div').hide();
	$('#fon').hide();
}

function close_auth()
{
	$('#auth_div').hide();
	$('#auth_div').remove();
	$('#fon').hide();
}

function loginvalid() {var login = $('#login').val();
$.ajax({
	type: "POST",
	url: "/response/login.ans.php",
	data: "login=" + login,
	success: function(msg){
		if(msg == 0) {
			$('#error_login').hide();$('#error_login2').hide();
		} else if (msg == 1) {
			$('#error_login2').show();
		} else if (msg == 2) {
			$('#error_login').show();
		}
	}
});
}

function add_comm() {	if($('#name_addc').val() == '' || $('#com_addc').val() == '' || $('#captcha_code').val() == '') {		$('#error_com').show();
	} else {    	$('#addc_form').submit();
	}
}
