var ran_unrounded=Math.random()*2;
var ran_number=Math.floor(ran_unrounded);
var featured_product;

// featured_product == 0 ==> Multisite
// featured_product == 1 ==> Flowing Pennies
// featured_product == 2 ==> Peek-a-Boo
// featured_product == 3 ==> crittersim
// featured_product == 4 ==> Dingaling
// featured_product == 5 ==> ZibblerPict
// featured_product == 6 ==> ZibblerScribe // not implemented yet
// featured_product == 7 ==> ZibblerTrip
// featured_product == 8 ==> ASCII Astro

switch (ran_number)
{
    case 0: // Bob
        var bobs_pick = Math.floor(Math.random()*10);
        switch (bobs_pick)
        {
            case 0:
                featured_product = 1;
                break;
            case 1:
                featured_product = 2;
                break;
            case 2:
                featured_product = 4;
                break;
            case 3:
                featured_product = 5;
                break;
            case 4:
            case 5:
            case 6:
                featured_product = 7;
                break;
            case 7:
            case 8:
            case 9:
                featured_product = 8;
                break;
        }
        break;
    case 1: // Elden
        featured_product = 0;
        break;
}

if (document.referrer.indexOf("apple.com/downloads/macosx/business_finance/flowingpennies") >= 0)
{
    featured_product = 1;
}

if (document.referrer.indexOf("apple.com/downloads/macosx/internet_utilities/multisiteforiweb") >= 0)
{
    featured_product = 0;
}

if (document.referrer.indexOf("apple.com/downloads/macosx/system_disk_utilities/peekaboo") >= 0)
{
    featured_product = 2;
}

if (document.domain.indexOf("crittersim.com") >= 0)
{
    featured_product = 3;
}

if (document.domain.indexOf("flowingpennies.com") >= 0)
{
    featured_product = 1;
}

if (document.domain.indexOf("zibbler.com") >= 0)
{
    featured_product = 7;
}

var splash = '';
splash += '<div id="nohilite">';
switch (featured_product)
{
    case 0:
        splash += '<div style="width:512px; float:right; padding-top:25px; text-align:center; ">';
        splash += '<a href="http://www.clarkwood.com/multisite/">';
        splash += '<img src="multisite512.jpg" width="431" height="426" border="0" /></a>';
        splash += '</div>';
        break;
    case 1:
        splash += '<div style="width:512px; float:right; padding-top:0; text-align:center; ">';
        splash += '<a href="http://www.clarkwood.com/flowingpennies/">';
        splash += '<img src="flowingpennies512.png" width="512" height="512" border="0" /></a>';
        splash += '</div>';
        break;
    case 2:
        if (Math.random() < 0.7)
        {
            splash += '<div style="width:512px; float:right; padding-top:2px; text-align:center; ">';
            splash += '<a href="http://www.clarkwood.com/peekaboo/">';
            splash += '<img src="peekaboo512.jpg" width="512" height="512" border="0" /></a>';
            splash += '</div>';
        }
        else
        {
            splash += '<div style="width:512px; float:right; padding-top:2px; text-align:center; ">';
            splash += '<a href="http://www.clarkwood.com/peekaboo/">';
            splash += '<img src="peekabooperspective.jpg" width="500" height="419" border="0" /></a>';
            splash += '</div>';
        }
        break;
    case 3:
        splash += '<div style="width:512px; float:right; padding-top:0; text-align:center; ">';
        splash += '<a href="http://www.clarkwood.com/crittersim/">';
        splash += '<img src="crittersim512.jpg" width="512" height="512" border="0" /></a>';
        splash += '</div>';
        break;
    case 4:
        splash += '<div style="width:512px; float:right; padding-top:0; text-align:center; ">';
        splash += '<br><object width="425" height="350"> <param name="movie" value="http://www.youtube.com/v/gNqveEV72IM"> </param> <embed src="http://www.youtube.com/v/gNqveEV72IM" type="application/x-shockwave-flash" width="425" height="350"> </embed> </object>';
        splash += '<br><br><center><a href="http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=292075489&mt=8"><img src="iphone_appstorebadge.jpg" width="367" height="120"/></a></center>';
        splash += '</div>';
        break;
    case 5:
        splash += '<div style="width:512px; float:right; padding-top:2px; text-align:center; ">';
        splash += '<a href="http://www.clarkwood.com/iphone/zibbler/">';
        splash += '<img src="zibbler512.png" width="512" height="512" border="0" /></a>';
        splash += '</div>';
        break;
    case 7:
        splash += '<div style="width:512px; float:right; padding-top:2px; text-align:center; ">';
        splash += '<a href="http://www.clarkwood.com/iphone/zibblertrip/">';
        splash += '<img src="zibblertrip512.png" width="512" height="512" border="0" /></a>';
        splash += '</div>';
        break;
    case 8:
        splash += '<div style="width:512px; float:right; padding-top:2px; text-align:center; ">';
        splash += '<a href="http://www.clarkwood.com/iphone/asciiastro/">';
        splash += '<img src="asciiastro512.png" width="512" height="512" border="0" /></a>';
        splash += '</div>';
        break;
    default:
        splash += 'nuttn';
        break;
}

splash += '<div style="width:191px; text-align:center; margin-top:3px; ">';
splash += '<div style="height:77px; padding-top: 2px; border-bottom:#d6efe7 1px solid; ">';
splash += '<div style="float:left; ">';
splash += '<img src="logoimg.gif" width="70" height="76" />'
splash += '</div>';
splash += '<div style="font: normal 1.8em/1.6em Times, serif; padding-top:7px; text-align:center; color:#444; ">clarkwood</div>';
splash += '<div style="font: normal 1.4em/1.4em Times, serif; margin-top:-10px; text-align:center; color:#999; text-rendering: optimizeLegibility; ">SOFTWARE</div></div></div>';

splash += '<br>';

splash += '<div style="height:420px; ">';
switch (featured_product)
{
    case 0:
        splash += '<div style="font-size: 17px;" >';
        splash += '<br><br><br>';
        splash += '<p>';
        splash += 'When using iWeb, do you find yourself wishing you could develop two or more sites';
        splash += ' and publish them separately?<br><br><br><a href="http://www.clarkwood.com/multisite/">';
        splash += 'Multisite for iWeb</a> solves your dilemma.';
        splash += '</p>';
        splash += '</div>';
        break;
    case 1:
        splash += '<br><br><br><br><p>';
        splash += '<a href="http://www.clarkwood.com/flowingpennies/">Flowing Pennies</a>,';
        splash += ' a Mac OS X personal finance solution, offers simplicity and clarity.';
        splash += '</p><br><br><br><br><br><br>';
        splash += '<p>';
        splash += '<div style="font: normal 11pt Zapfino, fantasy; letter-spacing: 1px; color: #272; padding-top:3px; text-align:center;" >';
        splash += 'Bring simplicity<br>to your finances.</div></p>';
        break;
    case 2:
        splash += '<center><br><br><a href="http://www.clarkwood.com/peekaboo/">Peek-a-Boo</a><br><br>Explore OS X Processes.<br><br><br><a href="http://itunes.apple.com/us/app/peek-a-boo/id463360323?ls=1&mt=12"><img src="http://www.clarkwood.com/peekaboo/Mac_App_Store_Badge_US_UK.png" width="160" height="52"></a></center>';
        break;
    case 3:
        splash += '<center><br><br><br><a href="http://www.clarkwood.com/crittersim/">Crittersim</a>';
        splash += '<br><br><br>Life&#8217;s little backyard...</center>';
        break;
    case 4:
        splash += '<center><br><a href="http://www.clarkwood.com/iphone/dingaling/">';
        splash += '<div id="nohilite"><img src="dingaling.png" alt="Dingaling icon" width="127" height="138" border=0></div>';
        splash += '<br>Dingaling</a><br>';
        splash += 'Turn your iPhone<br>into a handbell!</center>';
        break;
    case 5:
        splash += '<center><br><br><a href="http://www.clarkwood.com/iphone/zibbler/">ZibblerPict</a>';
        splash += '<br><br><a href="http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=297025259&mt=8"><img src="iphone_appstorebadge.jpg" width="183" height="60"/></a>';
        splash += '<br><br>Doodle.<br>Sketch.<br>Draw.<br>Scrawl.<br>Finger-painting.<br><br>All on your iPhone.';
        splash += '</center>';
        break;
    case 7:
        splash += '<center><br><br><a href="http://www.clarkwood.com/iphone/zibblertrip/">ZibblerTrip</a>';
        splash += '<br><br><a href="http://itunes.apple.com/us/app/zibblertrip/id469869983?ls=1&mt=8"><img src="iphone_appstorebadge.jpg" width="183" height="60"/></a>';
        splash += '<br><br>A speedometer while you&rsquo;re moving.<br>Trip analysis after you&rsquo;re done.';
        splash += '</center>';
        break;
    case 8:
        splash += '<center><br><br><a href="http://www.clarkwood.com/iphone/asciiastro/">ASCII Astro</a>';
        splash += '<br><br><a href="http://itunes.apple.com/us/app/ascii-astro/id475907025?ls=1&mt=8"><img src="iphone_appstorebadge.jpg" width="183" height="60"/></a>';
        splash += '<br><br><font color="007700" size="+2"><strong><pre>TILT TO AVOID<br>OBSTACLES</pre></strong></font>';
        splash += '</center>';
        break;
}
splash += '</div>';

splash += '</div>';

document.write(splash);

