
function takemeto(x){


if (document.form1.priorities.value != "null") {
	document.location.href = x;
	}
}

// This part of script alleviates a Netscape document.write bug
NS4 = document.layers;
if (NS4) {
	origWidth = innerWidth;
	origHeight = innerHeight;
}
	function reDo() {
		if (innerWidth != origWidth || innerHeight != origHeight)
			location.reload();
	}
		if (NS4) onresize = reDo;

	
	function rndNum()
	{
		var axel = Math.random() + ""; 
		var ord = axel * 1000000000000000000;
		return ord;
	}
	
	var ord = rndNum();
	//alert(ord);
		
	function getSitename (domain)
	{
		var sitename = "";
		
			switch (true) {
				case domain.search('fitnessonline') != -1 :
				sitename = "fitnessonline";
				break;
				case domain.search('mens') != -1 :
				sitename = "mens";
				break;
				case domain.search('naturalhealth') != -1 :
				sitename = "naturalhealth";
				break;
				case domain.search('preg') != -1 :
				sitename = "fitpreg";
				break;
				case domain.search('flex') != -1 :
				sitename = "flex";
				break;
				case domain.search('hers') != -1 :
				sitename = "mfhers";
				break;
				}
			return sitename;		
	}
		
		function getPage(url)
		{
			var pagename;
			var theURL1 = url.replace(/http:\/\/(\w+)\.(\w+)\.(\w+)\//g, '');	
			var theURL = theURL1.toLowerCase();
			
			if (theURL.search('fitnmagart') > -1 )							// if page is article								
				{																											
					pagename = 'article';
				}
			else if (theURL.search('fitnmagcat') > -1 )						// if page is category
				{
					pagename = 'toc';
				}
			else if (theURL.length < 1 || theURL.search('index') > -1 ) 	//if page is home
				{
					pagename = 'home';
				}	
			else  
				{
					pagename = 'other';
				}	
			return pagename;	
		}	
		
		function getDescriptor(url)
		{
			var questionIndex, tempDescriptor, descriptor = '/', addToDescriptor = '', queryString = '';
			var theURL1 = url.replace(/http:\/\/(\w+)\.(\w+)\.(\w+)\//g, '');							// get the URL without the domain name
			var theURL = theURL1.toLowerCase();
			//alert(theURL.search('fitnmag'));				
			if ( (theURL.search('fitnmagcat') > -1) || (theURL.search('fitnmagart') > -1) )										// if it's the category or article page
				{																		
					descriptor = 'generic';
					
					if ( theURL.search(/\?/) != -1 )												// if Querystring exist
					{
							questionIndex = theURL.search(/\?/);									// Get the strings
							queryString = theURL.substring(questionIndex + 1, theURL.length);		// and then parse it				
							var aryQueryStrings = queryString.split("&");
							var value;
							for (i=0; i < aryQueryStrings.length;i++)
								{
									if (aryQueryStrings[i].search('supercid') > -1)					//fid url parameter SuperCID
									{
										value = aryQueryStrings[i].replace( /\w+\=/gi,'');
										//alert(value);
										switch (true) {
											//FOL
											case value == "4" :
											descriptor = "exercise";
											break;
											case value == "5" :
											descriptor = "nutrition";
											break;
											case value == "6" :
											descriptor = "mindbody";
											break;
											case value == "9" :
											descriptor = "health";
											break;
											case value == "8" :
											descriptor = "adventure";
											break;
											case value == "7" :
											descriptor = "buyersguide";
											break;
											//fit preg
											case value == "464" :
											descriptor = "products";
											break;
											case value == "220" :
											descriptor = "fitness";
											break;
											case value == "221" :
											descriptor = "nutrition";
											break;
											case value == "222" :
											descriptor = "mindbody";
											break;
											case value == "462" :
											descriptor = "health";
											break;
											case value == "463" :
											descriptor = "yourbaby";
											break;
											//flex
											case value == "447" :
											descriptor = "training";
											break;
											case value == "446" :
											descriptor = "nutrition";
											break;
											case value == "474" :
											descriptor = "supplements";
											break;
											//mens
											case value == "207" :
											descriptor = "training";
											break;
											case value == "208" :
											descriptor = "nutrition";
											break;
											case value == "455" :
											descriptor = "sexbehavior";
											break;
											case value == "456" :
											descriptor = "health";
											break;
											case value == "457" :
											descriptor = "sportsadv";
											break;
											case value == "458" :
											descriptor = "gear";
											break;
											//mfhers
											case value == "535" :
											descriptor = "training";
											break;
											case value == "536" :
											descriptor = "nutrition";
											break;
											case value == "537" :
											descriptor = "mindbody";
											break;
											case value == "538" :
											descriptor = "health";
											break;
											case value == "539" :
											descriptor = "trainingscience";
											break;
											//nathealth
											case value == "201" :
											descriptor = "training";
											break;
											case value == "202" :
											descriptor = "nutrition";
											break;
											case value == "542" :
											descriptor = "recipes";
											break;
											case value == "452" :
											descriptor = "buyers";
											break;
											case value == "453" :
											descriptor = "homeremedies";
											break;
											case value == "454" :
											descriptor = "yourhealth";
											break;
											case value == "543" :
											descriptor = "supplement";
											break;
											}										 
									}
								}
					}
				}
			else
				{	
					descriptor = 'generic';
				}
			return descriptor;
		}
		
function replaceSubstring(inputString, fromString, toString) {
   // Goes through the inputString and replaces every occurrence of fromString with toString
   var temp = inputString;
   if (fromString == "") {
      return inputString;
   }
   if (toString.indexOf(fromString) == -1) { // If the string being replaced is not a part of the replacement string (normal situation)
      while (temp.indexOf(fromString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;
      }
   } else { // String being replaced is part of replacement string (like "+" being replaced with "++") - prevent an infinite loop
      var midStrings = new Array("~", "`", "_", "^", "#");
      var midStringLen = 1;
      var midString = "";
      // Find a string that doesn't exist in the inputString to be used
      // as an "inbetween" string
      while (midString == "") {
         for (var i=0; i < midStrings.length; i++) {
            var tempMidString = "";
            for (var j=0; j < midStringLen; j++) { tempMidString += midStrings[i]; }
            if (fromString.indexOf(tempMidString) == -1) {
               midString = tempMidString;
               i = midStrings.length + 1;
            }
         }
      } // Keep on going until we build an "inbetween" string that doesn't exist
      // Now go through and do two replaces - first, replace the "fromString" with the "inbetween" string
      while (temp.indexOf(fromString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + midString + toTheRight;
      }
      // Next, replace the "inbetween" string with the "toString"
      while (temp.indexOf(midString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(midString));
         var toTheRight = temp.substring(temp.indexOf(midString)+midString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;
      }
   } // Ends the check to see if the string being replaced is part of the replacement string or not
   return temp; // Send the updated string back to the user
} // Ends the "replaceSubstring" function

		
		function displayBanner(adwidth, adheight, adpopup, tile)
		{
			//is the ad a popup
			if (adpopup == true)
			{
				var popuptext = "dcopt=ist;";
			}
			else
			{
				var popuptext = "";
			}
			
			
			var url = document.location.href;
			var domain = window.location.host;
			var sitename = getSitename(domain);
			//alert(sitename);
			var adDescriptor = getDescriptor(url);
			//alert(adDescriptor);
			var adPage = getPage(url);
			//alert(adPage);
			//alert(popuptext);
			
			
			var adStr = "";
			//document.write('<!-- Begin DFP Ad Tag -->');	
			adStr += "<!-- Begin DFP Ad Tag -->";
						
			//document.write("<SCR" + "IPT LANGUAGE=\"JavaScript1.1\" SRC=\"http://ad.doubleclick.net/adj/"+ sitename + "." + adDescriptor + ".dart/"+ adDescriptor +";sub="+ adPage +";" + popuptext + "tile="+ tile +";sz="+ adwidth +"x"+ adheight +";ord=" + ord + "?\">");
			adStr += "<SCR" + "IPT LANGUAGE=\"JavaScript1.1\" SRC=\"http://ad.doubleclick.net/adj/"+ sitename + "." + adDescriptor + ".dart/"+ adDescriptor +";sub="+ adPage +";" + popuptext + "tile="+ tile +";sz="+ adwidth +"x"+ adheight +";ord=" + ord + "?\">";
			//document.write('</SCR' + 'IPT>');
			adStr += '</SCR' + 'IPT>';
				
			if ((!document.images && navigator.userAgent.indexOf("Mozilla/2.") >= 0)  || navigator.userAgent.indexOf("WebTV")>= 0) {
				//document.write('<A HREF="http://ad.doubleclick.net/jump/'+ sitename + '.' + adDescriptor + '.dart/'+ adDescriptor +';sub='+ adPage +';tile=' + tile + ';sz='+ adwidth + 'x' + adheight + ';ord=' + ord + '?" TARGET="_blank">');
				adStr += '<A HREF="http://ad.doubleclick.net/jump/'+ sitename + '.' + adDescriptor + '.dart/'+ adDescriptor +';sub='+ adPage +';tile=' + tile + ';sz='+ adwidth + 'x' + adheight + ';ord=' + ord + '?" TARGET="_blank">';
				//document.write('<IMG SRC="http://ad.doubleclick.net/ad/'+ sitename + '.' + adDescriptor + '.dart/' + adDescriptor + ';sub='+ adPage +';tile='+ tile +';sz='+ adwidth + 'x' + adheight + ';ord=' + ord + '?" WIDTH="'+ adwidth + '" HEIGHT="' + adheight + '" BORDER="0" ALT=""></A>');
				adStr += '<IMG SRC="http://ad.doubleclick.net/ad/'+ sitename + '.' + adDescriptor + '.dart/' + adDescriptor + ';sub='+ adPage +';tile='+ tile +';sz='+ adwidth + 'x' + adheight + ';ord=' + ord + '?" WIDTH="'+ adwidth + '" HEIGHT="' + adheight + '" BORDER="0" ALT=""></A>';
			}
			
			// Output Dynamic Ad String for DoubleClick			
			document.write(adStr);
						
			// If 'debug' exists in URL string, output for display the Ad String
			// simply for testing purposes
			if (document.location.href.indexOf("debug") > 0) {
				document.write(replaceSubstring(replaceSubstring(adStr, "<", "&lt;"), ">", "&gt;"));
			}
		}
		
		function displayad468x60(tile)
		{
			displayBanner('468', '60', false, tile);
		}
		
		function displayad468x60popup(tile)
		{
			displayBanner('468', '60', true, tile);
		}
		
		function displayad100x150(tile)
		{
			displayBanner('100', '150', false, tile);
		}
		
		function displayad100x150popup(tile)
		{
			displayBanner('100', '150', true, tile);
		}
		
		function displayad150x175(tile)
		{
			displayBanner('150', '175', false, tile);
		}
		
		function displayad150x175popup(tile)
		{
			displayBanner('150', '175', true, tile);
		}
		
		function displayad125x75(tile)
		{
			displayBanner('125', '75', false, tile);
		}
		
		function displayad125x75popup(tile)
		{
			displayBanner('125', '75', true, tile);
		}
		
		function displayad120x600(tile)
		{
			displayBanner('120', '600', false, tile);
		}
		
		function displayad120x600popup(tile)
		{
			displayBanner('120', '600', true, tile);
		}