var fdcQuotesURL = "/cms/components/wincol/quotes_js.jhtml";
var fdcWincolThreshhold;
var fdcWincolResult;
var fdcWincolStyle;
//  Set this to the % of frequency templates
//  will be rendered as columns.
//  eg. 30 = 30% column (and 70% windows).
var fdcWincolDefault = 50;
var OAS_sitepage = "";
var OAS_listpos = "";
var fdcDisableCallbacks = 0;

function fdcWincolComputeStyle(){

	var url = window.location + "";

	// 100 = all columns
	// 0 = all windows
	if (url.indexOf("/column/") != -1 )             { fdcWincolThreshhold = 100; }
	else if (url.indexOf("/window/") != -1 )        { fdcWincolThreshhold = 0; }
	else if (url.indexOf("/2005/01/19/cx_vg_0119feat") != -1 )        { fdcWincolThreshhold = 0; }
	else if (url.indexOf("/networks/") != -1 )        { fdcWincolThreshhold = 0; }
	else if (url.indexOf("/infoimaging/") != -1 )        { fdcWincolThreshhold = 0; }
	else if (url.indexOf("/ebusiness/") != -1 )        { fdcWincolThreshhold = 0; }
	else if (url.indexOf("/personaltech/") != -1 )        { fdcWincolThreshhold = 0; }
	else if (url.indexOf("/sciences/") != -1 )        { fdcWincolThreshhold = 0; }
	else if (url.indexOf("/enterprisetech/") != -1 )        { fdcWincolThreshhold = 0; }
	else                                            { fdcWincolThreshhold = fdcWincolDefault; }

	fdcWincolResult = Math.round( Math.random() * 99 );

	fdcWincolStyle = (fdcWincolResult < fdcWincolThreshhold ) ? "column" : "window";

}

function fdcWincolComputeSitepage(){

	url = '' + window.location;
	start = url.indexOf('//') + 2;
	start = url.indexOf('/',start) + 1;
	end = url.indexOf('?'); if(end==-1){end=url.length}
	OAS_sitepage = 'forbes.com/' + url.substring(start, end);
}

function fdcWincolComputeListpos(){

	if(fdcWincolStyle=="window"){
		OAS_listpos = "Block,BigEditPromoWind,AdController,BigBanner,CenterBanner,LeftTop,RightTop,RightBottom,x5,ZebusCompanion,x50,LeftBottom,LeftBottom2,x1,x2,SponsorLogo,x70,MiddleBanner,RightLower,x33,Loge,StoryLogo,LuxuryLogo";
	}
	else{	
		OAS_listpos = "RightAboveCol,RightMiddle,AdController,BigBanner,CenterBanner,LeftTop,RightTop,RightBottom,x5,ZebusCompanion,x50,LeftBottom,LeftBottom2,x1,x2,SponsorLogo,x70,MiddleBanner,RightLower,x33,Loge,StoryLogo,LuxuryLogo";
	}
	
}

function fdcWincolAlert(){

	alert(
		"OAS_sitepage: " + OAS_sitepage + "\n" +
		"OAS_listpos: " + OAS_listpos + "\n" +
		"Minimum for window: " + fdcWincolThreshhold + "\n" +
		"Result: " + fdcWincolResult + "\n" +
		"Style: " + fdcWincolStyle + "\n" +
		""
	);
}

function fdcWincolDebug(){
	document.write(
		"OAS_sitepage: " + OAS_sitepage + "<BR>" +
		"OAS_listpos: " + OAS_listpos + "<BR>" +
		"Minimum for window: " + fdcWincolThreshhold + "<BR>" +
		"Result: " + fdcWincolResult + "<BR>" +
		"Style: " + fdcWincolStyle + "<BR>" +
		""
	);
}

function fdcWincolStart(){

	if (fdcWincolStyle=="window"){_startWindow();}
	else{_startColumn();}
}

function fdcWincolAd(){
	if (fdcWincolStyle=="window"){_adWindow();}
	else{_adColumn();}
}

function fdcWincolEnd(){

	if (fdcWincolStyle=="window")	{_endWindow();}
	else				{_endColumn();}
}

function fdcWincolSwap(orig, repl){
	var span = document.getElementById(orig);
	if(span==null){return;}
	var newspan = document.getElementById(repl);
	if(newspan==null){return;}
	while(span.childNodes[0]) { span.removeChild(span.childNodes[0]); }
	span.parentNode.replaceChild(newspan,span);
}

function fdcWincolNewsAndAnalysis(){

	if (fdcDisableCallbacks == 1){return;}

	document.write('<script language=JavaScript src="/cms/components/newsAndAnalysis_story_js.jhtml"></script>');

}

function fdcWincolFaceScanStories(){

	if (fdcDisableCallbacks == 1){return;}

	document.write('<script language=JavaScript src="http://www.forbes.com/cms/components/faceScanStories_js.jhtml"></script>');

}

function fdcWincolMarketScanStories(){

	if (fdcDisableCallbacks == 1){return;}

	document.write('<script language=JavaScript src="http://www.forbes.com/cms/components/marketScanStories_js.jhtml"></script>');

}

function fdcWincolQuotes(){

	if (fdcDisableCallbacks == 1){return;}

	format = (fdcWincolStyle == "window") ? "?format=long&" : "?";

	query = "tickers=" + escape(fdcStoryTickers);

	fdcQuotesURL = fdcQuotesURL + format + query;

	var buster = _getBuster();

	var tag = "<scr" + "ipt language=\"ja" + "vascr" + "ipt\" " +
		"src=\"" + fdcQuotesURL + "&buster=" + buster + "\"></scr" + "ipt>";

	document.write(tag);
}

function _getBuster(){

	var date = new Date();
	var buster =  "" + date.getYear() + date.getMonth() + date.getDate() + 
				date.getHours() + date.getMinutes() + date.getSeconds();
	return buster;

}

function _startWindow(){
	document.write("<CENTER><span class=\"smallgreytxt\">ADVERTISEMENT</span>");
}

function _adWindow(){
	OAS_AD('Block');
}

function _endWindow(){

	document.write("</CENTER>");
	document.write("<FONT COLOR=white>end ad</FONT><BR>");
	document.write("<table cellspacing=\"0\" cellpadding=\"2\" border=\"0\" width=\"336\"><tr><td bgcolor =\"dece00\" colspan=\"3\"><img src=\"http://images.forbes.com/media/assets/spacer.gif\" width=\"1\" height=\"2\"></td></tr><tr><td valign=\"middle\"><a href=\"https://w1.buysub.com/servlet/OrdersGateway?cds_mag_code=FRB&cds_response_key=IL11FE5\" class=\"mainartlink\"><b>Free Trial Issue of <i>Forbes</i></b></a></td><td><br> <br></td><td align=\"right\" valign=\"middle\"><a href=\"https://w1.buysub.com/servlet/GiftsGateway?cds_mag_code=FRB&cds_response_key=ILG11B2\" class=\"mainartlink\"><b>Gift Subscriptions</b></a></td></tr><tr><td bgcolor=\"dece00\" colspan=\"3\"><img src=\"http://images.forbes.com/media/assets/spacer.gif\" width=\"1\" height=\"2\"></td></tr></table><BR>");

	_doAlertsWindow();

	document.write("<BR>");
}

function _startColumn(){
	document.write("<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"328\"><TR><TD WIDTH=168 VALIGN=TOP>");

	_doAlertsColumn();

	document.write("<BR><table cellspacing=\"0\" cellpadding=\"2\" border=\"0\" width=\"168\"><tr><td bgcolor=\"dece00\" colspan=\"3\"><img src=\"http://images.forbes.com/media/assets/spacer.gif\" width=\"1\" height=\"2\"></td></tr><tr><td><img src=\"http://images.forbes.com/media/assets/spacer.gif\" width=\"1\" height=\"25\"></td><td valign=\"middle\" align=\"center\"><a href=\"https://w1.buysub.com/servlet/OrdersGateway?cds_mag_code=FRB&cds_response_key=IMFFT009\" class=\"mainartlink\"><b><nobr>Free Trial Issue</nobr></b></a></td><td><img src=\"http://images.forbes.com/media/assets/spacer.gif\" width=\"1\" height=\"25\"></td></tr><tr><td bgcolor=\"dece00\" colspan=\"3\"><img src=\"http://images.forbes.com/media/assets/spacer.gif\" width=\"1\" height=\"2\"></td></tr></table><br clear=\"all\">");
	document.write("</td>");
	document.write("<td width=\"10\">  </td>");
	document.write("<td width=\"150\" valign=top>");
}

function _adColumn(){
	OAS_AD('RightMiddle');
}

function _endColumn(){
	document.write("</CENTER></TD></TR></TABLE>");
}

function tableForEach(keyArray, valueHash, numColumns, header) {

	if (keyArray.length==0) return;

	document.write('<tr><td colspan="4" class="mainarttxt" bgcolor="#c9dbed"><b>'
			+ header + '</b>  </td></tr>');

	for (var i=0; i<keyArray.length/numColumns; i++) {

		document.write('<tr valign="top">');

		for (var j=0; j<numColumns; j++) {

			if ((i*numColumns+j) < keyArray.length) {

				var element = keyArray[i*numColumns+j];

				document.write('<td><input type="checkbox" name="tickers.' +
					element + '" value="' + valueHash[element] + '"> </td>' +
					'<td class="mainarttxt" width="141">' + valueHash[element] + '</td>');

			}
		}
		document.write('</tr>');
	}
}		

function _doAlertsWindow(){

	if((typeof tickerKeyList == "undefined") && (typeof personKeyList == "undefined") && (typeof keywordKeyList == "undefined")){return;}

	document.write('<MAP name=alertsoptions><AREA shape=RECT coords=164,0,263,29 href="javascript:alerts_welcome()"><AREA shape=RECT coords=-1,0,113,29 href="http://www.forbes.com/membership/editprofile.jhtml"></MAP><form action="/alertSignup" method="post" name="alertForm" onSubmit="return checkAlertForm();"><input type="hidden" name="actionUrl" value="param:this.location.pathname"><table border="0" width="100%" cellspacing="0" cellpadding="3" class="blueback"><tr valign="top"><td class="whitetxt"><b>E-Mail Alerts</b></td></tr></table><table border="0" width="336" cellspacing="0" cellpadding="1" bgcolor="#000000"><tr><td><table cellspacing="0" cellpadding="2" border="0" width="334" bgcolor="#ffffff"><tr><td colspan="4"> <img src="http://images.forbes.com/media/alerts/story_window_getalerts.gif" width=330 height=30 border=0 alt="" ></td></tr>');

	if((typeof tickerKeyList != "undefined") && (typeof tickerHash != "undefined")){
		tableForEach(tickerKeyList, tickerHash, 2, "Companies");
	}
	if((typeof personKeyList != "undefined") && (typeof personHash != "undefined")){
		tableForEach(personKeyList, personHash, 2, "People");
	}
	if((typeof keywordKeyList != "undefined") && (typeof keywordHash != "undefined")){
		tableForEach(keywordKeyList, keywordHash, 2, "Topics");
	}

	document.write('<TR><TD class=mainarttxt bgColor=#c9dbed colSpan=4><B>Enter E-Mail Address:</B>                 <A class=smalltxt href="/2002/05/22/alertsfaq.html">FAQ</A>  |  <A class=smalltxt href="/fdc/privacy.shtml">Privacy Policy</A><BR><INPUT class=alertemail name=email> <B><INPUT class=alertsignup type=submit value="Sign Me Up!" name=submit> </B></TD></TR><TR><TD align=middle colSpan=4><IMG height=28 src="http://images.forbes.com/media/alerts/alerts_newsletters.gif" width=262 useMap=#alertsoptions vspace=8 border=0></TD></TR></table></td></tr></table></form>');

}

function _doAlertsColumn(){

	if((typeof tickerKeyList == "undefined") && (typeof personKeyList == "undefined") && (typeof keywordKeyList == "undefined")){return;}

    document.write('<MAP name=alertsoptions><AREA shape=RECT coords=0,51,124,87 href="javascript:alerts_welcome()"><AREA shape=RECT coords=0,-1,124,33 href="http://www.forbes.com/membership/editprofile.jhtml"></MAP><form action="/alertSignup" method="post" name="alertForm" onSubmit="return checkAlertForm();"><input type="hidden" name="actionUrl" value="' + this.location.pathname + '"><table border="0" width="168" cellspacing="0" cellpadding="2"><tr><td><table border="0" width="100%" cellspacing="0" cellpadding="3" class="blueback"><tr valign="top"><td class="whitetxt"><b>E-Mail Alerts</b></td></tr></table></td></tr></table><table border="0" width="166" cellspacing="0" cellpadding="1" bgcolor="#000000"><tr><td><table cellspacing="0" cellpadding="2" border="0" width="100%" bgcolor="#ffffff"><tr><td colspan="4"><img src="http://images.forbes.com/media/alerts/story_column_getalerts.gif" width=162 height=60 border=0 alt="" ><br></td></tr>');

	if((typeof tickerKeyList != "undefined") && (typeof tickerHash != "undefined")){
		tableForEach(tickerKeyList, tickerHash, 1, "Companies");
	}
	if((typeof personKeyList != "undefined") && (typeof personHash != "undefined")){
		tableForEach(personKeyList, personHash, 1, "People");
	}
	if((typeof keywordKeyList != "undefined") && (typeof keywordHash != "undefined")){
		tableForEach(keywordKeyList, keywordHash, 1, "Topics");
	}
    document.write('<tr><td class=mainarttxt bgColor=#c9dbed colSpan=4><B>Enter E-Mail Address:</B><br><INPUT class=alertemail size=10 name=email> <BR><INPUT class=alertsignup type=submit value="Sign Me Up!" name=submit><BR><A class=smalltxt href="/2002/05/22/alertsfaq.html">FAQ</A>  <A class=smalltxt href="/fdc/privacy.shtml">Privacy Policy</A></td></tr><tr><td class=linkset align=middle colSpan=4><IMG height=86 src="http://images.forbes.com/media/alerts/alerts_newsletters_tall.gif" width=123 useMap=#alertsoptions vspace=10 border=0></td></tr></table></td></tr></table></form>');
}

























