 	 
 	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';

 	function Get_Cookie() {

			var a_all_cookies = document.cookie.split( ';' );
			var a_temp_cookie = '';
			var cookie_name = '';
			var cookie_value = '';
			var b_cookie_found = false; // set boolean t/f default f
			
			for ( i = 0; i < a_all_cookies.length; i++ )
			{
				a_temp_cookie = a_all_cookies[i].split( '=' );
				
				
				cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
			
					if ( cookie_name == "ext" )
				{
					// window.alert("we found this cookie");
					b_cookie_found = true;
					if ( a_temp_cookie.length > 1 )
					{
						cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
					}
					return cookie_value;
					break;
				}
				
				a_temp_cookie = null;
				cookie_name ='';
			}
			if ( !b_cookie_found )
			{
				return null;
			}
}		

function checkDocument()
 {
		var url = document.URL;
  
  		var url1 = url.split("/");
  		
  		var appUrl = url1[2];

		var instanceName = appUrl.split(".");

		var inStance = instanceName[0];

		var mydomain="my.todaysparent.com";
		var targetDomain = "";

		if ( inStance != "www" && inStance != "recipes" && inStance != "community" && inStance != "search" && inStance != "my" )
		{
			mydomain = inStance+'.'+ mydomain ;
		}
		if ( inStance == "todaysparent" )
		{
			mydomain = "my.todaysparent.com";
				//alert("mydomain find :"+mydomain);
			targetDomain = "www.todaysparent.com";
		}
		if ( inStance == "www" || inStance == "my")  // RT 6232 and added instance "my" at line 57
		{
			targetDomain = "www.todaysparent.com";
		}

		if ( inStance == "design" )
		{
			mydomain = mydomain.replace(/design/,"");
			mydomain = 'dev'+ mydomain ;
			targetDomain = "design.todaysparent.com";
		}
		if ( inStance == "watchmegrow" )
		{
			mydomain = "my.todaysparent.com";
			targetDomain = "watchmegrow.todaysparent.com";
		}
		if ( inStance == "qa" )
		{
			mydomain = mydomain.replace(/qa/,"");
			mydomain = 'qa'+ mydomain ;
			targetDomain = "qa.todaysparent.com";
		}
		if ( inStance == "dev" )
		{
			targetDomain = "dev.todaysparent.com";
		}

		if ( inStance == "community" )      //  RT 6206
		{
			//alert(inStance);
			targetDomain = "www.todaysparent.com";
			
		}
    
	//alert("url :"+url);
	//alert("url1 :"+url1);
	//alert("appUrl :"+appUrl);
	//alert("appUrl :" +inStance);
	//	= mydomain.replace(/my./,"www.");
document.write("<!--"+mydomain+":"+inStance+":"+targetDomain+"-->");

var or="or";
var  val = Get_Cookie();

var userId = Get_UserID();

//alert("userId"+userId);

  if(val== null)
  {
	//alert("mydomain :"+mydomain);
	//alert("appUrl :"+appUrl);
	//alert("appUrl :" +inStance);
	
	if(inStance == "watchmegrow") {

    	document.write("<strong>Welcome </strong>Please "+"<a href='https://" +mydomain+"/uumsweb/login.do?property=100052&target=https://"+targetDomain+"/index.jsp'>Sign in</a>"+" "+or +"<a href='https://"+mydomain+"/uumsweb/presignup.do?property=100052&tier=1'>  Register</a>");
	
	} else {
	
    	document.write("<strong>Welcome </strong>Please "+"<a href='https://" +mydomain+"/uumsweb/login.do?property=100052&target=http://"+targetDomain+"/index.jsp'>Sign in</a>"+" "+or +"<a href='https://"+mydomain+"/uumsweb/presignup.do?property=100052&tier=1'>  Register</a>");

	}
  
	if (inStance == "toytester")
	{
	
	document.write("<strong>Welcome </strong>Please "+"<a href='https://" +mydomain+"/uumsweb/login.do?property=100052&target=http://"+targetDomain+"'>Sign in</a>"+" "+or +"<a href='https://"+mydomain+"/uumsweb/presignup.do?property=100052&tier=1'>  Register</a>");
	}
	
 // document.write("<strong>Welcome </strong>Please "+"<a href='https://"+domain1+"/uumsweb/login.do?property=100052&target=https://my.todaysparent.com/index.jsp'>Sign in</a> or <a href='https://my.todaysparent.com/uumsweb/presignup.do?property=100052&tier=1'> Register</a>");
  }
  else
  {
	  if(val=="")
	  {
		
		document.write("<strong>Welcome Back</strong>" + " <a href='http://www.todaysparent.com/persona/index.jsp?userid="+userId+"'>"+ val + "</a>"+"<a href='https://"+mydomain+"/uumsweb/displayProfile.do?property=100052&tier=2'>" + " "+"Profile"+"  |" + "</a><a href='https://"+mydomain+"/uumsweb/logout.jsp?property=100052&target=http://"+targetDomain+"/index.jsp'> Sign out</a>");
		
				
	  }
	  else
	  {
			
			var x = val;
			var y = x.split("|");

			screenName = y[5];

			if( screenName == "")
			  {
				screenName = y[3];	
			  }
			//alert(y[5]);
		
			if(inStance == "watchmegrow") {

			document.write("<strong>Welcome Back</strong>" + " <a href='http://www.todaysparent.com/persona/index.jsp?userid="+userId+"'>"+ screenName + "</a>  "+"<a href='https://"+mydomain+"/uumsweb/displayProfile.do?property=100052&tier=2'>" + " "+"Profile</a>"+" "+"|"+"<a href='https://"+mydomain+"/uumsweb/logout.jsp?property=100052&target=https://"+targetDomain+"/index.jsp'> Sign out</a>");	
			
			} else {
			
			document.write("<strong>Welcome Back</strong>" + " <a href='http://www.todaysparent.com/persona/index.jsp?userid="+userId+"'>"+ screenName + "</a>  "+"<a href='https://"+mydomain+"/uumsweb/displayProfile.do?property=100052&tier=2'>" + " "+"Profile</a>"+" "+"|"+"<a href='https://"+mydomain+"/uumsweb/logout.jsp?property=100052&target=http://"+targetDomain+"/index.jsp'> Sign out</a>");	

			}
		 
	  }
  }
  }

 function removeCookie()
 {
 if(cookie_name=="NEW_COOKIE1")
 {
 	cookie_name=="";
 	cookie_value=="";
 	
 }
 }

 function Get_UserID(){

			var a_all_cookies = document.cookie.split( ';' );
			var a_temp_cookie = '';
			var cookie_name = '';
			var cookie_value = '';
			var b_cookie_found = false; // set boolean t/f default f
			
			for ( i = 0; i < a_all_cookies.length; i++ )
			{
				a_temp_cookie = a_all_cookies[i].split( '=' );
				
				//window.alert("we found this cookie"+ a_temp_cookie);
				cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
			
				if ( cookie_name == "uid" )
				{
					//window.alert("we found the UID cookie");
					b_cookie_found = true;
					if ( a_temp_cookie.length > 1 )
					{
						cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
					}
					//window.alert("Returning +"+cookie_value);
					return cookie_value;
					break;
				}
				
				a_temp_cookie = null;
				cookie_name ='';
			}
			if ( !b_cookie_found )
			{
				return null;
			}


 }


  
  