


function start(){
    corrH();
    actSub();
    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: false,//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: true,//adds overlay icons to images within multibox links
        showControls: true,//adds overlay icons to images within multibox links
        showNumbers: false,
        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)
        clos: 'close2'
    });
    
    if($('proj')) {
        startUpload();
        actEditor(); 
    }
  
}

var editor0 = false;
var editor1 = false;

function showObject(obj) {
    var result = ""
    for (var i in obj){
        result +=  "" + i + " = " + obj[i] + "\n";
    }
    return result;

}


function actEditor(){

try{
editor0 = new EDITOR('fire0', {
    page: '',
     upload: {
       request: 'crop=0&prevu=130&max=600',     
       dop: 0,
      // nomultiple: true,
       type: 'area'      
    } 
});
                
editor1 = new EDITOR('fire1', {
    page: '',
     upload: {
       dop: 0,
       request: 'crop=0&prevu=130&max=600',     
      // nomultiple: true,
       type: 'area'      
    } 
});  

              
new EDITOR('fire2', {
    page: '',
    mode: 'slide',
     upload: {
       request: 'max=800&prevu=116',   
      // addCroper: {'w':220, 'h':145, 'pics': 126},     
       dop: 0,
       nomultiple: true,
       type: 'area'      
    } 
}); 
}catch (e) {
    alert(showObject(e));
}
              
}

var hid = false;
function actSub(){
	$('sub').addEvents({
		'mouseenter': function(){
			$('sub0').setStyle('display', 'block');
		},
		'mouseleave': function(){
			hid = (function(){$('sub0').setStyle('display', 'none')}).delay(200);
		}
        });
        
        $('sub0').addEvents({
		'mouseenter': function(){
			$clear(hid);
		},
		'mouseleave': function(){
			this.setStyle('display', 'none');
		}
        });
        
}

function corrH(){
    var h = $('main_tab').getHeight();
    var hm = $('main').getHeight();
    if(h<1245) $('main_tab').setStyle('height', '1245px');   
    if(hm>1360) $('main').setStyle('padding-bottom', '100px');   
}


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(); 

}










function footOver(){
    $each($$('.foot_links a'), function(element, i){
        element.addEvent('mouseenter', function(){
            var reg = /(.*?)\.gif/;
            var ima = this.getElement('img');
            ima.src = ima.src.replace(reg, "$1_.gif");
        });
        element.addEvent('mouseleave', function(){
            var reg = /(.*?)\_.gif/;
            var ima = this.getElement('img');
            ima.src = ima.src.replace(reg, "$1.gif");
        });
    });
}

function startTitls(){
    $each($$('.titls img'), function(element, i){
        element.addEvent('mouseenter', function(){
            var reg = /(.*?)\.gif/;
            this.src = this.src.replace(reg, "$1_.gif");
        });
        element.addEvent('mouseleave', function(){
            var reg = /(.*?)\_.gif/;
            this.src = this.src.replace(reg, "$1.gif");
        });
   });
}

function startDoska(){
    $each($$('.item_img'), function(element, i){
        element.addEvent('mouseenter', function(){
            this.style.backgroundColor = '#fffe8c';
        });
        element.addEvent('mouseleave', function(){
            this.style.backgroundColor = '';
        });
   });
   var rat = $$('.rat_in');
   
   $each($$('.vote'), function(el, z){
        el.addEvent('mouseenter', function(){
            var reg = /(.*?)\.gif/;
            if (Browser.Engine.trident){
                rat[z].style.backgroundColor = '#fffe8c';
                this.parentNode.parentNode.childNodes[0].style.backgroundColor = '#fffe8c';
            }else{
                //rat[z].style.backgroundColor = '#fffe8c';
                m[z].style.backgroundColor = '#fffe8c';
                this.parentNode.parentNode.childNodes[1].style.backgroundColor = '#fffe8c';
            }
            
            this.childNodes[0].childNodes[0].src = this.childNodes[0].childNodes[0].src.replace(reg, "$1_.gif");
            
        });
        el.addEvent('mouseleave', function(){
            var reg = /(.*?)\_.gif/;
            if (Browser.Engine.trident){
                this.parentNode.childNodes[0].style.backgroundColor = '';
                rat[z].style.backgroundColor = '';
            }else{
                rat[z].style.backgroundColor = '';
            }
            this.childNodes[0].childNodes[0].src = this.childNodes[0].childNodes[0].src.replace(reg, "$1.gif");
        });
   });
   
   $each($$('.rat_in'), function(elem, w){
        elem.addEvent('mouseenter', function(){
            this.style.backgroundColor = '#fffe8c';
            if (Browser.Engine.trident){
                this.parentNode.parentNode.childNodes[0].style.backgroundColor = '#fffe8c';
            }else{
                this.style.backgroundColor = '#fffe8c';
                //m[w].style.backgroundColor = '#fffe8c';
                this.parentNode.parentNode.childNodes[1].style.backgroundColor = '#fffe8c';
            }            
        });
        elem.addEvent('mouseleave', function(){
            this.style.backgroundColor = '';
            if (Browser.Engine.trident){
                this.parentNode.parentNode.childNodes[0].style.backgroundColor = '';
            }else{
                rat[w].style.backgroundColor = '';
                this.parentNode.parentNode.childNodes[1].style.backgroundColor = '';
            }
        });
   });
}

function startInSlide(){
    myAccordion = new Accordion($$('.toggle'), $$('.slide'), {
            onActive: function(toggler, slider){
                if (Browser.Engine.trident) slider.setStyle('display', 'block');
                //slider.setStyle('padding-bottom', '20px');
            },
            onBackground: function(toggler, slider){
                if (Browser.Engine.trident) slider.setStyle('display', 'none');
            },
            onComplete: function(){
                
            },

            opacity: 0,
            display: false,
            alwaysHide: true
    });
}
function re(){
    $each($$('.imagi img'), function(element, i){
        
        element.addEvent('mouseenter', function(){
            
            this.parentNode.parentNode.style.backgroundColor = '#fff';
            
        });
        element.addEvent('mouseleave', function(){
            this.parentNode.parentNode.style.backgroundColor = '';
            
        });
    });
}
function startImag(){
    $each($$('.imag img'), function(element, i){
        element.addEvent('mouseenter', function(){
            this.parentNode.parentNode.setStyle('background-color', '#fff');
            
        });
        element.addEvent('mouseleave', function(){
            if (!element.parentNode.parentNode.hasClass('cur_dom')) this.parentNode.parentNode.setStyle('background-color', '');
        });
   });
   
   
    if ($$('.imag_numb')){
        $each($$('.imag_numb'), function(element, i){
            element.addEvent('mouseenter', function(){
                $('im'+i).parentNode.setStyle('background-color', '#fff');
                this.parentNode.setStyle('background-color', '#fff');
            });
            element.addEvent('mouseleave', function(){
                if (!element.hasClass('cur_dom')) this.parentNode.parentNode.setStyle('background-color', '');
            });
       });
   }
}
function startDomik(){
    $each($$('.imag'), function(element, i){
        if (!element.hasClass('cur_dom') && element.hasClass('domiki')) {
             $('im'+i).setStyle('opacity', .5);
        }
        
        element.addEvent('mouseenter', function(){
            if (!element.hasClass('cur_dom')) {
                this.setStyle('background-color', '#fff');
                this.childNodes[0].style.backgroundColor = '#fff';
                this.childNodes[0].style.display = 'block';
                //alert(this.className)
            }
            if (element.hasClass('domiki')) $('im'+i).setStyle('opacity', 1);
        });
        element.addEvent('mouseleave', function(){
            if (!element.hasClass('cur_dom')){ 
                this.setStyle('background-color', '');
                this.childNodes[0].style.backgroundColor = '';
                this.childNodes[0].style.display = 'none';
                if (element.hasClass('domiki')) $('im'+i).setStyle('opacity', .5);
            }
            
        });
   });
   
   
    if ($$('.imag_numb')){
        $each($$('.imag_numb'), function(element, i){
            element.addEvent('mouseenter', function(){
                $('im'+i).parentNode.parentNode.setStyle('background-color', '#fff');
                this.parentNode.setStyle('background-color', '#fff');
            });
            element.addEvent('mouseleave', function(){
                if (!element.hasClass('cur_dom')) this.parentNode.parentNode.parentNode.setStyle('background-color', 'transparent');
            });
            element.addEvent('click', function(){
                var a = this.parentNode.getElement('a').href;
                document.location.href = a;
            });
       });
   }
}

function startNavPage(){
    $each($$('.pages2 a'), function(element, i){
        element.addEvent('click', function(){
            var ima = $('domik_images').getElement('img');
            var nim = $('img_name_'+i).value;
            ima.setAttribute('src', 'user.img/'+nim);
            remClass()
            this.addClass('page2');
            Cufon.replace('.pages2 a', {fontFamily: 'AGLettericaCondensed', hover: true});
        });
   });
}

function remClass(){
	$each($$('.pages2 a'), function(element){
		element.removeClass('page2');
		
	});
	return true;
}

function showTab(url){
    var ob = $('over');
    var fla = $(url);
    ob.setStyles({
        'display': 'block', 
        'opacity': .8,
        height: window.getScrollSize().y
    });
    fla.setStyle('display', 'block');
    
    var w = $(window).getWidth();
    //w = w-400;
    w=900;
    fla.setStyles({'width': w+'px', 'height': 440, 'background': '#afd898'});
    
    var top = (($(window).getHeight() - fla.getHeight()) / 2) + window.getScroll().y;
    var left = ($(window).getWidth() - fla.getWidth()) / 2;
    
    fla.setStyles({
        top: top,
        left: left
    });
    
    ob.addEvent('click', function(){
        ob.setStyles({'display': 'none', 'opacity': 0});
        fla.setStyle('display', 'none');
    });
}
function closeBox(url){
    var ob = $('over');
    ob.setStyles({'display': 'none', 'opacity': 0});
    
    if(url=='all'){
    	var fla = $('tab0');
    	var fla1 = $('tab1');
    
	fla.setStyle('display', 'none');
    	fla1.setStyle('display', 'none');
    }else{
	var fla = $(url);
	fla.setStyle('display', 'none');
    }
    
    
}

function correctBrowser(){
   var ob = $('container');
   var ob1 = $('container2');
   var ob2 = $('container3');
   var ob3 = $('container4');
   var style = '0 0 0 1px';
   if(Browser.Engine.trident) style = '0 0 0 2px'; 
   if(Browser.Engine.gecko) style = '0 0 0 2px'; 
   if(Browser.Engine.webkit || Browser.Engine.presto) style = '0 0 0 3px'; 
   
   if ($('container')) if(style) ob.setStyle('padding',style); 
   if ($('container2')) if(style) ob1.setStyle('padding',style); 
   if ($('container3')) if(style) ob2.setStyle('padding',style); 
   if ($('container4')) if(style) ob3.setStyle('padding',style); 
    
}

function startMenu(){
   $each(menu_array, function(element, i){
        element.addEvent('mouseenter', function(){
             if(timeout) clearTimeout(timeout);
             hideAllS(i);
             
        });
        element.addEvent('mouseleave', function(){
             timeout = setTimeout('hideAllS();', 90);
             
        });
   });
   
   $each(menu_proj, function(element, i){ 
         element.addEvent('mouseenter', function(){
             if(timeout) clearTimeout(timeout);
             hideAllS(i);
         });
         element.addEvent('mouseleave', function(){
             timeout = setTimeout('hideAllS();', 40);
         });
             
   });
   
}
function hideAllS(act){
    $each(menu_array, function(element, i){
        if(menu_proj[i]) {
        if(act !== false && act==i) {
             menu_proj[i].setStyle('display', 'block');
            element.setStyle('background-color', '#2f6312');
        } else {
            menu_proj[i].setStyle('display', 'none');
            element.setStyle('background-color', '');
        } 
        }
    });
}


function startWeather(){
    $each($$('.foot_links a'), function(element, i){ 
         element.addEvent('mouseenter', function(){
            $('v'+i).setStyle('display', 'block');
            if(Browser.Engine.webkit) $('v'+i).setStyle('left', '615px');
            if(Browser.Engine.presto) $('v'+i).setStyle('left', '616px');
            if(Browser.Engine.trident5) $('v'+i).setStyle('left', '613px');
            if(Browser.Engine.trident4) $('v'+i).setStyles({'left': '613px', 'bottom': '159px'});
         });
         element.addEvent('mouseleave', function(){
            $('v'+i).setStyle('display', 'none');
         });
             
   });   
}

function hideAllW(act){
    $each($$('.foot_links a'), function(element, i){
        if(act !== false && act==i) {
            
            
        } else {
            
        } 
    });
}

function startPart(){
    $each($$('.partners img'), function(element, i){
        element.setStyle('opacity', .5);
        
        element.addEvent('mouseenter', function(){
            this.setStyle('opacity', 1);
        });
        element.addEvent('mouseleave', function(){
            this.setStyle('opacity', .5);
        });
    });
}

function startSlideComment(){
    myAccordion = new Accordion($$('.leave_comment'), $$('.comment_form'), {
            onActive: function(toggler, slider){
                if (Browser.Engine.trident) slider.setStyle('display', 'block');
                //slider.setStyle('padding-bottom', '20px');
            },
            onBackground: function(toggler, slider){
                if (Browser.Engine.trident) slider.setStyle('display', 'none');
            },
            onComplete: function(){
                
            },

            opacity: 0,
            display: false,
            alwaysHide: true
    });
}
