photo_now = 0;
$(document).ready(function(){
	razmetka();

$('a.photo_a').click(function(){
  $(window).scrollTop(0);
  $("#abs").css("height",$('#global').height());
  $("#abs").show();
		photo_now = $(this).attr('rel');
		var path = $(this).attr('href');
  		$('#img_big').animate({opacity: 0},500,function(){
    		$(this).html('<img src=' + path + ' />').find('img').bind('load',function(){ $('#img_big').animate({opacity: 1},500); });
  		});
  	return false;
	});

$('#next_pics').click(function () {
		photo_now = photo_now*1 + 1;
    	var all_photo = $('a.photo_a').size();
    	var this_photo = photo_now;
    	if(this_photo > all_photo) {this_photo = 1; photo_now = 1;}
		var path = $('#fotka_' + this_photo).attr('href');
  		$('#img_big').animate({opacity: 0},500,function(){
    		$(this).html('<img src=' + path + ' />').find('img').bind('load',function(){ $('#img_big').animate({opacity: 1},500); });
  		});
	});

$('#prev_pics').click(function () {
		photo_now = photo_now*1 - 1;
    	var all_photo = $('a.photo_a').size();
    	var this_photo = photo_now;
    	if(this_photo < 1) {this_photo = all_photo*1 - 1; photo_now = all_photo*1 - 1}
		var path = $('#fotka_' + this_photo).attr('href');
  		$('#img_big').animate({opacity: 0},500,function(){
    		$(this).html('<img src=' + path + ' />').find('img').bind('load',function(){ $('#img_big').animate({opacity: 1},500); });
  		});
	});

});

$(window).resize(function() {
	razmetka();
});

function hide_abs(){
  $("#abs").hide();
  $('#photo_show').attr('src','/img/pixel.gif');
}
function view_shema(el){
	$(window).scrollTop(0);
	var path = $('#' + el).attr('href');
	$('#abs2').css('height',$('#global').height());
	$('#abs2').show();
  		$('#photobig').animate({opacity: 0},500,function(){
    		$(this).html('<img src=' + path + ' />').find('img').bind('load',function(){ $('#photobig').animate({opacity: 1},500); });
  		});
}
function hide_abs2(){
  $("#abs2").hide();
}

function razmetka(){

  var w = $(".short").width();

  if(w<765){
    $(".repeat").css("width","100%");
  } else {
    $(".repeat").css("width","47%");
    $(".repeat").css("margin-right","3%");
  }


}

function passw(){

  $('#old_pass').css("display","none");
  $('#new_pass').css("display","block");
  $('#new_passw').val('2');

}


function avatar(){

  $('#show_new_ava').css("display","block");
  $('#ava_link').css("display","none");
  $('#new_ava').val('2');

}



function necessary_value_and_mail(){
      if ((document.forms['registration_form'].log.value=='') ||
          (document.forms['registration_form'].pas.value=='') ||
          (document.forms['registration_form'].pas2.value=='') ||
          (document.forms['registration_form'].contact_email.value==''))
      {
        alert("Не заполнены обязательные поля!");
        return false;
      }
      else if (document.forms['registration_form'].pas.value != document.forms['registration_form'].pas2.value)
      {
        alert("Пароли не совпадают! Введите повторно!");
        document.forms['registration_form'].pas.value='';
        document.forms['registration_form'].pas2.value='';
        document.forms['registration_form'].pas.focus();
        return false;
      }
      else {
        var regexp=/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/ //regular expression defining an email address
	       if (document.forms['registration_form'].contact_email.value.search(regexp)==-1) { //if match failed
	       alert('Введите правильно Ваш e-mail');
	       document.forms['registration_form'].contact_email.value='';
	       document.forms['registration_form'].contact_email.focus();
	       return false;
	       } else return true;
	    }
}

function necessary_captcha_and_mail(){
      if ((document.forms['recovery_p_form'].captcha_code.value=='') ||
          (document.forms['recovery_p_form'].contact_email.value==''))
      {
        alert("Не заполнены обязательные поля!");
        return false;
      } else {
        var regexp=/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/ //regular expression defining an email address
	       if (document.forms['recovery_p_form'].contact_email.value.search(regexp)==-1) { //if match failed
	       alert('Введите правильно Ваш e-mail');
	       document.forms['recovery_p_form'].contact_email.value='';
	       document.forms['recovery_p_form'].contact_email.focus();
	       return false;
	       } else return true;
	    }
}
function necessary_l_p_c(){
      if ((document.forms['enter_form'].log.value=='') ||
          (document.forms['enter_form'].pas.value=='') ||
          (document.forms['enter_form'].captcha_code.value==''))
      {
        alert("Не заполнены обязательные поля!");
        return false;
      }
}

function chanje_class(id){
  document.getElementById(id).className='cat active';
}
function chanje_class2(id){
  document.getElementById(id).className='cat spok';
}


/*  BEGIN FLASH */
function show(value){
document.getElementById('flashover').style.left="0";
document.getElementById('flashover').style.top="180";

		setValue(value);
}

function setValue(value) {
			if (navigator.appName.indexOf("Microsoft") != -1) {
				window['podmenu'].sendToActionScript(value);
			} else {
				document['podmenu'].sendToActionScript(value);
			}
}

function hide(){
document.getElementById('flashover').style.left="0";
document.getElementById('flashover').style.top="-800";
	}
/*  END FLASH */


function shows(id1, id2)
 {

 //document.getElementById("tabl1").style.display="none";
 document.getElementById("tabl2").style.display="none";
 document.getElementById("tabl3").style.display="none";
 document.getElementById("tabl4").style.display="none";
 document.getElementById("tabl5").style.display="none";

 //document.getElementById("flat1").className="flat";
 document.getElementById("flat2").className="flat";
 document.getElementById("flat3").className="flat";
 document.getElementById("flat4").className="flat";
 document.getElementById("flat5").className="flat";

 if (document.getElementById(id1).style.display!="none")
  {
  document.getElementById(id1).style.display="none";
  document.getElementById(id2).className="flat";
  }
 else
  {
  document.getElementById(id1).style.display="block";
  document.getElementById(id2).className="flat_here";
  }
 }
 
function shows_plan(id1, id2){

 document.getElementById("div1").style.display="none";
 document.getElementById("div2").style.display="none";
 document.getElementById("div3").style.display="none";
 document.getElementById("div4").style.display="none";
 document.getElementById("div5").style.display="none";
 document.getElementById("div6").style.display="none";
 

 document.getElementById("flat1").className="flat";
 document.getElementById("flat2").className="flat";
 document.getElementById("flat3").className="flat";
 document.getElementById("flat4").className="flat";
 document.getElementById("flat5").className="flat";
 document.getElementById("flat6").className="flat";

 if (document.getElementById(id1).style.display!="none")
  {
  document.getElementById(id1).style.display="none";
  document.getElementById(id2).className="flat";
  }
 else
  {
  document.getElementById(id1).style.display="block";
  document.getElementById(id2).className="flat_here";
  }
 }

 function view_flat(h1_text,img_big){
	$(window).scrollTop(0);
	$('#fon2').css('height',$('#global').height());
	$('#fon2').show();
	$('#flat_info').html('<h1>' + h1_text + '</h1><img src="' + img_big + '" alt="">');
	$('#flat_gall').show();
}
function close_flat(){
  $('#fon2').hide();
  $('#flat_gall').hide();
  $('#flat_info').html('');
}
  function email_plus(email_aj)
        {
            $.ajax({
                url: "/tpl/includes/inc.subscribe.php",
                cache: false,
                data: "email="+email_aj,
                success: function(html){
                    $("#aj_ret").html(html);
                }
            });
        }


	function golos_plus(id,lang){
/*        //for (var i = 0; i < document.voting.vois.length; i++) if(document.voting.vois[i].checked == true) var vois = document.voting.vois[i].value;

        //$("input[name='"+radio_n+"']:checked").val()*/
        var vois = $('input:radio[name="vois"]:checked').val();

        if(vois) {
            $.ajax({
                url: "/tpl/ajax.voiting.php",
                cache: false,
                data: "id_voting=" + id + "&lang=" + lang + "&vois="+vois,
                success: function(html){
                    $("#vote_div").html(html);
                    window.location = "http://akvareli.ua/ru/media/vote/";
                }
            });
        }
        return false;
  }

