/**
 * function implements the iframe using for
 * unister cpc into the goggleAds
 */ 
function insertFrame()
{
	
}

/**
  * GoogleAd Request function
  */
  function google_afs_request_done(google_ads) {
	  
    /**
     * Verify that there are actually ads to display.
     */
    var google_num_ads = google_ads.length;
    if (google_num_ads <= 0) 
      return;

    var wideAds = "";   //wide ad unit html text
    var narrowAds = "";   //narrow ad unit html text
  
    var wideArr     = Array();
    var narrowArr   = Array();
    
    var w = 0;
    var n = 0;
    
    /**ads splitten 5 für wide und 6 für sky
     *wide ads zuerst füllen
     *wenn weniger als 6 dann nur wide füllen
     */
    if(google_num_ads < 6){
    	
    	for(var i = 0; i < google_num_ads; i++) {
    		wideArr[w++]  = google_ads[i];                 
    	}
    }
    //mehr als 6, dann sky auffüllen
    else{
    	
    	for(var i = 0; i < 5; i++){
    		wideArr[w++]  = google_ads[i];                 
    	}
    	
    	for(i = 5; i < google_num_ads; i++) {
    		narrowArr[n++] = google_ads[i];
    	}
    }
    
    //Widescren HTML bauen
    for(i = 0; i < wideArr.length; i++) {
        //Link bauen
        var href        = '<a onmousedown="triggerclick(\'google\');" target="_blank" rel="nofollow" href="' + wideArr[i].url + '">'; //link bauen
        var hrefAnker   = wideArr[i].line1;
        var line1       = wideArr[i].line2;       
        var line2       = wideArr[i].visible_url;
        var line3       = wideArr[i].line3;
         
        wideAds +=  '<div class="google_adsense_bigsize_row">'; //eine Row  
                wideAds +=  href; //link geöffnet
                wideAds +=  '<span class="ads"><span class="head">' + hrefAnker + '</span><br />';
                wideAds +=  '  <span class="text">' + line1 + ' ' + line3 + '</span>';        
                wideAds +=  '&nbsp;&nbsp;<span class="link">' + line2 + '</span>';
            wideAds +=  '</span></a>'; //base span schliessen und link schliessen
        wideAds +=  '</div>' //Row schließen              
    }   
    
    //Skycraper HTML bauen
    for(i = 0; i < (narrowArr.length); i++) {
        //Link bauen
        var href        = '<a onmousedown="triggerclick(\'google\');" target="_blank" rel="nofollow" href="' + narrowArr[i].url + '">'; //link bauen
        var hrefAnker   = narrowArr[i].line1;
        var line1       = narrowArr[i].line2;
        var line2       = narrowArr[i].visible_url;
        var line3       = narrowArr[i].line3;
        
        narrowAds +=  '<div class="google_adsense_narrow_row">'; //eine Row  
                narrowAds +=  href; //link geöffnet
                narrowAds +=  '<span class="ads">' + '<span class="head">' + hrefAnker + '</span>';
                narrowAds +=  '<br /><span class="text">' + line1 + ' ' + line3 + ' ' + '</span>';        
                narrowAds +=  '<br /><span class="link">' + line2 + '</span>';
            narrowAds +=  '</span></a>'; //base span schliessen und link schliessen
        narrowAds +=  '</div>' //Row schließen    
    }
    
    //** Write HTML for wide and narrow ads to the proper <div> elements
    if(document.getElementById("wide_ad_unit"))
        document.getElementById("wide_ad_unit").innerHTML = wideAds;
    
    if(document.getElementById("SkyscraperAdGoogle") && narrowArr.length > 0)
        document.getElementById("SkyscraperAdGoogle").innerHTML = '<h3>Sponsoren Links</h3> ' + narrowAds;
  }


if(typeof(addKey) != 'undefined') {
	google_afs_query = decodeURI(addKey);
	google_afs_ad = 'n11';	
	google_afs_client = 'unister-travel';
	//google_afs_client = 'unister-aidu-browse';		
	google_afs_channel = 'channel1'; 
	google_afs_ie = 'latin1'; 
	google_afs_oe = 'latin1'; 
	google_afs_adsafe = 'high'; 
	if(testModeSense && testModeSense == true) {
		var google_afs_adtest = 'on';
	} else {
		var google_afs_adtest = 'off';	
	}  
	google_afs_hl = 'de';
	google_ad_client = 'unister_js';
}


afcNumCount = 0;

function afcBottom(google_ads) {
	  
    /*
     * Verify that there are actually ads to display.
     */
    var google_num_ads = google_ads.length;
    if (google_num_ads <= 0) 
      return;
    afcNumCount = google_num_ads;
  
  
    var wideAds = "";   
  
    //Widescren HTML bauen
    for(i = 0; i < google_ads.length; i++) {
        var href        = '<a onmousedown="triggerclick(\'google\');" target="_blank" rel="nofollow" href="' + google_ads[i].url + '">'; //link bauen
        var hrefAnker   = google_ads[i].line1;
        var line1       = google_ads[i].line2;       
        var line2       = google_ads[i].visible_url;
        var line3       = google_ads[i].line3;
         
        wideAds +=  '<div class="google_adsense_bigsize_row">'; //eine Row  
                wideAds +=  href; //link geöffnet
                wideAds +=  '<span class="ads"><span class="head">' + hrefAnker + '</span><br />';
                wideAds +=  '  <span class="text">' + line1 + ' ' + line3 + '</span>';        
                wideAds +=  '&nbsp;&nbsp;<span class="link">' + line2 + '</span>';
            wideAds +=  '</span></a>'; //base span schliessen und link schliessen
        wideAds +=  '</div>' //Row schließen              
    }
    

    
    //** Write HTML for wide and narrow ads to the proper <div> elements
    if(document.getElementById("wide_ad_unit"))
        document.getElementById("wide_ad_unit").innerHTML = wideAds;
}


function afcSky(google_ads) {
	  
    /*
     * Verify that there are actually ads to display.
     */
     
    var google_num_ads = google_ads.length;
    if (google_num_ads <= 0) 
      return;

    var narrowAds = "";   //narrow ad unit html text
       
    //Skycraper HTML bauen
    for(i = 0; i < (google_ads.length); i++) {
        //Link bauen
        var href        = '<a onmousedown="triggerclick(\'google\');" target="_blank" rel="nofollow" href="' + google_ads[i].url + '">'; //link bauen
        var hrefAnker   = google_ads[i].line1;
        var line1       = google_ads[i].line2;
        var line2       = google_ads[i].visible_url;
        var line3       = google_ads[i].line3;
        
        narrowAds +=  '<div class="google_adsense_narrow_row">'; //eine Row  
                narrowAds +=  href; //link geöffnet
                narrowAds +=  '<span class="ads">' + '<span class="head">' + hrefAnker + '</span>';
                narrowAds +=  '<br /><span class="text">' + line1 + ' ' + line3 + ' ' + '</span>';        
                narrowAds +=  '<br /><span class="link">' + line2 + '</span>';
            narrowAds +=  '</span></a>'; //base span schliessen und link schliessen
        narrowAds +=  '</div>'; //Row schließen    
    }
      
    if(document.getElementById("SkyscraperAdGoogle"))
        document.getElementById("SkyscraperAdGoogle").innerHTML = '<h3><a href="https://www.google.com/adsense/support/bin/request.py?contact=abg_afc&gl=US&hideleadgen=1" style="text-decoration: none; color: #FFFFFF;">Sponsoren Links</a></h3> ' + narrowAds;
}


function google_ad_request_done(google_ads) {
	if(bottomAFC == true) {
    	afcBottom(google_ads, 'true');
    }
	if(heightAFC == true) {
		afcSky(google_ads, 'true');
	}    
    return;
}
