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 + ";");
}

/// ord number for ads
var ord = Math.random() + "" ;
ord = ord.substring(2,ord.length);


// revenue science stuff
if (rsinetsegs == null) var rsinetsegs = "";
if (rsistring == null) var rsistring = "";
if (segQS == null) var segQS = "";


var rsistring = "";
var segCookie, ampTokens, numSegs, segs, rsistring;
var firstSeg = 1234;
var cookieName = "DMSEG";
if((segCookie = GetCookie("; ",cookieName)) != null) {
	segCookie = unescape(segCookie);
	ampTokens = segCookie.split("&");
	if(ampTokens.length >= 6) {
		segs = ampTokens[5].split(",");
		for(i=0; i<segs.length; i++) {
			segstring = ("rsi=" + segs[i] + ";");
			rsistring += segstring;  // rsistring var used in ad tags
		}
	}
}

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));
}



