
function randomTextLink() {
	lnk1 = '<a href="http://www.chooseyourdiet.com/cheker/cheker.php?idmk=18" target="_blank">2008 Diet Of The Year:</a><br />Amazing Chinese Weight Loss Secret<br />As Seen On CNN, NBC &amp; Fox News<br /><a href="http://www.chooseyourdiet.com/cheker/cheker.php?idmk=18" target="_blank">www.Wu-YiSource.com</a>';
	lnk2 = '';
	lnk3 = '';
	/* rand = Math.ceil(Math.random()*3);
	only 1 link now */
	rand = 1;
	//alert(rand);
	if (rand < 1 || rand > 3) { randomTextLink(); }
	else { // just incase something break with the random number
		randLnk = eval('lnk' + rand);
		//alert(randLnk);
		return '<div align="left" style="line-height:20px;font-weight:bold;background-color:#EDEDED;padding:10px;margin:15px 0px 0px 0px;text-align:left;">' + randLnk + '</div>';
	}
}

function jsWriteAdCode(pos,adLoc) { // pos is the type of ad, adLoc is home or other
	if(!adLoc) { adLoc = 'other'; }
	if ((adLoc != 'other') && (adLoc != 'home')) { adLoc = 'other'; }
	/* set in adType; utm_source; utm_medium; 
	adRandNum; adCode = ''; */
	googleAdChanReg = "3300658164"; googleAdChanCPV = "2287974446";
	googleAdChan = "3300658164"; // set to regular by default;
	vibrantIDRes = '4279'; vibrantIDCPV = '9652';
	vibrantID = '4279'; // set to regular by default;
	
	if (adType == 'reg') { // non cpv
		adSite = 'fim.cyd/';
		if (adLoc == 'home') {
			googleAdChan = '7741758873';
		} else { googleAdChan = googleAdChanReg; }
		vibrantID = vibrantIDRes;
	} else if (adType == 'cpv') { // cpv 
		adSite = 'fim.cydcpv/';
		// in the future may use below
		//adSite = 'fim.cyd' + utm_source + '/';
		googleAdChan = googleAdChanCPV;
		vibrantID = vibrantIDCPV;
	} else { }
	
	ScriptBeg = '<script language="JavaScript" type="text/javascript"> document.write(\'<scr\' + \'ipt language="JavaScript" src="http://ad.doubleclick.net/adj/' + adSite + adLoc;
	ScriptEnd =  adRandNum + '?" type="text/javascript"></scr\' + \'ipt>\'); </script>';
	NoScrBeg = '<noscript><a href="http://ad.doubleclick.net/jump/' + adSite + adLoc;
	NoScrMid = adRandNum + '?" target="_blank"><img src="http://ad.doubleclick.net/ad/' + adSite + adLoc;
	NoScrEnd = 'border="0" alt=""></a></noscript>' + "\n<!-- End ad tag -->";
	
	if (pos == 'top') {
		adCode = "<!-- begin 728x90 CYD " + utm_source + "Top ad tag  (tile=1) -->\n";
		adCode += ScriptBeg + ';pos=top728;tile=1;dcopt=ist;sz=728x90;ord=' + ScriptEnd;
		adCode += "\n" + NoScrBeg + ';pos=top728;tile=1;sz=728x90;ord=' + NoScrMid;
		adCode += ';pos=top728;tile=1;sz=728x90;ord=' + adRandNum + '?" width="728" height="90" ' + NoScrEnd;
	} else if (pos == 'square') {
		adCode = "<!-- begin 300x250 CYD " + utm_source + "Square ad tag  (tile=2) -->\n";
		adCode += ScriptBeg + ';pos=top300;tile=2;sz=300x250;ord=' + ScriptEnd;
		adCode += "\n" + NoScrBeg + ';pos=top300;tile=2;sz=300x250;ord=' + NoScrMid;
		adCode += ';pos=top300;tile=2;sz=300x250;ord=' + adRandNum + '?" width="300" height="250" ' + NoScrEnd;
	} else if (pos == 'tower') {
		adCode = "<!-- begin 160x600 CYD " + utm_source + "Tower ad tag  (tile=3) -->\n";
		adCode += ScriptBeg + ';pos=;tile=3;sz=160x600;ord=' + ScriptEnd;
		adCode += "\n" + NoScrBeg + ';pos=;tile=3;sz=160x600;ord=' + NoScrMid;
		adCode += ';pos=;tile=3;sz=160x600;ord=' + adRandNum + '?" width="160" height="600" ' + NoScrEnd;
	} else if (pos == 'bot') {
		adCode = "<!-- begin 728x90 CYD " + utm_source + "Bottom ad tag  (tile=4) -->\n";
		adCode += ScriptBeg + ';pos=bot728;tile=4;sz=728x90;ord=' + ScriptEnd;
		adCode += "\n" + NoScrBeg + ';pos=bot728;tile=4;sz=728x90;ord=' + NoScrMid;
		adCode += ';pos=bot728;tile=4;sz=728x90;ord=' + adRandNum + '?" width="728" height="90" ' + NoScrEnd;
	} else if (pos == 'google') {
		adCode =  "\n" + '<script type="text/javascript">';
		adCode +=  "\n" + '<!--';
		adCode += "\n" + 'google_ad_client = "pub-8301011321395982";' + "\n" + 'google_ad_width = 300;';
		adCode += "\n" + 'google_ad_height = 250;' + "\n" + 'google_ad_format = "300x250_as";';
		adCode += "\n" + 'google_ad_type = "text_image";' + "\n" + 'google_color_bg = "F9F9F9";';
		adCode += "\n" + 'google_ad_channel = "' + googleAdChan + '";';
		adCode += "\n//-->\n</script>";
		adCode += "\n" + '<script type="text/javascript" ' + "\n" +  'src="http://pagead2.googlesyndication.com/pagead/show_ads.js">' + "\n" + '</script>';
	} else if (pos == 'kanoodle') {
		adCode = '<script language="javascript"  type="text/javascript" ';
		if (adType == 'reg') {
			adCode +=  'src="http://context3.kanoodle.com/cgi-bin/context.cgi?id=86941632&db=context&cgroup=glycemicindex&format=sky3&width=600&newtarget=1&numresults=5&nologo=1&bordercolor=ffffff&linkcolor=CC3300&textcolor=333366"></script>';
		} else { 
			adCode +=  'src="http://context3.kanoodle.com/cgi-bin/context.cgi?id=89514779&db=context&cgroup=cyd_cpv_glycemicindex&format=sky3&width=728&newtarget=1&numresults=5&nologo=1&bordercolor=ffffff&linkcolor=CC3300&textcolor=000000&titlecolor=000000"></script>';
		}
	} else if (pos == 'vibrant') {
		adCode = "<!-- start Vibrant Media IntelliTXT script section -->\n";
		adCode += '<script type="text/javascript" src="http://chooseyourdiet.us.intellitxt.com/intellitxt/front.asp?ipid=' + vibrantID + '"></script>';
		adCode += "\n<!-- end Vibrant Media IntelliTXT script section -->";
	} else { }
	return adCode;
}
