
$(document).ready(function(){
	CreateTextMask("subscribe","e-mail");
	
	if ($().resizableCarousel) {
		$('div.carousel:first').resizableCarousel({
			buttonNext:'.carousel-container img.next:first',
			buttonPrev:'.carousel-container img.prev:first'
		});

		$('div.carousel:not(:first)').resizableCarousel({
			buttonNext:'.carousel-container img.next:not(:first)',
			buttonPrev:'.carousel-container img.prev:not(:first)'
		});
	}
	
	//делаем загрузку многих файлов на сервер
	if ($().multyUpload) {
		$('input#multy_upload').multyUpload( {uploadForm : $('form[name=frm]')} );
	}
	
	if ($().lightBox) {
		var pars = {
			imageLoading:			'/img/default/images/lightbox-ico-loading.gif',		// (string) Path and the name of the loading icon
			imageBtnPrev:			'/img/default/images/lightbox-btn-prev.png',			// (string) Path and the name of the prev button image
			imageBtnNext:			'/img/default/images/lightbox-btn-next.png',			// (string) Path and the name of the next button image
			imageBtnClose:			'/img/default/images/lightbox-btn-close.gif',		// (string) Path and the name of the close btn
			imageBlank:				'/img/default/images/lightbox-blank.gif',
			txtImage:				'Изображение',	// (string) Specify text "Image"
			txtOf:					'из'		// (string) Specify text "of"
		};
		$('#gallery a').lightBox(pars);
		$('a[rel=lightBox]').click(function(e){
			e.preventDefault();
			$(this).lightBox(pars).click();
		});
	}

 	if (typeof FRAMES !== 'undefined' && FRAMES === true) {
		
		
	} else {
		$('a[rel^=prettyPhoto]').prettyPhoto();
		$('#enter_one_more_time').click(function(e){
			e.preventDefault();
			$('a[href$="#login_form_js"]').click();
		});
	 } 
	var menuInit = function (pCat) {
		if (typeof pCat === 'undefined') return;
		var a = $('ul.hierarchy').find("a[href$='" + pCat + "']");
		a.parents('li').find('ul:first').slideDown( 1 );
		a.css({color : '#000000', textDecoration:'underline', cursor : 'default'}).click(function(e){
			e.preventDefault();
		});
	};
	
	if ($().hierarchy) {
		$('ul.hierarchy').hierarchy({
			showClass:'hierarchyShowClass',
			noAnimationClass:'hierarchyNoAnimationClass',
			hideClass:'hierarchyHideClass',
			callback : function(){menuInit( CATEGORY_ENDING );}
		});
	}
	
	$('.item_logo').each(function(){
		var me = $(this);
		$(this).find('img:first:not([src$="no-photo.gif"])').add( $(this).find('span.total_photos:first') ).click(function(){
			me.find('.gallery_photos img:first').click();
		});
	});

});
function CreateTextMask(elementid, masktext)
{
    var element = document.getElementById(elementid);
	if (element == null) return;
      element.value = masktext;
      element.onfocus = function()
    {
        if (element.value == masktext)
        {
            element.className = "maskable-false";
            element.value = ""; 
        }
    }
    
    element.onblur = function()
    {
        if (element.value.length == 0)
        {
            element.className = "maskable-true";
            element.value = masktext;
        }
    }
}
