num=1 // porfolio fotos
cur_num=1
obj_id=0  // porfolio id
img_path="/images/portfolio/"
$(document).ready(function(){

  if (!$.browser.msie){ // mouse position
    document.onmousemove=function(e){
    mousex=e.pageX;
    mousey=e.pageY;
    }
  }
  else {
    document.onmousemove=function(){
      mousex=event.clientX;
      mousey=event.clientY;
    }
  }

  a=$("#allarea").height();
  if (a < 900)
   a=900;
  if (!($.browser.msie) || (($.browser.msie) && (parseInt($.browser.version) >=7))){
    $("#hand_img").css("background","url(/img/hand.png) center top no-repeat");
    if (parseInt($.browser.version) ==7)
      $("#menu").css("right","-35px")
  }
  else{
    $("#menu").css("right","-34px")

    $("#hand_img").css("filter","progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/img/hand.png', sizingMethod='none');");
    $("#disk").attr("style","filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/img/disk.png', sizingMethod='none')");
    $("#logo").attr("style","filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/img/logo.png', sizingMethod='none')");
    $("#fresh").attr("style","filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/img/fresh.png', sizingMethod='none')");

    $("#im1").attr("style","filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/img/m1.png', sizingMethod='none')");
    $("#im2").attr("style","filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/img/m2.png', sizingMethod='none')");
    $("#im3").attr("style","filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/img/m3.png', sizingMethod='none')");
    $("#im1a").attr("style","filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/img/m1_a.png', sizingMethod='none')");
    $("#im2a").attr("style","filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/img/m2_a.png', sizingMethod='none')");
    $("#im3a").attr("style","filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/img/m3_a.png', sizingMethod='none')");
  }
 $("#allarea").css("height",a);
  $("#div_left").css("height",a);

  $("#m1a").fadeOut("fast");
  $("#m2a").fadeOut("fast");
  $("#m3a").fadeOut("fast");

  $("#allarea").show();
}
)

function check_f(){
for(n=1;n<4;n++){
  if (!$("#"+i[n]).attr("value") || $("#"+i[n]).attr("value")==t[n]){
    alert ("Заполненны не все поля");
    return false;
   }
 }
}
function act(n){
  if ($.browser.msie && (parseInt($.browser.version)) ==7){
//    $("#m"+n).hide()
    $("#m"+n+"a").show()
  }
  else{
//    $("#m"+n).fadeOut("fast")
    $("#m"+n+"a").show()
  }
}

function deact(n){
  if ($.browser.msie && (parseInt($.browser.version)) ==7){
    $("#m"+n).show()
    $("#m"+n+"a").hide()
  }else{
    $("#m"+n).fadeIn("fast")
    $("#m"+n+"a").fadeOut("fast")
  }
}

function show(id){
  $("#ch_"+id).fadeIn("fast")
  
}
function hide(id){
  $("#ch_"+id).fadeOut("fast")
  
}
function img_open(id){
   curent_scroll=document.body.scrollTop;
   $("#big_foto").hide();
//   $("#big_foto").fadeOut("fast");
   if(id)
  $.post(                 
    'include/foto_img.php',
    {
    id: id
    },
    onfotoSuccess
    );
  $("#big_foto").css("top",mousey+curent_scroll);
   $("#big_foto").html("<div class='foto_text' style='padding:10px;'>Загрузка...</div>");
   $("#big_foto").fadeIn("fast");
}

function onfotoSuccess(data){
   $("#big_foto").html(data);
   d=data.split("-=-")
   f_h=parseInt(d[1])+parseInt(100)
   hh=document.body.clientHeight

   d_h=$("#content").height()
   if (d_h > (curent_scroll+50+f_h))   {
    $("#big_foto").css("top",curent_scroll+50);
//	alert(curent_scroll+50)
}
   else
   {
    $("#big_foto").css("top",d_h-f_h+300);
//alert(d_h-f_h+300)
   }
}

function list_img(n){
  cur_num=cur_num+n  
  if (cur_num==0)  cur_num=num
  if (cur_num>num)  cur_num=1
  
  $("#portf_img").attr("src",img_path+"img_b_"+cur_num+"_"+obj_id+".jpg")
}

function img_change(prevb,nextb){
  ww=$("#big_f_div").width()/2
  left=$("#big_f_div").offset()
  if  ((left.left + ww) < mousex){
    if (nextb)
      img_open (nextb)
  }
  else
    if (prevb)
      img_open (prevb)
}