
    function writeAdTag(location) {
        var path = window.location.pathname;
	var webSite = window.location.hostname;
        //Trim the first /
        path = path.substring(1, path.length);

        var directory = 'index';

        //if we are in a directory
        if (path != '') {
            //if there is a trailing /, remove it
            if (path.charAt(path.length - 1) == '/') {
                path = path.substring(0, path.length - 1);
            }
            if (path.indexOf('/') > -1) {
                var pathArray = path.split('/');

                if (pathArray[pathArray.length - 1].indexOf('.') > -1) {
                    //the last part is a file
                    if (pathArray[pathArray.length - 2].indexOf('.') == -1) {
                        //the part preceeding is not a file but a directory
                        directory = pathArray[pathArray.length - 2];
                    }
                }
                else {
                    directory = pathArray[pathArray.length - 1];
                }
            }
            else {
                //either a file or a path
                if (path.indexOf('.') == -1) {
                    directory = path;
                }
            }
        }

        switch (directory.toUpperCase()) {
            case 'ALTERNATIVE':
                directory = 'alternative';
                break;
			case 'METAL':
                directory = 'metal';
                break;
			case 'PUNK':
                directory = 'punk';
                break;
			case 'ELECTRONIC':
                directory = 'electronic';
                break;
			case 'HIP-HOP':
                directory = 'hiphop';
                break;
			case 'REGGAE':
                directory = 'reggae';
                break;
			case 'SURF':
                directory = 'surf';
                break;
			case 'SKATE':
                directory = 'skate';
                break;
			case 'SNOW':
                directory = 'snow';
                break;
			case 'MOTO-BMX':
                directory = 'motobmx';
                break;
			case 'HVC-BLK':
                directory = 'hvcblk ';
                break;
			case 'ULTIMATE-WAVE':
                directory = 'ultimatewave';
                break;
			case 'QUICKTAKES-1':
                directory = 'quicktakes';
                break;
			case 'HAVOCLIVE':
                directory = 'havoclive';
                break;
			case 'WTF':
                directory = 'wtf';
                break;
			default:
				directory = 'index';
				break;
        }
	
		
		var now = new Date();
		var sr_num = (now.getMonth() * 10000000) + (now.getDay() * 100000) + (now.getHours() * 1000) + (now.getMinutes() * 10) + (Math.round(now.getSeconds() /30));
		
	
		//www.site.com/page/1234567890@Top,TopLeft!Top
        document.write('<!--OAS SETUP=' + webSite + '/' + directory + '/' + sr_num + '@' + location + '-->');
        document.write('<SCRIPT LANGUAGE="JavaScript1.1" SRC="http://ads.havoctv.com/RealMedia/ads/adstream_jx.ads/' + webSite + '/' + directory + '/' + sr_num + '@' + location + '"><\/script>');
        document.write('<noscript>');
        document.write('<a href="http://ads.havoctv.com/RealMedia/ads/click_nx.ads/' + webSite + '/' + directory + '/' + sr_num + '@' + location + '"><img src="http://ads.havoctv.com/RealMedia/ads/adstream_nx.ads/' + webSite + '/' + directory + '@' + location + '" \/></a><\/noscript>');
    }