﻿function regNew() {
    /** @type Elem[]*/
    var inputs = $('.reg-over input[type=text], .reg-over input[type=password], .reg-over-forum input[type=text], .reg-over-forum input[type=password] '),
    /** @type Elem[] */
        elemInputs = $('.login_TextBox input');
    elemInputs.focus(function () {
        this.parentNode.style.backgroundPosition = '0 -24px';
        if (this.value == 'Логин или e-mail' || this.value == 'Пароль') {
            this.value = '';
        }
    });
    elemInputs.blur(function () {
        var wrapper = this.parentNode,
            parent = wrapper.parentNode;
        wrapper.style.backgroundPosition = '0 2px';
        if (this.value == '' && this.type == 'text') {
            this.value = 'Логин или e-mail';
        }
    });
    var tooltip = $('.vldtr > .valregEmail,.vldtr > .valregPass, .vldtr > .valcmpPassword, .block_name > .valreqName '),
        btnReg = $('.reg-btn input'),
        btnUsrIn = $('.usr-in'),
        btnUsrReg = $('.usr-reg');
    $('#auth').append("<div id='overlay'></div>");
    var overlay = $('#overlay'),
        loginForm = $('.login_container'),
        regForm = $('.reg-over'),
        btnCloseLogin = $('.login_container .btn-close'),
        btnCloseReg = $('.reg-over .btn-close');
    btnCloseLogin.click(function (event) {
        event.preventDefault();
        overlay.animate({ opacity : '0'}, 'normal', function () {
	        loginForm.css('display', 'none');
	        overlay.css({ opacity : '0', display: 'none'});
        });
        //правим z-index для IE 6-7
        if (!jQuery.support.cssFloat && $('#maincontainer').length != 0) {
            $('#maincontainer').css('z-index', '1');
        }
    });
    btnCloseReg.click(function (event) {
        event.preventDefault();
        overlay.animate({ opacity : '0'}, 'normal', function () {
            regForm.css('display', 'none');
            overlay.css({ opacity : '0', display: 'none'});
        });
        // правим z-index для IE 6-7
        if (!jQuery.support.cssFloat && $('#maincontainer').length != 0) {
            $('#maincontainer').css('z-index', '1');
        }
    });
    overlay.css('opacity', '0');
	btnUsrIn.click(function (event) {
        event.preventDefault();
        overlay.css({'opacity' : '0', 'display' : 'block'});
	    overlay.animate({ opacity : '0.5'}, 'normal');
	    loginForm.css('display', 'block');
        //правим z-index для IE 6-7
        if (!jQuery.support.cssFloat && $('#maincontainer').length != 0) {
            $('#maincontainer').css('z-index', '-1');
        }
	});
    btnUsrReg.click(function (event) {
        event.preventDefault();
        overlay.css({'opacity' : '0', 'display' : 'block'});
        overlay.animate({ opacity : '0.5'}, 'normal');
        regForm.css('display', 'block');
        //правим z-index для IE 6-7
        if (!jQuery.support.cssFloat && $('#maincontainer').length != 0) {
            $('#maincontainer').css('z-index', '-1');
        }
    });
    btnReg.mouseover(function () {
        this.style.backgroundPosition = '0 -33px';
    });
    btnReg.mouseout(function () {
        this.style.backgroundPosition = '0 2px';
    });
    inputs.focus(function () {
        var parent = this.parentNode;
        parent.style.backgroundPosition = '0px -24px';
        switch (this.value) {
            case 'Логин' :
                this.value = '';
                break;
            case 'E-mail' :
                this.value = '';
                break;
            case 'Пароль' :
                this.value = '';
                break;
        }
    });
    inputs.blur(function () {
        var wrapper = this.parentNode;
        var parent = wrapper.parentNode;
        wrapper.style.backgroundPosition = '0px 2px';
        if (this.value == '') {
            switch (parent.className) {
                case 'block_name' :
                    this.value = 'Логин';
                    break;
                case 'block_email' :
                    this.value = 'E-mail';
                    break;
            }
        }
    });
    for (var i = 0; i < inputs.length; i++) {
        var wrapper = inputs[i].parentNode,
            parent = wrapper.parentNode;
        if (inputs[i].value == '') {
           switch (parent.className) {
                case 'block_name' :
                    inputs[i].value = 'Имя';
                    break;
                case 'block_email' :
                    inputs[i].value = 'E-mail';
                    break;
            }
        }
    }
    var href = location.href, uri = 'zvezdy', arrIn = [], startPage = $('#start_page'), banner = $('#banner_1000x90')
        wmjContent =  $('#bg_monster');
    arrIn = href.split('/');

    if (!jQuery.support.cssFloat) {
        startPage.css('display', 'block');
        $('#start_page > a').click(function (event) {
            event.preventDefault();
            this.style.behavior = 'url(#default#homepage)';
            this.setHomePage('http://www.wmj.ru');
        });
    }
  /*  
   var href = location.href, uri = 'krasota-i-zdorove', arrIn = [], startPage = $('#start_page'), banner = $('#banner_1000x90'),
        wmjContent =  $('#bg_monster');
        arrIn = href.split('/');
    for (var i = 0, legnth = arrIn.length; i < legnth; i++) {
    if (arrIn[i] === uri) {
    $("#menu_top").css("z-index","10");
    $("#toolbar").css("z-index","200");
	$("#logo").css({"z-index": "30", "top" : "80px"});
		$("#hot_links").css({"z-index": "10", "display": "block","top":"220px"});
         wmjContent.append("<a href='http://ad.adriver.ru/cgi-bin/click.cgi?sid=1&ad=256535&bt=39&bid=987247&bn=987247&rnd=1017334068' target='_blank' style='position: absolute; width: 100%; height: 100%; z-index: 5; top:0; left:0;'></a>");
          banner.empty();
		  $("#top_logo").empty();
      } 
    }  
*/
/* ST-Valentine */

   var href = location.href, uri = 'special', arrIn = [], startPage = $('#start_page'), banner = $('#banner_1000x90'),
        wmjContent =  $('#bg_monster');
        arrIn = href.split('/');
    $("#menu_top").css("z-index","10");
    for (var i = 0, legnth = arrIn.length; i < legnth; i++) {
    if (arrIn[i] != uri && arrIn[2] == "old.wmj.ru" ) {
	wmjContent.append("<a href='/special/trendy-vesna-leto-2011/' target='_blank' style='position: absolute; width: 100%; height: 100%; z-index: 4; top:0; left:0;'></a>");
        
      } 
    }  
	
/********/
/* Zalmer */
/*
 var href = location.href, uri = 'dom-i-eda', arrIn = [], startPage = $('#start_page'), banner = $('#banner_1000x90'),
        wmjContent =  $('#bg_monster');
        arrIn = href.split('/');
    for (var i = 0, legnth = arrIn.length; i < legnth; i++) {
    if (arrIn[i] === uri && arrIn[2] == "www.wmj.ru" ) {
	wmjContent.append("<a href='http://ad.adriver.ru/cgi-bin/click.cgi?sid=1&ad=255277&bt=40&bid=979205&bn=979205&rnd=891065061' target='_blank' style='position: absolute; width: 100%; height: 100%; z-index: 4; top:0; left:0;'></a>"); 
	$("#top_logo").empty();
	$("#top_logo").hide();
	banner.remove();
      } 
    }  
*/
/*********/

/* рейтинг */
/*
   var href = location.href, uri = 'zvezdy', arrIn = [], startPage = $('#start_page'), banner = $('#banner_1000x90'),
        wmjContent =  $('#bg_monster');
        arrIn = href.split('/');
    for (var i = 0, legnth = arrIn.length; i < legnth; i++) {
    if (arrIn[i] === uri && arrIn[2] == "www.wmj.ru" ) { 
	wmjContent.append("<a href='/special/ratings' target='_blank' style='position: absolute; width: 100%; height: 100%; z-index: 4; top:0; left:0;'></a>");
	$("#top_logo").empty();
	$("#top_logo").hide();
	banner.empty();
      } 
    }  
	*/
/*********/
}
var TestApproveCheck = function (checkboxId) {
    this.checkboxId = checkboxId;
}
TestApproveCheck.prototype.testfunction = function(event, args){
    args.IsValid = document.getElementById(this.checkboxId).checked;
}
$(document).ready(regNew);
/* Слово "Поиск" по умолчанию */
 $(document).ready(function(){
var sear = $(".search-form .form-find");
sear.attr("value",'Поиск');
sear.attr("onfocus","if(this.value=='Поиск') this.value='';");
sear.attr("onblur","if(this.value=='') this.value='Поиск';");
sear.css("font-weight","normal");

 /* Потом убрать!!! убираем Timotey  */
 /*
 $("#hot_links .l:eq(0),#hot_links .c:eq(0),#hot_links .r:eq(0)").hide(); 
 $("#hot_links .l:eq(1),#hot_links .c:eq(1),#hot_links .r:eq(1)").hide();
		$("#hot_links").show();
		*/
/*********************/

});
