/********************************
 * Functions List:
 * - banner (sitepage, position, querystr, filterstr)
 * - banner2 (sitepage, position, querystr, filterstr)
 * - callBanner(sitepage, position, staticpos, querystr, filterstr)
 * - bannerTop1_2(sitepage, server, staticpos)
 * Library Used:
 * - sniffer2.js
 ********************************/

// variabili comuni
var server = 'adv.ilsole24ore.it'; // server ADV

/*
 *  Funzione generata automaticamante da RealMedia
 *  e parametrizzata da noi.
 */
function banner (sitepage, position, querystr, filterstr) {
	//var staticpos = 'Bottom,Left,Middle1,Middle2,Middle3,Right,Top,Top1,Top2,Top3!';
	var staticpos = '';
	callBanner(sitepage, position, staticpos, querystr, filterstr);
}

/*
 * Vecchia funzione banner senza la lista delle posizioni.
 * Ovvero chiamo callBanner con staticpos vuota.
 */
function banner2 (sitepage, position, querystr, filterstr) {
	var staticpos = '';
	callBanner(sitepage, position, staticpos, querystr, filterstr);
}

function bannerPay (sitepage, position, querystr, filterstr) {
	var staticpos = '';
	if (position == "Top" || position == "Bottom" || position == "SkyScraper" || position == "VideoBox") {
		callBanner(sitepage, position, staticpos, querystr, filterstr);
	} 
}

/*
 *  Chiamata comune per i banner.
 *  Funzione generata automaticamante da RealMedia
 *  e parametrizzata da noi.
 */
function callBanner(sitepage, position, staticpos, querystr, filterstr) {
	var retValue;
	if (position == "Top1" || position == "Top2") {
		bannerTop1_2(sitepage, server, staticpos);
	} else {
		if (! (RN)) {
			var RN = new String (Math.random());
			var RNS = RN.substring (2, 11);
		}
		
		var oas='http://' + server + '/RealMedia/ads/';
		var oaspage = sitepage + '/1' + RNS + '@' + staticpos + position;
		if (querystr != "") oaspage += "?q=" + querystr + "&filter=" + filterstr;
		oaspage = oaspage.replace("\ ", "\+");
		
		// is_js è calcolato dal file sniffer2.js
		if ( is_js < 1.1 ) {
			//retValue = '<A HREF="' + oas + 'click_nx.ads/'+ oaspage + '" TARGET="_blank" ><IMG SRC="' + oas + 'adstream_nx.ads/' + oaspage + '"  BORDER="0" ALT="" ></a>';
					
		document.write ('<A HREF="' + oas + 'click_nx.ads/'+ oaspage + '" TARGET="_blank" ><IMG SRC="' + oas + 'adstream_nx.ads/' + oaspage + '"  BORDER="0" ALT="" ></a>');
		} else {
			/*retValue = '<SCRIPT LANGUAGE="JavaScript1.1" SRC="' + oas + 'adstream_jx.ads/' + oaspage + '">';
			retValue += '\<\!-- --\>';
			retValue += '\<\/SCRIPT\>';
			retValue += '\<\!-- --\>';*/
			
		  document.write ('<SCRIPT LANGUAGE="JavaScript1.1" SRC="' + oas + 'adstream_jx.ads/' + oaspage + '">');
		  document.write ('\<\!-- --\>');
		  document.write ('\<\/SCRIPT\>');
		  document.write ('\<\!-- --\>');
		}
	}
	
}

/*
 *  Funzione per renderizzare i banner top1 e top2.
 *  Funzione generata automaticamante da RealMedia
 *  e parametrizzata da noi. 
 */
function bannerTop1_2(sitepage, server, staticpos) {
	if (!document.layers)
	{
	   if (document.body.clientWidth>900)
	   {
	     document.write('<SCRIPT LANGUAGE="JavaScript"><\!--\n');
		   document.write('_version=10;\n');
		   document.write('//--'+'>\n');
		   document.write('<'+'/script><SCRIPT LANGUAGE="JavaScript1.1"><\!--\n');
		   document.write('_version=11;\n');
		   document.write('if (navigator.userAgent.indexOf(\'Mozilla/3\') != -1){\n');
		   document.write('_version=10;}\n');
		   document.write('//--'+'>\n');
		   document.write('<'+'/script><SCRIPT LANGUAGE="JavaScript"><\!--\n');
		   document.write('var server = \'' + server + '\';\n');
		   document.write('var sitepage = "' + sitepage + '";\n');
		   document.write('var staticpos = "' + staticpos + '";\n');
		   document.write('var position ="Top1";\n');
		   document.write('if (! (RN)){\n');
		   document.write('var RN = new String (Math.random());\n');
		   document.write('var RNS = RN.substring (2, 11);}\n');
		   document.write('var oas=\'http://\'+ server +\'/RealMedia/ads/\';\n');
		   document.write('var oaspage= sitepage + \'/1\' + RNS + \'@\' + staticpos + position;\n');
		   document.write('if (_version < 11){\n');
		   document.write('document.write (\'<A HREF="\'+ oas +\'click_nx.ads/\'+ oaspage +\'" TARGET="_blank" ><IMG SRC="\'+ oas +\'adstream_nx.ads/\'+ oaspage +\'" BORDER="0" WIDTH="468" HEIGHT="60" ALT="Visita il nostro sponsor!" ></a>\');\n');
		   document.write('} else {\n');
		   document.write('document.write (\'<\' + \'SCRIPT LANGUAGE="JavaScript1.1" SRC="\' + oas + \'adstream_jx.ads/\' + oaspage + \'">\');\n');
		   document.write('document.write (\'\\<\\!\\-- --\\>\');\n');
		   document.write('document.write (\'\\<\\/SCRIPT\\>\');\n');
		   document.write('document.write (\'\\<\\!\\-- --\\>\'); }\n');
	       document.write('//--'+'><'+'/SCRIPT>');
	   }
	   else
	   {
	       document.write('<SCRIPT LANGUAGE="JavaScript"><\!--\n');
		   document.write('_version=10;\n');
		   document.write('//--'+'>\n');
		   document.write('<'+'/script><SCRIPT LANGUAGE="JavaScript1.1"><\!--\n');
		   document.write('_version=11;\n');
		   document.write('if (navigator.userAgent.indexOf(\'Mozilla/3\') != -1){\n');
		   document.write('_version=10;}\n');
		   document.write('//--'+'>\n');
		   document.write('<'+'/script><SCRIPT LANGUAGE="JavaScript"><\!--\n');
		   document.write('var server = \'' + server + '\';\n');
		   document.write('var sitepage = "' + sitepage + '";\n');
		   document.write('var staticpos = "' + staticpos + '";\n');
		   document.write('var position ="Top2";\n');
		   document.write('if (! (RN)){\n');
		   document.write('var RN = new String (Math.random());\n');
		   document.write('var RNS = RN.substring (2, 11);}\n');
		   document.write('var oas=\'http://\'+ server +\'/RealMedia/ads/\';\n');
		   document.write('var oaspage= sitepage + \'/1\' + RNS + \'@\' + staticpos + position;\n');
		   document.write('if (_version < 11){\n');
		   document.write('document.write (\'<A HREF="\'+ oas +\'click_nx.ads/\'+ oaspage +\'" TARGET="_blank" ><IMG SRC="\'+ oas +\'adstream_nx.ads/\'+ oaspage +\'" BORDER="0" WIDTH="468" HEIGHT="60" ALT="Visita il nostro sponsor!" ></a>\');\n');
		   document.write('} else {\n');
		   document.write('document.write (\'<\' + \'SCRIPT LANGUAGE="JavaScript1.1" SRC="\' + oas + \'adstream_jx.ads/\' + oaspage + \'">\');\n');
		   document.write('document.write (\'\\<\\!\\-- --\\>\');\n');
		   document.write('document.write (\'\\<\\/SCRIPT\\>\');\n');
		   document.write('document.write (\'\\<\\!\\-- --\\>\'); }\n');
	       document.write('//--'+'></SCR'+'IPT>');
	   }
	}
	else
	{
	   if (window.innerWidth > 900)
	   {
		   document.write('<SCRIPT LANGUAGE="JavaScript"><\!--\n');
		   document.write('_version=10;\n');
		   document.write('//--'+'>\n');
		   document.write('<'+'/script><SCRIPT LANGUAGE="JavaScript1.1"><\!--\n');
		   document.write('_version=11;\n');
		   document.write('if (navigator.userAgent.indexOf(\'Mozilla/3\') != -1){\n');
		   document.write('_version=10;}\n');
		   document.write('//--'+'>\n');
		   document.write('<'+'/script><SCRIPT LANGUAGE="JavaScript"><\!--\n');
		   document.write('var server = \'' + server + '\';\n');
		   document.write('var sitepage = "' + sitepage + '";\n');
		   document.write('var staticpos = "' + staticpos + '";\n');
		   document.write('var position ="Top1";\n');
		   document.write('if (! (RN)){\n');
		   document.write('var RN = new String (Math.random());\n');
		   document.write('var RNS = RN.substring (2, 11);}\n');
		   document.write('var oas=\'http://\'+ server +\'/RealMedia/ads/\';\n');
		   document.write('var oaspage= sitepage + \'/1\' + RNS + \'@\' + staticpos + position;\n');
		   document.write('if (_version < 11){\n');
		   document.write('document.write (\'<A HREF="\'+ oas +\'click_nx.ads/\'+ oaspage +\'" TARGET="_blank" ><IMG SRC="\'+ oas +\'adstream_nx.ads/\'+ oaspage +\'" BORDER="0" WIDTH="468" HEIGHT="60" ALT="Visita il nostro sponsor!" ></a>\');\n');
		   document.write('} else {\n');
		   document.write('document.write (\'<\' + \'SCRIPT LANGUAGE="JavaScript1.1" SRC="\' + oas + \'adstream_jx.ads/\' + oaspage + \'">\');\n');
		   document.write('document.write (\'\\<\\!\\-- --\\>\');\n');
		   document.write('document.write (\'\\<\\/SCRIPT\\>\');\n');
		   document.write('document.write (\'\\<\\!\\-- --\\>\'); }\n');
		   document.write('//--'+'><'+'/SCRIPT>');
	   }
	   else
	   {
		   document.write('<SCRIPT LANGUAGE="JavaScript"><\!--\n');
		   document.write('_version=10;\n');
		   document.write('//--'+'>\n');
		   document.write('<'+'/script><SCRIPT LANGUAGE="JavaScript1.1"><\!--\n');
		   document.write('_version=11;\n');
		   document.write('if (navigator.userAgent.indexOf(\'Mozilla/3\') != -1){\n');
		   document.write('_version=10;}\n');
		   document.write('//--'+'>\n');
		   document.write('<'+'/script><SCRIPT LANGUAGE="JavaScript"><\!--\n');
		   document.write('var server = \'' + server + '\';\n');
		   document.write('var sitepage = "' + sitepage + '";\n');
		   document.write('var staticpos = "' + staticpos + '";\n');
		   document.write('var position ="Top2";\n');
		   document.write('if (! (RN)){\n');
		   document.write('var RN = new String (Math.random());\n');
		   document.write('var RNS = RN.substring (2, 11);}\n');
		   document.write('var oas=\'http://\'+ server +\'/RealMedia/ads/\';\n');
		   document.write('var oaspage= sitepage + \'/1\' + RNS + \'@\' + staticpos + position;\n');
		   document.write('if (_version < 11){\n');
		   document.write('document.write (\'<A HREF="\'+ oas +\'click_nx.ads/\'+ oaspage +\'" TARGET="_blank" ><IMG SRC="\'+ oas +\'adstream_nx.ads/\'+ oaspage +\'" BORDER="0" WIDTH="468" HEIGHT="60" ALT="Visita il nostro sponsor!" ></a>\');\n');
		   document.write('} else {\n');
		   document.write('document.write (\'<\' + \'SCRIPT LANGUAGE="JavaScript1.1" SRC="\' + oas + \'adstream_jx.ads/\' + oaspage + \'">\');\n');
		   document.write('document.write (\'\\<\\!\\-- --\\>\');\n');
		   document.write('document.write (\'\\<\\/SCRIPT\\>\');\n');
		   document.write('document.write (\'\\<\\!\\-- --\\>\'); }\n');
		   document.write('//--'+'><'+'/SCRIPT>');
	   }
	}
}

