function menuEffect(){
  $('.lAcc .cur UL').slideDown('fast');
  $('.lAcc .mLink').click(function (){
  cur = $(this).parent().attr('className')=="cur"; 
  hc = $(this).next(":has(LI)").length == 1;
  if (cur && hc) {
      $(this).next().slideUp('fast');
      $(this).parent().removeClass('cur');
      return false;
  }
  if (!cur && hc){
    el = $('.lAcc .cur:has(LI)');
      el.find('UL').slideUp('fast');
      el.removeClass('cur');
      $(this).parent().addClass('cur');
      $(this).next().slideDown('fast');
      return false;
  }
  });
};

function layerPosition(){
//DD_belatedPNG.fixPng('#ahtung1 img');
var ahtungH, perCent, c, offset, offset1, ml, ml1, clientWidth, clientHeight, h, leftCorrect;
clientWidth = document.body.clientWidth;
perCent = clientWidth/100;
c = perCent*10;
if (clientWidth <= 1600) {
  leftCorrect = 0;
} else {
  if ((800+c) > (clientWidth/2)) {
    leftCorrect = 800+c-(clientWidth/2);
  }
}
$("#ahtung1 img").css('width', c+'px');
offset = $("#top").css('margin-left').slice(0, -2);
ml = Math.abs(offset)+c/2-leftCorrect;
$('#top').css('margin-left', -ml+'px');
offset1 = $(".frameTable").css('margin-left').slice(0, -2);
ml1 = Math.abs(offset1)+c/2-leftCorrect;
$(".frameTable").css('margin-left', -ml1+'px');
clientHeight = document.body.clientHeight;
ahtungH = $('#ahtung1 img').height();
h = (clientHeight - ahtungH)/2;
$('#ahtung1 img').css('margin-top', h+'px');
h = 663;
if (clientHeight < h) {
  $("#top").css('top', '60px');
} else {
  if (h + 181 > clientHeight) {
    $("#top").css({'top':'60px'});
  } else {
    $("#top").css('bottom', '180px');
  }
}
h = clientHeight - parseInt($('.headFrame').css('height').slice(0,-2)) - parseInt($('.bottomFrame').css('height').slice(0,-2));
if ($.browser.mozilla || $.browser.opera || $.browser.msie) {
  h1 = 300;
  h2 = 0;
} else {
  if (h+60 < 663) {
    h1 = 100;
  } else {
    h1 = 60;
  }
  h2 = -223;
}
if (h+h1 < 663) {
  $('#top').css({ 'height':h+h1+'px'});
}
$('.maddleFrame').css('height',h+h2+'px');
}

function Tips() {
  /*$(".tipsTable a").click(function () {
    $(".active").removeClass("active");
    $(this).addClass("active");
    return false;
  });*/
}

function Trigger(param) {
  if (param != null) {
    $(".contentTrigger").hide();
    $("#t_" + param).show();
    $(".active").removeClass("active");
    $("#s_" + param).addClass("active");
  } else {
    /*
    $(".contentTrigger").hide();
    var initshow = $(".active").attr("rel");
    $("#t_" + initshow).show();
    */
  }
  
  $(".tipsTable a").click(function () {
                    var whatshow = $(this).attr("rel");
                    $(".contentTrigger").hide();
                    $("#t_" + whatshow).show();
                    $(".active").removeClass("active");
                    $(this).addClass("active");
                    return false;
                    });
}

function picEffect(){
  $('.cNagradyList a').fadeTo('fast',0.25)
    .mouseenter(function(){
      $(this).fadeTo('normal',1);
    })
  .mouseout(function(){
      $(this).fadeTo('normal',0.25);
    });
}

function ajaxVoteSendChecker(voteId, isMulty, div) {
  /*
      var name = 'ajaxVoteSend' + voteId;
    if (cook.get(name) == voteId) {
          alert('');
    } else {
  */
  if (typeof(answerId) == 'string' && isMulty == true) {
          var el = document.getElementById(answerId);
          var a = el.getElementsByTagName('INPUT');
          var votes = new Array();
          for (var i = 0; i < a.length; i ++) {
            if (a[i].checked == true && a[i].name.indexOf('answer') != -1) {
                answerId = a[i].value
            }
          }
  }

  var n1 = 'pollxtd' + voteId;
  var id = 'answer' + voteId;
  var theGroup = document.forms[n1].elements[id];
  var answerId = 0;

  for (i = 0; i < theGroup.length; i ++) {
     if (theGroup[i].checked) {
       answerId = theGroup[i].value;
       break;
     }
  }
  if (!answerId) alert('Вы не сделали свой выбор. Пожалуйста, попробуйте ещё раз'); else {
     document.getElementById('voteMainContainer'+voteId).innerHTML = '';
     da_ajaxVoteSend(voteId, answerId, div);
  }
    //}
}

function ajaxSendAll(idElement, voteId, div) {
    var el = document.getElementById(idElement);
    var a = el.getElementsByTagName('INPUT');
    var votes = new Array();
    for (var i = 0; i < a.length; i ++) {
      if (a[i].checked == true && a[i].name.indexOf('answer') != -1) {
        var val = a[i].name.replace('answer', '');
        votes.push(val);
      }
    }
    ajaxVoteSendChecker(voteId, votes.join('&'), div);
}

var cook = {
    set : function(name, value, expires, path, domain, secure) {
      var expl = new Date();
      var expires = expl.getTime() + (expires * 24 * 60 * 60 * 1000);
      expl.setTime(expires);
      expires = expl.toGMTString();
      var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires: "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "")
      document.cookie = curCookie;
      return curCookie;   
    },
    get : function(name) {
      var d = document.cookie; var prefix = name + "="; var s = d.indexOf(prefix); if (s == -1) { return false; } 
      var e = d.indexOf(";", s + prefix.length); if (e == -1) { e = d.length; } 
      return unescape(d.substring(s + prefix.length, e)); 
    } 
}

function contacts() {
  $("h4 span").click(function () {
                 a = $(this).parent().next().hasClass("ololo");
                 if (!a) {
                   $(".ololo").slideUp("fast").removeClass("ololo");
                   $(this).parent().next().slideDown("slow").addClass("ololo");
                 }
                 else {
                   $(".ololo").slideUp("fast").removeClass("ololo");
                 }
                 });
}


/* Header vitrina picture switcher */
function Vitrina(){}
Vitrina.curPic = 1;
Vitrina.sw = false;
Vitrina.picList = new Array();
Vitrina.interval = 5000;

Vitrina.start = function(){
  $('.hVitrina').find('img').attr('id','pswPic1');
  $('.hVitrina').prepend('<img id="pswPic2" style="display:none; position:absolute; top:0; left:0" src="' + Vitrina.picList[1] + '" alt="">');
  setInterval(Vitrina.picFade, Vitrina.interval);
}

Vitrina.picFade = function(){
  Vitrina.sw = !Vitrina.sw;
  if (Vitrina.sw) $('#pswPic2').fadeIn('slow', Vitrina.picSw);
  else $('#pswPic2').fadeOut('slow', Vitrina.picSw);
}

Vitrina.picSw = function(){
  Vitrina.curPic++;
  if (Vitrina.curPic >= Vitrina.picList.length) Vitrina.curPic = 0;
  if (Vitrina.sw) $('#pswPic1').attr('src', Vitrina.picList[Vitrina.curPic]);
  else $('#pswPic2').attr('src', Vitrina.picList[Vitrina.curPic]);
}

function hotLinkFormCheck() {
  var form = $("form[name='hotLinkForm']");
  
  var message = new Array();
  if ($.trim(form.find(":text[name='name']").val()) == "") message.push('Заполните поле "Имя"');
  
  var email = $.trim(form.find(":text[name='email']").val());
  if (email == "") message.push('Заполните поле "E-mail"'); 
  else if (!checkEmail(email)) message.push('Поле "E-mail" заполнено неверно');
  
  if ($.trim(form.find("textarea[name='message']").val()) == "") message.push('Заполните поле "Текст сообщения"');
  
  var antispam = $.trim(form.find(":text[name='image_value_antispam']").val());
  if (antispam == "") message.push('Заполните поле "Код подтверждения"');
  else if (!/^\d{4}$/.test(antispam)) message.push('Поле "Код подтверждения" заполнено неверно');
  
  message.length ? daAlert("Внимание", message.join("<br>"), "Закрыть", "error") : form.submit();
}

//function HappyNewYear() {
  //  setTimeout(function(){$(".NG").fadeIn("slow");},500);
    //$('.NG img').click(function () {
      //$('.NG').fadeOut("slow");
     // return false;
   // });
//}
