Question: hello I have two div on my page. 

```
<div id="adsense" style="display:block">some stuff</div>
<div id="timeout" style="display:none>Some stuff</div>

```

I have a variable `var type`.

The page on which these two div's are loads two times. First time the type=0. At this time i want to show the `<div id="adsense">`. Then the page goes to other pages and when the page loads second time the type becomes 1.

Now what I want is at first page load the `<div id="adsense">` to be shown. When page reloads `type becomes 1` I want to show the `<div id="timeout">` for 9 seconds and then again switch to first div.

I want to know how can I do that? How can I embed if condition in it.

Answer: 
I hope I understood correctly:

```
(function(){
    // put the code that will evaluate the value of 'type' here

    var $adsense = $("#adsense");
    var $timeout = $("#timeout");
    if(type == 0) {
        $timeout.hide();
        $adsense.show();        
    } else if (type == 1) {     
        $adsense.hide();
        $timeout.show();        
        setTimeout(function() {
            $timeout.hide();
            $adsense.show();
        }, 9000);
    }
});

```

This can of course be optimized, its mainly for understanding how it works.
I'm not sure I fully understand you but maybe you could so something like

```
function showAdsenseDiv(){
    //show adsense div    
}

function showTimeoutDiv(){
    //show timeout div
}

showAdsenseDiv();
setTimeout(showTimeoutDiv, 9000);

```