/*тут небольшие скрипты*/

$(document).ready(function() {

   $("#footer_text").focus(function () {
       if($(this).attr("value") == "Поиск") {
           $(this).css('color','#000');
           $(this).attr("value","");
       }
   });
   $("#footer_text").blur(function () {
       if($(this).attr("value") =="") {
           $(this).css('color','#999');
           $(this).attr("value","Поиск");
       }
   });

   $("#b_h_f_s_text").focus(function () {
       if($(this).attr("value") == "Поиск") {
           $(this).css('color','#000');
           $(this).attr("value","");
       }
   });
   $("#b_h_f_s_text").blur(function () {
       if($(this).attr("value") =="") {
           $(this).css('color','#999');
           $(this).attr("value","Поиск");
       }
   });

   $("#m_h_a_r_t_text").focus(function () {
       if($(this).attr("value") == "Поиск") {
           $(this).css('color','#000');
           $(this).attr("value","");
       }
   });
   $("#m_h_a_r_t_text").blur(function () {
       if($(this).attr("value") =="") {
           $(this).css('color','#999');
           $(this).attr("value","Поиск");
       }
   });

   $("#input_openid").focus(function () {
       if($(this).attr("value") == "Например: user.livejournal.com") {
           $(this).css('color','#000');
           $(this).attr("value","");
       }
   });
   $("#input_openid").blur(function () {
       if($(this).attr("value") =="") {
           $(this).css('color','#999');
           $(this).attr("value","Например: user.livejournal.com");
       }
   });

$(".s_w_left").hover(function () {
   $(this).css("background-position", "left bottom");
}, function () {
   $(this).css("background-position", "left top");
   });

$(".s_w_right").hover(function () {
   $(this).css("background-position", "left bottom");
}, function () {
   $(this).css("background-position", "left top");
   });


$("textarea, .f_none div input:not('.sm_send_details div div label input')").focus(function () {
  $(this).css("border","1px solid #2a98d3");
  $(this).css("background","#fafcfc");
  $(this).css("color", "#000");
});
$("textarea, .f_none div input:not('.sm_send_details div div label input')").blur(function () {
  $(this).css("border","1px solid #ABC3CF");
  $(this).css("background","#EFF4F6");
  $(this).css("color", "#999");
});

$(".p_m_a_in textarea, .p_m_a_in input, .profile_form input").focus(function () {
   $(this).css("border","1px solid #2a98d3");
   $(this).css("background","#fafcfc");
});
$(".p_m_a_in textarea, .p_m_a_in input, .profile_form input").blur(function () {
   $(this).css("border","1px solid #ABC3CF");
   $(this).css("background","#fff");
});


slider_wide("carousel_00");
slider_wide("carousel_01");
slider_wide_second("carousel_second_00");

});


var ar_positions = new Array();
ar_positions["carousel_00"] = 0;
ar_positions["carousel_01"] = 0;

var ar_positions_second = new Array();
ar_positions_second["carousel_second_00"] = 0;


/*1-й слайдер*/
function slider_wide (name) {
   $("#" + name + " .s_w_right").click(function () {
       if (ar_positions[name] < $("#" + name + " .s_w_inner ul li").length - 3) {
           $("#" + name + " .s_w_inner ul").animate({left: '-=813px'}, 1000 );
           ar_positions[name] += 3;
       }
   });

   $("#" + name + " .s_w_left").click(function () {
       if (ar_positions[name] > 0) {
          $("#" + name + " .s_w_inner ul").animate({left: '+=813px'}, 1000 );
          ar_positions[name] -= 3;
       }
   });
}

/*2-й слайдер*/
function slider_wide_second (name) {
   $("#" + name + " .w_s_s_right").click(function () {
       if (ar_positions_second[name] < $("#" + name + " .w_s_s_inner ul li").length - 5) {
           $("#" + name + " .w_s_s_inner ul").animate({left: '-=186px'}, 700 );
           ar_positions_second[name]++;
       }
   });

   $("#" + name + " .w_s_s_left").click(function () {
       if (ar_positions_second[name] > 0) {
          $("#" + name + " .w_s_s_inner ul").animate({left: '+=186px'}, 700 );
          ar_positions_second[name]--;
       }
   });
}


/*3-й слайдер*/
var ar_positions_third = new Array();
//фотогалерея материала
function slider_wide_third (name, wide) {
   ar_positions_third[name] = 0;

   var liNum = $("#" + name + " .r_d_c_inner ul li").length;
   var timeOut = 300;
   var liWidth = (wide == 4) ? 120 : 146;

   $("#" + name + " a.r_d_c_right").click(function () {
       var delta = wide;
       if (liNum - ar_positions_third[name] - wide < delta) {
           delta = liNum - ar_positions_third[name] - wide;
       }

       $("#" + name + " .r_d_c_inner ul").animate({left: "-="+(delta*liWidth)+"px"}, timeOut);

       ar_positions_third[name] += delta;

       //показать левую стрелку
       $("#" + name + " a.r_d_c_left").css("display", "block");
       $("#" + name + " div.r_d_c_left").css("display", "none");

       //скрыть правую стрелку
       if (ar_positions_third[name] + wide == liNum) {
           $("#" + name + " a.r_d_c_right").css("display", "none");
           $("#" + name + " div.r_d_c_right").css("display", "block");
       }

       return false;
   });

   $("#" + name + " a.r_d_c_left").click(function () {
       var delta = wide;
       if (ar_positions_third[name] - wide < 0) {
           delta = ar_positions_third[name];
       }

       $("#" + name + " .r_d_c_inner ul").animate({left: "+="+(delta*liWidth)+"px"}, timeOut);

       ar_positions_third[name] -= delta;

       //показать правую стрелку
       $("#" + name + " a.r_d_c_right").css("display", "block");
       $("#" + name + " div.r_d_c_right").css("display", "none");

       //скрыть левую стрелку
       if (ar_positions_third[name] == 0) {
           $("#" + name + " a.r_d_c_left").css("display", "none");
           $("#" + name + " div.r_d_c_left").css("display", "block");
       }

       return false;
   });
}