var box;
var link;    
var initMultiBox;
function start(){
    box = 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;
        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
        showControls: false,//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)
    });
    
    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
        addOverlayIcon: false,//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)
    });
    
    
    //if ($$('.images')) startGal();
    

}

function showBox(url){
    var ob = $('overlay');
    var fla = $(url);
    ob.setStyles({
        'display': 'block', 
        'opacity': .7,
        height: window.getScrollSize().y
    });

    fla.setStyle('display', 'block');
    
    var top = (($(window).getHeight() - fla.getHeight()) / 2) + window.getScroll().y;
    var left = ($(window).getWidth() - fla.getWidth()) / 2;
    
    fla.setStyles({
        top: top,
        left: left
    });
    
}
function closeBox(url){
    var ob = $('overlay');
    var fla = $(url);
    
    ob.setStyles({'display': 'none', 'opacity': 0});
    fla.setStyle('display', 'none');
}





function submF(form, cl){
    if(checkForm(cl)){
        var form = $(form); 
        var stri = 'aj.php?sid='+SID;       
        form.set('send', {url: stri, evalResponse: true});
        form.send();
        
         
        return false;
    }
}

function checkForm(cl){
   var clean = true;
   var mail = false;
   $each($$("."+cl), function(element, i){      
        element.addClass('succ');
        element.removeClass('unsucc');
        
        if(element.nodeName == 'INPUT' || element.nodeName == 'input'){        
                if(!element.value || element.value == 'Введите код'){
                    element.removeClass('succ');
                    element.addClass('unsucc');    
                        clean = false;
                }else{
                    if(element.name == 'mail' || element.name == 'email'){
                         var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
                         var address = element.value; 
                         if(reg.test(address) == false) {
                               element.removeClass('succ');
                        element.addClass('unsucc');
                               clean = false;
                               mail = true;
                         } 
                    }
                }
          }else if(element.nodeName == 'SELECT' || element.nodeName == 'select'){
                if(!element.selectedIndex){
                        element.removeClass('succ');
                    element.addClass('unsucc');
                        clean = false;
                }
          }else if(element.nodeName == 'TEXTAREA' || element.nodeName == 'textarea'){
                if(!element.value){
                        element.removeClass('succ');
                    element.addClass('unsucc');
                        clean = false;
                }
          }
   });
 
   if(!clean) {
        if(mail) alert('Вы ввели неверный E-mail !'); else alert('Заполните необходимые поля!');  
        }
   return clean;
}


