var webDomain = "http://www.thestreet.com";
var secureDomain = "https://secure2.thestreet.com";
var imagesDomain = "http://images.thestreet.com";
var appsDomain = "http://apps.thestreet.com";
var searchDomain = "http://find.thestreet.com";
var toolsDomain = "http://tools.thestreet.com";
var ratingsDomain = "http://ratings.thestreet.com"
var currentHost = location.host;

if (currentHost == "dfind01.thestreet.com" || currentHost == "appsdev.thestreet.com" || currentHost == "dpub01.thestreet.com" || currentHost == "stools.thestreet.com" || currentHost == "cms01.thestreet.com" || currentHost == "sratings.thestreet.com") {
	webDomain = "http://cms01.thestreet.com";
	secureDomain = "https://commercestage.thestreet.com";
	imagesDomain = "http://cms01.thestreet.com";
	appsDomain = "http://appsstage.thestreet.com";
	searchDomain = "http://dfind01.thestreet.com";
	toolsDomain = "http://stools.thestreet.com";
	ratingsDomain = "http://sratings.thestreet.com"
}

if (currentHost == "devweb.thestreet.com" || currentHost == "dratings.thestreet.com") {
	webDomain = "http://devweb.thestreet.com";
	ratingsDomain = "http://dratings.thestreet.com"
}

// extract _puc for partner pages and ad tags
var path = document.location.pathname;
var partner = null;
var adpuc = null;
var puc = null;
var index = path.indexOf("/_");
if(index > -1) {
	start = path.substring(index+2);
	partner = start.substring(start,start.indexOf("/"));  // used on partner story page
	puc = partner; // used in ad tags
	if(puc != null) adpuc = ("adpuc=" + puc + ";");
}

function __ds(e) { return false;}
	function __ra() { return true;}

try {
   if((path.indexOf("/k/aap") == 0) || (path.indexOf("/k/esa")==0)){
      document.onselectstart=new Function ("return false");

        if (window.sidebar)
        {
          document.onmousedown=__ds;
          document.onclick=__ra;
        }
   }
}catch(e){}



<!-- ord number for generic ads -->
var ord = Math.random() + "" ;
ord = ord.substring(2,ord.length);

<!-- common cookie parsing code (My StockWatch, User Status -->
function GetCookie (splitby,name) {

    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
    while (i < clen) {
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg)
            return getCookieVal(splitby,j);
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) break;
    }

    return null;
}

function getCookieVal (splitby,offset) {
    var endstr = document.cookie.indexOf (splitby,offset);
    if (endstr == -1)
    endstr = document.cookie.length;
    return unescape(document.cookie.substring(offset, endstr));
}


<!-- called by surveys -->
function showLiveSurvey(expiration, workFlowState, liveMode) {
	var now = Date.parse(new Date());
	var endDate = Date.parse(expiration);
 
	if (endDate > now && workFlowState == liveMode) {
		document.getElementById("divTable").style.display="inline";
	}
}

	//called by radio pages and search
function audioPlayer(clip, author){

	var cookieSelectedFormat = null;
	var editPreference = false;
	var cookieName = "selectedAudioFormat"; // cookie name
	var wmaplayer = "wma_player.html";
	var mp3player = "audio_player.html";

	if(author != null) {
		wmaplayer = author + "_wma_player.html";
		mp3player = author + "_audio_player.html";
	}

	// read the cookie
	if(document.cookie.indexOf(cookieName) > -1) {
		cookieSelectedFormat = GetCookie(";",cookieName);
	
		// if wma, pop up the player
		if( (cookieSelectedFormat != null) && (cookieSelectedFormat == "formatSelectedWMA") ) {
			url = webDomain +"/radio/" + wmaplayer + "?clip=" + clip;
			window.open(url,"clip","WIDTH=400,HEIGHT=490,top=50,left=50,status=yes,toolbar=no,menubar=no,location=no,resizable=yes");
		} else {
			var url = webDomain +"/radio/" + mp3player + "?clip=" + clip;
			window.open(url,"clip","WIDTH=400,HEIGHT=490,top=50,left=50,status=yes,toolbar=no,menubar=no,location=no,resizable=yes");		
		}
	
	} else {
		var url = webDomain +"/radio/" + mp3player + "?clip=" + clip;
		window.open(url,"clip","WIDTH=400,HEIGHT=490,top=50,left=50,status=yes,toolbar=no,menubar=no,location=no,resizable=yes");
	}
}


<!-- called by the glossary tag -->
function popUp(href) {
popupWin = window.open(href, 'remote', 'width=380,height=480,left=40,top=30,scrollbars=yes');
}

<!-- called by media tag -->
function popping(href,mediaUrl, width, height) {
poppingWin = window.open(href, mediaUrl, 'width=' + width + ',height=' + height + ',left=40,top=30,scrollbars=yes');
}

<!-- called by bigchart ads -->
function switchimg(newImg, whichImg) {
var imgRoot ;
var randNum ;
randNum = Math.random() ;
imgRoot = "http://a1128.g.akamaitech.net/v/1128/402/3m/akachart.bigcharts.com/custom/thestreet-com/";
document.images[whichImg].src = imgRoot + newImg + ".img?" + randNum ;
}

 
 
<!-- Status cookie js --> 
	document.write("<SCR" + "IPT LANGUAGE='JavaScript1.2' SRC='"+ webDomain + "/tsc/userStatus.js' TYPE='text/javascript'><\/SCR" + "IPT>");

<!-- called by My StockWatch index, gets userid, user lists -->
var userid = GetCookie("|","RGIS");

function StockWatchCookie(){
    //Cookie format example: {list1`~`AMAT AOL/}{list2`~`MSFT DELL/}
    this.watchList = new Array();
    var cookieVal = GetCookie(";","StockWatchList");

    if(cookieVal != null && cookieVal.length > 2){
        cookieVal = cookieVal.substring(1, cookieVal.length - 2);

        var list = cookieVal.split("/}||{");

        for( var i = 0; i < list.length; i++){
            var data = list[i].split("`~`");
            this.watchList[i] = data;
        }
    }
}

// Browser detection for unsupported browser message
    document.write("<SCR" + "IPT LANGUAGE='JavaScript1.2' SRC='" + webDomain + "/tsc/common/javascript/unsupportedBrowserDetect.js' TYPE='text/javascript'><\/SCR" + "IPT>");

// flash detection script
        document.write("<SCR" + "IPT LANGUAGE='JavaScript1.2' SRC='" + webDomain + "/tsc/common/javascript/flash_sniff.js' TYPE='text/javascript'><\/SCR" + "IPT>");

//revenue science
	if (rsinetsegs == null) var rsinetsegs = "";
	if (rsistring == null) var rsistring = "";
	if (segQS == null) var segQS = "";
	document.write("<SCR" + "IPT LANGUAGE='JavaScript1.2' SRC='" + webDomain + "/tsc/common/javascript/rsi.js' TYPE='text/javascript'><\/SCR" + "IPT>");

// tscm js - ratings utils, yahoo utils
   var mod = "/tsc/tscm.js";
	if(typeof document.createElement!="undefined"){
		var h=document.getElementsByTagName('head').item(0);
		var s=document.createElement('script');
		s.setAttribute("type","text/javascript");
		s.setAttribute("src",webDomain+mod);
		s.setAttribute("defer", true);
		h.appendChild(s);
	}else{
		document.write("<scr" + "ipt type='text/javascript' src='" + mod + "'><" + "/" + "scr" + "ipt>");
	}

   mod = "/tsc/yui.js";
	if(typeof document.createElement!="undefined"){
		var h=document.getElementsByTagName('head').item(0);
		var s=document.createElement('script');
		s.setAttribute("type","text/javascript");
		s.setAttribute("src",webDomain+mod);
		s.setAttribute("defer", true);
		h.appendChild(s);
	}else{
		document.write("<scr" + "ipt type='text/javascript' src='" + mod + "'><" + "/" + "scr" + "ipt>");
	}



// subnav div Date/Time stamp
function CustomDate(value){
	if(value)
		this.currentDate = value;
	else
	    this.currentDate = new Date();
	    
	this.days = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
	this.months = new Array('January','February','March','April','May','June','July','August','September','October','November','December');


}

function CustomDate_asString(){
	var date = ((this.currentDate.getDate() < 10) ? "0" : "") + this.currentDate.getDate();
	var hours =  this.currentDate.getHours();
	var minutes =((this.currentDate.getMinutes()<10) ? "0" : "")+ this.currentDate.getMinutes();
	var dn=" a.m. ";
	if (hours >=12){
		dn=" p.m. ";
	}

	if (hours > 12){
		hours = hours-12;
	}
	
	
	var retval = this.days[this.currentDate.getDay()] + ", " + this.months[this.currentDate.getMonth()] + " " + date + ", " + this.currentDate.getFullYear() + "&nbsp;&nbsp;|&nbsp;&nbsp;" + hours + ":" + minutes + dn + " ET";
	
	return retval; 
}

CustomDate.prototype.asString = CustomDate_asString;

// sets div widths, placements
function init(usesDivs) {


	if((usesDivs != null) && (usesDivs != "")) {
		// set div widths, nav tab widths, etc.
		// set page width
		var width = 770;
		if(document.getElementById("toparea") != null) {
			document.getElementById("toparea").style.width = width + "px";
		}
		if(document.getElementById("navdivcontainer") != null) {
			document.getElementById("navdivcontainer").style.width = width + "px";
		} else {
			if(document.getElementById("navtable") != null) document.getElementById("navtable").style.width = "770px";
		}

		if(document.getElementById("wrapper") != null) {
			document.getElementById("wrapper").style.width = width + "px";
		}
		if(document.getElementById("footerdiv") != null) {
			document.getElementById("footerdiv").style.width = width + "px";
		}
		if(document.getElementById("botNavDiv") != null) {
			document.getElementById("botNavDiv").style.width = width + "px";
		}

		if(document.getElementById("navdiv") != null) {
			// this code adjusts tab widths evenly for fixed width page, 
			// final tab adjust to fit total container width

			numTabs = 7;
			tabWidth = Math.round(width/numTabs);
			adjuster = 6; // set int fine tune width of last LI

			navDiv = document.getElementById("navdiv");	// the nav div
			numLIs = navDiv.getElementsByTagName("li").length; // total number of LIs under nav div
			for(i=0; i<numLIs; i++) {
				if(navDiv.getElementsByTagName("li")[i].id != null && navDiv.getElementsByTagName("li")[i].id != "line") {
					navDiv.getElementsByTagName("li")[i].style.width = tabWidth + "px";

					if(navDiv.getElementsByTagName("li")[i].id == "lastLI") { // final tab
						navDiv.getElementsByTagName("li")[i].style.width = (tabWidth-adjuster) + "px";
					}
				}
			}

			// event handler used for the navigation rollovers
			sfHover = function(){
				var sfEls = document.getElementById("nav").getElementsByTagName("li");
				for (var i = 0; i < sfEls.length; i++){
					sfEls[i].onmouseover = function(){
						this.className += " sfhover";
					}
					sfEls[i].onmouseout = function(){
						this.className = this.className.replace(new RegExp(" sfhover\\b"), "");
					}
				}
			}
			if (window.attachEvent) window.attachEvent("onload", sfHover);
		}
	}
}

