function zMSRand(){
    return Math.round(Math.abs(Math.sin((new Date()).getTime())) * 1000000000) % 10000000;
}

var zMSdomain = "http://media.sensis.com.au";
var zMSsecureDomain = "https://media.sensis.com.au";
var zMSlocation = window.location + "";

if (zMSlocation.indexOf("https://") != -1) 
    var zMSHome = zMSsecureDomain;
else 
    var zMSHome = zMSdomain;
var zMSpagenum = zMSRand();

var zMSACCsite = "TEL.AFL_HOME.SPORT";
var zMSACCarea = "SPORT.AFL_HOME.OTHER";
	if(zMSlocation.indexOf("dreamteam") != -1){
		zMSACCarea = "SPORT.AFL_HOME.AFL_DREAMTEAM"; 
	}
var zMSmask;
var zMSadvdecider = (Math.floor(Math.random() * 100));
var zMSaddmask;
var zMSindex = 0;
var zMSarray = new Array();


function zMSsecureMe(){
}

function zMSgetValue(zMSmyStr, zMStagline){
    zMSmyStr = zMSmyStr + "=";
    var zMSind = zMStagline.indexOf(zMSmyStr) + zMSmyStr.length;
    if (zMSind == (zMSmyStr.length - 1)) //test for myStr not found
        return "";
    zMStagline += "&";
    return zMStagline.substring(zMSind, zMStagline.indexOf("&", zMSind));
}

function zMSconvertSize(zMSsize){
    if (zMSsize == "hariable") {
        /*if(zMSlocation == "http://collingwoodfc.com.au/" || zMSlocation == "http://collingwoodfc.com.au/default.asp?pg=home")
         return "468x60";*/
        return "728x90";
    }
    if (zMSsize == "variable") 
        return "120x240";
    if (/\d+x\d+/.test(zMSsize)) 
        return zMSsize;
    return "ERROR";
}

function zMSgetJS(zMSmyStr){
	if(zMSlocation.indexOf("dreamteam") != -1){
		zMSACCarea = "SPORT.AFL_HOME.AFL_DREAMTEAM"; 
	}
	
	if(zMSlocation.indexOf("development") != -1){
		zMSsub_section='afl_DEVELOPMENT';
		zMSACCarea = "SPORT.AFL_HOME.AFL_DEVELOPMENT"; 
	}
	
	//manual betting targeting
	if(zMSlocation.indexOf("betting") != -1){
		zMSsub_section='afl_BETTING';
		zMSACCarea = "SPORT.AFL_HOME.AFL_BETTING"; 
	}
	
	//manual TICKETS section targeting
	if(zMSlocation.indexOf("ticket") != -1){
		zMSsub_section='afl_TICKETS';
		zMSACCarea = "SPORT.AFL_HOME.AFL_TICKETS"; 
	}
	
	
	if (zMSmyStr.indexOf("100x29") != -1) {
/* Temp fix for 100x29 */
		if(top.zMSsection == 'afl_') {
			//AFL homepage
			zMSACCarea = zMSACCarea.replace(/OTHER/i, top.zMSsub_section.toUpperCase());
		}
		if(top.zMSsection == 'clubs_') {
			//AFL club pages
			zMSACCsite = zMSACCsite.replace(/AFL_HOME/i, "AFL_"+top.zMSsub_section.toUpperCase());		
			zMSACCarea = "SPORT.AFL_"+top.zMSsub_section.toUpperCase()+".CLUB_PLAYERS";
if(zMSACCsite.indexOf("MAGPIESFC_NEWS") != -1 ) {
				zMSACCsite = zMSACCsite.replace(/NEWS/i,"HOME");
				zMSACCarea = zMSACCarea.replace(/NEWS/i,"HOME");
			}		

}
		zMSgetIframe(zMSmyStr);
	}
	else {
		
	
	//BigPond Promotions code
	var posMod = "";
	zmsSiteTemp = "";
	if (zMSmyStr.indexOf("position=bppromo") != -1) {
		zmsSiteTemp = zMSACCsite;
		zMSACCsite = zMSACCsite.replace(/AFL_HOME/i, "BPPROMO.AFL_HOME");
		zms_temp_pos = zMSmyStr.indexOf("position=bppromo");
		posMod = "/POSITION=" + zMSmyStr.charAt(zms_temp_pos + 16);
	}
	if (zMSconvertSize(zMSgetValue("adsize", zMSmyStr)) == "300x250" && zMSsub_section != "afl_home" && zMSsub_section !='afl_tipping' && (zMSlocation.indexOf("afl.com") != -1) && zMSmyStr.indexOf("OTHER") == -1 && zMSsub_section != 'afl_dreamteam' && (zMSsection=="news" || zMSsub_section == 'afl_news')) {
		var brickpercent = 30;
		//temp change for time targeted brick
		
		/*
		var zMSDate = new Date();
		var zMSHour = zMSDate.getHours();
		var zMSd = zMSDate.getDate();
		
		
		if((zMSHour > 9 && zMSHour < 14) || (zMSHour > 15 && zMSHour < 21)){
		//	if(zMSd < 14){
				brickpercent = 80;
		//	}
			
		}
		
		
		if (parntLocation.indexOf("zmstestingenvironment375") != -1) {
			brickpercent = 50;
    	}
		*/
		var sizedecider = (Math.floor(Math.random() * 100));
		var AAMsize = "300x600"; // default ad unit to show
		if (sizedecider < (100 - brickpercent)) {
			AAMsize = "300x250";
		}
	}
	else {
		AAMsize = zMSconvertSize(zMSgetValue("adsize", zMSmyStr))
	}
	
	//hack to get rid of extra 1x1 ad call in iframe
	if (location.href.indexOf("/Default.aspx?tabid=") == -1) {
	
		if (zMSACCarea == "SPORT.AFL_HOME.AFL_DREAMTEAM") 
			zMSpagenum++;
		if (typeof(zMSsubsection) == "undefined" && typeof(zMSsub_section) != "undefined") 
			var zMSsubsection = zMSsub_section;
		zMSACCsiteDec = zMSACCsite;
/*		if (zMSmyStr.indexOf("145") != -1 || (zMSsection == 'clubs_' && (zMSmyStr.indexOf("head") != -1 || (zMSmyStr.indexOf("island") != -1 && Math.floor(Math.random() * 100) < 50)))){
			if(zMSsubsection.indexOf("bombers") == -1){
				zMSACCsiteDec = "TEL.AFL_" + zMSsubsection.substring(0, zMSsubsection.indexOf("fc_")).toUpperCase() + "FC_HOME.SPONSORSHIP";
			}		
		} 
*/			
		//club sponsorship hack
		if ((zMSsubsection.indexOf("crows") != -1  || zMSsubsection.indexOf("dockers") != -1 || zMSsubsection.indexOf("cats") != -1 || zMSsubsection.indexOf("eagles") != -1 || zMSsubsection.indexOf("saints") != -1 || zMSsubsection.indexOf("tigers") != -1 || zMSsubsection.indexOf("hawks") != -1 || zMSsubsection.indexOf("swans") != -1 || zMSsubsection.indexOf("magpies") != -1 || zMSsubsection.indexOf("kangaroos") != -1 || zMSsubsection.indexOf("blues") != -1) && (zMSmyStr.indexOf("island") != -1 || zMSmyStr.indexOf("head") != -1 || zMSmyStr.indexOf("leader") != -1)) 
			zMSACCsiteDec = "TEL.AFL_" + zMSsubsection.substring(0, zMSsubsection.indexOf("fc_")).toUpperCase() + "FC_HOME.SPONSORSHIP";
		else
			if((zMSsubsection.indexOf("lions") != -1 || zMSsubsection.indexOf("bulldogs") != -1 || zMSsubsection.indexOf("portpower") != -1 || zMSsubsection.indexOf("demons") != -1) && (zMSmyStr.indexOf("island") != -1 || zMSmyStr.indexOf("head") != -1 || zMSmyStr.indexOf("leader") != -1)){
				zMSACCsiteDec = "TEL.AFL_" + zMSsubsection.substring(0, zMSsubsection.indexOf("fc_")).toUpperCase() + "FC_HOME.SPONSORSHIP";
				if (zMSmyStr.indexOf("island1") != -1 && Math.floor(Math.random() * 100) < 50){
					zMSACCsiteDec = zMSACCsite;
				}
			}
		//end club sponsorship hack
		var zMSkey = "";
		if (zMSsection.indexOf("draft") != -1 || zMSsection.indexOf("risingstar") != -1) 
			zMSkey = "/KEYWORD=AFL_DRAFT";
		if (zMSACCarea == "SPORT.AFL_HOME.AFL_DREAMTEAM") 
			zMSkey = "/KEYWORD=AFL_DREAMTEAM";
		if (location.href.indexOf("aflfinal") != -1) 
			zMSkey = "/KEYWORD=AFL_DREAMTEAM_FINAL";
		
if ((document.location + "").indexOf("/competitions/mark") != -1) {
        zMSkey = "HUNGRY_JACKS";
    }

		
		if (zMSgetValue("position", zMSmyStr) == "island1" || zMSgetValue("position", zMSmyStr) == "island") 
			posMod = "/POSITION=1";
		if (zMSgetValue("position", zMSmyStr) == "leader1" || zMSgetValue("position", zMSmyStr) == "leader"){
			var zmsleadertmp = document.location + "";
			if(zmsleadertmp.indexOf("&resize")!= -1){
				posMod = "/POSITION=2";
			}else{
				posMod = "/POSITION=1";
			}			
		}
		if (zMSgetValue("position", zMSmyStr) == "island2" || zMSgetValue("position", zMSmyStr) == "leader2") 
			posMod = "/POSITION=2";
		if (zMSgetValue("position", zMSmyStr) == "leader2") 
			posMod = "/POSITION=2";
		if (zMSgetValue("position", zMSmyStr) == "button1") 
			posMod = "/POSITION=1";
		if (zMSgetValue("position", zMSmyStr) == "button2") 
			posMod = "/POSITION=2";
		if (zMSgetValue("position", zMSmyStr) == "button3") 
			posMod = "/POSITION=3";
		if (zMSgetValue("position", zMSmyStr) == "button4") 
			posMod = "/POSITION=4";
		if (zMSgetValue("position", zMSmyStr) == "button5") 
			posMod = "/POSITION=5";
		if (zMSgetValue("position", zMSmyStr) == "button6") 
			posMod = "/POSITION=6";
		if (zMSgetValue("position", zMSmyStr) == "OTHER") 
			posMod = "/POSITION=OTHER";
		
		if (zMSsubsection.indexOf("eagles") !== -1) {
			if (zMSgetValue("adsize", zMSmyStr) == "176x76") {
				if (zMSindex == 0) {
					zMSlogo = 6;
					
					for (var zMSi = 0; zMSi < zMSlogo; zMSi++) 
						zMSarray[zMSi] = "/POSITION=" + (zMSi + 1);
					for (var ind = zMSlogo; ind > 0; ind--) 
						zMSarray.push(zMSarray.splice(Math.floor(Math.random() * ind), 1));
					
				}
				posMod = zMSarray[zMSindex];
				zMSindex++;
			}
		}
		
		//adding classification mask into ad call-only if the ad call is not a sponsorship ad and the site is a club site
		if ((zMSACCsiteDec.indexOf("SPONSORSHIP") == -1 && typeof(zMSmask) != "undefined")) {
			zMSaddmask = zMSACCarea;
			zMSACCarea = zMSACCarea + zMSmask;
			
			
			if (zMSmyStr.indexOf("island") != -1) {
				if (Math.random() * 100 < 20) {
					var zMSdaVals = 'acc_random=' + zMSRand() + '/SITE=' + zMSACCsiteDec + '/AREA=' + zMSACCarea + '/AAMSZ=' + AAMsize + zMSkey + '/pageid=' + zMSpagenum + posMod;
					document.write('<iframe src="http://ad.sensismediasmart.com.au/images/sensis/cookieFix.html?' + escape(zMSdaVals.replace(/\//gi, "&")) + '" allowtransparency="true" width=300 height=250 frameborder="no" MARGINWIDTH="0" MARGINHEIGHT="0" SCROLLING="no">\n</iframe>\n');
				}
				else {
					if (zMSACCarea == "SPORT.AFL_HOME.AFL_DREAMTEAM")//AFL Dream Team Fix
					{
						if (location.href.indexOf("aflfinal") != -1) 
							document.write("<scr" + "ipt src=\"" + zMSHome + "/jserver/acc_random=" + zMSRand() + "/SITE=" + zMSACCsiteDec + "/AREA=" + zMSACCarea + "/AAMSZ=" + AAMsize + "/KEYWORD=AFL_DREAMTEAM_FINAL/pageid=" + zMSpagenum + posMod + "\">\n");
						else 
							document.write("<scr" + "ipt src=\"" + zMSHome + "/jserver/acc_random=" + zMSRand() + "/SITE=" + zMSACCsiteDec + "/AREA=" + zMSACCarea + "/AAMSZ=" + AAMsize + "/KEYWORD=AFL_DREAMTEAM/pageid=" + zMSpagenum + posMod + "\">\n");
					}
					else 
						document.write("<scr" + "ipt src=\"" + zMSHome + "/jserver/acc_random=" + zMSRand() + "/SITE=" + zMSACCsiteDec + "/AREA=" + zMSACCarea + "/AAMSZ=" + AAMsize + "/KEYWORD=EXPANDABLE/pageid=" + zMSpagenum + posMod + "\">\n");
					document.write("</scr" + "ipt>");
				}
			}
			else {
			
			
				if (zMSmyStr.indexOf("footy_tipping_tower") == -1) {
					if (typeof(zMSsub_section) != "undefined" && zMSsub_section == "afl_markgoal") {
						zMSgetIframe(zMSmyStr);
					}
					else {
						document.write("<scr" + "ipt src=\"" + zMSHome + "/jserver/acc_random=" + zMSRand() + "/SITE=" + zMSACCsiteDec + "/AREA=" + zMSACCarea + "/AAMSZ=" + AAMsize + zMSkey + "/pageid=" + zMSpagenum + posMod + "\">\n");
						document.write("</scr" + "ipt>");
					}
				}
			}
			zMSACCarea = zMSaddmask;
		}
		else {
			if (zMSmyStr.indexOf("island") != -1) {
				if (Math.random() * 100 < 0) {
					var zMSdaVals = 'acc_random=' + zMSRand() + '/SITE=' + zMSACCsiteDec + '/AREA=' + zMSACCarea + '/AAMSZ=' + AAMsize + zMSkey + '/pageid=' + zMSpagenum + posMod;
					document.write('<iframe src="http://ad.sensismediasmart.com.au/images/sensis/cookieFix.html?' + escape(zMSdaVals.replace(/\//gi, "&")) + '" allowtransparency="true" width=300 height=250 frameborder="no" MARGINWIDTH="0" MARGINHEIGHT="0" SCROLLING="no">\n</iframe>\n');
				}
				else {
					if (zMSACCarea == "SPORT.AFL_HOME.AFL_DREAMTEAM") //AFL Dream Team Fix
					{
						if (location.href.indexOf("aflfinal") != -1) 
							document.write("<scr" + "ipt src=\"" + zMSHome + "/jserver/acc_random=" + zMSRand() + "/SITE=" + zMSACCsiteDec + "/AREA=" + zMSACCarea + "/AAMSZ=" + AAMsize + "/KEYWORD=AFL_DREAMTEAM_FINAL/pageid=" + zMSpagenum + posMod + "\">\n");
						else 
							document.write("<scr" + "ipt src=\"" + zMSHome + "/jserver/acc_random=" + zMSRand() + "/SITE=" + zMSACCsiteDec + "/AREA=" + zMSACCarea + "/AAMSZ=" + AAMsize + "/KEYWORD=AFL_DREAMTEAM/pageid=" + zMSpagenum + posMod + "\">\n");
					}
					else 
						document.write("<scr" + "ipt src=\"" + zMSHome + "/jserver/acc_random=" + zMSRand() + "/SITE=" + zMSACCsiteDec + "/AREA=" + zMSACCarea + "/AAMSZ=" + AAMsize + "/KEYWORD=EXPANDABLE/pageid=" + zMSpagenum + posMod + "\">\n");
					document.write("</scr" + "ipt>");
				}
			}
			else {
			
			
				if (zMSmyStr.indexOf("footy_tipping_tower") == -1) {
					if (typeof(zMSsub_section) != "undefined" && zMSsub_section == "afl_markgoal") {
						zMSgetIframe(zMSmyStr);
					}
					else {
						if(zMSlocation.indexOf("dreamteam") != -1){
							zMSACCarea = "SPORT.AFL_HOME.AFL_DREAMTEAM"; 
						}
						document.write("<scr" + "ipt src=\"" + zMSHome + "/jserver/acc_random=" + zMSRand() + "/SITE=" + zMSACCsiteDec + "/AREA=" + zMSACCarea + "/AAMSZ=" + AAMsize + "/KEYWORD="+zMSkey + "/pageid=" + zMSpagenum + posMod + "\">\n");
						document.write("</scr" + "ipt>");
					}
				}
			}
		}
	}
	if (zmsSiteTemp != "") {
		zMSACCsite = zmsSiteTemp;
	}
}
}

function zMSgetIframe(zMSmyStr){
    if (typeof(zMSmyStr) == 'undefined') 
        var zMSmyStr = '';
    zMSmySize = zMSconvertSize(zMSgetValue("adsize", zMSmyStr)); //get adsize
    if (zMSmyStr.length > 0) 
        zMSmyStr += '&';
    zMSmySize = zMSmySize.toLowerCase();
    var zMSwidth = zMSmySize.substring(0, zMSmySize.indexOf("x") ? zMSmySize.indexOf("x") : 0); //get width
    var zMSheight = zMSmySize.substring(zMSmySize.indexOf("x") + 1, zMSmySize.length); //get height
    var zMSdim = "";
    if (zMSwidth != "" && (zMSwidth * 1) > 0) //test that adsize is in correct format
    {
        zMSdim = "width=" + zMSwidth + " height=" + zMSheight;
    }
    //adding classification mask into ad call-only if the ad call is not a sponsorship ad and the site is a club site
    if ((zMSACCsite.indexOf("SPONSORSHIP") == -1 || zMSACCsite.indexOf("SITE=TEL.AFL_HOME.SPORT" != -1)) && typeof(zMSmask) != "undefined") {
        zMSaddmask = zMSACCarea;
        zMSACCarea = zMSACCarea + zMSmask;
        
        
        document.write('<IFRAME src="' + zMSHome + "/hserver/acc_random=" + zMSRand() + "/SITE=" + zMSACCsite + "/AREA=" + zMSACCarea + "/AAMSZ=" + zMSconvertSize(zMSgetValue("adsize", zMSmyStr)) + "/pageid=" + zMSpagenum + '" ' + zMSdim + ' frameborder="no" border=0 marginwidth=0 marginheight=0 scrolling="no">\n');
        document.write('</IFRAME>\n');
        zMSACCarea = zMSaddmask;
    }
    else {
        document.write('<IFRAME src="' + zMSHome + "/hserver/acc_random=" + zMSRand() + "/SITE=" + zMSACCsite + "/AREA=" + zMSACCarea + "/AAMSZ=" + zMSconvertSize(zMSgetValue("adsize", zMSmyStr)) + "/pageid=" + zMSpagenum + '" ' + zMSdim + ' frameborder="no" border=0 marginwidth=0 marginheight=0 scrolling="no">\n');
        document.write('</IFRAME>\n');
    }
}

function zMScallGeneric(){
    zMSlocation = window.location.toString();
    
    
    if ((zMSlocation.indexOf("http://afl.com.au") != -1 && zMSlocation.length <= 17) || zMSlocation.indexOf("http://afl.com.au/default.asp?pg=home&spg=default") != -1) 
        zMSsection = "afl_home";
    
    if (zMSlocation.indexOf("afl.com.au/default.asp?pg=news") != -1 || (typeof(zMSsub_section) != "undefined" && zMSsub_section == "afl_news")) 
        zMSACCarea = "SPORT.AFL_HOME.AFL_NEWS";
    
    if (zMSsection == "afl_home" || (typeof(zMSsub_section) != "undefined" && zMSsub_section == "afl_home")) 
        zMSACCarea = "SPORT.AFL_HOME.HOME";
    if (zMSsection == "afl_gameday") 
        zMSACCarea = "SPORT.AFL_HOME.AFL_GAMEDAY";
    if (zMSlocation.indexOf("FixturesResults") != -1) //TEMP FIX FOR FIXTURES RESULTS
        zMSACCarea = "SPORT.AFL_HOME.AFL_FIXTURE";
    
    if (zMSlocation.indexOf("pg=broadcastguides") != -1) 
        zMSsection = "afl_broadcastguides";
    else 
        if (zMSlocation.indexOf("pg=fixture&spg=2006") != -1) 
            zMSsection = "afl_fixture";
        else 
            if (zMSlocation.indexOf("pg=news&spg=display") != -1 && zMSlocation.indexOf("afl.com.au") != -1) 
                zMSsection = "afl_news";
    
    //hack for afl subsection
    if (typeof(zMSsubsection) == "undefined" && typeof(zMSsub_section) != "undefined") 
        var zMSsubsection = zMSsub_section;
    
    if (zMSlocation.indexOf("FixturesResults") != -1 && zMSlocation.toLowerCase().indexOf("afl.com.au") != -1) //TEMP FIX FOR FIXTURES RESULTS
        zMSsubsection = "AFL_FIXTURE";
    
    if (typeof(zMSsubsection) != "undefined" && typeof(zMSsection) != "undefined") {
        if (zMSsubsection.indexOf("fc_") != -1) {
            zMSACCsite = "TEL.AFL_" + zMSsubsection.substring(0, zMSsubsection.indexOf("fc_")).toUpperCase() + "FC_HOME.SPORT";
            zMSACCarea = "SPORT.AFL_" + zMSsubsection.substring(0, zMSsubsection.indexOf("fc_")).toUpperCase() + "FC_HOME.CLUB_PLAYERS";
        }
        else 
            if (zMSsubsection.length > 4 && zMSsubsection.indexOf("afl_") == 0) {
                zMSACCarea = "SPORT.AFL_HOME." + zMSsubsection.toUpperCase();
					if(zMSlocation.indexOf("dreamteam") != -1){
						zMSACCarea = "SPORT.AFL_HOME.AFL_DREAMTEAM"; 
					}
            }
        //hack for inserting classification mask for clubs' protected sponsors
        if (zMSsubsection.indexOf("crows") != -1) {
            zMSmask = "/AAMCM=4000e02";
            if (zMSadvdecider <= 100) {
                zMSmask = zMSmask + "/ADVID=2953";
            }
        }
        else 
            if (zMSsubsection.indexOf("lions") != -1) {
                zMSmask = "/AAMCM=244000004";
                if (zMSadvdecider < 25) {
                    zMSmask = zMSmask + "/ADVID=1796";
                }
                else 
                    if (zMSadvdecider < 50) {
                        zMSmask = zMSmask + "/ADVID=2553";
                    }
                    else 
                        if (zMSadvdecider < 75) {
                            zMSmask = zMSmask + "/ADVID=2763";
                        }
                        else 
                            if (zMSadvdecider <= 100) {
                                zMSmask = zMSmask + "/ADVID=424";
                            }
            }
            else 

                if (zMSsubsection.indexOf("blues") != -1) {
                    zMSmask = "/AAMCM=00000e004";
                    if (zMSadvdecider < 50) {
                        zMSmask = zMSmask + "/ADVID=1696";
                    }
                    else 
                        if (zMSadvdecider <= 100) {
                            zMSmask = zMSmask + "/ADVID=1811";
                        }
                }
                else 
                    if (zMSsubsection.indexOf("magpies") != -1) {
                        zMSmask = "/AAMCM=400000109";
                        if (zMSadvdecider <= 33) {
                            zMSmask = zMSmask + "/ADVID=2618";
                        }
                        else 
                            if (zMSadvdecider <= 66) {
                                zMSmask = zMSmask + "/ADVID=223";
                            }
                            else 
                                if (zMSadvdecider <= 100) {
                                    zMSmask = zMSmask + "/ADVID=2552";
                                }
                    }
                    else 
                        if (zMSsubsection.indexOf("dockers") != -1) {
                            zMSmask = "/AAMCM=00400010080";
                            if (zMSadvdecider <= 33) {
                                zMSmask = zMSmask + "/ADVID=2710";
                            }
                            else 
                                if (zMSadvdecider <= 66) {
                                    zMSmask = zMSmask + "/ADVID=2703";
                                }
                                else 
                                    if (zMSadvdecider <= 100) {
                                        zMSmask = zMSmask + "/ADVID=2854";
                                    }
                        }
                        else 
                            if (zMSsubsection.indexOf("cats") != -1) {
                                zMSmask = "/AAMCM=00000W10W";
                                if (zMSadvdecider <= 100) {
                                    zMSmask = zMSmask + "/ADVID=1676";
                                }
                            }
                            else 
                                if (zMSsubsection.indexOf("hawks") != -1) {
                                    zMSmask = "/AAMCM=00020W";
                                    if (zMSadvdecider <= 33) {
                                        zMSmask = zMSmask + "/ADVID=2961";
                                    }
                                    else 
                                        if (zMSadvdecider <= 66) {
                                            zMSmask = zMSmask + "/ADVID=1777";
                                        }
                                        else 
                                            if (zMSadvdecider <= 100) {
                                                zMSmask = zMSmask + "/ADVID=2660";
                                            }
                                }
                                else 
                                    if (zMSsubsection.indexOf("kangaroos") != -1) {
                                        zMSmask = "/AAMCM=00000W104";
                                        if (zMSadvdecider <= 100) {
                                            zMSmask = zMSmask + "/ADVID=2703";
                                        }
                                    }
                                    else 
                                        if (zMSsubsection.indexOf("demons") != -1) {
                                            zMSmask = "/AAMCM=00000W104";
                                            if (zMSadvdecider <= 100) {
                                                zMSmask = zMSmask + "/ADVID=2687";
                                            }
                                        }
                                        else 
                                            if (zMSsubsection.indexOf("tigers") != -1) {
                                                zMSmask = "/AAMCM=G0000W0008";
                                                
                                            }
                                            else 
                                                if (zMSsubsection.indexOf("saints") != -1) {
                                                    zMSmask = "/AAMCM=0000G000K01";
                                                    if (zMSadvdecider <= 100) {
                                                        zMSmask = zMSmask + "/ADVID=1796";
                                                    }
                                                }
                                                else 
                                                    if (zMSsubsection.indexOf("swans") != -1) {
                                                        zMSmask = "/AAMCM=20000W104";
                                                        if (zMSadvdecider <= 33) {
                                                            zMSmask = zMSmask + "/ADVID=1696";
                                                        }
                                                        else 
                                                            if (zMSadvdecider <= 66) {
                                                                zMSmask = zMSmask + "/ADVID=1676";
                                                            }
                                                            else 
                                                                if (zMSadvdecider <= 100) {
                                                                    zMSmask = zMSmask + "/ADVID=2961";
                                                                }
                                                    }
                                                    else 
                                                        if (zMSsubsection.indexOf("portpower") != -1) {
                                                            zMSmask = "/AAMCM=0W000W004";
                                                            if (zMSadvdecider <= 100) {
                                                                zMSmask = zMSmask + "/ADVID=1796";
                                                            }
                                                        }
                                                        else 
                                                            if (zMSsubsection.indexOf("bulldogs") != -1) {
                                                                zMSmask = "/AAMCM=00040000m";
                                                            }
                                                            else 
                                                                if (zMSsubsection.indexOf("eagles") != -1) {
                                                                    zMSmask = "/AAMCM=20000W014";
                                                                    if (zMSadvdecider <= 25) {
                                                                        zMSmask = zMSmask + "/ADVID=1796";
                                                                    }
                                                                    else 
                                                                        if (zMSadvdecider <= 50) {
                                                                            zMSmask = zMSmask + "/ADVID=2961";
                                                                        }
                                                                        else 
                                                                            if (zMSadvdecider <= 75) {
                                                                                zMSmask = zMSmask + "/ADVID=2013";
                                                                            }
                                                                            else 
                                                                                if (zMSadvdecider <= 100) {
                                                                                    zMSmask = zMSmask + "/ADVID=2931";
                                                                                }
                                                                }
        //end of classification mask hack
    }
    
	if(zMSlocation.indexOf("dreamteam") != -1){
		zMSACCarea = "SPORT.AFL_HOME.AFL_DREAMTEAM"; 
	}

	if(zMSlocation.indexOf("development") != -1){
		zMSACCarea = "SPORT.AFL_HOME.AFL_DEVELOPMENT"; 
	}
	
	
	parntLocation = top.location + "";
    
	//fixture and venues
	if (parntLocation.indexOf("venues") != -1) {
        if (parntLocation.indexOf("victoria") != -1) {
			zMSsub_section='afl_VENUES.VIC';
			zMSACCarea = "SPORT.AFL_HOME.AFL_VENUES.VIC";
		}else{
			zMSsub_section='afl_VENUES';
			zMSACCarea = "SPORT.AFL_HOME.AFL_VENUES";
		}
	
    }
	
	
	
    //Testing environment
    if (parntLocation.indexOf("zmstestingenvironment375") != -1) {
        zMSACCarea = "MOB.TEST.DEMO";
        zMSACCsite = "Z_ZORRO";
    }
	

    
    //DoubleClick Testing
    if (parntLocation.indexOf("doubleclick_testingenvironment_jscript182") != -1) {
        zMSACCarea = "MOBILE.BOOMERANG.OTHER";
        zMSACCsite = "Z_ZORRO";
    }
    if (parntLocation.indexOf("doubleclick_testingenvironment_iframe182") != -1) {
        zMSACCarea = "MOBILE.BOOMERANG.CHEAPMOBILES";
        zMSACCsite = "Z_ZORRO";
    }
    if(zMSlocation.indexOf("dreamteam") != -1){
		zMSACCarea = "SPORT.AFL_HOME.AFL_DREAMTEAM"; 
	}
	//manual betting targeting
	if(zMSlocation.indexOf("betting") != -1){
		zMSsub_section='afl_BETTING';
		zMSACCarea = "SPORT.AFL_HOME.AFL_BETTING"; 
	}
	//manual TICKETS section targeting
	if(zMSlocation.indexOf("ticket") != -1){
		zMSsub_section='afl_TICKETS';
		zMSACCarea = "SPORT.AFL_HOME.AFL_TICKETS"; 
	}
	
	//Hack for NavBar on AFL Club site
	//Geelong
	if(zMSlocation.indexOf("www.geelongcats.com") != -1) {
		zMSACCsite = "TEL.AFL_CATSFC_HOME.SPORT";
		zMSACCarea = "SPORT.AFL_CATSFC_HOME.HOME";
	}
	if(zMSlocation.indexOf("www.gfc.com") != -1) {
		zMSACCsite = "TEL.AFL_CATSFC_HOME.SPORT";
		zMSACCarea = "SPORT.AFL_CATSFC_HOME.HOME";
	}
	//Hawthorn
	if(zMSlocation.indexOf("www.hawthornfc.com") != -1) {
		zMSACCsite = "TEL.AFL_HAWKSFC_HOME.SPORT";
		zMSACCarea = "SPORT.AFL_HAWKSFC_HOME.HOME";
	}
	//Brisbane
	if(zMSlocation.indexOf("www.lions.com") != -1) {
		zMSACCsite = "TEL.AFL_LIONSFC_HOME.SPORT";
		zMSACCarea = "SPORT.AFL_LIONSFC_HOME.HOME";
	}
    //Fremantle
    if(zMSlocation.indexOf("www.fremantlefc.com") != -1) {
		zMSACCsite = "TEL.AFL_DOCKERSFC_HOME.SPORT";
		zMSACCarea = "SPORT.AFL_DOCKERSFC_HOME.HOME";
	}
}

var zMSHasUtilFileBeenAlreadyLoaded = true;