function blackOrWhite(color){
	var avg = parseInt(color.substring(1,3),16)*0.3 + parseInt(color.substring(3,5),16)*0.59 + parseInt(color.substring(5,7),16)*0.11 ;
	if(avg<128){
		return '#FFFFFF';
	}else{
		return '#000000';
	}
}

function initializeAdsStyle(){
	doc_ads = document.getElementById('ads');
	ads_style = doc_ads.style;

	doc_credit = document.getElementById('credit');
	credit_style = doc_credit.style;
	//credit_text_style = doc_credit.childNodes[0].style;

	ads_style.width = ads_width;

	ads_style.fontSize = ads_font_size;

	ads_style.borderColor = ads_border;
	credit_style.background = ads_border;
	credit_style.color = blackOrWhite(ads_border);

	ads_style.background = ads_background;

	doc_ads_a = doc_ads.getElementsByTagName('span');
	var l = doc_ads_a.length;
	for(var i=0;i<l;i++){
		doc_ads_a[i].style.color = ads_title;
	}

	doc_ads_div = doc_ads.getElementsByTagName('div');
	var l = doc_ads_div.length;
	for(var i=0;i<l;i++){
		if (doc_ads_div[i].className == 'desc') doc_ads_div[i].style.color = ads_desc;
		if (doc_ads_div[i].className == 'url') doc_ads_div[i].style.color = ads_link;
	}
}
initializeAdsStyle();