$(document).ready(function() {

 var pa;
 var referal = document.referrer;
 $.post('/ultra/count.php', {w: $(window).width(), h: $(window).height(), ref: referal });
 pa = window.location.hash;
 // open hash port
 if(pa){
  now = pa; now = now.replace('#', '');
   $.ajax({
           type: "POST",
           url: "/ultra/viewport/",
           dataType: "text",
           data : 'uid='+now,
            success: function(data) {
             json = eval("(" + data + ")");
              $("#pbimg").attr('src', '/i/portfolio/norm/'+json.img)
              $("#pbname").html(json.Bname);
              $("#pbcont").html(json.content);
              $("#pblink").html(json.link);
            }
           }); }

 $("ul.top_menu li").click(function(){
  $("ul.top_menu li").css('background-image', 'url(/i/images/)');
  $(this).css('background-image', 'url(/i/images/top_menu_bg.png)');
  var pa = $(this).attr('rel');
  window.location = '/'+pa+'.html'; })

 $("div[class=left_news]").hover(function(){  $(this).css('background-image', 'url(/i/images/select_news.png)') }, function(){  $(this).css('background-image', 'url(/i/images/)') })
 $("td[class=hp]").hover(function(){  $(this).css('background-image', 'url(/i/images/hat_light.png)');
  $(this).css('color', '#000'); }, function(){  $(this).css('background-image', 'url(/i/images/)');
  $(this).css('color', '#FFF') })
 $("td[class=hp]").css('height', '158px');

 var z = 1;
 $(".port_h").click(function(){  if(z == 1){
   z++;   $(this).animate({height: '220px'})  }
  else{   z--;
   $(this).animate({height: '70px'})
  } })

 $("#3dvideo").click(function(){  var uid = $(this).attr('rel');
  $.post('/ultra/video/', {uid: uid}, function(d){$(".tv").html(d);}) })
 // Отказ от рассылки /////////////////////////////////////////////////////////
 $("#stops").click(function(){
  var em = $("#umail").val();
  if(em != ""){
   $.post('/ultra/stopspam/', {email: em})
   $("#umail").val("");   alert('Спасибо, Ваш email будет удален из рассылки');  }
  else{   alert('Ошибка. Вы не указали email');  }
 })
 // Подписка на новости ///////////////////////////////////////////////////////
 $('#amail').focus(function(){
    if($(this).val() == $(this).attr('title')){
      $(this).val('').css('color','#333');
    }
  }).blur(function(){
    if($(this).val() != $(this).attr('title') && $.trim($(this).val()).length == 0){
      $(this).val($(this).attr('title')).css('color','#AAA');
    }
  }).blur();
  //
  $("#samail").click(function(){   var ma = $("#amail").val();
   if(ma == ""){    alert('Вы не указали email');   }
   else{    $.post('/ultra/addspam/', {email: ma})
    alert('Спасибо, Вы подписались на нашу рассылку');
    $("#amail").val("");   }  })



 // Выводим работу
 $("a[id=port]").click(function(){
   var now = $(this).attr('href');
   now = now.replace('#', '');
   $.ajax({
           type: "POST",
           url: "/ultra/viewport/",
           dataType: "text",
           data : 'uid='+now,
            success: function(data) {
             json = eval("(" + data + ")");
              $("#pbimg").attr('src', '/i/portfolio/norm/'+json.img)
              $("#pbname").html(json.Bname);
              $("#pbcont").html(json.content);
              $("#pblink").html(json.link);
            }
           });
 })
 $.post('/ultra/seopriceform/', function(d){  $("#seoprice").append(d); })


 $("#sendseo").live('click', function(){

  $.post('/ultra/sendseo/', {fio: $("#ufio").val(), www: $("#uwww").val(), type: $("#utype").val(), email: $("#umail").val(), keywords: $("#ukeywords").val()}, function(d){   if(d == "bad"){    alert('Ошибка\n - Вы заполнили не все поля.');   }
   else{
    alert('Ваша заявка принята, в ближайшее время мы ответим Вам. ');    window.location = '/order.html';
   }  }) })

 $("a[id=viewpeople]").click(function(){
  //$(this+" > img").effect("bounce", { times:3 }, 300);
  var kids = $(this).children();
  kids.effect("bounce", { times:10 }, 200);

  var uid = $(this).attr('href');
    $.ajax({
           type: "POST",
           url: "/ultra/vpeople/",
           dataType: "text",
           data : 'uid='+uid,
            success: function(data) {
             json = eval("(" + data + ")");
              $("#bimg").attr('src', '/i/peoples/'+json.img)
              $(".name").html(json.name);
              $(".work").html(json.work);
              $(".more").html(json.info);
            }
           });  return false; })


 function init_dw_Scroll() {var wndo = new dw_scrollObj('lyr1','t1');wndo.setUpScrollControls('scrollLinks');}
 if ( dw_scrollObj.isSupported() ) {dw_Event.add( window, 'load', init_dw_Scroll);}
 function over(x){x.className="td_over";}
 function out(x){x.className="td_out";}

});




