// AdServer. NMH

var AllNvAds = new Array(
new AddAd("Your own web community","http://www.netvillage.com","http://adserver.netvillage.com/AdServer/Netvillage/","300x250,180x150,160x600,468x60,88x31,120x60,120x90,120x240,120x600,125x125,234x60,240x400,250x250,300x100,300x600,336x280,720x300,726x90,728x90"),
new AddAd("Dating Service for beautiful people","http://www.dreammatches.com","http://adserver.netvillage.com/AdServer/DreamMatches/","468x60,120x240,125x125,234x60")
); // No comma after last array item

// read javaScript arguments via the src attribute
var scripts = document.getElementsByTagName('script');
var myScript = scripts[ scripts.length - 1 ];
var queryString = myScript.src.replace(/^[^\?]+\??/,'');
var params = parseQuery( queryString );
function parseQuery ( query ) {
   var Params = new Object ();
   if ( ! query ) return Params; // return empty object
   var Pairs = query.split(/[;&]/);
   for ( var i = 0; i < Pairs.length; i++ ) {
      var KeyVal = Pairs[i].split('=');
      if ( ! KeyVal || KeyVal.length != 2 ) continue;
      var key = unescape( KeyVal[0] );
      var val = unescape( KeyVal[1] );
      val = val.replace(/\+/g, ' ');
      Params[key] = val;
   }
   return Params;
}

function AddAd(alt,url,img,formats) {
	this.alt=alt;
	this.url=url;
	this.img=img;
	this.formats=formats;
}
var SomeAds=new Array();
var nvAd;
var nvAdWH;
var nvAdWidth;
var nvAdHeight;
var nvAdType;

nvAdWH=params['nvAdFormat'].split("x");
nvAdWidth=nvAdWH[0];
nvAdHeight=nvAdWH[1];
nvAdType=params['nvAdType'];

if (nvAdType=='T') {
	document.write('<iframe src="http://adserver.netvillage.com/AdServer/TextAds/' + params['nvAdFormat'] + '.HTM" width=' + quoteString(nvAdWidth) + ' height=' + quoteString(nvAdHeight) + ' frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no"></iframe>');
} else {

	var adFormats;
	for(i = 0; i < AllNvAds.length; i++){
		nvAd = AllNvAds[i];
		adFormats = nvAd.formats.split(",");
		for(j = 0; j < adFormats.length; j++){
			if (adFormats[j] == params['nvAdFormat'])
				SomeAds[SomeAds.length]=nvAd;
		}
	}
	nvAd = SomeAds[Math.floor(Math.random()*SomeAds.length)];

	document.write('<a href=\"' + nvAd.url + '\" target=\"_blank\" class="noline">');
	document.write('<img src=\"' + nvAd.img +  params['nvAdFormat'] +'.jpg\" ');
	document.write(' width=' + nvAdWidth + ' height=' + nvAdHeight + ' ');
	document.write('alt=\"' + nvAd.alt + '\"></a>');
}

function quoteString(b) {
	return b != null ? '"' + b + '"' : '""';
}


