	
	//Function Name:CardInfoMessageEx  Created By:Simon Huang Created Date: 06/09/2006
	//Purpose: This function is used to show the pre-approve image link at header next my promotions;
    //          If user has been pre-approved, the pre-approve image and link will show up, otherwise, not show this link and image	            
	function CardInfoMessageEx(cookieStringCreditInfo, cookieStringPreApprovedOfferDeclined, ccLinkID, ccImageID)
	{	
	
		var cookieValueCreditInfo  = GetUserSubCookieValue(cookieStringCreditInfo);
		var cookieValuePreApprovedOfferDeclined  = GetUserSubCookieValue(cookieStringPreApprovedOfferDeclined);
		
		//alert(cookieValueCreditInfo);
		var ccLink = document.getElementById(ccLinkID);
		var ccImage  = document.getElementById(ccImageID);		
		
		
		
		if(ccLink == null || ccImage == null)
		{
			return;
			
		}
		
		var urlBase = "https://secureimages.redcatsusa.com/images/site_images/chadwicks/";
				
		var imagePre = urlBase + "121-preapproved-blue.gif";
			
		
		if (cookieValueCreditInfo != null && cookieValueCreditInfo.length > 0)
		{
			var offerDeclined = false;
		    if (cookieValuePreApprovedOfferDeclined != null)
		    {
		        if (cookieValuePreApprovedOfferDeclined == "true")
		        {
		            offerDeclined = true;
		        }
		    }
		    
			var  startIndex= 0;
			
			var endIndex = cookieValueCreditInfo.indexOf(';');
			
			//Credit Indicator is the first value and Offerseen is the 4th value in the cookie.
			//Please see the UserInfo Class to see the exact order.
			var creditIndicator  =  cookieValueCreditInfo.substring(startIndex, endIndex);
			//alert(creditIndicator);
				
			if (creditIndicator.toUpperCase() == "P")
			{
			    //alert("p");
			    if (!offerDeclined)
			    {
				    ccLink.style.display="inline";
				    ccImage.style.display="inline";
				    ccLink.href = "/Account/Acct_PreQualifiedOffer_common.aspx";
				    ccImage.src = imagePre;
				}
				
			}
			else// hidden this link and image
			{
				//alert("O");
				ccLink.style.display="none";
				ccImage.style.display="none";
			}

		}
		else
		{
		    //alert("sd");
			ccLink.style.display="none";
			ccImage.style.display="none";
		}
	}
	//This function has one more hyperlink to handle for Special size
	function CardInfoMessageNew(cookieStringCreditInfo, ccLinkID,ccLink1ID, ccImageID)
	{	
	
		var cookieValueCreditInfo  = GetUserSubCookieValue(cookieStringCreditInfo);
		
		var ccLink = document.getElementById(ccLinkID);
		var ccLink1= document.getElementById(ccLink1ID);
		var ccImage  = document.getElementById(ccImageID);		
		//alert(cookieValueCreditInfo);
		
		
		//if(ccLink == null || ccImage == null || ccLink1==null)
		//{
			//return;
			
		//}
		
        var urlBase;
		
		if(window.location.protocol.indexOf("s")>0)
		{
		    urlBase = "https://secureimages.redcatsusa.com/images/site_images/jessicalondon/";
		}
		else
		{
		    urlBase = "http://images.redcatsusa.com/images/site_images/jessicalondon/";
		}	
				
		//ToDo change the image into imageOTB	
		var imageOTB = urlBase + "123_img_easygreat.gif";
		//ToDo change the image into preapproved
		var imagePre = urlBase + "123_img_easygreat.gif";
		
		var imageStandard = urlBase + "123_img_easygreat.gif";
		
			
		
		if (cookieValueCreditInfo != null && cookieValueCreditInfo.length > 0)
		{
			
			var  startIndex= 0;
			
			var endIndex = cookieValueCreditInfo.indexOf(';');
			
			//Credit Indicator is the first value and Offerseen is the 4th value in the cookie.
			//Please see the UserInfo Class to see the exact order.
			var creditIndicator  =  cookieValueCreditInfo.substring(startIndex, endIndex);
			
		
			//we dont need this for now
			/*
			endIndex = cookieValueCreditInfo.indexOf(';',endIndex+1);
			startIndex = cookieValueCreditInfo.indexOf(';',endIndex+1) + 1;
			
			var offerseen = cookieValueCreditInfo.substring(startIndex, cookieValueCreditInfo.indexOf(';',startIndex)); //4
		
			*/
					
			
			if (creditIndicator.toUpperCase() == "A")
			{
				//ccLink.href = "/Account/Acct_CreditCards.aspx";
				ccLink1.href ="/Account/Acct_CreditCards.aspx";
				//ccImage.src = imageOTB;
			}
			else if (creditIndicator.toUpperCase() == "P" )
			{
				
				//ccLink.href = "/Account/Acct_PreQualifiedOffer_common.aspx";
				ccLink1.href = "/Account/Acct_PreQualifiedOffer_common.aspx";
				//ccImage.src = imagePre;
				
			}
			else if(creditIndicator.toUpperCase()=="R")
			{
				//ccLink.href = "/Account/Acct_PreQualifiedOfferDetails.aspx";
				ccLink1.href = "/Account/Acct_PreQualifiedOfferDetails.aspx";
				//ccImage.src = imagePre;

			}
			else
			{
				//ccLink.href = "/Account/Apply_CreditCard.aspx";
				ccLink1.href = "/Account/Apply_CreditCard.aspx";
				//ccImage.src = imageStandard;
			}

		}
		else
		{
			if(ccLink1!=null)
			{		
    			ccLink1.href = "/Account/Apply_CreditCard.aspx";
    		}	
		}
	}
	
	
	function CardInfoMessage(cookieStringCreditInfo, cookieStringPreApprovedCardType, ccLinkID, ccImageID)
	{	
		var cookieValueCreditInfo  = GetCookieValueFor(cookieStringCreditInfo);
		var cookieValuePreApprovedCardType = GetCookieValueFor(cookieStringPreApprovedCardType);
		
		cookieValuePreApprovedCardType = cookieValuePreApprovedCardType.substring(0, 4);
		
		var ccLink = document.getElementById(ccLinkID);
		var ccImage  = document.getElementById(ccImageID);		
		
		
		
		if(ccLink == null || ccImage == null)
		{
			return;
			
		}
		
		var urlBase = "";
		
		if(window.location.protocol.indexOf("s")>0)
		{
		    urlBase = "https://secureimages.redcatsusa.com/images/site_images/chadwicks/";
		}
		else
		{
		    urlBase = "http://images.redcatsusa.com/images/site_images/chadwicks/";
		}	
			
		
				
		var imageOTB = urlBase + "121_footer_otb.gif";
		
		
		var imagePre;
		var imageStandard = urlBase + "121_footer_apply.gif";
		if (cookieValuePreApprovedCardType != null && cookieValuePreApprovedCardType.length > 0)
		{
		    if (cookieValuePreApprovedCardType == "plcc")
		    {
		        imagePre = urlBase + "121_footer_pre_plcc.gif"
		    }
		    else if (cookieValuePreApprovedCardType == "cobr")
		    {
		        imagePre = urlBase + "121_footer_pre_cobrnd.gif"
		    }
		    else
		    {
		        imagePre = imageStandard;
		    }
		}
		else
		{
		    imagePre = imageStandard;
		}
		if (cookieValueCreditInfo != null && cookieValueCreditInfo.length > 0)
		{
			
			var  startIndex= 0;
			
			var endIndex = cookieValueCreditInfo.indexOf(';');
			
			//Credit Indicator is the first value and Offerseen is the 4th value in the cookie.
			//Please see the UserInfo Class to see the exact order.
			var creditIndicator  =  cookieValueCreditInfo.substring(startIndex, endIndex);
			
			
			//we dont need this for now
			/*
			endIndex = cookieValueCreditInfo.indexOf(';',endIndex+1);
			startIndex = cookieValueCreditInfo.indexOf(';',endIndex+1) + 1;
			
			var offerseen = cookieValueCreditInfo.substring(startIndex, cookieValueCreditInfo.indexOf(';',startIndex)); //4
		
			*/
					
			
			if (creditIndicator.toUpperCase() == "A")
			{
				ccLink.href = "/Account/Acct_CreditCards.aspx?MEC=CH07_009_03_01_01";
				ccImage.src = imageOTB;
			}
			else if (creditIndicator.toUpperCase() == "P")
			{
				if (cookieValuePreApprovedCardType != null && cookieValuePreApprovedCardType.length > 0)
		        {
		            if (cookieValuePreApprovedCardType == "plcc")
		            {
		                ccLink.href = "/Account/Acct_PreQualifiedOffer_plcc.aspx?MEC=CH07_009_01_01_01";
		            }
		            else if (cookieValuePreApprovedCardType == "cobr")
		            {
		                ccLink.href = "/Account/Acct_PreQualifiedOffer_cobrnd.aspx?MEC=CH07_009_02_01_01";
		            }
		            else
		            {
		                ccLink.href = "/Account/Apply_CreditCard.aspx?MEC=CH07_009_04_01_01";
		            }
		        }
		        else
		        {
		            ccLink.href = "/Account/Apply_CreditCard.aspx?MEC=CH07_009_04_01_01";
		        }
				ccImage.src = imagePre;
				
			}
			else
			{
				ccLink.href = "/Account/Apply_CreditCard.aspx?MEC=CH07_009_04_01_01";
				ccImage.src = imageStandard;
			}

		}
		else
		{
			ccLink.href = "/Account/Apply_CreditCard.aspx?MEC=CH07_009_04_01_01";
			ccImage.src = imageStandard;
		}
	}
	
	
	
	//link to different pages
	function CardInfoLink(cookieStringCreditInfo, cookieStringHasCard, cookieStringPreApprovedOfferDeclined, ccLinkID)
	{	
		var cookieValueCreditInfo  = GetUserSubCookieValue(cookieStringCreditInfo);
		var cookieValueHasCard  = GetUserSubCookieValue(cookieStringHasCard);
		var cookieValuePreApprovedOfferDeclined  = GetUserSubCookieValue(cookieStringPreApprovedOfferDeclined);
		
		var ccLink = document.getElementById(ccLinkID);
		
		
		if(ccLink == null)
		{
			return;
			
		}		
				
		if (cookieValueCreditInfo != null && cookieValueCreditInfo.length > 0 && cookieValueHasCard != null && cookieValueHasCard.length > 0)
		{
		
		    var offerDeclined = false;
		    if (cookieValuePreApprovedOfferDeclined != null)
		    {
		        if (cookieValuePreApprovedOfferDeclined == "true")
		        {
		            offerDeclined = true;
		        }
		    }
			
			var  startIndex= 0;
			
			var endIndex = cookieValueCreditInfo.indexOf(';');
			
			//Credit Indicator is the first value and Offerseen is the 4th value in the cookie.
			//Please see the UserInfo Class to see the exact order.
			var creditIndicator  =  cookieValueCreditInfo.substring(startIndex, endIndex);
			var hasotherCard = false;
			
			if(cookieValueHasCard.toUpperCase() == "TRUE")
			{
				hasotherCard = true;
			}					
			
			if (creditIndicator.toUpperCase() == "A")
			{
				ccLink.href = "/Account/Acct_CreditCards.aspx";
				
			}
			else if (creditIndicator.toUpperCase() == "P")
			{
			    if (!offerDeclined)
    				ccLink.href = "/Account/Acct_PreQualifiedOffer_common.aspx";
			}
			else if(hasotherCard)
			{
				
				ccLink.href = "/Account/Acct_CreditCards.aspx";
				
			}
			else
			{
				
				ccLink.href = "/Account/Apply_CreditCard.aspx";
				
			}

		}
		else
		{
			ccLink.href = "/Account/Apply_CreditCard.aspx";
			
		}
	}
	
	
	function WelcomeMessageInterface(cookieStringFirstName, nameLabel,welcomeLabel, disconnectHyperLink, wishListSpan)
	{
	
		var cookieValueFirstName  = GetUserSubCookieValue(cookieStringFirstName);
		
		
		
		var _disconnectHyperLink = document.getElementById(disconnectHyperLink);
		var _nameLabel = document.getElementById(nameLabel);
		var _welcomeLabel = document.getElementById(welcomeLabel);
		
		var _wishListSpan = null;
		
		
		if(wishListSpan != null && wishListSpan.length > 0)
		{
			_wishListSpan = document.getElementById(wishListSpan);
			
		}
		
		if(	_welcomeLabel == null || _nameLabel == null || _disconnectHyperLink == null)
		{
			return;
		}
		
		if (cookieValueFirstName != null && cookieValueFirstName.length > 0)
		{
			
			var temp = new String(cookieValueFirstName);
			
			cookieValueFirstName = temp.toLowerCase();
			
			
			_welcomeLabel.innerHTML = "Welcome back, " + " <span class='capitalize'>" + cookieValueFirstName + "</span>! ";
						
			//Removed the following line because of white space issue -- JS
			//_nameLabel.innerHTML =  "<span class='capitalize'>" + cookieValueFirstName + "</span>! ";
			//_nameLabel.style.fontWeight ='bold';
			
			_disconnectHyperLink.innerHTML = " Not <span class='capitalize'>" + cookieValueFirstName + "</span>?";
			
			if(_wishListSpan != null)
			{
				_wishListSpan.innerHTML = "&nbsp;|&nbsp;&nbsp;<a href='/account/acct_wishlist.aspx'>Wish List</a>";
				
				
			}
		
		}
		else
		{
			_nameLabel.innerHTML = "First time visitor? Create a <a href=/account/Acct_CreateProfile.aspx?ReturnUrl=%2fAccount%2fAcct_Main.aspx>New Account</a>";
			_nameLabel.style.fontWeight ='normal';

			_welcomeLabel.innerHTML = "Welcome. <a href=/account/acct_login.aspx?ReturnUrl=%2fAccount%2fAcct_Main.aspx>Log In</a>  " ;
					
			_disconnectHyperLink.innerHTML = "";
			
			if(_wishListSpan != null)
			{
				_wishListSpan.innerHTML = "";				
				
			}
		}
		
		//move to another function
		/*var _productHistoryImageDivider = document.getElementById(productHistoryImageDivider);
		var _productHistoryHyperLink = document.getElementById(productHistoryHyperLink);
		var _PACCLink = document.getElementById(PACCLink);
		var _OTBLink  = document.getElementById(OTBLink);
		var _imageDivider2 = document.getElementById(imageDivider2);
		
		var cookieValuePoductHistory = GetCookieValueFor(cookieStringProductHistory);
		if (cookieValuePoductHistory.length == 0)
		{
			_productHistoryHyperLink.style.visibility  = "hidden";
			_productHistoryImageDivider.style.visibility = "hidden";
			_productHistoryImageDivider.style.visibility = "hidden";
			
			if ((_PACCLink.innerHTML.length == 0)&& (_OTBLink.innerHTML.length == 0))
			{
			
				_imageDivider2.style.visibility = "hidden";
			}
		}
		else
		{
			if ((_PACCLink.innerHTML.length == 0)&& (_OTBLink.innerHTML.length == 0))
			{	
			
				_PACCLink.innerHTML = _productHistoryHyperLink.innerHTML
				_PACCLink.href =_productHistoryHyperLink.href
				_productHistoryHyperLink.style.visibility  = "hidden";
				_productHistoryImageDivider.style.visibility = "hidden";
			}
			else
			{
				_productHistoryHyperLink.style.visibility  = "visible";
				_productHistoryImageDivider.style.visibility  = "visible";
			}
					
		}*/
	}
	
	
	function ProductMessageInterface(cookieStringProduct, viewProductLinkID, dividerID)
	{	
		var cookieValueProduct  = GetCookieValueFor(cookieStringProduct);		
		var viewProductLink = document.getElementById(viewProductLinkID);	
		var divider = document.getElementById(dividerID);
		
		if(viewProductLink != null)
		{
			if (cookieValueProduct != null && cookieValueProduct.length > 0)
			{
				
				viewProductLink.style.display  = "";
				if(divider !=  null)
				{
					divider.style.display  = "";
				}
			
			}
			else
			{
				viewProductLink.style.display  = "none";				
				if(divider !=  null)
				{
					divider.style.display  = "none";
				}
				
			}
		}	
		
	}
	
	
	function GetCookieValueFor(CookieNameString)
	{
		var cookieContents = this.document.cookie; 
		var startIndex = cookieContents.indexOf(CookieNameString + '=');
		var cookieValue = "";
		
		if (startIndex != -1)
		{
			startIndex += CookieNameString.length + 1;
			
			var endIndex = cookieContents.indexOf(';', startIndex);
			if (endIndex == -1)
				endIndex = cookieContents.length;
		
			cookieValue = decode(cookieContents.substring(startIndex, endIndex)).replace(/%0/g, '');
		
			if (cookieValue.substring(0,3) == '%$&')
				cookieValue = unicodelessDecode(cookieContents.substring(startIndex, endIndex)).replace(/%0/g, '');
		}
		
		return cookieValue;
	}
	
	function GetUserSubCookieValue(subcookieName)
	{
	    var rawCookieValue =  GetSubCookieValue("User", subcookieName);
	    var cookieValue = rawCookieValue;
	    
	     if(rawCookieValue != null)
	    {
	        cookieValue = decode(rawCookieValue).replace(/%0/g, '');		
	        
	        if (cookieValue.substring(0,3) == '%$&')
				cookieValue = unicodelessDecode(rawCookieValue).replace(/%0/g, '');
		
	    }
	    
	    //alert(cookieValue);
	    return cookieValue;
	}
	function GetMPID()
	{
	    var rawCookieValue =  GetSubCookieValue("OM", "MPID");
	    var cookieValue = rawCookieValue;	    
	     if(rawCookieValue != null)
	    {
	        cookieValue = decode(rawCookieValue).replace(/%0/g, '');			        
	        if (cookieValue.substring(0,3) == '%$&')
				cookieValue = unicodelessDecode(rawCookieValue).replace(/%0/g, '');		
	    }
	    return cookieValue;   
	}
	
	
	//to display/hide otb link on the header
	function CardLinkDisplay(cookieStringCreditInfo, cookieStringHasCard, cookieStringPreApprovedOfferDeclined, ccLinkID)
	{	
		var cookieValueCreditInfo  = GetUserSubCookieValue(cookieStringCreditInfo);
		var cookieValueHasCard  = GetUserSubCookieValue(cookieStringHasCard);
		var cookieValuePreApprovedOfferDeclined  = GetUserSubCookieValue(cookieStringPreApprovedOfferDeclined);
		
		var ccLink = document.getElementById(ccLinkID);
		
		
		if(ccLink == null)
		{
			return;
			
		}		
				
		if (cookieValueCreditInfo != null && cookieValueCreditInfo.length > 0 && cookieValueHasCard != null && cookieValueHasCard.length > 0)
		{
			var offerDeclined = false;
		    if (cookieValuePreApprovedOfferDeclined != null)
		    {
		        if (cookieValuePreApprovedOfferDeclined == "true")
		        {
		            offerDeclined = true;
		        }
		    }
		    
			var  startIndex= 0;
			
			var endIndex = cookieValueCreditInfo.indexOf(';');
			
			//Credit Indicator is the first value and Offerseen is the 4th value in the cookie.
			//Please see the UserInfo Class to see the exact order.
			var creditIndicator  =  cookieValueCreditInfo.substring(startIndex, endIndex);
			var hasotherCard = false;
			
			if (creditIndicator.toUpperCase() == "P")
			{
				if (!offerDeclined)
				{
				    if((creditIndicator.toUpperCase() == "G" || creditIndicator.toUpperCase() == "R") && cookieValueHasCard.toUpperCase() == "TRUE")
				    {
				        hasotherCard = true;
				        ccLink.href = "/Account/Acct_CreditCards.aspx";
				        ccLink.style.display = "";
				        ccLink.innerHTML = "Your Credit Card";
				    }
				    else
				    {
				        ccLink.style.display = "none";
				    }
				}
				else
				{
				    ccLink.style.display = "none";
				}
				
				
			}
			else if(cookieValueHasCard.toUpperCase() == "TRUE" || creditIndicator.toUpperCase() == "A" )
			{
				hasotherCard = true;
				ccLink.href = "/Account/Acct_CreditCards.aspx";
				ccLink.style.display = "";
				ccLink.innerHTML = "Your Credit Card";
			}					
			
			

		}
		else
		{
			ccLink.style.display = "none";
			
		}
	}
	