/* istruzioni
id: id portale
idLang: id lingua
sezione: dart site
attivo: 0 = presente, 1 = non presente
seTypo: 0 = dart, 1 = housebarter,
width: larghezza
height: altezza
type: 0 = full 468x60, 1 = button 120x90, 2 = button 120x60 tile=1, 3 = button 120x60 tile=2, 4 = full 468x60 ricerca
*/

var ord = Math.floor(Math.random()*10000000);
var tile = "";
var lang = "it";
var url = createArrayUrl();
var src = createArraySrc();
function bannersVis(id,idLang,sezione,attivo,width,height,type){
    adsite = sezione.substring(sezione.indexOf(".")+1,sezione.indexOf("/")).toUpperCase();
	switch (idLang){
		case "1":
			lang = "ITA";
		break;
		case "2":
			lang = "ENG";
		break;
		case "3":
			lang = "ESP";
		break;
		case "4":
			lang = "FRA";
		break;
		case "5":
			lang = "GER";
		break;
		default:
			lang = "ITA";
	}
	
	switch (type){
		case "0":
			tile = "";
			
		break;
		case "1":
			tile = "";
			
		break;
		case "2":
			tile = "tile=1;";
			
		break;
		case "3":
			tile = "tile=2;";
			
		break;
		default:
			tile = "";
			
	}
	if (setVisibility(type)){
		if (setTypo == 0){
		
			now = new Date();
			random = now.getTime();
			// Modify to reflect site specifics
			site = "http://wayin.adbureau.net";
			target = "/SITE="+adsite+"/AREA="+lang+"/AAMSZ="+width+"X"+height+"";
			document.write('<IFRAME SRC="' + site + '/hserver/acc_random=' + random + target + '"');
			document.write(' NORESIZE SCROLLING=NO HSPACE=0 VSPACE=0 FRAMEBORDER=0 MARGINHEIGHT=0 MARGINWIDTH=0 WIDTH='+width+' HEIGHT='+height+'>');
			document.write('<SCR');
			document.write('IPT SRC="' + site + '/jnserver/acc_random=' + random + target + '">');
			document.write('</SCR');
			document.write('IPT>');
			document.write('</IFRAME>');				
		}
		if (setTypo == 1){
			
			var numRndVal = selezionaBanner(type);
			//alert(numRndVal +" "+ type)
			//alert(src[numRndVal,type])
			document.write ('<A HREF="'+url[numRndVal]+'" TARGET="_new"><IMG SRC="'+src[numRndVal][type]+'" BORDER=0 WIDTH='+width+' HEIGHT='+height+'></A>');
		}
	}

}
function selezionaBanner(type){
 var bannRnd = Math.floor(Math.random()*url.length);
 var control = 0;
   while (src[bannRnd][type] == ""){
   	control += 1;
	if (control > 1000) break
	bannRnd = Math.floor(Math.random()*url.length);
   } 
   return bannRnd;
}





