// Related To Ads
var iTopic = 0;
var aGoogleAds = ['0','4','7'];
var aGiftShoeAds = ['1'];

// First visit to the site?
// Minimize all but the first two Categories
if (!ipb.Cookie.get('toggleCats')) {
	// NOTE: there is no way to figure out the category ID's BEFORE the page loads for the first time
	// since we WANT to set these before a persons first visit, we are forced to manually compose
	// the variable 'cookie' below.
	// NOTE: This WILL BREAK if the user changes categories or adds new categories via the ACP.
	var cookie = ',251,246,247,249,250,248,';
	ipb.Cookie.set('toggleCats', cookie, 1);
}

// Call this function to see if we need to display an ad.
// this also increments the topic counter
function boardIndexTemplate_thing() {
	// alert(iAdCount);
	if (in_array(iTopic, aGoogleAds)) doGoogle();
	if (in_array(iTopic, aGiftShoeAds)) doGiftStore();
	iTopic++;
}

function doGoogle() {
	google_ad_client = "pub-0900741024027445";
	/* DC Message Board Topic Ads */
	google_ad_slot = "0957783500";
	google_ad_width = 728;
	google_ad_height = 90;
	document.writeln('<div class="matt_ad_google matt_indexad"><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script></div>');
}

function doGiftStore() {
	document.writeln('<div class="matt_ad_giftstore matt_indexad">');
	document.writeln('<a href="http://www.dcgiftshop.com/" target="_blank"><img width="785" height="100" src="/public/hylwtio5.jpg" alt="Gift"/></a>');
	document.writeln('</div>');
}

function setcookie (name, value, expires, path, domain, secure) {
    // http://kevin.vanzonneveld.net
    // +   original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +   bugfixed by: Andreas
    // +   bugfixed by: Onno Marsman
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // -    depends on: setrawcookie
    // *     example 1: setcookie('author_name', 'Kevin van Zonneveld');
    // *     returns 1: true
 
    return this.setrawcookie(name, encodeURIComponent(value), expires, path, domain, secure);
}

function in_array (needle, haystack, argStrict) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: vlado houba
    // *     example 1: in_array('van', ['Kevin', 'van', 'Zonneveld']);
    // *     returns 1: true
    // *     example 2: in_array('vlado', {0: 'Kevin', vlado: 'van', 1: 'Zonneveld'});
    // *     returns 2: false
    // *     example 3: in_array(1, ['1', '2', '3']);
    // *     returns 3: true
    // *     example 3: in_array(1, ['1', '2', '3'], false);
    // *     returns 3: true
    // *     example 4: in_array(1, ['1', '2', '3'], true);
    // *     returns 4: false
 
    var key = '', strict = !!argStrict;
 
    if (strict) {
        for (key in haystack) {
            if (haystack[key] === needle) {
                return true;
            }
        }
    } else {
        for (key in haystack) {
            if (haystack[key] == needle) {
                return true;
            }
        }
    }
 
    return false;
}