/*--( DH BRASIL )--------------------------------------------------------------
# PROJETO: SITE V3                                                
# LOCALIZAÇÃO DESTE ARQUIVO: /arquivo/banner/js/controle_album_ximiti.js
# RESPONSÁVEL: RAFAEL BAENA NETO         ÚLTIMA PUBLICAÇÃO: 26/01/2012 15:57:24
#------------------------------------------------------------------------------
# FUNÇÃO QUE GERENCIA OS BANNERS DO SITE. SESSÃO: ALBUM_XIMITI
#----------------------------------------------------------------------------*/

function banner(imgSource,url,alt,chance,type) {
	this.imgSource = imgSource;
	this.url = url;
	this.alt = alt;
	this.chance = chance;
	this.type = type;
}

banners_TOPO = new Array();
banners_LEFT1 = new Array();
banners_LEFT2 = new Array();
banners_LEFT3 = new Array();
banners_X1 = new Array();
banners_SKY = new Array();

banners_TOPO[0] = new banner("http://www.dhbrasil.com.br/v3/arquivo/banner/imagem/banner_103.gif",
                             "http://www.dhbrasil.com.br/v3/conta_clique.php?codigo=103&tipo=B&url=http://www.racepoint.com.br",
                             "",
                             5,
                             "gif");

banners_TOPO[1] = new banner("http://www.dhbrasil.com.br/v3/arquivo/banner/imagem/banner_101.gif",
                             "http://www.dhbrasil.com.br/v3/conta_clique.php?codigo=101&tipo=B&url=http://www.dcycles.com.br/lojaon/",
                             "DCycles.com.br",
                             5,
                             "gif");

banners_TOPO[2] = new banner("http://www.dhbrasil.com.br/v3/arquivo/banner/imagem/banner_99.gif",
                             "http://www.dhbrasil.com.br/v3/conta_clique.php?codigo=99&tipo=B&url=http://www.xtore.com.br",
                             "",
                             5,
                             "gif");



function randomBanner(position) {
	chance_limit = 0;
	sum_of_all_chances = 0;
	banner = eval("banners_" + position);
	for (i = 0; i < banner.length; i++) { sum_of_all_chances += banner[i].chance; }
	randomly_selected_chance = Math.round((sum_of_all_chances - 1) * Math.random()) + 1;
    
	for (i = 0; i < banner.length; i++) {
		chance_limit += banner[i].chance;
		if (randomly_selected_chance <= chance_limit ) {
				switch(position){
					case "TOPO": 
						if(banner[i].type == "gif"){
							document.write("<a href='" + banner[i].url + "' target='_blank'><img src='" + banner[i].imgSource + "' width='468' height='60' border='0' alt='" + banner[i].alt + "'></A>"); 
						}else{
							document.write("<OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0' width='468' height='60'><PARAM NAME='movie' VALUE='" + banner[i].imgSource + "'><PARAM NAME='quality' VALUE='high'><PARAM NAME='bgcolor' VALUE='#FFFFFF'><EMBED src='" + banner[i].imgSource + "' quality='high' bgcolor='#FFFFFF'  width='468' height='60' TYPE='application/x-shockwave-flash' PLUGINSPAGE='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash'></EMBED></OBJECT>");
						}
						break;
					case "LEFT1": case "LEFT2": case "LEFT3": 
						if(banner[i].type == "gif"){
							document.write("<a href='" + banner[i].url + "' target='_blank'><img src='" + banner[i].imgSource + "' width=120 height=60 border=0 alt='" + banner[i].alt + "'></A>"); 
						}else{
							document.write("<OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0' width='120' height='60'><PARAM NAME='movie' VALUE='" + banner[i].imgSource + "'><PARAM NAME='quality' VALUE='high'><PARAM NAME='bgcolor' VALUE='#FFFFFF'><EMBED src='" + banner[i].imgSource + "' quality='high' bgcolor='#FFFFFF'  width='468' height='60' TYPE='application/x-shockwave-flash' PLUGINSPAGE='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash'></EMBED></OBJECT>");
						}
						break;
					case "X1": 
						if(banner[i].type == "gif"){
							document.write("<script>win = window.open('','popX1','top=100,left=100,width=200,height=200'); win.document.write('<html><head><title>" + banner[i].alt + "</title></head><body bgcolor=#FFFFFF bottommargin=0 leftmargin=0 marginheight=0 marginwidth=0 rightmargin=0 topmargin=0><a href=" + banner[i].url + " target='_blank'><img src=" + banner[i].imgSource + " border=0 width=200 heigth=200 alt=" + banner[i].alt + "></a></body></html>');</script>");
						}else{
							document.write("<script>win = window.open('','popX1','top=100,left=100,width=200,height=200'); win.document.write('<html><head><title>" + banner[i].alt + "</title></head><body bgcolor=#FFFFFF bottommargin=0 leftmargin=0 marginheight=0 marginwidth=0 rightmargin=0 topmargin=0><OBJECT classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 codebase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0 width=120 height=60><PARAM NAME=movie VALUE=" + banner[i].imgSource + "><PARAM NAME=quality VALUE=high><PARAM NAME=bgcolor VALUE=#FFFFFF><EMBED src=" + banner[i].imgSource + " quality=high bgcolor=#FFFFFF  width=200 height=200 TYPE=application/x-shockwave-flash PLUGINSPAGE=http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash></EMBED></OBJECT></body></html>');</script>");
						}
						break;
				}
			break;
		}
	}
}
