		//Set the Cookies
	    function SetCookie(cookieName, cookieData) {
	            var days = 10;
	            // Calculate the expiration date
	            var expires = new Date ();
	            expires.setTime(expires.getTime() + days * (24 * 60 * 60 * 1000)); 
	    
	        document.cookie = cookieName + "=" + escape(cookieData) + "; expires=" + expires.toGMTString()+"; path=/";
		  }    


		//Get the Cookies
		function GetCookie(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 (j);
	            i = document.cookie.indexOf(" ", i) + 1;
	            if (i == 0) break; 
	          }
	        return null;
	    }
	
	    function GetCookieVal (offset) {
	        var endstr = document.cookie.indexOf (";", offset);
	        if (endstr == -1)
	            endstr = document.cookie.length;
	        return unescape(document.cookie.substring(offset, endstr));
	    }
	    
	    
	 // Portfolio FundsList
	 
	  function saveSelectionFunds()
	   {
	   		var portfolioCookieName= 'portfolio'+ document.forms[0].fundType.value +'Cookie';
	   	
	   		if(document.getElementsByName('fundslistname'))
	   		{
		   		var chkBx=document.getElementsByName('fundslistname');
		   		if(chkBx.length>0){
		   			var csvFundsCode="";
		   			for(var i=0;i<chkBx.length;++i)
		   			{		
		   				if(chkBx[i].checked==true){
			   				if(csvFundsCode=="") csvFundsCode=chkBx[i].value;
			   				else csvFundsCode+= ","+chkBx[i].value;	
		   				}		   			
		   			}

					// If  funds selected 
					if(csvFundsCode!="" && csvFundsCode!=null)	{
						SetCookie(portfolioCookieName,csvFundsCode);		
						document.forms[0].selFundsList.value=csvFundsCode;   								
					}
					else{
						SetCookie(portfolioCookieName,"");
						return "indexHTML";
						//document.forms[0].methodToCall.value="";						
					}
		   		}
	   		}	   
	   }     
	    
	
			//To keep the selected funds checked when the user come back to the funds list page
			function highlightSelectedItems()
			{
				var portfolioCookieName= 'portfolio'+ document.forms[0].fundType.value +'Cookie';
				
				if(GetCookie(portfolioCookieName)){
					var fundsCodeCookieValue=GetCookie(portfolioCookieName);
					if(fundsCodeCookieValue!=null && fundsCodeCookieValue!=""){
			
						var fundCSVval= fundsCodeCookieValue.split(",");	
						if(fundCSVval.length>0){
							var chkFundslistName=document.getElementsByName("fundslistname");
							if(chkFundslistName.length>0)
							{
								for(var i=0;i<chkFundslistName.length;++i){
									for(var j=0;j<fundCSVval.length;++j){
										if(chkFundslistName[i].value==fundCSVval[j]){
											chkFundslistName[i].checked=true;
										}
									}								
								}							
							}						
						}						
						//alert(fundCSVval.length);
					}	
				}			
			}
	 
			//Checking for the cookies whether the user alredy selected the funds or not.
			function checkPortfolioCookies(fundType)
			{
			var portfolioCookieName= 'portfolio'+ fundType +'Cookie';

				if(GetCookie(portfolioCookieName)){
					var fundsCodeCookieValue=GetCookie(portfolioCookieName);
					if(fundsCodeCookieValue!=null && fundsCodeCookieValue!=""){

						var fundCSVval= fundsCodeCookieValue.split(",");	
						if(fundCSVval.length>0){
						portfolioCookieVal=fundsCodeCookieValue;
						targetMethod="getFundDetails";
						// Navigating to the selected funds details page
						 openPortfolioWin();
						}						
					}
					else{
						targetMethod="getFundsList";		
					}						
				}
				else{
						targetMethod="getFundsList";
				}			
			}		    
	    
	    
	    
	    
	    
	    
