
function loadJS(sName) {
var head = document.getElementsByTagName("head")[0];
   script = document.createElement('script');
   script.type = 'text/javascript';
   script.src = sName;
   head.appendChild(script);
}


function loadAds() {
	loadJS("/javascript/click_ads.js");
	loadJS("/click_ads.js");

	document.write("<script type='text/javascript' src='/javascript/click_yes.js'></script>");
}





	if (self.textLinks) {
	  if (click_yes_ad_type == "text") {
		selectAdFormat();
		document.write("<font family=\"arial\" face=\"Arial\"/>");
		document.write("<div style=\"background-color:#" + click_yes_color_bg + ";border:1px solid #" + click_yes_color_border + ";width:" + click_yes_ad_width+ "px;height:" + click_yes_ad_height + "px;\">");
		document.write("<div style=\"width:" + click_yes_ad_width + "px;height:" + (click_yes_ad_height - 20) + "px\";>");
		while (__ad_count-- > 0) {
		 	 writeTextAd();
		}
		document.write("</div>");
		if (__ad_height > 60) {
	    	document.write("<div style=\"position:relative;left:"+ (click_yes_ad_width - 100) +"px;\">");
		document.write("<a href=\"http://www.sitesads.com\"><img style=\"display: inline-block;\" border=0 src=\"http://www.sitesads.com/images/ads_"+click_yes_theme+".gif\"></a>");
		document.write("</div>");
		}
		document.write("</div></font>");
	
	  } else if (click_yes_ad_type == "image") {
		writeImageAd();
	  }
	} else {
	  loadAds();
	}



function selectAdFormat() {
    switch(click_yes_theme) {
    case "black_g":
    case "black":
    click_yes_color_border = "FFFFFF";
    click_yes_color_bg = "FFFFFF";
    click_yes_color_link = "0000FF";
    click_yes_color_url = "008000";
    click_yes_color_text = "000000";
    break;
    case "pink_g":
    case "pink":
    click_yes_color_border = "FF00CC";
    click_yes_color_bg = "FFFFFF";
    click_yes_color_link = "0000FF";
    click_yes_color_url = "FF80FF";
    click_yes_color_text = "000000";
    break;
    case "white_g":
    case "white":
    click_yes_color_border = "0000FF";
    click_yes_color_bg = "FFFFFF";
    click_yes_color_link = "0000FF";
    click_yes_color_url = "008000";
    click_yes_color_text = "000000";
    break;
    }

    switch(click_yes_ad_format) {
    case "728x90":	
	__ad_width = 180;
	__ad_height = 60;
	__ad_count = 4;
	break;
    case "468x60":
	__ad_width = 233;
	__ad_height = 60;
	__ad_count = 2;
	break;
    case "125x125":
	__ad_width = 120;
	__ad_height = 105;
	__ad_count = 1;
	break
    case "234x60":
	__ad_width = 230;
	__ad_height = 60;
	__ad_count = 1;
	break;
    case "120x600":
	__ad_width = 100;
	__ad_height = 140;
	__ad_count = 4;
	break;
    case "160x600":
	__ad_width = 140;
	__ad_height = 110;
	__ad_count = 5
	break;
    case "180x150":
	__ad_width = 150;
	__ad_height = 130;
	__ad_count = 1;
	break;
    case "120x240":
	__ad_width = 100;
	__ad_height = 200;
	__ad_count = 1;
	break;
    case "200x200":
	__ad_width = 180;
	__ad_height = 90;
	__ad_count = 2;
	break;
    case "250x250":
	__ad_width = 230;
	__ad_height = 110;
	__ad_count = 2;
	break;
    case "300x250":
	__ad_width = 290;
	__ad_height = 55;
	__ad_count = 4;
	break;
    case "336x280":
	__ad_width = 320;
	__ad_height = 60;
	__ad_count = 4
	break;
    default :
	__ad_width = 200;
	__ad_height = 200;
	__ad_count = 1;

    }
}

function getTextAd() {
    return Math.round(Math.random() * (textLinks.length - 1)) ; 
}

function getImageAd() {
    return Math.round(Math.random() * (imageLinks.length - 1)) ; 
}


function goAd(adLink) {
    window.location=adLink;
}

function writeImageAd() {
    var adId = getImageAd();
    var link = "";
    var image = "";
    var alt = "";

    if (imageLinks[adId].length == 3) {
	alt = imageLinks[adId][0];
	image = imageLinks[adId][1];
	link = imageLinks[adId][2];

	document.write("<a href=\"" + link + "\"><img width=\"" + click_yes_ad_width + "\" height=\"" + click_yes_ad_height + "\" src=\"" + image + "\" alt=\"" + alt + "\"></a>");
    }

}

function writeTextAd() {
    var adId = getTextAd();
    var link = "";
    var url = "";
    var title = "";
    var text = "";

 

    if (textLinks[adId].length == 4) {
       title = textLinks[adId][0];
       text = textLinks[adId][1];
       url = textLinks[adId][2];
       link = textLinks[adId][3];
    } else if (textLinks[adId].length == 5) {
       title = textLinks[adId][0];
       text = textLinks[adId][1] + " " + textLinks[adId][2];
       url = textLinks[adId][3];
       link = textLinks[adId][4];
    }
    
    document.write("<div style=\"float:left;margin:0px 0px\"><table style=\"width:" + __ad_width + "px;height:" + __ad_height + "px;table-layout:fixed;overflow:hidden\"><tr><td valign=\"top\" onClick=\"goAd(" + link + ")\"><a style=\"text-decoration:none;\" href=" + link + " target=" + click_yes_target + "> ");
    document.write("<span style=\"text-decoration:underline;color: #" + click_yes_color_link + ";font-family:arial;font-size: 11px; font-weight:bold;\" >" + title + "</span><br>");
    document.write("<span style=\"text-decoration:none;color: #" + click_yes_color_text + ";font-family:arial;font-size: 10px;\">" + text + "</span><br>");
    document.write("<span style=\"text-decoration:none;color: #" + click_yes_color_url + ";font-family:arial;font-size: 10px;\">"+ url +"</span>");
    document.write("</a></td></tr></table></div>");
}

