var TimeOutID;

function showContentFirstPage() {
        window.clearInterval(TimeOutID);
        if (jQuery.browser.msie) {
            $("#ohayo").css('background', 'url("/i/spaser.gif")');
        }
        $("#content").fadeIn(2000, function() {if (jQuery.browser.msie) {}});
    }
function showContent() {
    //680
    window.clearInterval(TimeOutID);
    if (!jQuery.browser.opera) {
        $("#content")
        .slideDown("slow")
        .animate({ 
            width: "680px"
        }, 1500, null, function() {$("#textBlock").fadeIn("slow", function() { if (openedSection>0){openSection(openedSection);} CSBfleXcroll('mycustomscroll2'); } );})
    }
    else {
        
        $("#content")
        .css("width", "680px")
        .slideDown("slow", function() {$("#textBlock").fadeIn("slow", function() { if (openedSection>0){openSection(openedSection); } else {CSBfleXcroll('mycustomscroll2');} } ) } )
        
    }
       
}

function openSection(i) {
    if ($("#content_"+i).css('display') != 'none') return;
    
    if (openedSection>0 && openedSection!=i) {
        $("#a"+openedSection).css('color', '#fff');
        $("#content_"+openedSection).fadeOut("fast", function(){
                $("#content_"+i).fadeIn("slow");
                /*if(i!=5)*/ {CSBfleXcroll('mycustomscroll2'); $('#showBox a').lightBox();$('#showBox2 a').lightBox();} });
    }
    else {
        $("#content_"+i).fadeIn("slow", function(){
        /*if(i!=5)*/ { CSBfleXcroll('mycustomscroll2'); $('#showBox a').lightBox(); $('#showBox2 a').lightBox();} });
    }
    $("#a"+i).css('color', '#FF4720');
    openedSection = i;
}

$(document).ready(function(){
    var openId = 0;
    
    $("span.menutitle").click(function () { 
        if ($("#sub_"+this.id).is(":hidden")) {
            if (openId>0) {
                $("#sub_"+ openId).slideUp("slow");
            }
            $("#sub_"+this.id).slideDown("slow");
            openId = this.id;
        }
        else {
            $("#sub_"+this.id).slideUp("normal");
        }
        //return false;
    });
    
    if ($("#content").is(":hidden")) {
        if (ParentId>0) {
            $("#sub_"+ParentId).slideDown("slow");
        }
        
        if (isFirstPAge) {
            TimeOutID = window.setInterval('showContentFirstPage()',1500); 
        }
        else if (ParentId>0 && isModel==0) {
            openId = isModel;
            $("p").css('padding', '0px 0px 0px 60px');
            $("p").css('margin', '0px 0px 0px 0px');
            $("h1").css('height', '40px');
            
            $("#content").css('width', '680px');
            $("#content").css('height', '500px');
            
            $("#content").css('display', 'block');
            $("#content").css('background', 'url("/i/spaser.gif")');
            $("#textBlock").fadeIn(2500);
            
        }
        else {
            TimeOutID = window.setInterval('showContent()',300);
        }
        
        
    }
   
});

var ShopObj = function(){ 
    return { 
        model:
    	   function (id) {
    		location.href = '/model/'+id+'';
        }
    }
}(); 
