//USAGE:
//paste the following codes on the right place via editortool (for ad inside story) and templatetool //(for skyscriper and buttom)
//
// <!-- cut from here -->
//
//  <script language="JavaScript">
//     var hosted_site ="__SITE__";
//     var hosted_section ="__SECTION__";
//     if ( !(hosted_site)) { hosted_site="AP";}
//     if ( !(hosted_section)) { hosted_section="FRONT";}
//     
//  </script>
//
//  <script language="JavaScript" src="http://hosted.ap.org/specials/hosted_ad.js"></script>
//
//<!-- AP call to x96  -->
//   <script language="JavaScript">hosted_ad('@x96');</script>
//
//<!-- AP call to @x03  -->
//   <script language="JavaScript">hosted_ad_pop('@x03');</script>
//
//<!-- AP call to @x02  -->
//   <script language="JavaScript">hosted_ad('@x02');</script>
//
// <!-- end of cut -->
//
//END of USAGE

	var hosted_site;
	var hosted_section;
//###############################
// Frequency control Popout ad 
//###############################
	var siteDomain = 'ap.org';//set domain for cookie
	var forcePop = 0;//set to 1 to force window to pop | set to 0 to not force pop-up
	var freq = 2;//how often to show same user spawned ad (hour)

//delete cookie by uncomment below line
//document.cookie="appop=winstar;expires="+"Fri, 18 Jul 2001 14:08:33 UTC"+";path=/";

// create control cookie
	var expdate = new Date ();
	expdate.setTime(expdate.getTime() + (freq*60*60*1000));
	expdate=expdate.toGMTString();
 	var wsCkEx=document.cookie.indexOf("appop=winstar");
 	
function check_exc()
{
  var excArray = new Array('ORSAL','ASIAONE','WNYC','GORBC','FINDO','ILCDLB','OREUG','SGSPL','NPROLY','DCSAS','WBAL','IXPRS','IIHGL','KWVE','WBZAM','LYCOS','WIRE','TXTYL','ZEBRA');
  for (var i = 0; i < excArray.length; i++)
  {
   if (excArray[i] == hosted_site) { return 0; }
  }
  return 1;
}

function check_exc_pop()
{
  var excPopArray = new Array('1010WINS','AKAJC','AKFAI','ALACN','ALDOT','ALOPE','ARLID','AZPHG','CACRU','CAELI','CARED','CASTO','COCAN','CODEN','CODER','CTDAN','CTGRN','DCUSN','FLPAP','FLTAM','IDMOS','ILLIN','ININS','KBMT','KQVAM','KYW','KYWAM','KYWIN','LACHA','MABED','MAHYC','MIANN','MITRA','MTBIL','MTHEL','NCCON','NCHIC','NCSTA','NCWIN','NHPOR','NMALJ','NVLAS','NYMID','NYNSU','NYNYP','NYONE','NYPLA','OHALL2','OHCOL','OKOKL','ORMED','PAGET','PAHAN','PAPIT','PASOM','PASTR','PASUN','SCFLO','TNCHA','TXADT','TXBAY','TXCLU','TXCOR','TXDEL','TXGAL','TXKER','TXNEW','TXTEC','VACHA','VACUL','VALYD','VANOV','VAPET','VARIT','VAWOO','WASPO','WDNZ','WHIZ','WHSV','WOOD','WOZZ','WSHU','WTMJ','NCWILHN');
  for (var i = 0; i < excPopArray.length; i++)
  {
   if (excPopArray[i] == hosted_site) { return 0; }
  }
  return 1;
}


function hosted_ad(hosted_pos)
{
 
  var excVal = check_exc();

  if( excVal == 1 )
  {
   var RN = new String(Math.random());
   var RNS = RN.substring(2, 11);
   document.write('<div align="center"><font face="Arial,Helvetica,Sans Serif" color="#999999" size="1">Advertisement</font></div>');
   document.write('<div align="center"><script language="JavaScript1.1" src="http://oascentral.hosted.ap.org/RealMedia/ads/adstream_jx.ads/'+ hosted_site + '.hosted.ap.org/'+ hosted_section + '/1' + RNS + hosted_pos + '">');
   document.write('<a href="http://oascentral.hosted.ap.org/RealMedia/ads/click_nx.ads/' + hosted_site + '.hosted.ap.org/' + hosted_section + '/1' + RNS + hosted_pos + '">');
   document.write('<img src="http://oascentral.hosted.ap.org/RealMedia/ads/adstream_nx.ads/'+ hosted_site +'.hosted.ap.org/' + hosted_section + '/1' + RNS + hosted_pos + '"></a>');
   document.write('<\/script>'+'\</div>');
  }
}


function hosted_ad_pop(hosted_pos)
{  
  var excVal = check_exc();  
  
  if (excVal == 1)
  {
  	  var excPopVal = check_exc_pop();
	  if (excPopVal == 1)
	  {
	    var RN = new String(Math.random());
	    var RNS = RN.substring(2, 11);
	    document.write('<div align="center"><script language="JavaScript1.1" src="http://oascentral.hosted.ap.org/RealMedia/ads/adstream_jx.ads/'+ hosted_site + '.hosted.ap.org/'+ hosted_section + '/1' + RNS + hosted_pos + '">');
	    document.write('<a href="http://oascentral.hosted.ap.org/RealMedia/ads/click_nx.ads/' + hosted_site + '.hosted.ap.org/' + hosted_section + '/1' + RNS + hosted_pos + '">');
	    document.write('<img src="http://oascentral.hosted.ap.org/RealMedia/ads/adstream_nx.ads/'+ hosted_site +'.hosted.ap.org/' + hosted_section + '/1' + RNS + hosted_pos + '"></a>');
	    document.write('<\/script>'+'\</div>');
	  }
  }
}
 
//###############################################
//popout ad for tracking the traffic for Winstar
//###############################################

function winstar_pop(hosted_pos)
{
  var excVal = check_exc();  
  if (excVal == 1)
  {
    	  var excPopVal = check_exc_pop();

	  if (((forcePop == 1) || (wsCkEx == -1)) && excPopVal == 1)
	  {
	  	document.cookie="appop=winstar;expires="+expdate+";path=/";
		win247=window.open("http://c5.zedo.com/jsc/c5/ff2.html?n=305;c=377/1;s=248;d=17;w=720;h=300", 'windowName', 'toolbar=no,location=no,scrollbars=no,resizable=no,width=720,height=300');
		win247.blur();
		self.window.focus();
		if (!win247.opener) {win247.opener = self;}
		hosted_ad_pixel(hosted_pos);
	  }
  }
}


function hosted_ad_ctx(hosted_pos)
{
  var excVal = check_exc();
  if( excVal == 1 )
  {
   var RN = new String(Math.random());
   var RNS = RN.substring(2, 11);
   document.write('<div align="center"><script language="JavaScript1.1" src="http://oascentral.hosted.ap.org/RealMedia/ads/adstream_jx.ads/'+ hosted_site + '.hosted.ap.org/'+ hosted_section + '/1' + RNS + hosted_pos + '">');
   document.write('<a href="http://oascentral.hosted.ap.org/RealMedia/ads/click_nx.ads/' + hosted_site + '.hosted.ap.org/' + hosted_section + '/1' + RNS + hosted_pos + '">');
   document.write('<img src="http://oascentral.hosted.ap.org/RealMedia/ads/adstream_nx.ads/'+ hosted_site +'.hosted.ap.org/' + hosted_section + '/1' + RNS + hosted_pos + '"></a>');
   document.write('<\/script>'+'\</div>');
  }
}

//###############################################
//pixel ad for tracking the traffic for Winstar
//###############################################
function hosted_ad_pixel(hosted_pos)
{
 
  var excVal = check_exc();

  if( excVal == 1 )
  {
   var RN = new String(Math.random());
   var RNS = RN.substring(2, 11);
   document.write('<div align="center"><script language="JavaScript1.1" src="http://oascentral.hosted.ap.org/RealMedia/ads/adstream_jx.ads/'+ hosted_site + '.hosted.ap.org/'+ hosted_section + '/1' + RNS + hosted_pos + '">');
   document.write('<a href="http://oascentral.hosted.ap.org/RealMedia/ads/click_nx.ads/' + hosted_site + '.hosted.ap.org/' + hosted_section + '/1' + RNS + hosted_pos + '">');
   document.write('<img src="http://oascentral.hosted.ap.org/RealMedia/ads/adstream_nx.ads/'+ hosted_site +'.hosted.ap.org/' + hosted_section + '/1' + RNS + hosted_pos + '"></a>');
   document.write('<\/script>'+'\</div>');
  }
}