var ratio_300x250 = 60; // percentage for rectangles
var ratio_300x600 = 20; // percentage for half pages
var ratio_160x600 = 0; // percentage for skyscraper
var ratio_opa = 20; // percentage for opa ads

var opa_ad_size = "336x850"; //defines the size of opa ads. Could be either 336x700 or 336x850
var hide_728x90_with_opa = true; // if set to true the 728x90 banner ad will be hidden when an opa is served
var hide_260x60_with_opa = false; // if set to true the 260x60 masthead ad will be hidden when an opa ad is served. 
var hide_all_modules_with_opa = true; //if set to true all modules in right column are hidden

var default_layout = "magpromo,mostemailed"; //no spaces, default modules that are show when flex template is in use. works on id containers

//var fixed_right_column = true;  // disable right column magic and init adArray with default layout
var double_rectangles = true;  // serve extra rectangle on article pages

var fixedtarget = [
				   
['/guides/valentines/2008/43072','300x250,magpromo,mostemailed'],
['/relationships/sex/43062','300x250,magpromo,mostemailed'],
['/arts/cultureawards/2006/25317','160x600,magpromo,FIXED'],
['/arts/art/','300x250,magpromo,mostemailed,sectionpromo,FIXED'],
['arts/cultureawards/2006/25309','160x600,magpromo,FIXED'],
//['/arts/','300x600,magpromo,mostemailed,FIXED'],
['guides/everything/shoes/27345','160x600,FIXED,magpromo'],
['guides/halloween/extra160/22289','160x600,FIXED,magpromo'],
['guides/halloween/extra160/22290','160x600,FIXED,magpromo'],
['guides/holidays/gifts/24411','160x600,magpromo'],
['guides/fallpreview/2009','300x250,magpromo,mostemailed,FIXED'],
//['news/','300x600,magpromo,mostemailed,FIXED'],
['/news/index.html','300x250,FIXED'],
['news/features/2007/cancer/32123','160x600,magpromo,FIXED'],
['news/features/27341/index7.html','160x600,FIXED,magpromo'],
['news/features/27845/index2.html','160x600,FIXED,magpromo'],
['news/intelligencer/27854','160x600,FIXED,magpromo'],
['news/people/18842/index4.html','160x600,magpromo'],
['news/people/31541','160x600,magpromo'],
['nightlife/partylines','160x600,FIXED'],
['realestate/features/21339/index1.html','160x600,magpromo'],
['realestate/map/25311/','160x600,magpromo'],
['restaurants/features/31268/index1.html','160x600,magpromo'],
['shopping/articles/sb','160x600,magpromo'],
['/special_wide_feature/','160x600,FIXED'], // Default category for setting an article to use a tower ad. 
['travel/weekends','300x250,magpromo,mostemailed,travelscreamwide'],
['travel', '336x600,magpromo,mostemailed,travelscreamwide'],
['/realestate/vu/2007/10/','336x600,FIXED'],
['/realestate/vu/2008/04/','336x600,FIXED'],
['/fashion/look/','300x250,magpromo,FIXED'],
['/nymag/sponsored/paris/', '336x600,FIXED'],
['/nymag/sponsored/green-design/', '300x250,FIXED'],
['/fashion/fashionshows/seasons/2008/paris-wrtw/', '160x600,FIXED'],
['/fashion/','300x250,FIXED'],
['/shopping/','300x250,FIXED'],
['/beauty/','300x250,FIXED'],
['/listings/attraction/french-institute-alliance-francaise/', '160x600,FIXED'],
['/realestate/features/','336x600,realestatepromo'],
['weddings','160x600,FIXED']
];

function showDefaultFlexModules(){
	$nymag_j("div.modBlock").css("display","none");
	var defaultModules = fixed_targeting ? modBlocks : default_layout.split(",");

	for (var i=0; i < defaultModules.length; i++) {
		var selector = '#' + defaultModules[i];
		$nymag_j(selector).show();
	}
	
	if (hide_all_modules_with_opa && opa_ad_served){
		$nymag_j("div.modBlock").css("display","none");
	}
}

function changeClass(){
	if($nymag_j("body").length) $nymag_j("body").removeClass("fixed_right_column").addClass("ad-column-180");
	else timer = setTimeout(changeClass, 10);
}

var fixed_targeting = false;
var currenturl = parent.location.href;
var adSize="";
for (var i=0; i < fixedtarget.length; i++) {
	var pattern = fixedtarget[i][0];
	if (!fixed_targeting && currenturl.match(pattern)) {
		targetString = fixedtarget[i][1];
		fixed_targeting = true;
		adSize = fixedtarget[i][1].split(",")[0];
		var modBlocks = targetString.split(",");
		rightColadSize = modBlocks[0];
	} 
}

if(fixed_targeting && adSize == "160x600"){
	changeClass();
}