/***
 * Google Custom AD Library
 **/ 
 


// Variables de genéricas
google_ad_client = 'pub-0839604175348775'; // sustituya su código id_cliente (pub-#)
google_ad_output = 'js';
google_ad_type = 'text'; // Unicamente anuncios de texto
google_language = 'es'; // Idioma español
google_ad_type = 'text_html';
//google_image_size = '728x90';
google_feedback = 'on';
	
// Activamos modo test
//google_adtest = 'on';

// Calculamos el número de anuncios
switch(google_ad_bannerformat){
	case "300x250":
	case "728x90":	
		google_max_num_ads = '2';
	break;

	case "400x300":
	case "550x300":
		google_max_num_ads = '3';
	break;
	
	default: 
		google_max_num_ads = '1';
	break;
}




/***
 * Impresion del banner
 **/
 function google_ad_print(google_ads,format,numads,s,color_fondo,color_titulo,color_texto,color_link,color_adsby){
 	switch(format){
 		case "450x95":
 			// Revisado y probado en MAC ( Firefox 3 y Safari)			
 			s += '<table cellpadding="0" cellspacing="0" border="0" style="width: 450px; height: 95px; background-color: '+color_fondo+'; padding: 5px; padding-top: 0px; ">';
			s += '<tr><td style="width: 100%; font-family: tahoma, verdana, aria; font-size: 9px; text-align: left; height: 10px; table-layout : fixed;"><a href=\"' + google_info.feedback_url + '\" style="color:'+color_adsby+'; text-decoration: none;">Ads by Google</a></td></tr>' 

			for(i = 0; i < numads; ++i) {			
				s += '<tr><td style="table-layout : fixed;"><a style="font-family: tahoma, verdana, arial; font-size: 22px; font-weight: bold; height: 24px; color: '+color_titulo+'; text-decoration: underline;" href="' + google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'vaya a ' + google_ads[i].visible_url + '\';return true">'+google_ads[i].line1+'</a></td><tr>';
				s += '<tr><td style="font-family: tahoma, verdana, arial; color:'+color_texto+'; font-size: 14px; height: 36px; vertical-align: middle; table-layout : fixed;">'+google_ads[i].line2+' '+google_ads[i].line3+'</td><tr>';				
				
				s += '<tr><td style="vertical-align: bottom; table-layout : fixed;"><a style="font-family: tahoma, verdana, arial; font-size: 10px; height: 12px; color: '+color_link+'; text-decoration: none;" href="' + google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'vaya a ' + google_ads[i].visible_url + '\';return true">'+google_ads[i].visible_url+'</a></td><tr>';

			}
			s += '</table>'; 		

			return s;

 		break;
 		
 		case "728x90":
 			// Revisado y probado en MAC ( Firefox 3 y Safari) 		
			if(numads==1){
				s += '<table cellpadding="0" cellspacing="0" border="0" style="width: 728px; height: 90px; background-color: '+color_fondo+'; padding: 5px; padding-top: 0px; ">';
				s += '<tr><td style="font-family: tahoma, verdana, aria; font-size: 9px; text-align: left; height: 10px; table-layout : fixed;"><a href=\"' + google_info.feedback_url + '\" style="color:'+color_adsby+'; text-decoration: none;">Ads by Google</a></td></tr>' 

				s += '<tr><td style="table-layout : fixed;"><a style="font-family: tahoma, verdana, arial; font-size: 20px; font-weight: bold; height: 22px; color: '+color_titulo+'; text-decoration: underline;" href="' + google_ads[0].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'vaya a ' + google_ads[0].visible_url + '\';return true">'+google_ads[0].line1+'</a></td><tr>';
				s += '<tr><td style="font-family: tahoma, verdana, arial; color:'+color_texto+'; font-size: 14px; height: 33px; vertical-align: middle; table-layout : fixed;">'+google_ads[0].line2+' '+google_ads[0].line3+'</td><tr>';				
				
				s += '<tr><td style="vertical-align: bottom; table-layout : fixed;"><a style="font-family: tahoma, verdana, arial; font-size: 10px; height: 12px; color: '+color_link+'; text-decoration: none;" href="' + google_ads[0].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'vaya a ' + google_ads[0].visible_url + '\';return true">'+google_ads[0].visible_url+'</a></td><tr>';
				s += '</table>';
				adAlternativos--;
			}else{
 			// Revisado y probado en MAC ( Firefox 3 y Safari) 		
 			s += '<table cellpadding="0" cellspacing="0" border="0" style="width: 728px; height: 90px; background-color: '+color_fondo+'; padding: 5px; padding-top: 0px; ">';
			s += '<tr><td style="font-family: tahoma, verdana, aria; font-size: 9px; text-align: left; height: 10px; table-layout : fixed;" colspan="2"><a href=\"' + google_info.feedback_url + '\" style="color:'+color_adsby+'; text-decoration: none;">Ads by Google</a></td></tr>' 

				// Titulo 1
				s += '<tr>';				
				s += '<td width="50%" style="table-layout : fixed;"><a style="font-family: tahoma, verdana, arial; font-size: 20px; font-weight: bold; height: 22px; color: '+color_titulo+'; text-decoration: underline;" href="' + google_ads[0].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'vaya a ' + google_ads[0].visible_url + '\';return true">'+google_ads[0].line1+'</a></td>';
				// Titulo 2				
				s += '<td width="50%" style="table-layout : fixed;"><a style="font-family: tahoma, verdana, arial; font-size: 20px; font-weight: bold; height: 22px; color: '+color_titulo+'; text-decoration: underline;" href="' + google_ads[1].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'vaya a ' + google_ads[1].visible_url + '\';return true">'+google_ads[1].line1+'</a></td>';				
				s += '</tr>';				
				
				// Desc 1				
				s += '<tr>';
				s += '<td style="font-family: tahoma, verdana, arial; color:'+color_texto+'; font-size: 14px; height: 33px; vertical-align: middle; table-layout : fixed;">'+google_ads[0].line2+' '+google_ads[0].line3+'</td>';				
				// Desc 2								
				s += '<td style="font-family: tahoma, verdana, arial; color:'+color_texto+'; font-size: 14px; height: 33px; vertical-align: middle; table-layout : fixed;">'+google_ads[1].line2+' '+google_ads[1].line3+'</td>';
				s += '</tr>';								

				s += '<tr>';				
				s += '<td style="vertical-align: bottom; table-layout : fixed;"><a style="font-family: tahoma, verdana, arial; font-size: 10px; height: 12px; color: '+color_link+'; text-decoration: none;" href="' + google_ads[0].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'vaya a ' + google_ads[0].visible_url + '\';return true">'+google_ads[0].visible_url+'</a></td>';				
				s += '<td style="vertical-align: bottom; table-layout : fixed;"><a style="font-family: tahoma, verdana, arial; font-size: 10px; height: 12px; color: '+color_link+'; text-decoration: none;" href="' + google_ads[1].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'vaya a ' + google_ads[1].visible_url + '\';return true">'+google_ads[1].visible_url+'</a></td>';
				s += '</tr>';												

				s += '</table>'; 		
			}
			return s;		
 		
 		break;
 		
  		case "300x250":
 			// Revisado y probado en MAC ( Firefox 3 y Safari) 		
			if(numads==1){
				s += '<table cellpadding="0" cellspacing="0" border="0" style="width: 300px; height: 250px; background-color: '+color_fondo+'; padding: 5px; padding-top: 0px; ">';
				s += '<tr><td style="width: 100%; font-family: tahoma, verdana, aria; font-size: 9px; text-align: left; height: 10px; table-layout : fixed;"><a href=\"' + google_info.feedback_url + '\" style="color:'+color_adsby+'; text-decoration: none;">Ads by Google</a></td></tr>'  			
				s += '<tr><td style="table-layout : fixed;"><a style="font-family: tahoma, verdana, arial; font-size: 18px; font-weight: bold; height: 27px; color: '+color_titulo+'; text-decoration: underline;" href="' + google_ads[0].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'vaya a ' + google_ads[0].visible_url + '\';return true">'+google_ads[0].line1+'</a></td><tr>';
				s += '<tr><td style="font-family: tahoma, verdana, arial; color:'+color_texto+'; font-size: 14px; height: 50px; vertical-align: middle; table-layout : fixed;">'+google_ads[0].line2+' '+google_ads[0].line3+'</td><tr>';				
				s += '<tr><td style="vertical-align: bottom; table-layout : fixed;"><a style="font-family: tahoma, verdana, arial; font-size: 10px; height: 17px; color: '+color_link+'; text-decoration: none;" href="' + google_ads[0].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'vaya a ' + google_ads[0].visible_url + '\';return true">'+google_ads[0].visible_url+'</a></td><tr>';
				s += '<tr><td style="height:50%">&nbsp;</td><tr>';
				s += '</table>'; 	
				adAlternativos--;				
			}else{

				// Revisado y probado en MAC ( Firefox 3 y Safari) 		
				s += '<table cellpadding="0" cellspacing="0" border="0" style="width: 300px; height: 250px; background-color: '+color_fondo+'; padding: 5px; padding-top: 0px; ">';
				s += '<tr><td style="width: 100%; font-family: tahoma, verdana, aria; font-size: 9px; text-align: left; height: 10px; table-layout : fixed;"><a href=\"' + google_info.feedback_url + '\" style="color:'+color_adsby+'; text-decoration: none;">Ads by Google</a></td></tr>'  			
				for(i = 0; i < numads; ++i) {			
					s += '<tr><td style="table-layout : fixed;"><a style="font-family: tahoma, verdana, arial; font-size: 18px; font-weight: bold; height: 27px; color: '+color_titulo+'; text-decoration: underline;" href="' + google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'vaya a ' + google_ads[i].visible_url + '\';return true">'+google_ads[i].line1+'</a></td><tr>';
					s += '<tr><td style="font-family: tahoma, verdana, arial; color:'+color_texto+'; font-size: 14px; height: 50px; vertical-align: middle; table-layout : fixed;">'+google_ads[i].line2+' '+google_ads[i].line3+'</td><tr>';				
					
					s += '<tr><td style="vertical-align: bottom; table-layout : fixed;"><a style="font-family: tahoma, verdana, arial; font-size: 10px; height: 17px; color: '+color_link+'; text-decoration: none;" href="' + google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'vaya a ' + google_ads[i].visible_url + '\';return true">'+google_ads[i].visible_url+'</a></td><tr>';

				}
				s += '</table>'; 		
			}
			
			return s;		
 		
 		break;		
 		
  		case "400x300":
 			// Revisado y probado en MAC ( Firefox 3 y Safari) 		
 			s += '<table cellpadding="0" cellspacing="0" border="0" style="width: 400px; height: 300px; background-color: '+color_fondo+'; padding: 5px; padding-top: 0px; ">';
			for(i = 0; i < numads; ++i) {			
				s += '<tr><td style="table-layout : fixed;"><a style="font-family: tahoma, verdana, arial; font-size: 18px; font-weight: bold; height: 25px; color: '+color_titulo+'; text-decoration: underline; vertical-align: bottom; " href="' + google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'vaya a ' + google_ads[i].visible_url + '\';return true">'+google_ads[i].line1+'</a></td><tr>';
				s += '<tr><td style="font-family: tahoma, verdana, arial; color:'+color_texto+'; font-size: 14px; height: 40px; vertical-align: top; table-layout : fixed;">'+google_ads[i].line2+' '+google_ads[i].line3+'</td><tr>';				
				
				s += '<tr><td style="vertical-align: top; table-layout : fixed;"><a style="font-family: tahoma, verdana, arial; font-size: 10px; height: 25px; color: '+color_link+'; text-decoration: none;" href="' + google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'vaya a ' + google_ads[i].visible_url + '\';return true">'+google_ads[i].visible_url+'</a></td><tr>';

			}
			s += '<tr><td style="width: 100%; font-family: tahoma, verdana, aria; font-size: 9px; text-align: right; height: 12px; table-layout : fixed;"><a href=\"' + google_info.feedback_url + '\" style="color:'+color_adsby+'; text-decoration: none;">Ads by Google</a></td></tr>' 
			s += '</table>'; 		
			
			return s;		
 		
 		break;		
 		
  		case "550x300":
 			// Revisado y probado en MAC ( Firefox 3 y Safari) 		
 			s += '<table cellpadding="0" cellspacing="0" border="0" style="width: 550px; height: 300px; background-color: '+color_fondo+'; padding: 5px; padding-top: 0px; ">';
			for(i = 0; i < numads; ++i) {			
				s += '<tr><td style="table-layout : fixed;"><a style="font-family: tahoma, verdana, arial; font-size: 19px; font-weight: bold; height: 25px; color: '+color_titulo+'; text-decoration: underline; vertical-align: bottom; " href="' + google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'vaya a ' + google_ads[i].visible_url + '\';return true">'+google_ads[i].line1+'</a></td><tr>';
				s += '<tr><td style="font-family: tahoma, verdana, arial; color:'+color_texto+'; font-size: 15px; height: 40px; vertical-align: top; table-layout : fixed;">'+google_ads[i].line2+' '+google_ads[i].line3+'</td><tr>';				
				
				s += '<tr><td style="vertical-align: top; table-layout : fixed;"><a style="font-family: tahoma, verdana, arial; font-size: 10px; height: 25px; color: '+color_link+'; text-decoration: none;" href="' + google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'vaya a ' + google_ads[i].visible_url + '\';return true">'+google_ads[i].visible_url+'</a></td><tr>';

			}
			s += '<tr><td style="width: 100%; font-family: tahoma, verdana, aria; font-size: 9px; text-align: right; height: 12px; table-layout : fixed;"><a href=\"' + google_info.feedback_url + '\" style="color:'+color_adsby+'; text-decoration: none;">Ads by Google</a></td></tr>' 
			s += '</table>'; 		
			
			return s;		
 		
 		break;	
 		
 		default:
 			return "Formato inexistente";
 		break; 
 	}
 }



/***
 * Solicitud del banner a Google
 **/
 function google_ad_request_done(google_ads) {
	var s = '';
	var i;

	if (google_ads.length == 0) {
		return;
	}


	// Montamos los anuncios de texto
	s = google_ad_print(google_ads,google_ad_bannerformat,google_ads.length,s,color_fondo,color_titulo,color_texto,color_link,color_adsby);

    document.write(s);
    return;
}


