<!--
function createRequest() {
	vRequest = false;
	try{
		vRequest = new XMLHttpRequest();
	}
	catch( trymicrosoft ){
		try{
			vRequest = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch( othermicrosoft ){
			try{
				vRequest = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch( failed ){
				vRequest = false;
			}
		}
	}

	if( !vRequest )
		alert("Ваш браузер не поддерживает технологию Ajax. Некоторые функции сайта могут быть не доступны.");
	else	
		return vRequest;
    return null;
}

var charRus = new Array('А','Б','В','Г','Д','Е','Ё','Ж','З','И','Й','К','Л','М','Н','О','П','Р','С','Т','У','Ф','Х','Ч','Ц','Ш','Щ','Э','Ю','Я','Ы','Ъ','Ь','Ё','а','б','в','г','д','е','ё','ж','з','и','й','к','л','м','н','о','п','р','с','т','у','ф','х','ч','ц','ш','щ','э','ю','я','ы','ъ','ь','ё',' ','-','_');
var charRusTrans = new Array('A','B','V','G','D','E','Jo','Zh','Z','I','J','K','L','M','N','O','P','R','S','T','U','F','H','Ch','C','Sh','Shch','E','Ju','Ja','Y','','','E','a','b','v','g','d','e','jo','zh','z','i','j','k','l','m','n','o','p','r','s','t','u','f','h','ch','c','sh','shch','e','ju','ja','y','','','e','-','-','_');
var charOther = new Array(' ','-','_');
var charOtherTrans = new Array('-','-','_');
var charDigit = new Array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9');
var charLat = new Array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z');


function translit( vStr ) {
	vOut = '';
	for( i=0; i<vStr.length; i++ ) {
		vChar = vStr.substr(i,1);
		isRus = false;
		for( j=0; j<charRus.length; j++ )
			if( vChar==charRus[j] ) {
				isRus = true;
				break;
			}
		vOut += (isRus) ? charRusTrans[j] : vChar;
	}
	return vOut;
}

function generateAlias( vStr ) {
    vStr = translit(vStr);
	vOut = '';
	for (i = 0; i < vStr.length; i++) {
		vChar = vStr.substr(i,1);
        
		isOther = false;
		for (j = 0; j < charOther.length; j++)
			if (vChar==charOther[j]) {
				isOther = true;
				break;
			}

        isDigit = false;
		for (k = 0; k < charDigit.length; k++)
			if (vChar == charDigit[k]) {
				isDigit = true;
				break;
			}

        isLat = false;
		for (l = 0; l < charLat.length; l++)
			if (vChar == charLat[l]) {
				isLat = true;
				break;
			}

		vOut += isOther ? charOtherTrans[j] : ( isDigit ? charDigit[k] : ( isLat ? charLat[l] : '' ) );
	}
	return vOut;
}

function setAlias( vSrc, vDst ) {
    document.getElementById(vSrc).value = generateAlias( document.getElementById(vDst).value ).toLowerCase();
}

function trim( str ) {
    str = str.replace(/^\s+/, '');
    for (var i = str.length; --i >= 0;)
        if (/\S/.test(str.charAt(i))) {
               str = str.substring(0, i + 1);
               break;
        }
    return str;
}

function toggle( id ) {
	var tmp = document.getElementById(id);
	tmp.style.display = ( tmp.style.display!='none' ) ? 'none' : 'block';
    return;
}

function insertAfter( parent, node, referenceNode ) {
    parent.insertBefore(node, referenceNode.nextSibling);
}

Array.prototype.inArray = function (value) {
    for (var i = 0; i < this.length; i++)
        if (this[i] === value)
            return true;
    return false;
}

function addOption( listBox, value, text, isDefaultSelected, isSelected ) {
    var option = document.createElement('option');
    option.appendChild( document.createTextNode(text) );
    option.setAttribute( 'value', value );

    if( isDefaultSelected ) option.defaultSelected = true;
    else if( isSelected ) option.selected = true;

    listBox.appendChild(option);
    return;
}

function getSelectedIndexes( listBox ) {
    var arrIndexes = new Array;
    for( i=0; i<listBox.options.length; i++ )
        if( listBox.options[i].selected ) arrIndexes.push(i);
    return arrIndexes;
}

function getScrollTop() {
  return self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop);
}

function getScrollLeft() {
  return self.pageXOffset || (document.documentElement && document.documentElement.scrollLeft) || (document.body && document.body.scrollLeft);
}

function setPageScroll() {
	if (document.getElementById('pageYScroll'))
		document.getElementById('pageYScroll').value = getScrollTop();
	if (document.getElementById('pageXScroll'))
		document.getElementById('pageXScroll').value = getScrollLeft();
	return;
}

function isRemove(vMessage) {
    return window.confirm(vMessage);
}

function get(id) {
    return document.getElementById(id);
}

function volumeChange(obj, val) {
    var volume = parseInt(obj.val());
    volume = isNaN(volume) ? 1 : volume;
    volume += val;
    volume = volume < 1 ? 1 : volume;

	obj.val(volume);
	return;
}

$(document).ready(function ()
{
	var defaultStr = 'поиск по каталогу';
	var str = $('.catalog-search-lite input').val();
	
	if (str == '') {
		$('.catalog-search-lite input').val(defaultStr);
		$('.catalog-search-lite input').addClass('noactive');
	}
	
	$('.catalog-search-lite input').focus(function () {
		$('.catalog-search-lite input').removeClass('noactive');
		var str = $('.catalog-search-lite input').val();
		if (str == defaultStr)
			$('.catalog-search-lite input').val('');
	});
	$('.catalog-search-lite input').blur(function () {
		var str = $('.catalog-search-lite input').val();
		if (str == '') {
			$('.catalog-search-lite input').addClass('noactive');
			$('.catalog-search-lite input').val(defaultStr);
		}
	});

    var val, value;
    $('.forms-prompt').each(function () {
		val = $(this).attr('val');
        value = $(this).val();
        if (value == '') {
            $(this).val(val);
            $(this).addClass('forms-prompt-active');
            if ($(this).attr('id') == 'pass1')
                $('#pass2').hide();
        }
	});
    $('.forms-prompt').focus(function () {
		val = $(this).attr('val');
        value = $(this).val();
        if (value == val) {
            $(this).val('');
            $(this).removeClass('forms-prompt-active');
            if ($(this).attr('id') == 'pass1') {
                $(this).hide();
                $('#pass2').show();
                $('#pass2').focus();
            }
        }
	});
    $('.forms-prompt').blur(function () {
		val = $(this).attr('val');
        value = $(this).val();
        if (value == '') {
            $(this).val(val);
            $(this).addClass('forms-prompt-active');
            if ($(this).attr('id') == 'pass2') {
                $(this).hide();
                $('#pass1').show();
                $('#pass1').focus();
            }
        }
	});
    $('.forms-prompt-pass:password').each(function () {
		value = $(this).val();
        if (value == '')
            $(this).hide();
	});
    $('.forms-prompt-pass:text').focus(function () {
        $(this).hide();
        $('.forms-prompt-pass:password').show();
        $('.forms-prompt-pass:password').focus();
	});
    $('.forms-prompt-pass:password').blur(function () {
		value = $(this).val();
        if (value == '') {
            $(this).hide();
            $('.forms-prompt-pass:text').show();
        }
	});
    $('.forms-prompt-button').click(function () {
        $('.forms-prompt').each(function () {
            val = $(this).attr('val');
            value = $(this).val();
            if (value == val)
                $(this).val('');
        });
	});

    $('.userUnAuth').click(function () {
        $('#userUnAuth').submit();
    });
	
	$('.calendar-button').click(function () {
		var obj = $(this).prev('input');
		show_calendar(obj.attr('id'), obj.val());
    });
	
	$('.form-fast-hover').hover(function () {}, function () {
		$('.form-fast-hide').slideUp(200);
	});
	
	$('.callback-button').click(function ()
	{
		var top = $('.formcallback').offset().top;
		if ($('.form-callback').css('display') == 'none')
		{
			$('html').animate({scrollTop:top}, 750, '', function(){
				$('.form-callback').slideToggle();
			});
		}
		else
		{
			$('.form-callback').slideToggle();
		}
	});
	
    $('.forms-prompt').blur(function () {
		value = $(this).val();
        if (value == '')
		{
            $(this).val('Поиск товаров');
            $(this).addClass('forms-prompt-active');
        }
	});
	
	$('.form-fast-hover').click(function () {
		$('.form-fast-hide').slideDown(200);
	});
	
	$(".button-callback").fancybox({
		'width'				: 600,
		'height'			: 420,
		'autoScale'			: false,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});
	
	$(".button-order").fancybox({
		'width'				: 400,
		'height'			: 550,
		'autoScale'			: false,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});
	
	$('#date').change(function ()
	{
		val = $(this).attr('val');
		value = $(this).val();
		if (value != val)
		{
			$(this).removeClass('forms-prompt-active');
		}
	});
	
	$('a[rel=fota]').fancybox();
	
	$('a[rel=fotanoscale]').fancybox({
		autoScale: false
	});
});
//-->
