<html><head><meta http-equiv="Content-type" content="text/html; charset=UTF-8">
<link rel="icon" href="http://www.cooliris.com/favicon.ico" type="image/x-icon"> 
<link rel="shortcut icon" href="http://www.cooliris.com/favicon.ico" type="image/x-icon"> 
<title>Cooliris</title>
<style type="text/css">
body {
margin: 0px;
overflow: hidden;
background-color: #000000;
color: #ffffff;
}
</style>
<script type="text/javascript" src="http://www.google-analytics.com/ga.js"></script>
<script type="text/javascript" src="http://b.scorecardresearch.com/beacon.js"></script>
<script type="text/javascript">
var _qoptions={qacct:"p-4bmyopS-ggoEk"},
    cooliris = null,
    currentHash = location.hash,
    ignoreNextFeedChange = false,
    anchorHolder = null,
    anchors = {},
    head = document.getElementsByTagName('head')[0],
    origNrRows,
    home = '#f=Home',
    Cookie=(function(){return{set:function(name,value,days,domain,path){var expires="";if(days){var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));expires="; expires="+date.toGMTString();}if(!domain)domain=document.domain;if(!path)path='/';document.cookie=name+"="+value+expires+"; path="+path+"; domain="+domain;},eat:function(name){this.set(name,"eaten",-10);},get:function(cookieName){var a_all_cookies=document.cookie.split(';');var a_temp_cookie='';var cookie_name='';var cookie_value='';var b_cookie_found=false;for(var i=0;i<a_all_cookies.length;i++){a_temp_cookie=a_all_cookies[i].split('=');cookie_name=a_temp_cookie[0].replace(/^\s+|\s+$/g,'');if(cookie_name==cookieName){b_cookie_found=true;if(a_temp_cookie.length>1){cookie_value=unescape(a_temp_cookie[1].replace(/^\s+|\s+$/g,''));}return cookie_value;}a_temp_cookie=null;cookie_name='';}if(!b_cookie_found){return null;}}};})();

(function () {
    if (location.pathname === "/tab/debug.html") {
        window.debugMode = true;
        if (!window.console){
             window.log = function() {};
         } else {
             window.log = function() {
                 console.log.apply(console, arguments);
             };
         }
     } else {
        window.log = function() {};
    }    
})();

function getHashString() {
    var hash = location.href.split('#')[1];
    return hash;
}

function updateTitle() {
    var title = getCooliris().feedTitle || '';
    document.title = "Cooliris" + title;
}

function setFeed(feed) {
    var dh = decodeHash(feed.split('#')[1]);
    if (dh.url && dh.url.match(/^\s*jsfeed:\s*javascript:/i)) {
        feed = home;
    }
    getCooliris().feed = feed;
}

function pollHash() {
    if (currentHash != location.hash) {
        currentHash = location.hash;
        ignoreNextFeedChange = true;
        setFeed(getHashString());
        log('pollHash has seen change! ignore next change? ' + ignoreNextFeedChange);
    }
}

// In case of safari, we need to inspect changes to cooliris.feed from JavaScript. 
// We do a little bit of plumbing in order to be able to check cleanly and then 
// re-use as much existing stuff as possible. 
var safari = !!~navigator.userAgent.toLowerCase().indexOf('safari');
function enableSafariWorkAround() {
    log('enabling Safari event work-around');
    
    var current_feed_params = {},
        pollUrl = pollHash;
        setCoolirisFeed = setFeed;
        
    function updateCurrentFeedParams(feed) {
        current_feed_params = decodeHash(feed || getCooliris().feed);
    }
    
    setFeed = function(feed) {
        setCoolirisFeed(feed);
        updateCurrentFeedParams(feed);
    };

    function pollFeed() {
        var feed = getCooliris().feed,
            fp = decodeHash(feed),
            cfp = current_feed_params;
            
        
        if (((fp.f || cfp.f) && (fp.f !== cfp.f)) ||
            ((fp.c || cfp.c) && (fp.c !== cfp.c)) ||
            ((fp.url || cfp.url) && (fp.url !== cfp.url))) {
            handleFeedChange();
            updateCurrentFeedParams(feed);
        } 

        if ((fp.guid || cfp.guid) && fp.guid !== cfp.guid) {
            handleSelectionChanged();
            updateCurrentFeedParams(feed);
        }
    }
    
    pollHash = function() {
        pollUrl();
        pollFeed();
        updateTitle();
    };
}

function postEmbedInitialized() {
    log('postEmbedInitialized' );
    try {
        var url = getHashString() || home;
        updateAnchor(url);
        setFeed(url);
    } catch (err) {}
}

function updateAnchor(url){
    if (safari) return;
    if (url.match(/\<\s*script/i)) return;
    
    if (!anchors[url]) {
        anchors[url]=true;
        var newAnchor = '<a name="' + url + '"></a>';
        anchorHolder.innerHTML += newAnchor;
        anchorHolder.style.display = 'none';
    }
}

function handleFeedChange() {
    log('handleFeedChanged' + (ignoreNextFeedChange ? ' ignore' : ''));
    handleRowRequirements();
    // guarantees that mosaic ads are turned off and overlay ads don't start playing upon feed load.
    getCoolirisBridge().setConfigProperty('com.cooliris.showAd', 'false');
    getCoolirisBridge().setConfigProperty('com.cooliris.feed.load.time', ''+(new Date).getTime());
    
    if (ignoreNextFeedChange) {
        ignoreNextFeedChange = false;
        return;
    }
    
    var url = getCooliris().feed,
        dh = decodeHash(url);
        
    // support in-xslt tracking pixel time stamping. 
    // if (dh.p === 'Channels' || dh.f === 'Channels') {
    //     getCoolirisBridge().setConfigProperty('com.cooliris.feed.load.time', ''+(new Date).getTime());
    // }
     
    
    updateAnchor(url);
    location.hash = '#' + url;
    currentHash = location.hash;
    updateTitle();
    trackPageViews();
}

function handleFeedUpdated() {
    log('handleFeedUpdated');
    updateTitle();
}

function handleFeedRedirected() {
    log('handleFeedRedirect');
    handleRowRequirements();
    
    location.replace('#'+getCooliris().feed);
    currentHash = location.hash;
    updateTitle();
}

function handleSelectionChanged() {
    log('handleSelectionChanged');
    
    location.replace('#'+getCooliris().feed);
    currentHash = location.hash;
    updateTitle();
    // if we don't differentiate de-selections from feed loads, analytics are way off. 
    trackPageViews(true);
}

function decodeHash(hash) {
    var hashParts = (hash || getHashString() || '').split('&'),
        hashPartsIndex = hashParts.length,
        hashParams = {};
        
    while (hashPartsIndex--) {
        var hashParam = hashParts[hashPartsIndex].split('=');
        hashParams[hashParam[0]] = decodeURIComponent(hashParam[1]);
    }
    
    if (hashParams.url) {
        var hashMatch = hashParams['url'].match(/(jsfeed:)?(\w+:\/\/)([^\/]+)\//);
        hashParams.domain = hashMatch && hashMatch.length >= 4 && hashMatch[3];
    }
    
    if (hashParams.lu) {
        var luSplit = hashParams.lu.split('?');
        if (luSplit[1]) {
            hashParams.lu_params = decodeHash(luSplit[1]);
        }
    }
    
    return hashParams;
}

function createTrackPath(decodedHash) {
    var dh = decodedHash || decodeHash(),
        slash = '/',
        prefix = (dh.f || dh.p || dh.cs || dh.lt ) ? '/FrontDoor' : '/SideDoor',
        root = prefix,
        path = slash + (dh.domain || dh.f || dh.p || dh.lt || (dh.lu_params && dh.lu_params.vertical)),
        pathExt = dh.c ? (slash + dh.c) : '',
        navigation = dh.guid ? '/navigation' : '/feedLoad';
    
 
     if (dh.lu_params) {
         root += dh.lu_params.q ? '/Search' : '';
         root += (dh.lu_params.src || dh.lu_params.series) ? '/Pivot' : '';
     } else {
         root += dh.p ? '/Search' : '';
     }
        
    if ((dh.f || dh.lt) === 'Local') {
        pathExt = slash + ((pathExt.match(/:iphoto:/) || dh.domain == 'iphoto') ? 'iPhoto' : 'Dir');
    }
    
    
    
    switch (dh.cs) {
        case "33":
            path = slash + "Local";
            pathExt = slash + "iPhoto";
            break;
        case "11":
            path = slash + "Places";
            break;
        default:
    }
    
    return (root + path + pathExt + navigation);
}

function trackPageViews(fromSelection) {
    if (window.debugMode) return;
    
    try {
        if (!window.pageTracker) {
            window.pageTracker = _gat._getTracker("UA-9156646-1");
            
            var version = window.pageTracker._getVersion(),
                gaJSNames = { "4.5.6" : {
                    outerFunction : "pc", 
                    innerFunction : "Bp"
                }, "4.5.7" : {
                    outerFunction : "Jb", 
                    innerFunction : "Ya"
                }, "4.5.9" : {
                    outerFunction : "Kb", 
                    innerFunction : "$a"
                }};
                
                        
            if (gaJSNames[version]) {
                window.pageTracker._initData();
                window.adTracker = _gat._getTracker("UA-8178238-3");
                
                var outerF = gaJSNames[version].outerFunction,
                    innerF = gaJSNames[version].innerFunction,
                    F = window._gat,
                    oldOuterFunction = F[outerF];
                    F[outerF] = function(g) {
                        var of = new oldOuterFunction(g);
                        of[innerF] = function(m,n) {
                            if (m.match(/feedLoad/)) {
                                var m2 = m.
                                    replace(/(utmhn=)[^&]+/, '$1{UTMHN}').
                                    replace(/(utmp=)[^&]+/, '$1{UTMP}').
                                    replace(/(utmac=)[^&]+/, '$1{UTMAC}');
                                log("time is: " + (new Date()).getTime() + "\n" + m + "\nNew Stuff\n" + m2);
                                getCoolirisBridge().setConfigProperty('com.cooliris.feed.gatrack.url', m2);
                            }
                        };
                        return of;
                    };
            };
            
        }
        
        var dh = decodeHash();
            tp = createTrackPath(dh);
            
        // Track Feed & Item selections (but not de-selections) with Google Analytics & CS
        if (!fromSelection || dh.guid) {
            window.pageTracker && window.pageTracker._trackPageview(tp);
            pingCS();
        }
        
        // Only track Feed related events with QC
        if (!fromSelection) {
            window.adTracker && window.adTracker._trackPageview(tp);
            pingQC();
        }
        
    } catch(err) {}
}

function pingQC() {
    try {
        var qcId = 'ci_qc_block';
        qc = document.getElementById(qcId);
        try {
          delete window._qpixelsent;
        } catch(e) {
          window._qpixelsent = undefined;
        }
        qc && (head.removeChild(qc));
    
        qc = document.createElement('SCRIPT');
        qc.id = qcId;
        qc.src = 'http://edge.quantserve.com/quant.js';
        head.appendChild(qc);
    } catch (err) {}
}

function pingCS() {
    try {
        COMSCORE && COMSCORE.beacon({
            c1:2,
            c2:6882160,
            c3:"",
            c4:"http://www.cooliris.com/tab/",
            c5:"",
            c6:"",
            c15:""
          });
    } catch (err) {}
}

function getCooliris() {
    return window.cooliris || (window.cooliris = document.getElementById("coolirisObject"));
}

function getCoolirisBridge() {
    return window.coolirisBridge || 
    (function() {
        var context = null;
        if (typeof PicLensContext != 'undefined') {
            // Firefox
            context = new PicLensContext();
        } else {
            try {
                // IE
                context = new ActiveXObject("PicLens.Context");
            } catch (e) {
                if (navigator.mimeTypes['application/x-cooliris']) {
                    // Safari
                    context = document.createElement('object');
                    context.style.height="0px";
                    context.style.width="0px";
                    context.type = 'application/x-cooliris';
                    document.documentElement.appendChild(context);
                }
            }
        }
        window.coolirisBridge = context;
        return window.coolirisBridge;
    })();
}


function captureWallRowsSetting() {
    origNrRows = getCoolirisBridge().getConfigProperty('com.cooliris.wall.rows');
    if (! (origNrRows >= 0 && origNrRows <= 7) ) {
        origNrRows = 0;
        resetRows();
    }
}

function handleRowRequirements() {
    log("handleRowRequirements");
    var dh = decodeHash(cooliris.feed),
        rows = getCoolirisBridge().getConfigProperty('com.cooliris.wall.rows'),
        forceThree = (dh.c) || (dh.p == "Channels" && dh.s) || (dh.f == "Channels");
        
    forceThree = forceThree || (dh.url === "http://hf.cooliris.com/branding-mixer/client?ad=demo-2010-1-21-0-5-5&url=http%3A%2F%2Fsearch.cooliris.com%2Fdiscover%2Fsearch%3Fc%3D399%26flash%3D1%26noads%3D0%26pageSize%3D12");

    if (forceThree) {
        if (rows == "3") return;
        
        log("forcing 3 rows");
        
        getCoolirisBridge().setConfigProperty('com.cooliris.wall.rows', '3');
        getCooliris().feed = getCooliris().feed;
    } else {
        resetRows();
    }
}

function resetRows() {
    log("resetting rows");
    getCoolirisBridge().setConfigProperty('com.cooliris.wall.rows', ''+origNrRows);
}

function snowLeopardCheck(){
    // if Firefox, check the Cooliris version
    if (navigator.userAgent.match(/OS X 10.6.*?Firefox/)) {
        var v = getCooliris().version.split(/\./);
        if (v[1] < 12 && (v[1] != 11 || v[2] < 3)) {
            location.href = "http://www.cooliris.com/install/snowleopard.php";
        }
    }
}

function eulaCheck() {
    if (getCoolirisBridge().getConfigProperty('com.cooliris.eula') === 'not_accepted') {
        location.href = "http://www.cooliris.com/prompt/legal/" + (getCoolirisBridge().getConfigProperty('sys.partner-id') != "" ? getCoolirisBridge().getConfigProperty('sys.partner-id') : "9999999");
    }
}

function initCooliris() {
    cooliris = getCooliris();
    
    if (cooliris.attachEvent) {
        cooliris.attachEvent('onEmbedInitialized', handleEmbedInitialized);
    }
    
    if (typeof cooliris.version === 'undefined') {
        var hash = getHashString();
        window.location = '/install' + (hash ? '?url=' + encodeURIComponent(hash) : '');
    } 
}

function handleEmbedInitialized() {
    log('handleEmbedInitialized');
    cooliris = getCooliris();
    
    if (cooliris.attachEvent) {
        cooliris.attachEvent('onFeedChanged', handleFeedChange);
        cooliris.attachEvent('onFeedUpdated', handleFeedUpdated);
        cooliris.attachEvent('onFeedRedirected', handleFeedRedirected);
        cooliris.attachEvent('onSelectedItemChanged', handleSelectionChanged);
    } else {
        cooliris.addEventListener('FeedChanged', handleFeedChange, false);
        cooliris.addEventListener('FeedUpdated', handleFeedUpdated, false);
        cooliris.addEventListener('FeedRedirected', handleFeedRedirected, false);
        cooliris.addEventListener('SelectedItemChanged', handleSelectionChanged, false);
    } 
    
    snowLeopardCheck();
    eulaCheck();

    captureWallRowsSetting();

    getCoolirisBridge().setConfigProperty('com.cooliris.gfx.maxthumbnailsize', '256');

    if (safari && (26881 > getCooliris().version.split('.')[3]) ) {
        enableSafariWorkAround();
    }
    
    anchorHolder = document.getElementById('anchorHolder');
    // Only do location polling on browsers that are not IE. 
    if (!window.VBArray) {
        log('start polling');
        setInterval(pollHash, 1100);
    }
    
    // should always be at the bottom, this kicks off the actual loading of the feed.
    start('init');
}

function start(component) {
    var canStart = true;
    log("start: " + component + " is ready");
    start.waitForComponents[component] = true;
    for (var waitFor in start.waitForComponents) {
        canStart &= start.waitForComponents[waitFor];
    }
    if (canStart) {
        window.setTimeout(postEmbedInitialized, 1000);
    }
    
}
start.waitForComponents = {init:false};
if (navigator.userAgent.match(/safari/i) && !navigator.userAgent.match(/Chrome/)) {
    start.waitForComponents = {bing:false};
}

(function () {
    // The IE equivalent happens in initCooliris()
    // this is because we need to register an event listener before the cooliris object is added to the dom. 
    // on IE, the event listener is added to the cooliris object itself, and timing doesn't seem to be an issue there.. 
    if (!window.attachEvent) {
        window.addEventListener('EmbedInitialized', handleEmbedInitialized, false);
    }
})();

</script>
</head>
<body scroll="no" onunload="resetRows();return true;">
<div id="anchorHolder" style="display:none;"></div>
<script>
if (navigator.userAgent.match(/safari/i) && !navigator.userAgent.match(/Chrome/)) {
    document.write('<div style="position:absolute;z-index:-1">\
    <iframe src="http://www.bing.com/" width="0" height="0" onload="start(\'bing\')"></iframe>\
</div>');
}
</script>
<!--[if IE]>
<object id="coolirisObject" classid="clsid:CEE49C36-A170-4f0c-B098-257BA4CF46E5" height="100%" width="100%"></object>
<![endif]-->
<!--[if !IE]><!-->
<object id="coolirisObject" type="application/x-cooliris-embedded" height="100%" width="100%"></object>
<!--<![endif]-->

<script>
initCooliris();
</script>
</body>
</html>
