/**
 * Заглушка для браузеров без firebug
 */
if (typeof(console)=='undefined') {
    console = {log: function(){}, error: function(){}, info: function(){}}
}

function wo(link,name,w,h){
	window.open(link,name,"height="+h+",width="+w+",status=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=no");
	return false;
}

function showhideglossary(id){
	$('#dt' + id).toggleClass("active");
	$('#dd' + id).toggleClass("active");
	$('#dd' + id).toggle();
	return false;
}

$(document).click(function(e)
		{
		var evt=e||window.event;
		var target = evt.target||evt.srcElement;
		if ((target == document.getElementById("breadcrumbs-popup"))||(target==""))
			return;
		$("#breadcrumbs-popup").hide();
		});

function activate_poll( poll_id ) {
    $(document).ready(function() {
        if($("#poll-" + poll_id).length == 0) return false
        if( $.cookie('poll_' + poll_id + '_voted') == 1 ) {
            return false
        }
        var ans_id
        var ans
        $("#poll-" + poll_id + " > dt").each(function() {
            ans = $(this)
            ans_id =  ans.attr("id")
            ans_id = ans_id.replace(/^ans-(\d+)$/i, "$1")
            $(this).next().find('a')
                .bind('click',{'n_ans_id':ans_id}, function(e) {
//                    $.getJSON('/polls/poll_id:'+poll_id+'/ans_id:' + e.data.n_ans_id, function(data) {
                    $.getJSON('/opr.php?poll_id='+poll_id+'&ans_id=' + e.data.n_ans_id, function(data) {
                    	if( data.flag == 'ok' ) {
                            var updated_data = data
                            $(updated_data.answers).each(function() {
                                var rounded_percents = Math.round(this.ans_percent_weight)
                                
                                $('dt#ans-' + this.ans_id).text( rounded_percents + '%' )
                                var ans_dd = $('dt#ans-' + this.ans_id).next()
                                ans_dd.find('span').filter(function(index) {
                                	  return index < 1;
                                }).animate({width:rounded_percents+'%'},700)
                                ans_dd.find('a').remove()
                                ans_dd.append(this.ans_title)
                            })
                            $("#poll-" + poll_id + " > p > span").text("Проголосовало " + updated_data.total_votes + " человек")
                            $.cookie('poll_' + poll_id + '_voted', 1, {'expires':100, 'path': '/'})
                        }
                    })
                    return false
                })
        })
    })
}

/**
 * Хэндлер навешиваемый на document.onkeydown для навигаци по стрелкам
 */
function keydown_handler(e) {
    if (!e) e = window.event
    var k = e.keyCode
    if (e.ctrlKey) {
        var d
        switch(k) {
            case 37:
                d = $('a[rel=prev]')
                break
            case 39:
                d = $('a[rel=next]')
                break
            case 38:
                d = $('a[rel=parent]')
                break
        }
        if(d) {
            var href = d.attr('href')
            if (href) location.href = href
        }
    }
}

/**
 * Обработчик сабмита формы поиска
 */
function search_submit_handler() {
    var searchquery = getCurrentQuery()
    if( searchquery && searchquery != 'поиск' ) {
        window.location.href='/search/searchquery:' + searchquery
    }
    return false
}

/**
 * Возвращает почищенную строку поиска
 */
function getCurrentQuery() {
    if( !document.getElementById('searchfield') ) return null
    var query = trim(document.getElementById('searchfield').value)
    query = query.replace(/"/g, "")
    query = query.replace(/\//g,"")
    query = query.replace(/\\/g,"")
    query = query.replace(/«/g,"")
    query = query.replace(/»/g,"")
    query = query.replace(/,/g,"")
    query = query.replace(/:/g,"")
    query = query.replace(/`/g,"")
    query = query.replace(/[_-]/g," ")
    return query    
}

// jquery загружена?
if( typeof($) != 'undefined' ) {

    /*$('body').load(function() {
//        alert('123')
    })*/

    // Для навигации по Ctrl
    document.onkeydown = keydown_handler

    // Все скрипты выполняеммые после готовности DOM страницы
    $(document).ready(function() {

        // Генерация тенюшек
        Shadower.init()

        // Иницализация скроллера
        Scroller.init()
        // Всплывалка с картинками, fancybox
        if( typeof($.fancybox) != 'undefined' ) {
            $("a.fancybox").fancybox({
                'titleShow':false,
                'transitionIn':'elastic',
                'transitionOut':'none',
                'hideOnContentClick': true,
                'centerOnScroll': true,
                'overlayShow': true,
                'showCloseButton': false
            })
        }

        $('dl.faq > dt > a').click(
            function() {
            	$(this).parent().next('dd').toggle("slow");
            	return false;
            });
        
        $('dl.glossary > dt > a').click(
                function() {
                	$(this).parent().next('dd').toggle("slow");
                	return false;
                });
            
        // Проверка формы "вопрос гостю"
        if($('#guest-item-askguest')) {
            $('#data-Question-submitbutton').attr({'disabled':true})
            var initial_values = {
                'data-Question-text':'Текст вопроса',
                'data-User-firstname':'имя',
                'data-User-lastname':'фамилия'
            }
            $('.onkeyup-activate')
                .keyup(function() {
                    if(!window.keyup_timer) {
                        window.keyup_timer = true
                        setTimeout(checkform_guest_item_askguest, 300)
                    }
                })
                .bind('focus',function() {
                    this.select()
                })
            function checkform_guest_item_askguest() {
                $('#ajax-loading').show();
                var disabled_flag = false
                var input = null
                for( index in initial_values ) {
                    input = $('#' + index)
                    if( input.val() == initial_values[index] || input.val() == '' ) {
                        disabled_flag = true
                    }
                }
                $.get('/kcaptcha/keystring:' + $('#data-Captcha-value').val(), function(data) {
                      disabled_flag = data == 'ok' ? false : true
                      $('#data-Question-submitbutton').attr({'disabled':disabled_flag})
                      $('#ajax-loading').hide();
                })
                window.keyup_timer = null
            }
        }

        // Всплывалка над персоной
        $('dl.personslist > dt.needpopup > a').mouseover(
            function() {
                if( window.person_popup_active ) person_popup_remove()
                if($('#popups').length == 0) {
                    var html = $(this).parent().html()
                    var description = $(this).parent().next('dd').html()
                    $("body").append(
                          '<div id="popups">'
                        + '<dl id="person-popup" class="personslist needshadow" style="display:block">'
                        + '<dt>' + html + '</dt>'
                        + '<dd>' + description + '</dd>'
                        + '</dl>'
                        + '</div>'
                    )
                }
                $('#popups').mouseleave(function() {
                    person_popup_remove()
                })
                var offset = $(this).parent().offset()
                $('#person-popup').css({
                    'left':(offset.left-2) + 'px',
                    'top':(offset.top-2) + 'px'
                })
                Shadower.addFor('#person-popup')
                window.person_popup_active = true
            }
        )


        /**
         * Удаление попапа с персоной
         */
        function person_popup_remove() {
            $('#popups').remove()
            $('#person-popup-shadow').remove()
            Shadower.needshadows.splice(Shadower.needshadows.length-1,1)
            window.person_popup_active = false
        }

    })
}






/**
 * Создание теней под обьектами
 */
var Shadower = {
    shadow_image_src: '/i/shadow.png',
    needshadows: null,
    shadows: null,
    images_cnt: 0,
    images_loaded_cnt: 0,
    addFor: function( selector ) {
        if( this.shadows == null ) {
            $("body").append('<div id="shadows"></div>')
        }
        var new_shadows = $(selector)
        new_shadows.each(function() {
            $("#shadows").append(Shadower._make_one_shadow(this))
        })
        this.needshadows = this.needshadows.add( new_shadows )
        this.shadows = $("#shadows").children()
        this._resize()
    },
    init: function() {
        if(this.needshadows == null) {this.needshadows = $(".needshadow")}
        // если среди элементов, которым нужна тень есть картинки - ждем их загрузки
        this.needshadows.each(function() {
             if(this.tagName == 'IMG') {
                Shadower.images_cnt++
                $(this).load(function() {
                    Shadower.images_loaded_cnt++
                    if( Shadower.images_loaded_cnt == Shadower.images_cnt ) {
                        Shadower._create()
                        Shadower._resize()
                    }
                })
             }
        })
        // если нет - сразу создаем тени.
        if(this.images_cnt == 0) {
            this._create()
            this._resize()
        }
        $(window).resize(function(){Shadower._resize()})
    },
    _create: function() {
        $("body").append('<div id="shadows"></div>')
        this.needshadows.each(function() {
            $("#shadows").append(Shadower._make_one_shadow(this))
        })
    },
    _resize: function() {
        if(this.shadows == null) {this.shadows = $("#shadows").children()}
        var i = 0
        this.needshadows.each(function() {
            var needshadow = this
            if(typeof(Shadower.shadows[i])!='undefined'){
                var shadow = Shadower.shadows[i]
                var offset = absPosition( needshadow )
                shadow.style.width = needshadow.offsetWidth*1.2 + 'px'
                shadow.style.height = needshadow.offsetHeight*1.4 + 'px'
                shadow.style.left = offset.x + needshadow.offsetWidth/2 + 'px'
                shadow.style.top = offset.y + needshadow.offsetHeight/2 + 'px'
                shadow.style.marginLeft = - shadow.offsetWidth/2 + 'px'
                shadow.style.marginTop = - shadow.offsetHeight/2 + 'px'
            }
            i++
        })
    },
    _make_one_shadow: function( needshadow_elem ) {
        var shadow = $('<div class="shadow"><img src="' + Shadower.shadow_image_src + '" /></div>')
        if( needshadow_elem.id ) {shadow.attr('id', needshadow_elem.id + '-shadow')}
        if( $(needshadow_elem).is(':hidden') ){shadow.css({display:'none'})}
        var cStyle = null
        var zIndex = null
        if( window.getComputedStyle ) {
            cStyle = window.getComputedStyle(needshadow_elem,'')
            zIndex = cStyle.getPropertyValue('z-index')
        } else { // IE
            cStyle = needshadow_elem.currentStyle
            zIndex = cStyle['zIndex']
        }
        if( parseInt(zIndex) > 1 ) {shadow.css({'zIndex':parseInt(zIndex) - 2})}
        return shadow
    }
}

/**
 * Обработчик листания элементов
 */
var Scroller = {

    delay: 300,

    shift_left: null,
    shift_right: null,

    date_left: null,
    date_right: null,

    /**
     * Флаг того, что скроллер работает
     * (ajax запрос или анимация в процессе)
     */
    busy: false,
    /**
     * Имя ajax контроллера
     */
    controller: null,
    /**
     * Инициальзация
     */
    init: function() {

        //jQuery.ajax( settings )

//        if( !$('#pager div.scroller').length ) return false
//        this.controller = $('#pager').attr('class')
//        if( !this.controller ) {
//            console.error('Check presence of attr "class" whith correct name of controller in div#pager tag')
//            return false
//        }
        // Обработка кликов по ссылкам
//        $('div#bigbanner>a.prev').click( function(){ Scroller.prev(); return false;} )
//        $('div#bigbanner>a.next').click( function(){Scroller.next() return false;} )
        //        Работа с колесиком мыши
        //        if( typeof($().mousewheel) != 'undefined' ) {
        //            $('div.scroller').mousewheel(function(event, delta) {
        //                    if (delta > 0)
        //                        Scroller.prev(50)
        //                    else if (delta < 0)
        //                        Scroller.next(50)
        //                    return false;
        //            });
        //        }
    },
    _get_shifts: function() {
        this.shift_left  = parseInt( $('div.scroller>dl:first').css('left'))
        this.shift_right = parseInt( $('div.scroller>dl:last').css('left'))
        this.date_left   = $('div.scroller>dl:first>dt').attr('title')
        this.date_right  = $('div.scroller>dl:last>dt').attr('title')
    },
    /**
     * Предыдушие элементы
     */
    prev: function() {
        if( this.busy ) {
            return
        }
        this._get_shifts()
        if( this.shift_left >= 21 ) return
        this.busy = true
        $('div.scroller>dl').animate({left:"+=19%"}, this.delay, function() {
            Scroller.busy = false
        })
        //this.busy = true
        setTimeout( function() {
            if( Scroller.shift_left >= -36 && !Scroller.busy ) {
                Scroller.busy = true
                $.get('/' + Scroller.controller + '/scroller/earlier_than:' + Scroller.date_left, function(data) {
                    var dls = $(data)
                    dls.each(function() {
                        if(this.tagName == 'DL') {
                            Scroller._get_shifts()
                            $(this).css({'left':(Scroller.shift_left-19)+'%'})
                            $('div.scroller').prepend(this)
                        }
                    })
                    Scroller.busy = false
                })
            }
            Scroller.busy = false
            if( Scroller.shift_right >= 116 ) {
                $('div.scroller>dl:last').remove()
            }
        }, Scroller.delay + 10)
    },
    /**
     * Последующие элементы
     */
    next: function() {
        if( this.busy ){
            return
        }
        this._get_shifts()
        if( this.shift_right <= 21 ) return
        this.busy = true
        $('div.scroller>dl').animate({left:"-=19%"}, this.delay, function() {
            Scroller.busy = false
        })
        this.busy = true
        setTimeout( function() {
            if( Scroller.shift_right <= 116  && !Scroller.busy ) {
                Scroller.busy = true
                $.get('/' + Scroller.controller + '/scroller/later_than:' + Scroller.date_right, function(data) {
                    var dls = $(data)
                    dls.each(function() {
                        if(this.tagName == 'DL') {
                            Scroller._get_shifts()
                            $(this).css({'left':(Scroller.shift_right+19)+'%'})
                            $('div.scroller').append(this)
                        }
                    })
                    Scroller.busy = false
                })
            }
            Scroller.busy = false
            if( Scroller.shift_left <= -36 ) {
                $('div.scroller>dl:first').remove()
            }
        }, Scroller.delay + 10)
    }
}

////////////////////////////////////////////////////////////////////////////////

/**
 * Распечатка JS обьекта
 */
function pr( obj ) {
    if(obj) {
        var result = ''
        for (var i in obj) {
            result += 'obj' + '.' + i + ' = ' + obj[i] + '\n'
        }
        alert( result )
    } else {
        alert( '[empty]' )
    }
}

/**
 * Калькулирование абсолютной позиции элемента в DOM
 */
function absPosition(obj) {
	var x = y = 0;
	while(obj) {
		x += obj.offsetLeft;
		y += obj.offsetTop;
		obj = obj.offsetParent;
	}
	return {x:x, y:y};
}

/**
 * Аналог php ф-и trim
 */
function trim(string) {
    return string.replace(/(^\s+)|(\s+$)/g, "")
}
 
function typeplace(click){
		var startorder = document.getElementById('startorder');
		var input = document.getElementById(click.id.replace('name','input'));
		var name = document.getElementById(click.id.replace('input','name'));
		var help = document.getElementById('place-help');
		if (click.tagName=='A') {
			startorder.className='disabled';
			input.value=name.innerHTML;
			name.style.display='none';
			input.style.display='inline';
			input.focus();
		} else if (click.tagName=='INPUT') {
			startorder.className='';
			name.innerHTML=input.value;
			input.style.display='none';
			
			name.style.display='inline';
//			help.style.display='none';
		}
		return false;
	}

function showcrumbs(link){
	var crumbs = document.getElementById('breadcrumbs-popup');
	var crumb = document.getElementById('select-' + link.id);

	crumbs.style.display = 'block';

	var current = link.parentNode;
	var top = topprev = left = leftprev = 0;
	while ( current.id != 'layout' ){
		if ( current.offsetTop != topprev ){
			topprev = current.offsetTop;
			top = top + current.offsetTop;
		}
		if ( current.offsetLeft != leftprev ){
			leftprev = current.offsetLeft;
			left = left + current.offsetLeft;
		}
		current = current.parentNode;
	}

	var current = crumb.parentNode.firstChild;
	var width = 0;
	while ( current != null ) {
		if ( current.tagName == 'A' ) {
			current.style.display = 'inline';
			if ( current.offsetWidth > width ) {
				width = current.offsetWidth;
			}
			current.style.display = 'block';
		}
		current = current.nextSibling;
	}

	crumbs.style.width = width + 'px';
	crumbs.style.top = top + link.offsetTop - 1 - crumb.offsetTop + 'px';
	crumbs.style.marginLeft = left + link.offsetLeft - 1 - crumb.offsetLeft - (5 * document.getElementById('layout').offsetWidth / 100) + 'px';
	crumb.className = 'nolink';

	crumb.onclick = function() { crumbs.style.display = 'none'; return false; };
	return false;
}

function showsearchresults(link){
	var current = document.getElementById('searchresultsfilter').firstChild;
	while ( current != null ) {
		if ( current.tagName == 'LI' ) {
			current.className = current.className.replace(' selected','');
		}
		current = current.nextSibling;
	}

	var current = document.getElementById('searchresults').firstChild;
	while ( current != null ) {
		if ( current.tagName == 'LI' ) {
			current.className = current.className.replace(' blind','');
			if (link.parentNode.className != 'show-all' && current.className != link.parentNode.className) {
				current.className = current.className + ' blind';
			}
		}
		current = current.nextSibling;
	}
	link.parentNode.className = link.parentNode.className + ' selected';
	return false;
}


function isValidEmail(email)
{
    re = /^([a-z0-9_\-]+\.)*[a-z0-9_\-]+@([a-z0-9][a-z0-9\-]*[a-z0-9]\.)+[a-z]{2,4}$/i;
    return re.test(email);
}
function isValidTranslit(txt)
{
    re = /^([a-z0-9_\-]+\.)*[a-z0-9_\-]+[a-z]$/i;
    return re.test(txt);
}
function isValidCyr(txt)
{
    re = /^([а-я0-9_\- "]+\.)*[а-я0-9_\- "]+[а-я0-9_\- "]$/i;
    return re.test(txt);
}

function CheckTypingRU(el)
{
	el.value = el.value.replace(/[a-zієї]/gi, '')
	return true
}

function CheckTypingEMAIL(el)
{
	el.value = el.value.replace(/[а-яА-Яієї]/gi, '')
	return true
}

function checkFields_ask()
{
	var i;
	var errors=0;

	if ((document.form.t2.value=="")) { document.getElementById('t2-label').className='required'; document.getElementById('t2').className='wfitit required'; errors=1; } else {document.getElementById('t2-label').className=''; document.getElementById('t2').className='wfitit';}
	if ((document.form.t4.value=="")) { document.getElementById('t4-label').className='required'; document.getElementById('t4').className='w19sym required'; errors=1; } else {document.getElementById('t4-label').className=''; document.getElementById('t4').className='w19sym';}
	if ((document.form.t3.value=="")||(!isValidCyr(document.form.t3.value))) { document.getElementById('t3-label').className='required'; document.getElementById('t3').className='w10sym required'; errors=1; } else {document.getElementById('t3-label').className=''; document.getElementById('t3').className='w10sym';}
	
	if ((document.form.t7.value=="")||(!isValidEmail(document.form.t7.value))) { document.getElementById('t7-label').className='required'; document.getElementById('t7').className='w29sym required'; errors=1; } else {document.getElementById('t7-label').className=''; document.getElementById('t7').className='w29sym';}
	if (errors==0)
	{
		document.form.submitbutton.disabled=false;
		document.form.submitbutton.value="Спросить";
	} else
	{
		document.form.submitbutton.disabled=true;
		document.form.submitbutton.value="Спросить";
	}
	
}

function checkFields_order()
{
	var i;
	var errors=0;

	if ((document.form.companyname.value=="")) { document.getElementById('companyname-label').className='required'; document.getElementById('companyname').className='wfitit required'; errors=1; } else {document.getElementById('companyname-label').className=''; document.getElementById('companyname').className='wfitit';}
	if ((document.form.companycity.value=="")) { document.getElementById('companycity-label').className='required'; document.getElementById('companycity').className='w24sym required'; errors=1; } else {document.getElementById('companycity-label').className=''; document.getElementById('companycity').className='w24sym';}
	if ((document.form.lastname.value=="")) { document.getElementById('lastname-label').className='required'; document.getElementById('lastname').className='w19sym required'; errors=1; } else {document.getElementById('lastname-label').className=''; document.getElementById('lastname').className='w19sym';}
	if ((document.form.firstname.value=="")) { document.getElementById('firstname-label').className='required'; document.getElementById('firstname').className='w10sym required'; errors=1; } else {document.getElementById('firstname-label').className=''; document.getElementById('firstname').className='w10sym';}
	
	if ((document.form.phonecode.value=="")||(document.form.phonenumber.value=="")) { document.getElementById('phone-label').className='required'; } else {document.getElementById('phone-label').className='';}
	if ((document.form.phonecode.value=="")) { document.getElementById('phonecode').className='w3sym required'; } else {document.getElementById('phonecode').className='w3sym';}
	if ((document.form.phonenumber.value=="")) { document.getElementById('phonenumber').className='w7sym required'; } else {document.getElementById('phonenumber').className='w7sym';}

	if ((document.form.elements["e-mail"].value=="")) { document.getElementById('e-mail-label').className='required'; document.getElementById('e-mail').className='w29sym required'; errors=1; } else {document.getElementById('e-mail-label').className=''; document.getElementById('e-mail').className='w29sym';}
	
	if ((document.form.cargoname.value=="")) { document.getElementById('cargoname-label').className='required'; document.getElementById('cargoname').className='wfitit required'; errors=1; } else {document.getElementById('cargoname-label').className=''; document.getElementById('cargoname').className='wfitit';}
	
	if ((document.form.adv.value=="")) { document.getElementById('adv-label').className='required'; document.getElementById('adv').className='wfitit required'; errors=1; } else {document.getElementById('adv-label').className=''; document.getElementById('adv').className='wfitit';}
	
//	if ((document.form.tnvedcode.value=="")||(document.form.brutto.value=="")||(document.form.brutto3.value=="")) { document.getElementById('tnvedcode-label').className='required'; } else {document.getElementById('tnvedcode-label').className='';}
	if ((document.form.brutto.value=="")||(document.form.brutto3.value=="")) { document.getElementById('tnvedcode-label').className='required'; } else {document.getElementById('tnvedcode-label').className='';}
//	if ((document.form.tnvedcode.value=="")) { document.getElementById('tnvedcode').className='w10sym required'; } else {document.getElementById('tnvedcode').className='w10sym';}
	if ((document.form.brutto.value=="")) { document.getElementById('brutto').className='w5sym required'; } else {document.getElementById('brutto').className='w5sym';}
	if ((document.form.brutto3.value=="")) { document.getElementById('brutto3').className='w3sym required'; } else {document.getElementById('brutto3').className='w3sym';}
	

	if ((document.form.fromcountry.value=="")||(document.form.fromcity.value=="")) { document.getElementById('fromcountry-label').className='required'; } else {document.getElementById('fromcountry-label').className='';}
	if ((document.form.fromcountry.value=="")) { document.getElementById('fromcountry').className='w15sym required'; } else {document.getElementById('fromcountry').className='w15sym';}
	if ((document.form.fromcity.value=="")) { document.getElementById('fromcity').className='w24sym required'; } else {document.getElementById('fromcity').className='w24sym';}
	
	if ((document.form.tocountry.value=="")||(document.form.tocity.value=="")) { document.getElementById('tocountry-label').className='required'; } else {document.getElementById('tocountry-label').className='';}
	if ((document.form.tocountry.value=="")) { document.getElementById('tocountry').className='w15sym required'; } else {document.getElementById('tocountry').className='w15sym';}
	if ((document.form.tocity.value=="")) { document.getElementById('tocity').className='w24sym required'; } else {document.getElementById('tocity').className='w24sym';}
	if (errors==0)
	{
		document.form.submitbutton.disabled=false;
		document.form.submitbutton.value="Отправить";
	} else
	{
		document.form.submitbutton.disabled=true;
		document.form.submitbutton.value="Отправить";
	}
	
}

function checkFields_job()
{
	var i;
	var errors=0;

	if ((document.form.position.value=="")) { document.getElementById('position-label').className='required'; document.getElementById('position').className='wfitit required'; errors=1; } else {document.getElementById('position-label').className=''; document.getElementById('position').className='wfitit';}
	
	if ((document.form.lastname.value=="")) { document.getElementById('lastname-label').className='required'; document.getElementById('lastname').className='w19sym required'; errors=1; } else {document.getElementById('lastname-label').className=''; document.getElementById('lastname').className='w19sym';}
	if ((document.form.firstname.value=="")) { document.getElementById('firstname-label').className='required'; document.getElementById('firstname').className='w10sym required'; errors=1; } else {document.getElementById('firstname-label').className=''; document.getElementById('firstname').className='w10sym';}
	
	if ((document.form.dayofbirth.value=="")||(document.form.yearofbirth.value=="")) { document.getElementById('dayofbirth-label').className='required'; } else {document.getElementById('dayofbirth-label').className='';}
	if ((document.form.dayofbirth.value=="")) { document.getElementById('dayofbirth').className='w2sym required'; } else {document.getElementById('dayofbirth').className='w2sym';}
	if ((document.form.yearofbirth.value=="")) { document.getElementById('yearofbirth').className='w4sym required'; } else {document.getElementById('yearofbirth').className='w4sym';}

	if ((document.form.elements["e-mail"].value=="")) { document.getElementById('e-mail-label').className='required'; document.getElementById('e-mail').className='w29sym required'; errors=1; } else {document.getElementById('e-mail-label').className=''; document.getElementById('e-mail').className='w29sym';}
	
	if ((document.form.home.value=="")) { document.getElementById('home-label').className='required'; document.getElementById('home').className='w24sym required'; errors=1; } else {document.getElementById('home-label').className=''; document.getElementById('home').className='w24sym';}
	if ((document.form.phonecode.value=="")||(document.form.phonenumber.value=="")) { document.getElementById('phone-label').className='required'; } else {document.getElementById('phone-label').className='';}
	if ((document.form.phonecode.value=="")) { document.getElementById('phonecode').className='w3sym required'; } else {document.getElementById('phonecode').className='w3sym';}
	if ((document.form.phonenumber.value=="")) { document.getElementById('phonenumber').className='w7sym required'; } else {document.getElementById('phonenumber').className='w7sym';}

	
	
	
	if ((document.form.resume.value=="")) { document.getElementById('resume-label').className='required'; document.getElementById('resume').className='wfitit required'; errors=1; } else {document.getElementById('resume-label').className=''; document.getElementById('resume').className='wfitit';}
	if (errors==0)
	{
		document.form.submitbutton.disabled=false;
		document.form.submitbutton.value="Отправить";
	} else
	{
		document.form.submitbutton.disabled=true;
		document.form.submitbutton.value="Отправить";
	}
	
}

