
var initMultiBox2;

function start2(){
    if ($('gal_image')) actGalChang();
    if (list = $$('.pages a')) actRightPages(list);
    if (list2 = $$('.reg_hov')) actReg(list2);
    
     if ($('gallery_container')) {
    new SlideItMoo({itemsVisible:4, // the number of thumbnails that are visible
                    currentElement: 0, // the current element. starts from 0. If you want to start the display with a specific thumbnail, change this
                    thumbsContainer: 'thumbs',
                    elementScrolled: 'thumb_container',
                    overallContainer: 'gallery_container'
    });
    
    }
}

function initMultiboxes(){
    var initMultiBox = new multiBox({
        mbClass: '.mb',//class you need to add links that you want to trigger multiBox with (remember and update CSS files)
        container: $(document.body),//where to inject multiBox
        descClassName: false,//the class name of the description divs
        path: './Files/',//path to mp3 and flv players
        useOverlay: true,//use a semi-transparent background. default: false;
        addDownload: false,//do you want the files to be downloadable?
        pathToDownloadScript: './Scripts/ForceDownload.asp',//if above is true, specify path to download script (classicASP and ASP.NET versions included)
        addRollover: false,//add rollover fade to each multibox link
        showControls: true,
        addOverlayIcon: false,//adds overlay icons to images within multibox links
        addChain: false,//cycle through all images fading them out then in
        recalcTop: false,//subtract the height of controls panel from top position
        //fixedTop: true,
        addTips: false//adds MooTools built in 'Tips' class to each element (see: http://mootools.net/docs/Plugins/Tips)
    });
    
    initMultiBox2 = new multiBox({
        mbClass: '.mbhtml',//class you need to add links that you want to trigger multiBox with (remember and update CSS files)
        container: $(document.body),//where to inject multiBox
        descClassName: false,//the class name of the description divs
        path: './Files/',//path to mp3 and flv players
        useOverlay: true,//use a semi-transparent background. default: false;
   //     maxSize: {w:900, h:400},//max dimensions (width,height)
        addDownload: false,//do you want the files to be downloadable?
        pathToDownloadScript: './Scripts/ForceDownload.asp',//if above is true, specify path to download script (classicASP and ASP.NET versions included)
        addRollover: false,//add rollover fade to each multibox link
        addOverlayIcon: false,//adds overlay icons to images within multibox links
        addChain: false,//cycle through all images fading them out then in
        recalcTop: false,//subtract the height of controls panel from top position
        addTips: false//adds MooTools built in 'Tips' class to each element (see: http://mootools.net/docs/Plugins/Tips)
    });
    
     var initMultiBox3 = new multiBox({
        mbClass: '.mb2',//class you need to add links that you want to trigger multiBox with (remember and update CSS files)
        container: $(document.body),//where to inject multiBox
        descClassName: false,//the class name of the description divs
        path: './Files/',//path to mp3 and flv players
        useOverlay: true,//use a semi-transparent background. default: false;
        addDownload: false,//do you want the files to be downloadable?
        pathToDownloadScript: './Scripts/ForceDownload.asp',//if above is true, specify path to download script (classicASP and ASP.NET versions included)
        addRollover: false,//add rollover fade to each multibox link
        showControls: false,
        addOverlayIcon: false,//adds overlay icons to images within multibox links
        addChain: false,//cycle through all images fading them out then in
        recalcTop: false,//subtract the height of controls panel from top position
        addTips: false//adds MooTools built in 'Tips' class to each element (see: http://mootools.net/docs/Plugins/Tips)
    });     
}

function actGalChang(){
    $each($$('.fotoname'), function(element, i){  
         element.addEvent('click', function(){
              $('gal_image').src = element.href;
              return false;
         }); 
    });
}
 
function submSort(t,ob){
 var op = ob.parentNode;
 $('ordd').value = op.hasClass('desc') ? 1 : 0;
 
 $('orderd').value = t;
 $('s_catalog').submit();
 
}

function submSort2(t,ob){
 var op = ob.parentNode;
 ordd = op.hasClass('desc') ? 1 : 0;
 document.location.href = 'regat?order='+t;

 
}

function actRightPages(list){
   $each(list, function(el, i){ 
        el.addEvent('click', function(){
              var ar = el.href.split('/');
              var p = ar[ar.length-1];
              sendPage(p,list);
              return false;  
         }); 
        
   });
}

function actReg(list){
   $each(list, function(el, i){ 
        el.addEvent('click', function(){
              var a = this.getElement('a')
             document.location.href = a.href
              
         }); 
         
          el.addEvent('mouseenter', function(){ 
              this.addClass('reg_ho');
              var img = this.getElement('img');
              img.setStyle('display', 'block');
         });
         
          el.addEvent('mouseleave', function(){
              this.removeClass('reg_ho');
              var img = this.getElement('img');
              img.setStyle('display', 'none');
         });
        
   });
}

function sendPage(n,list){
    var tt = $('type') ? $('type').value : 0;
    var r = $('freg') ? $('freg').value : 0;
    var places = $('fplaces') ? $('fplaces').value : 0;
    var url = '/mods/a.function.php';
    
    var str = "aj=9&n="+n+"&tt="+tt+"&r="+r+"&places="+places; 
    var requ = new Request.HTML({url: url, onSuccess: function(responseText, responseXML){
                                    var el = $('mods');
                                    el.empty().adopt(responseText);
                                        $each(list, function(el, i){
                                            if((n-1)!=i) el.removeClass('pag');
                                                else el.addClass('pag');
                                        });
                                    startMods();
                                    }});    
    requ.send(str);    
    
}

function compare(id, type, ob, img){
    var obj = $('id'+id);    
    var url = 'mods/a.function.php';
    var str = "aj=10&id="+id+"&type="+type+"&sid="+sid; 
    var requ = new Request.HTML({url: url, onSuccess: function(responseText, responseXML){
                                    
                                    if(img) {
                                        $('ieid').set('html', '<img src="img/compare_.gif" />Добавлено в сравнение');
                                        $('ieid').set('href', 'compare/gulet');
                                        $('ieid').addClass('ccacta'); 
                                    }else {
                                        obj.set('html', 'Добавлено в сравнение'); 
                                        obj.set('href', 'compare/bareboat'); 
                                        ob.addClass('ccacta'); 
                                    }
                                        if($('switcher')){
                                            $('switcher').setStyle('display', 'block');
                                            $('switcherrem').removeClass('last');
                                        }  
                                    }});    
    requ.send(str);    
}

function removeComp(id, type){
    var url = 'mods/a.function.php';
    
    var str = "aj=14&id="+id+"&type="+type+"&sid="+sid; 
    var requ = new Request.HTML({url: url, onSuccess: function(responseText, responseXML){
                                    
                                    if(responseText && (responseText.item(0).nodeValue=='bareboat' || responseText.item(0).nodeValue=='gulet')) {
                                        document.location.href = 'catalog/'+responseText.item(0).nodeValue;
                                    }else {
                                       
                                        document.location.href = document.location.href;    
                                        
                                    }
                                    }});    
    requ.send(str);    
}

function chList(n,ob){
   var t = n ? 0 : 1; 
   $('cat_sw'+n).setStyle('display', 'block'); 
   $('cat_sw'+t).setStyle('display', 'none'); 
   
   $('lin_'+n).addClass('noact_link');
   $('lin_'+t).removeClass('noact_link');
   
   $('svis').setStyle('display', (!n ? 'block' : 'none')); 
   
}

function printdoc(clas){  
    var conthtml = '';
    
    
    
    $each($$(clas), function(element, i){
           conthtml += element.innerHTML + '<br />';  
        });
        
     var html = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'
                + '<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="ru-ru" xml:lang="ru-ru">'
                +'<head>'
                +'<meta http-equiv="content-type" content="text/html; charset=UTF-8" /> '
                + '<style type="text/css">'
                + ' body{ font-family: Times New Roman; font-size: 10pt; color: #000; background: #fff;} '
                + ' h1{ font-size: 18pt;} '
                +'</style>'
                + '<script language="Javascript">'
                + ' function printpage(){ window.focus(); window.print(); }'
                + ' </script> '
                + '</head><body onload="printpage()">'
                + conthtml
                + '</body></html>';
            
    var frame = new Element('iframe', {'id': 'iprint'}).injectInside($('frame'));
        var testFrame = frame;
        var doc = testFrame.contentDocument;
        if (doc == undefined || doc == null)
            doc = testFrame.contentWindow.document;
        doc.open();
        doc.write(html);
        doc.close(); 

}
