function UserStatus(){


   this.RM = '1';
   this.SI = '631';
	this.AAP = '765';
		

	this.globalState = "U";
	this.version = "VER0";
	
	this.streetCookie =  (readCookie("STATUS"))
	if (this.streetCookie != null){
		var list = this.streetCookie.split('|');
      if(list[0].length==1){
         this.globalState = list[0];
      }else{
         var sublist = list[0].split('~');
         this.version=sublist[0];
         this.globalState = sublist[1];
      }
	}
	
}

function UserStatus_isEtradeUser(product){

   var retVal = '';
	if (this.streetCookie != null){
		var statusList = this.streetCookie.split('|');
		
	    for(i=1;i<statusList.length;i++) {
         if(this.version=="VER1"){
	        if(statusList[i].split(':')[0] == product && (((statusList[i].split(':')[2]).substring(5,7) == "ET") 
			|| (statusList[i].split(':')[2]).substring(5,7) == "EI")){
	            retVal = true;
               break;
           }
         }
	    }
	}
    return retVal;
	
}

function UserStatus_hasAccess(product){
   var retVal = '';
	if (this.streetCookie != null){
		var statusList = this.streetCookie.split('|');
		
	    for(i=1;i<statusList.length;i++) {
         if(this.version=="VER1"){
	        if(statusList[i].split(':')[0] == product && statusList[i].split(':')[1] != 'E'){
	            retVal = true;
               break;
           }
         }else{
	        if(statusList[i].split('-')[0] == product && statusList[i].split('-')[1] != 'E'){
	            retVal = true;
               break;
           }
         }
	    }
	}
    return retVal;
	
}


function UserStatus_hasPaidAccess(product){
   var retVal = '';
	if (this.streetCookie != null){
		var statusList = this.streetCookie.split('|');
		
	    for(i=1;i<statusList.length;i++) {
         if(this.version=="VER1"){
	        if(statusList[i].split(':')[0] == product && statusList[i].split(':')[1] == 'P'){
	            retVal = true;
               break;
           }
			}else{
	        if(statusList[i].split('-')[0] == product && statusList[i].split('-')[1] == 'P'){
	            retVal = true;
               break;
           }
         }
	    }
	}
    return retVal;
	
}

function UserStatus_hasCompAccess(product){
   var retVal = '';
	if (this.streetCookie != null){
		var statusList = this.streetCookie.split('|');
		
	    for(i=1;i<statusList.length;i++) {
         if(this.version=="VER1"){
	        if(statusList[i].split(':')[0] == product && statusList[i].split(':')[1] == 'C'){
	            retVal = true;
               break;
           }
			}else{
	        if(statusList[i].split('-')[0] == product && statusList[i].split('-')[1] == 'C'){
	            retVal = true;
               break;
           }
         }
	    }
	}
    return retVal;
}


function UserStatus_isPaid(){
	return (this.globalState == "P");
}

function UserStatus_isTrialer(){
	return (this.globalState == "F");
}

function UserStatus_isComp(){
	return (this.globalState == "C");
}

function UserStatus_isRegistrant(){
	return (this.globalState == "R");
}

function UserStatus_isExpired(){
	return (this.globalState == "E");
}



UserStatus.prototype.isEtradeUser = UserStatus_isEtradeUser;
UserStatus.prototype.hasCompAccess = UserStatus_hasCompAccess;
UserStatus.prototype.hasPaidAccess = UserStatus_hasPaidAccess;
UserStatus.prototype.hasAccess = UserStatus_hasAccess;
UserStatus.prototype.isPaid = UserStatus_isPaid;
UserStatus.prototype.isTrialer = UserStatus_isTrialer;
UserStatus.prototype.isComp = UserStatus_isComp;
UserStatus.prototype.isRegistrant = UserStatus_isRegistrant;
UserStatus.prototype.isExpired = UserStatus_isExpired;


function disablePopup()
{
	var user = new UserStatus();
	if ( (user.isPaid()) || (user.isTrialer()) )
	{
	return true;
	}

}

function readCookie(name) {
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
			
		}
		return null;
}

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 currentHost = location.host;

if (currentHost == "dfind01.thestreet.com" || currentHost == "appsdev.thestreet.com" || currentHost == "dpub01.thestreet.com" || currentHost == "stools.thestreet.com" || currentHost == "cms01.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";
}

function showAdvertisement(myURL) {
	//window.open(myURL, "_blank");
}

