$(function(){
    

    
    
    if ($("a[rel=wzoom]").length) {
        
        $("a[rel=wzoom]").parent().addClass('tormove').after("<div id='mkgl'></div>");
        $("#mkgl").html($("a[rel=wzoom]").parent().html());
        $(".tormove").remove();
        
        $("#mkgl a").lightBox();
        
    }
    
    
    
	$(".wmali").each(function(){
		targ = $(this).text(); tmp = targ.split('~');
		$(this).text(tmp[0]+"@"+tmp[2]).attr("href","mailto:"+tmp[0]+"@"+tmp[2]);
	});
    
    
    
    // если есть вложенное меню, переназначаем сылки для их открытия и закрытия
    
    $("#m ul ul").each(function(){
        $(this).addClass("subulclosed");
        $(this).parent().find("a:first").click(function(){
            
            if ($(this).parent().find("ul").hasClass("subulclosed")) {
                $(".subulopened").attr("class","subulclosed").slideUp(300);
                $(this).parent().find("ul").slideDown(300,function(){$(this).attr("class","subulopened")});
            } else {
                $(this).parent().find("ul").slideUp(300,function(){$(this).attr("class","subulclosed")});
            }
            return false;
        });
    });
    
    if ($(".msel").length) {
		if ($(".msel:first").parent().find('ul').length>0) {
			$(".msel:first").parent().find('ul').attr("class","subulopened").show();
		}
    }
    
    
    
    
});





function getBrowserInfo() {
    var t,v = undefined;
    if (window.opera) t = 'Opera';
    else if (document.all) {
       t = 'IE';
       var nv = navigator.appVersion;
       var s = nv.indexOf('MSIE')+5;
       v = nv.substring(s,s+1);
    }
    else if (navigator.appName) t = 'Netscape';
    return {type:t,version:v};
}
 
function bookmark(a){
    var url = window.document.location;
    var title = window.document.title;
    var b = getBrowserInfo();
    if (b.type == 'IE' && 7 >= b.version && b.version >= 4) {
        window.external.AddFavorite(url,title);
    } else if (b.type == 'Opera') {
        a.href = url;
        a.rel = "sidebar";
        a.title = url+','+title;
        return true;
    } else if (b.type == "Netscape") {
        window.sidebar.addPanel(title,url,"");
    } else {
        alert("Нажмите CTRL-D, чтобы добавить страницу в закладки.");
    }
    return false;
}

