
    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 'HIPHOP':
                directory = 'hiphop';
                break;
			case 'REGGAE':
                directory = 'reggae';
                break;
			case 'SURF':
                directory = 'surf';
                break;
			case 'SKATE':
                directory = 'skate';
                break;
			case 'SNOW':
                directory = 'snow';
                break;
			case 'MOTOBMX':
                directory = 'motobmx';
                break;
			case 'BEHINDTHELENS':
                directory = 'behindthelens';
                break;
			case 'HVCBLK':
                directory = 'hvcblk';
                break;
			case 'ULTIMATEWAVE':
                directory = 'ultimatewave';
                break;
			case 'QUICKTAKES':
                directory = 'quicktakes';
                break;
			case 'HAVOCLIVE':
                directory = 'havoclive';
                break;
			case 'WTF':
                directory = 'wtf';
                break;
			case 'PRIMO':
                directory = 'primo';
                break;
			case 'SKATE3':
                directory = 'skate3';
                break;
			case 'SKATE-SPONSORED-BY-SKATE-3':
                directory = 'skate';
                break;
			case 'SKATE-3':
                directory = 'skate3';
                break;
			case 'THEFORCEUNLEASHED2':
                directory = 'theforceunleashed2';
                break;
			case 'THEFORCEUNLEASHEDII':
                directory = 'theforceunleashed2';
                break;


			default:
				directory = 'index';
				break;
        }
	
		
  switch (location.toLowerCase()) {
	case 'top':
	location = '2';
	break;
	case 'middle':
	location = '1';
	break;
	case 'right':
	location = '3';
	break;
}

   document.MAX_ct0 ='INSERT_CLICKURL_HERE';

   var m3_u = (location.protocol=='https:'?'https://machine.havoc.tv/openx/www/delivery/ajs.php':'http://machine.havoc.tv/openx/www/delivery/ajs.php');
   var m3_r = Math.floor(Math.random()*99999999999);
   if (!document.MAX_used) document.MAX_used = ',';
   document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
   document.write ("?zoneid=" + location + "&amp;source=" + directory);
   document.write ('&amp;cb=' + m3_r);
   if (document.MAX_used != ',') document.write ("&amp;exclude=" + document.MAX_used);
   document.write (document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : ''));
   document.write ("&amp;loc=" + escape(window.location));
   if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer));
   if (document.context) document.write ("&context=" + escape(document.context));
   if ((typeof(document.MAX_ct0) != 'undefined') && (document.MAX_ct0.substring(0,4) == 'http')) {
       document.write ("&amp;ct0=" + escape(document.MAX_ct0));
   }
   if (document.mmm_fo) document.write ("&amp;mmm_fo=1");
   document.write ("'><\/scr"+"ipt>");

    }
