// JavaScript Document


function winstat(w) {window.status = 'go to' + w; return true;}

function clearstat(){window.status='';}

function createHorizontalAds(google_ads, goog_url, posStart, posEnd){
		var ad_unit = "";
		if(posEnd > google_ads.length ) posEnd = google_ads.length;
		for(var i = posStart; i < posEnd; ++i) {
			if (google_ads[i].type == 'text') {
				if (i == posStart){
					ad_order = '<div class="first" align="left">';
					goog_url = '<div style="padding-bottom:6px" align="left"> ' + '<a class="alinks1" href=\"' + google_info.feedback_url + '\">Ads by Google</a></div>';
					
				}
				else if (i == posStart+1){
					ad_order = '<div class="second" align="left">';
					goog_url = '<div ></div>';
				}
				else{
					ad_order='<div class="third" align="left">';
					goog_url = '<div></div>';
				};
				goog_ad = ad_order + goog_url + '<div>'+
				'<strong><a class="alinks" href="' + google_ads[i].url + '" onMouseOver="javascript:window.status=\'go to ' + google_ads[i].visible_url +'\';return true;" onMouseOut="window.status=\'\';return true;">' +
				google_ads[i].line1 + '</a></strong></div>' +
				'<div class="alinks2">' +
				google_ads[i].line2 + 
				google_ads[i].line3 + 
				'</div>' +
				'<div><a class="alinks1" href="' + google_ads[i].url + '" onMouseOver="javascript:window.status=\'go to ' + google_ads[i].visible_url +'\';return true;" onMouseOut="window.status=\'\';return true;">' +				
				 google_ads[i].visible_url + '</a></div></div>';
			} // end if text 
			
			ad_unit += goog_ad; 
			
		}     // end for	
		return ad_unit;
}
function createVerticalAds(google_ads, goog_url, posStart, posEnd){
		var ad_unit = "";
		if(posEnd > google_ads.length ) posEnd = google_ads.length;
		for(var i = posStart; i < posEnd; ++i) {
			if (google_ads[i].type == 'text') {
				if (i == posStart){
					ad_order = '<div class="first">';
					goog_url = '<div ><a class="alinks1" href=\"' + google_info.feedback_url + '\">Ads by Google</a></div>';
				}
				else if (i == posStart+1){
					ad_order = '<div class="second">';
					goog_url = '<div></div>';
				}
				else{
					ad_order = '<div class="third">';
					goog_url = '<div></div>';
				};
				var ads_url = (google_ads[i].visible_url.length > 16 )? google_ads[i].visible_url.substring(0,15)+"...":google_ads[i].visible_url;
				goog_ad = ad_order + goog_url + '<div>'+
				'<a class="alinks" href="' + google_ads[i].url + '" onMouseOver="javascript:window.status=\'go to ' + google_ads[i].visible_url +'\';return true;" onMouseOut="window.status=\'\';return true;">' +
				google_ads[i].line1 + '</a></div>' +
				'<div class="alinks2">' +
				google_ads[i].line2 + 
				google_ads[i].line3 + 
				'</div>' +
				'<div><a class="alinks" href="' + google_ads[i].url + '" onMouseOver="javascript:window.status=\'go to ' + google_ads[i].visible_url +'\';return true;" onMouseOut="window.status=\'\';return true;">' +				
				 ads_url + '</a></div></div>';
			} // end if text 
			
			ad_unit += goog_ad; 
			
		}     // end for	
		return ad_unit;
}

function google_ad_request_done(google_ads) {  
	
	var first_ad_unit = '', second_ad_unit='', third_ad_unit='', goog_ad='', goog_url='', ad_order='';
	if (google_ads.length > 0) {
		var goog_url="";
		if (google_info.feedback_url) {
			 goog_url += '<div class="ads-by-google"><span class="ads-by-google-title"> ' +
			  '<a href=\"' + google_info.feedback_url + '\">Ads by Google</a></span></div>';
		 } else {
			  goog_url += '<div class="ads-by-google"><span class="ads-by-google-title">  ' +
			  'Sponsored links (Ads by Google)</span></div>';
		 }	
		
		first_ad_unit = createHorizontalAds(google_ads, goog_url, 0, 2);
		third_ad_unit = createVerticalAds(google_ads, goog_url, 2, 5);
		second_ad_unit = createHorizontalAds(google_ads, goog_url, 5, 8);
	}

	if (document.getElementById('ads_unit_mid') != null){
		if(document.getElementById('ads_unit_mid_load') != null){
			document.getElementById('ads_unit_mid_load').style.display = 'none';
		}
		document.getElementById('ads_unit_mid').innerHTML += first_ad_unit;
	}
	document.getElementById('ads_unit_bottom').innerHTML += second_ad_unit;
	
	var show = 1;
	try{ if(tower == 1 )show = 0;}catch(ex){}
	if(show == 1){
		document.getElementById('ads_unit_side').innerHTML += third_ad_unit;
		els = document.getElementById("div_tv");
		if(els != null) els.style.display = ""; 
	}
}
