var listSpecial;

function listSpecialInit()
{
    listSpecial = $$('div.list-special-entry');
}

function listSpecialSelect(id, obj)
{
    listSpecial.each(function(el){
        el.setStyle('display', 'none');		
    });

    $$('a.list-special-menu-active').each(function(el){		
        el.setAttribute('class', 'list-special-menu-inactive set-left')		
    });
	
    obj.setAttribute('class', 'list-special-menu-active set-left')
	
    $('list-special-entry-'+id).setStyle('display', '');
}

var imgFlip;
var srcFlipActive;
var srcFlipInactive;

function imageFlipInit()
{
    var hrefFlip = $('image-flip');	
    var imgs = hrefFlip.getChildren();
    imgFlip = imgs[0]; 
    srcFlipActive = hrefFlip.getAttribute('name');
    srcFlipInactive = imgFlip.getAttribute('src');	
	
    imageFlip.periodical(1000);
}

function imageFlip()
{
    imgFlip.setAttribute('src', srcFlipActive);
    var tmp = srcFlipActive;
    srcFlipActive = srcFlipInactive;
    srcFlipInactive = tmp;
}

var cat_fast;
var man_fast;

function searchInit(global, session)
{			
    searchInitCat();
}

function searchInitCat()
{
    if (cat_fast == undefined)
    {
        cat_fast = new MavSelectBox({
            elem: $('id_search_cat'), 
            onSelect: function()

            {					
                var idCat = $('id_search_cat').value;
            //	$('id_search_cat').value.substring(30);
            //	console.log($('id_search_cat'));
            //	var searchHref = $('search-href').value;
            //	window.location.href = searchHref + '&id_man=' + idMan;
            }
        });	
    }
	
    if (man_fast == undefined)
    {
        man_fast = new MavSelectBox({
            elem: $('id_search_man'), 
            onSelect: function()

            {					
                var idMan = $('id_search_man').value;
            //	var searchHref = $('search-href').value;
            //	window.location.href = searchHref + '&id_man=' + idMan;
            }
        });	
    }
}
var site_city;
function mapCitySearchInit()
{
    if (site_city == undefined)
    {
        site_city = new MavSelectBox({
            elem: $('id_city_select'), 
            onSelect: function()

            {					
                var idCity = $('id_city_select').value;
                window.location.href = idCity;
            //	$('id_search_cat').value.substring(30);
            //	console.log($('id_search_cat'));
            //	var searchHref = $('search-href').value;
            //	window.location.href = searchHref + '&id_man=' + idMan;
            }
        });	
    }
}
var main_cat_select;
var sub_cat_select;
var licence_select;
function searchCategorySelInit()
{
    if (main_cat_select == undefined)
    {
        main_cat_select = new MavSelectBox({
            elem: $('id_category_main'), 
            onSelect: function()
            {		
                var id_main_cat = $('id_category_main').value;
                var request_url = host_url+'/www/ajax.php?action=cat&id_cat='+id_main_cat;
                var json = new cmsAjaxResponse(request_url,{
                    loader: false,
                    completeFunction:function(){
                            
                    }
                }).doRequest();            
            }
        });	
    }
    if (sub_cat_select == undefined)
    {
        sub_cat_select = new MavSelectBox({
            elem: $('id_category_sub'), 
            id:'holder',
            onSelect: function()

            {					
                var id_sub_cat = $('id_category_sub').value;
            //  window.location.href = idCity;
            //	$('id_search_cat').value.substring(30);
            //	console.log($('id_search_cat'));
            //	var searchHref = $('search-href').value;
            //	window.location.href = searchHref + '&id_man=' + idMan;
            }
        });	
    }
    if (licence_select == undefined)
    {
    	licence_select = new MavSelectBox({
            elem: $('id_licence')//, 
           // id:'holder',
         //   onSelect: function()

           // {					
         //       var id_sub_cat = $('id_category_sub').value;
            //  window.location.href = idCity;
            //	$('id_search_cat').value.substring(30);
            //	console.log($('id_search_cat'));
            //	var searchHref = $('search-href').value;
            //	window.location.href = searchHref + '&id_man=' + idMan;
           // }
        });	
    }
}
function showBoxBanners(id)
{
    var links = $$('div.box-banners-nav a');
    
    var myFx = new Fx.Tween('box-banners-entry-'+id, {
        duration: 'long',
        transition: 'tween',
        link: 'cancel',
        property: 'height'
    });
    myFx.start(40, 100);
    $$('div.box-banners-entry').setStyle('display', 'none');
    $('box-banners-entry-'+id).setStyle('display', '');
	
    links.removeClass('box-banners-nav-active');
    links[id].addClass('box-banners-nav-active');
}

var shortCurImg = 0;
var shortCurArr = 5;
var shortCurTimer = 0;
var shortTabArr = new Array();

function shortInit( tab ){
	
    shortTabArr = $$('#shortcut-'+tab+' img');
	
    if (typeof(PicsArray[tab])!='undefined')
    {
        if ( shortCurImg >= shortTabArr.length ) shortCurImg = 0;
        if ( shortCurArr >= PicsArray[tab].length ) shortCurArr = 0;

        var curImg = shortTabArr[shortCurImg];
        //console.log( 'shortCurImg:'+ shortCurImg );
        //console.log( 'shortCurArr:'+ shortCurArr );
        Asset.image(PicsArray[tab][shortCurArr]);
        curImg.fade('out');
        (function(){
            curImg.src =  str_replace('&amp;','&',PicsArray[tab][shortCurArr]);
        }).delay(500);
        (function(){
            curImg.fade('in');
            shortCurImg++;
            shortCurArr++;
        }).delay(1000);
    }	
}

function showBoxShortcuts(id)
{
    var links = $$('div.box-shortcuts-nav a');
	
    $$('div.box-shortcuts-entry').setStyle('display', 'none');
    $('shortcut-'+id).setStyle('display', '');
    
   // $$('div.box-shortcuts-entry').fade('out');
   // $('shortcut-'+id).fade('in');
    
    $$('div.box-shortcuts-entry').each(function(el){
        el.fade('out');		
    });
    
    $('shortcut-'+id).fade('in');
    
    //initialize
    clearInterval(shortCurTimer);
    shortCurImg = 0;
    shortCurArr = 5;
    if (typeof(PicsArray[id])!='undefined')
    {	
        shortTabArr = $$('#shortcut-'+id+' img');
        shortTabArr.each(function(item, index){
            var curImg = shortTabArr[index];
            curImg.src =  str_replace('&amp;','&',PicsArray[id][index]);
        });
    }
		
    shortCurTimer = (function(){
        shortInit( id );
    }).periodical(2000);
	
    links.removeClass('box-shortcuts-nav-active');
    links[id].addClass('box-shortcuts-nav-active');
}
//
//function reloadAbout(id_art){
//    
//    
//    $$('.menu_a').addClass('menu_i');
//    $$('.menu_a').removeClass('menu_a');
//    $('menul'+id_art).removeClass('menu_i');
//  
//  
//    var myFx = new Fx.Slide('arttext');
//    myFx.slideOut('horizontal').chain(function(){
//        $('arttext').innerHTML = '';
//        
//        var request_url = host_url+'/www/ajax.php?action=about&id_art='+id_art;
//        var json = new cmsAjaxResponse(request_url,{
//            loader: false,
//            completeFunction:function(){
//                myFx.slideIn('horizontal')
//                }
//            }).doRequest();
//    });
//    $('menul'+id_art).addClass('menu_a');
//}
