var tgtexInfo = '';
var scripsList = new Array();
var totalScrips = 0;    	
var sortingType ="profitpotential";
var picksDataGlobal = "current";




var formatDateTgt = "";
var tgtExid = "";
var isVolatileTGT = '';
var tgtPgno = 1;
var TGTDataArray = new Array;
var TGTpageNavigationUrl = "";
var tgtcompyFlag = true;
var tgtsigStrgthFlag = true;
var tgtpriceFlag = true;
var tgtroiFlag =true;
var tgtalphaChar = "";
var tgtDate = "";
var exIdTGT = "";
var tgtSignal = "";
var showchart = false;
var vmSPExchangeTGT = '';
var getAZClassificationNameTGT = '';
var mgidTGT ='';

var selectedRoiTGT = 0;
var selectedStrengthTGT = 0;
var getDivHeaderContent1 = "";
var multiIndusTGT = new Array();
var mssearchTxtTGT = "";
var tgtorderBy = "";

var getmsTRC = '';
// Formatting the Result to required format
var selectScrip = '';
var getLoopCount = 0;
var getExId = '';

// When user click the next button this will get call
var msTRCTGT  = "";
function ms_next_tgt() {
		getId =null;
		portfolioFlag = true;
		imageFlag = false;
	if (tgtPgno == Math.ceil(msTRCTGT / tgtpgSize)) {
		document.getElementById("msprevDivTGT").innerHTML = "<a href=\"javascript:ms_prev_tgt();\" alt=\"Previous\">< Previous</a>";
		document.getElementById("msnxtDivTGT").innerHTML = "<a href=\"javascript:ms_next_tgt();\" alt=\"Next\">Next ></a>";
	} else {
		tgtPgno = tgtPgno + 1;
		MSpageNavigation_tgt(tgtPgno);
	}
}
// When user click the previous button this will get call
function ms_prev_tgt() {
		getId =null;
		portfolioFlag = true;
		imageFlag = false;
	if (tgtPgno == 1) {
		document.getElementById("msprevDivTGT").innerHTML = "&nbsp;<span id =\"msprevDivTGT\"><a href=\"javascript:ms_prev_tgt();\" alt=\"Previous\">< Previous</a></span>";
	} else {
		tgtPgno = tgtPgno - 1;
		MSpageNavigation_tgt(tgtPgno);
	}
}
// When user click the next button or previous button this will get call
function MSpageNavigation_tgt(pNo) {
	tgtPgno = pNo;
	getTargetPrice(formatDateTgt, tgtExid, isVolatileTGT);
}



	
// Goto option
function goto_tgtpg(e) {
	var key;
	if (window.event) {
		key = window.event.keyCode;
	} else {
		key = e.which;
	}

	if (key == 13) {
		var numbers = "0123456789";
		var pgno = document.getElementById("gototxtTGT").value;
		pgno = trim(pgno);
		if (pgno == "" || pgno == "null") {
			alert("Enter Page Number");
			document.getElementById("gototxtTGT").focus();
			return;
		}
		for (var i = 0; i < pgno.length; i++) {
			temp = pgno.substring(i, i + 1);
			if (numbers.indexOf(temp) == "-1") {
				alert("Page Number should contain only numbers");
				document.getElementById("gototxtTGT").focus();
				return;
			}
		}
		var lpgno = Math.ceil(msTRCTGT / tgtpgSize);
		if (lpgno < eval(pgno) || eval(pgno) == 0) {
			alert("Please enter page number between 1 to " + lpgno);
			document.getElementById("gototxtTGT").focus();
			return;
		}
		var pno = parseInt(pgno);
		MSpageNavigation_tgt(pno);
	}
}

function ms_next_watch()
{
		try{
		         watching =1;
		         SPpgno++;	 
		         getMyaccountPortfolioData();
	    }catch(e){}
}	
function ms_prev_watch()
{
		try{
		        watching =1;
		        SPpgno--;	 
		        getMyaccountPortfolioData();
	    }catch(e){}
}	
 /* Adding stock to watchlist*/		 
  var watching = 0;
  var remove = 0;
  var watchListLoadFlag = true;
  
function addWatch(scripCode,exId)
  { 
      if(watchListLoadFlag){
		  try {
		        watchListLoadFlag = false; 
		        var j = scripsList.length; 						
		        pageLoad = 1;
				watching =1;
			
				WatchListDWR.addCalls(scripCode,exId,countryid,function(myArray){ 
				
							if(myArray == 25){
								alert("The portfolio limit is 25 .")  
								watchListLoadFlag = true;
							}else if(myArray == 0){
							   alert("This Stock Symbol already exists in portfolio");
							   watchListLoadFlag = true;
							}
							else {
							    scripsList[j+1] = scripCode;
								if(totalScrips == 0){
									document.getElementById("portfolioContentDiv").innerHTML = "";
								}
				     
					            var totallist= "";
								remove = 0;
					            try{
								    document.getElementById("list_"+scripCode).innerHTML = "<a href=\"javascript:removeWatch('" + scripCode + "','"+exId+"')\" />Remove</a>";
								    document.getElementById("portfoliopgInfoDiv").style.display ="block";
								    document.getElementById("dpWatch_"+scripCode).innerHTML = "<a href=\"javascript:removeWatch('"+scripCode +"','"+exId +"');\" >Remove</a>";
								}catch(e){}
								try{
								    document.getElementById("stocklist_"+scripCode).innerHTML = "<a href=\"javascript:removeWatch('" + scripCode + "','"+exId+"')\" class=\"red\"/>Remove</a>";
								    document.getElementById("portfoliopgInfoDiv").style.display ="block";
								}catch(e){ }   
								
								alert("Stock Code added to your portfolio successfully"); 
							
								getMyaccountPortfolioData();
							}
					              
		         });
		  }catch(e){
		    	watchListLoadFlag = true;
		   }		    
	          
	  }else{
	        alert("Please wait request is in process ");
	   }     
	   
}
 
  
 /*
   removing stocks from watchlist
 */   
function removeWatch(scripCode,exchId)
{	
  try{   
		if(watchListLoadFlag){
		 if (confirm("Are sure to remove this stock code from your account?")) {
		    alert("Stock Code Deleted Successfully from your Account");			
			watchListLoadFlag = false ;
			var UserId = getUserId();
			watching =1;
			try{   
				for (j = 0; j < scripsList.length; j++) 
				{
					if(scripsList[j] == scripCode) 
					{
						scripsList.splice(j,1);			                   
						totalScrips = totalScrips -1;  
						              
						if(totalScrips == 0 && SPpgno < 1) {						    
							document.getElementById("portfolioContentDiv").innerHTML = "<div style=\"width:100%; text-align:center; padding-top:40px; padding-bottom:50px; line-height:24px;\">You are currently not viewing any stocks for delivery signals.<br /> Please add the stocks either by  clicking on add from above.</div>";                 
							document.getElementById("portfoliopgInfoDiv").innerHTML = "";
							watching =0; 
						}         
						var myArray;
						try {				 					
							document.getElementById('list_'+scripCode).innerHTML = "<a href=\"javascript:addWatch('" + scripCode + "','"+exchId+"')\" />Add</a>";
						    document.getElementById("dpWatch_"+scripCode).innerHTML = "<a href=\"javascript:addWatch('"+scripCode +"','"+exchId+"');\" >Add</a>";
						}catch(e){} 
						try{
							document.getElementById("stocklist_"+scripCode).innerHTML = "<a href=\"javascript:addWatch('" + scripCode + "','"+exchId+"')\" class=\"red\"/>Add</a>";
						}catch(e){ }     		                     
						WatchListDWR.removeCallsList(loggedUserId,scripCode,countryid,function(myArray){ 
							remove = 1 ;                     
							if(SPpgno > 0 && backToPage == 1) {	
								backToPage	= 0;					           
								SPpgno--;						          				
							}	  
							getMyaccountPortfolioData();
						});				
					}
				}		
			}catch(e){ watchListLoadFlag = true}	
		} else{}
		}else{
			          alert("Please wait request is in process ");
		} 
	
	}catch(e){} 	 				
 } 
 function goto_page(e) {
    
	var key;
	if (window.event) {
		key = window.event.keyCode;
	} else {
		key = e.which;
	}
	
	if (key == 13) {

		var numbers = "0123456789";
		var pgno = document.getElementById("goPage").value;
		
		pgno = trim(pgno);
		if (pgno == "" || pgno == "null") {
			alert("Enter Page Number");
			document.getElementById("goPage").focus();
			return;
		}
		for (var i = 0; i < pgno.length; i++) {
			temp = pgno.substring(i, i + 1);
			if (numbers.indexOf(temp) == "-1") {
				alert("Page Number should contain only numbers");
				document.getElementById("goPage").focus();
				return;
			}
		}
		var lpgno = Math.ceil(totalsize / 10);
		if (lpgno < eval(pgno) || eval(pgno) == 0) {
			alert("Please enter page number between 1 to " + lpgno);
			document.getElementById("goPage").focus();
			return;
		}
		var pno = parseInt(pgno);
		
		SPpgno = pno-1 ;
		watching =1;
		getMyaccountPortfolioData();
	}
}	
 var SPpgno = 0;
 var totalsize = 0 ;
 var backToPage= 0;
 function getMyaccountPortfolioData() {  	          
		  
		  

		  var UserId = getUserId();
		    //  if(loggedUserId == null || loggedUserId == '' || loggedUserId == "null") {
			// var cookieUId = Get_Cookie("VTUID");
			 loggedUserId =UserId;
		   
		   if(loggedUserId != "null" && loggedUserId != 'null' ){				   
			   var startRow = SPpgno*10;
			   var watchInfo = "" ;			  
			   WatchListDWR.getUsersPortfolioList(countryid,loggedUserId,startRow, function(data)
			   { 
			
			       if(data != "null" ||data != null){  
					   var userPortData =  data.split("~~");					  			   
					   if(userPortData[1] != '0' ){     			      
					        var tenStocks =userPortData[0].split("_").length-1;						       
					        if(tenStocks==1 & SPpgno > 0){					           
					            backToPage =1;	
					        }   					       			        			
					        var count = userPortData[1] ;					        
					        totalsize = count ;
					        var watchListSize = 10;
					        var stockSize =Math.ceil(count/10) ;
					        var response = userPortData[0].split("_");						      
					        var totalScripsData = userPortData[2].split(",");
					       			        
					        for(var ss = 0 ; ss < totalScripsData.length ;ss++)
					        {  
					            totalScrips = ss +1;
								var stk_exn = totalScripsData[ss].split("~");
								stkCode = stk_exn[0].toUpperCase();							
								var exchangeId = stk_exn[1].toString() ;														
								scripsList[ss] = stkCode ;
								try {				 					
									document.getElementById('list_'+stkCode).innerHTML = "<a href=\"javascript:removeWatch('" + stkCode + "','"+exchangeId+"')\" />Remove</a>";
								}catch(e){	}  
								    
					        
				           }
				            /*for (var j = 0; j <  response.length-1; j++) {
					                 
					                 var stk_exn = response[j].split("`");
					                 stkCode = stk_exn[0].toUpperCase();
					                 var exchangeId = stk_exn[1].toString() ;
					                 scripsList[j] = stkCode ;
					                 
					             try {				 					
						              document.getElementById('list_'+stkCode).innerHTML = "<a href=\"javascript:removeWatch('" + stkCode + "','"+exchangeId+"')\" />Remove</a>";
						         }catch(e){	}  
						         try{
					                 document.getElementById("stocklist_"+stkCode).innerHTML = "<a href=\"javascript:removeWatch('" + scripCode + "','"+exchangeId+"')\" class=\"red\"/>Add</a>";
				                 }catch(e){ }       
							 }  */
					        if (count < watchListSize) {
					    
				                watchInfo = "1-" + count + "&nbsp;of&nbsp;" +count+ "&nbsp;Stocks";
			                 }  else {
				                      if (count < (( SPpgno+1) * watchListSize)) {
					                      watchInfo = ((( SPpgno+1) - 1) * watchListSize + 1) + "-" + count+ "&nbsp;of&nbsp;" + count + "&nbsp;Stocks";
				                      } else {
				                    
					                          watchInfo = (( SPpgno+1) * watchListSize - (watchListSize - 1)) + "-" + (( SPpgno+1) * watchListSize) + "&nbsp;of&nbsp;" + count + "&nbsp;Stocks";
				                        }
			                    }
			                 
			                 try{    	         
					             document.getElementById("portfoliopgInfoDiv").innerHTML = "<div class='gotoPage' style=\"text-align:left;\">Go to Page:&nbsp;<input type='text'id=\"goPage\"  class='txt_box'  maxlength='5'  onkeypress='javascript:goto_page(event)' />&nbsp;of&nbsp;"+(stockSize) +"</div>" + "<div class=\"gotoPage\" style=\"text-align:center;\">"+watchInfo +"</div>" +
					                "<div class=\"previousNext\" style=\"-margin-top:0px !important; *margin-top:0px;\"><span id = \"watchprevDivTGT\"><a href=\"javascript:ms_prev_watch();\" alt=\"Previous\">< Previous</a></span> | <span id = \"watchnxtDivTGT\"><a href=\"javascript:ms_next_watch();\" alt=\"Next\">Next ></a></span></div>";
			    	             document.getElementById("goPage").value =SPpgno+1;
                                 if(SPpgno == 0)		       
		                            document.getElementById("watchprevDivTGT").innerHTML = "< Previous" ;		                      
		                      	  
		                         if ((SPpgno+1) == stockSize ||count < 11 )	
                                 {   
		                             document.getElementById("watchnxtDivTGT").innerHTML  = "Next >" ;
		                         }
		                         if( count  == 0 && watching == 0)	{		
		 	                         document.getElementById("portfolioContentDiv").innerHTML = "<div style=\"width:100%; text-align:center; padding-top:40px; padding-bottom:50px; line-height:24px;\">You are currently not viewing any stocks for delivery signals.<br /> Please add the stocks either by  clicking on add from above.</div>";
		                         } 
		                     }catch(e){ watchListLoadFlag = true}  
			    	   getAdvancedPortfolioList(data);	
			      }else {
			             try{
			                 document.getElementById("portfolioContentDiv").innerHTML = "<div style=\"width:100%; text-align:center; padding-top:40px; padding-bottom:50px; line-height:24px;\">You are currently not viewing any stocks for delivery signals.<br /> Please add the stocks either by  clicking on add from above.</div>"; 	   		      	   
			                 //document.getElementById("portfoliopgInfoDiv").innerHTML = '' ;
			                 watchListLoadFlag = true
			                }catch(e){}
			       }
			       }else{  
			             try{
			                 document.getElementById("portfolioContentDiv").innerHTML = "<div style=\"width:100%; text-align:center; padding-top:40px; padding-bottom:50px; line-height:24px;\">You are currently not viewing any stocks for delivery signals.<br /> Please add the stocks either by  clicking on add from above.</div>"; 	   		      	   
			                 //document.getElementById("portfoliopgInfoDiv").innerHTML = '' ;
			                 watchListLoadFlag = true
			                }catch(e){}
			       }          
			 });
		 }
  }
var Accordion1;
var getPortData;
var totalUserList;
var totalrecno = "";
var paginateFlag = false;
var updateLivePrice = false ;
var loadingimg="<div class=\"loaderIMG\"><img height=\"24\" width=\"24\" src=\"images/ajax-loader.gif\"/></div>";

function getAdvancedPortfolioList(data) {
    
      
         try{
             document.getElementById("portfolioContentDiv").innerHTML  = loadingimg;	
	         if (!updateLivePrice ) {
	               
		         var codesExn = data.split("~~");	
		       
		         var codes_exn = codesExn[0].split("_");	
		   
		         totalrecno = codesExn[1];		
		         var panelcontent;
		         var contentFlag = false;	
		    
		         WatchListDWR.getPortalPortfolioContentListForMarket(codes_exn, "showAP",contentFlag, function (data1) {
		                  
			                  getPortData = data1;		
			                  	
			                  var isexst = document.getElementById("load");
			                  if (isexst == null || isexst == "undefined" || isexst == "null" || isexst == "") {
			                  } else {
				                      document.getElementById("load").innerHTML = "";
			                    }
			                  if (data1 != null && data1 != "") {
				                  var response = data1.split(";");
				                  var divname="advPORTPOli";
				                  var scroller = "<div class=\"topScrollDivpop\"></div>"+
							                    "<div id=\""+divname+"\" class=\"mainScrollDivPOPMa\">"
								                 + data1  +
				 			                    "</div>"+
						   	                    "<div class=\"botScrollDivpop\"></div>";		
               
				                  document.getElementById("portfolioContentDiv").innerHTML  = scroller ;
			                      
			                  }
			                  watchListLoadFlag = true	;
		        });
		
				
	     } 
  }catch(e){
   
   watchListLoadFlag = true}

} 



var chart = "Chart for this date could not be generated. Please try a more recent date.";
var feaAnalysis = "Analysis for this date could not be generated. Please try a more recent date.";
var feaSuggestion = "Suggestion for this date could not be generated. Please try a more recent date.";
var feaExceptional_alerts = "Alert for this date could not be generated. Please try a more recent date.";
var feaDays_action = "Day Action for this date could not be generated. Please try a more recent date.";
var featureScrip = '';
var featureExId = '';
var featureFlashId = '';
var uploadflag = false;
var isContainerReady = true;
var previousScrip = '';
var previousExid = '';
var previousRNo = '';
var featureFlag = false;
var feaTabFlag = false;
var featureScripCode='RIIL';
var featureExchangeId='';
var getCloseScrip = "";
var hidingWatchlistScrip = '';
var hidingWatchlistExchange = '';




function showWatchlistChart(scripCode,exid){
 
   try{
       pageName = "watchList";
       featureScripCode = scripCode;
       getAnalysisScrip = scripCode;  
       featureExchangeId = exid;
       previousScrip = scripCode;
       previousExid = exid; 
       
       var user  = getUserId();    
       var country = countryid ; 
       hidingWatchlistScrip = scripCode; 
       hidingWatchlistExchange = exid;

  
       WatchListDWR.getUsersLiveInvestDataList(country,user,scripCode,function(data)
       {	
             
                setCommonVar(exid);     
                document.getElementById("portfolioContentDiv").style.display = "none";
                document.getElementById(scripCode+'ch').href = "javascript:hideWatchlistChart('" + scripCode + "','"+exid+"')";
                document.getElementById(scripCode+'ch').className = "minus clearfix"; 
                document.getElementById(scripCode+'ch').style.width = "722px";
                document.getElementById("portfolio_calls_chat").innerHTML  = "<div class=\"grid_row clearfix\">"+document.getElementById(scripCode).innerHTML+"</div>"+ 
                  "<div class =\"transaction_div clearfix\" style=\"width:720px;\">"+data+"</div>"+ 
			      "<div style=\"width:98%;height:274px;padding-top:5px;background-color:#ffffff;\">"+
			      "<div id=\""+scripCode+"chart\" style=\"width:49%;float:left;\"></div><div id=\""+scripCode+"analyy\" style=\"width:35%;float:left; height:275px;\"></div><div class=\"close_chart\" style=\"width:900px;\"><a href=\"javascript:hideWatchlistChart('"+scripCode+"','"+exid+"')\" class=\"\">Close chart</a></div>";
   
                document.getElementById("portfolio_calls_chat").style.display="block";
                document.getElementById("portfoliopgInfoDiv").style.display="none";
               // document.getElementById("dailyPicksContent_chat").style.display="none";
                //document.getElementById("dailyPicksContent").style.display="block";
                feaTabFlag = false;
                featureFlag = false;
                openChart = false;
   
                showFeaturesContent("frtab1", scripCode);
       });
    }catch(e){}
	
}
function hideWatchlistChart(scripCode,exid){

         document.getElementById(scripCode+'ch').href = "javascript:showWatchlistChart('" + scripCode + "','"+exid+"')";
         document.getElementById(scripCode+'ch').className = "plus clearfix";      
	     document.getElementById("portfolio_calls_chat").style.display="none";
	     document.getElementById("portfolioContentDiv").style.display="block"; 
	     document.getElementById("portfoliopgInfoDiv").style.display="block";  
}

function setCommonVar(exid){
    featureExId = exid;
}





var tempInvestDate ;
var tempQty;
var tempAprice;
function invest_edit(investedDate,dbQty,dbAPrice){
        try{
			tempInvestDate  = investedDate;
			var guserid = getUserId();			
			var avgPr ;
			var quantity ;
			var investedDate ;
			WatchListDWR.getInvestedDateQtyAPrice(countryid,guserid,featureScripCode,investedDate,dbQty,dbAPrice, function(getData){
				if(getData == "" || getData == "null"){getData = 0+","+0.00+";"}
				var getResponse = getData.split(";");
				for(var count = 0; count < getResponse.length-1; count++){
					var result = getResponse[count].split(",");
					quantity = result[0];
					avgPr    = result[1];
					tempQty   = result[0];
					tempAprice = result[1];
					if(tempAprice == "0" || tempAprice == 0){
						tempAprice == "0.00";
					}
					if(quantity =="null")
						quantity = 0;
					if(avgPr == "null")
						avgPr = 0.00;

				 	
				 	var editFormat ="<div class=\"row_main clearfix\">" +
				 						"<div class=\"column\">" +
					 						"<div class=\"datarow1\">Quantity*</div><div class=\"datarow2\"><input id=\"qty\" name=\"qty\" value='"+quantity+"' size=\"5\" type=\"text\"></div>"+
					 					"</div>"+
					 					"<div class=\"column\">" +
					 						"<div class=\"datarow1\">Avg. Price</div><div class=\"datarow2\"><input id=\"aprice\" name=\"aprice\" value='"+avgPr+"' size=\"5\" type=\"text\"></div>"+
					 					"</div>"+
					 					"<div class=\"column\">" +
					 						"<div class=\"datarow1\">Purchased on</div>"+
					 						"<div class=\"datarow2\">"+
					 							"<input type=\"text\" name=\"_date\" id=\"_date\" maxlength=\"10\" value='"+investedDate+"' style=\"width:70px;\" />"+
												"<a href=\"javascript:{}\" onClick=\"new CalendarPopup().select(document.getElementById('_date'),'anchor','yyyy-MM-dd'); return false;\" name=\"anchor\" id=\"anchor\">"+
												"<img src=\"images/cal.gif\" width=\"14\" height=\"15\" /></a>"+
					 						"</div>"+
					 					"</div>"+
					 					"<div class=\"column\">" +
					 						"<div class=\"datarow1\">&nbsp;</div><div class=\"datarow2\">&nbsp;</div>"+
					 					"</div>"+
					 					"<div class=\"column\" style=\"width:140px;\">" +
					 						"<div class=\"datarow1\">&nbsp;</div>"+
					 						"<div class=\"datarow2\">"+
					 						"<a href = \"javascript:qa_save1('"+featureScripCode+"')\" class=\"btns\"><Strong style=\"font-size:12px\">save</Strong></a> "+
					 						"<a href = \"javascript:qa1_cancel()\" class=\"btns\"><Strong style=\"font-size:12px\">close</Strong></a></div>"+
					 					"</div>"+
				 					"</div>";
				 	
				 	/*var editFormat ="<div style=\"padding-left:7px;\" ><table width=\"100%\" valign= \"top\"><tr><td><table width=\"100%\" border=\"0\" cellspacing=\"2\" cellpadding=\"1\">"+
									"<tr><td><Strong style=\"font-size:12px\">Quantity<font color=\"#cc0000\">*</font></Strong></td><td><Strong style=\"font-size:12px\">Avg. Price<font color=\"#cc0000\">*</font></Strong></td><td><Strong style=\"font-size:12px\">Purchased on<font color=\"#cc0000\">*</font></Strong></td></tr>"+
									"<tr><td ><input id=\"qty\" name=\"qty\" value='"+quantity+"' size=\"5\" type=\"text\"></td><td><input id=\"aprice\" name=\"aprice\" value='"+avgPr+"' size=\"5\" type=\"text\"></td>"+
									"<td><input type=\"text\" name=\"_date\" id=\"_date\" maxlength=\"10\" value='"+investedDate+"'/>"+
									"<a href=\"javascript:{}\" onClick=\"new CalendarPopup().select(document.getElementById('_date'),'anchor','yyyy-MM-dd'); return false;\" name=\"anchor\" id=\"anchor\">"+
									"<img src=\"images/cal.gif\" width=\"14\" height=\"15\" /></a></td></tr>"+
									"<tr><td><a href = \"javascript:qa_save1('"+featureScripCode+"')\" class=\"btns\"><Strong style=\"font-size:12px\">save</Strong></a></td><td><a href = \"javascript:qa1_cancel()\" class=\"btns\"><Strong style=\"font-size:12px\">close</Strong></a></td></tr></table></td></tr></table></div>";
				 	*/
				 	//document.getElementById(scripName).innerHTML = editFormat;
				 	document.getElementById(featureScripCode+"editDrop").innerHTML = editFormat;
				 	//getportfolioWidget.updateHeight();
				 	//portfolioPortal._updateColumnsHeight();
				}
			});
		}catch(e){}
 } 
 
 function invest_delete(stockCode,exchangedIDs){
        try{   

				updateLivePrice = false ;paginateFlag = false;	
				hideWatchlistChart(stockCode,featureExchangeId);	           
				document.getElementById("portfolioContentDiv").innerHTML  = loadingimg;
				removeWatch(stockCode,exchangedIDs);
 			
		}catch(e){}
}
		
 function qa_save1(syockSymbol){
		try{
			var getQty = document.getElementById("qty").value;
			var getAprice = document.getElementById("aprice").value;
			var getSelDate = document.getElementById("_date").value;			
		    guserId = getUserId() ;
			var exid = "";				   
			var numbers  = ".0123456789";
			var numbersqty = "0123456789";
			var strfname_ok    =   "yes";
			var strfname_ok1    =   "yes";
			for (var i=0; i<getQty.length; i++) {
		         temp =getQty.substring(i, i+1);
		         if (numbersqty.indexOf(temp) == "-1") strfname_ok1 = "no";
		    }
		    for (var i=0; i<getAprice.length; i++) {
		         temp =getAprice.substring(i, i+1);
		         if (numbers.indexOf(temp) == "-1") strfname_ok = "no";
		    }
		    if (strfname_ok == "no"){
		        alert("Please enter valid buy price");
		   	    return;
		    }else if (strfname_ok1 == "no"){
		          	  alert("Please enter valid qty");
		          	  return;
		     }else{
		            try{
		               
		             	WatchListDWR.updatePortfolioInfo(countryid,guserId, syockSymbol, getAprice, getQty,getSelDate,tempInvestDate,tempQty,tempAprice, function(data){
						             updateLivePrice = false ;paginateFlag = false;
					
						             hideWatchlistChart(syockSymbol,featureExchangeId);						 
				                     document.getElementById("portfolioContentDiv").innerHTML  = loadingimg;
					                 getMyaccountPortfolioData();
				        });
				     }catch(e){}
			  }
		}catch(e){}	
 }		
		
 function qa1_cancel(){
         try{			
			document.getElementById(featureScripCode+"editDrop").innerHTML = "";
		 }catch(e){}
		}








function showFeaturesContent(tab, scrip){
	displayPBottomLinks = true;
	displaySBottomLinks = true;
	if(featureExchangeId == globalExId1){
		SupportDWR.getSmsScrip(featureScripCode, function(data){
	
			var getShortScrip = data.split("~~");
		//	document.getElementById("displayScripName").innerHTML = "<font color=\"#4FAD26\">Chart and Analysis for</font> <Strong>"+getShortScrip[0]+"</Strong>";
		});
	}else{
		//document.getElementById("displayScripName").innerHTML = "<font color=\"#4FAD26\">Chart and Analysis for</font> <Strong>"+featureScripCode+"</Strong>";
    }  
        if (feaTabFlag == false) {
       
	            var flashCon = getChartTabs(featureScripCode, featureExchangeId, scrip + 'f');
	          
	            try{
	           
	            document.getElementById(scrip+"chart").innerHTML = flashCon;
	       
	            }catch(e){}
	            feaTabFlag = true;
	            featureFlag = false;
	            var today = '';
	            widgetAnalysisCall(today)
        }
        //document.getElementById(scrip+'c').style.display = "block";
     //   document.getElementById(scrip + "ana").style.display = "block";
}

var getAnalysisScripCode = '';
function widgetAnalysisCall(selectedDate){    
    if (selectedDate == "" || selectedDate == null) {
        selectedDate = null;
    } else {
    
    	feaTabFlag = false;
        var sdate1 = new String(selectedDate);
        var sdate = sdate1.split("/");
        var smnth = sdate[1];
        var sday = sdate[2];
        var syear = sdate[0];
        selectedDate = syear + "-" + smnth + "-" + sday;
        feaTabFlag = false;       
    }    
    var ana_requestxml = "";
    if(pageName == "StockScreener")
     	featureFlag = false;
     	
    if (featureFlag) {
            getAnalysisScripCode = featureScrip;
			if(featureScripCode == "" || featureScripCode==null){
            	featureScripCode == "RIIL";
            	featureExId = 29
            }
            SupportDWR.getExnid(featureScripCode, countryid, function(data1){
                var exchnid = data1.split("~~");
                featureExId = exchnid[0];
				  if(featureScripCode.indexOf("&") > -1){
					  featureScripCode = featureScripCode.replace("&", "%26");
				  }
                ana_requestxml = "<request><type>FetchCartData</type>" + "<sessionID>010811233</sessionID>" + "<params><param name=\"ecode\">" + featureExId + "</param>" + "<param name=\"stkname\">" + featureScripCode + "</param>" + "<param name=\"stdate\">mainchart</param>" + "<param name=\"endate\">" + selectedDate + "</param>" + "<param name=\"charttype\">CandleStick</param>" + "<param name=\"indparams\">2~3~10;24~3;30;32;33</param></params></request>";
                var analysisurl = "showAnalysisServlet?requestxml=" + ana_requestxml;
                loadAnalysisDataFR(analysisurl, 0);
            });
            featureFlag = true;
     }else if(pageName == "watchList") {
        	getAnalysisScripCode = featureScrip;
        	if(featureScripCode == "" || featureScripCode==null){
            	featureScripCode == "RIIL";
            	featureExId = 29
            }
       
            document.getElementById(previousScrip+"analyy").innerHTML =  loadingimg;
            SupportDWR.getExnid(featureScripCode, countryid, function(data1){
                var exchnid = data1.split("~~");
                featureExId = exchnid[0];
          
				 if(featureScripCode.indexOf("&") > -1){
						featureScripCode = featureScripCode.replace("&", "%26");
					}
                ana_requestxml = "<request><type>FetchCartData</type>" + "<sessionID>010811233</sessionID>" + "<params><param name=\"ecode\">" + featureExId + "</param>" + "<param name=\"stkname\">" + featureScripCode + "</param>" + "<param name=\"stdate\">mainchart</param>" + "<param name=\"endate\">" + selectedDate + "</param>" + "<param name=\"charttype\">CandleStick</param>" + "<param name=\"indparams\">2~3~10;24~3;30;32;33</param></params></request>";
                var analysisurl = "showAnalysisServlet?requestxml=" + ana_requestxml;
               // document.getElementById(prevScripSS+'ana').innerHTML ="<div class=\"loaderIMG\" style=\"text-align:center;\"><img height=\"24\" width=\"24\" src=\"images/ajax-loader.gif\"></div>";
          
                loadAnalysisDataFR(analysisurl, 0);
                if(featureScripCode.indexOf("%26") > -1){
						featureScripCode = featureScripCode.replace("%26", "&");
				}
            });
            featureFlag = false;
           } 
     else if(pageName == "targetPrice") {
        	getAnalysisScripCode = featureScrip;
        	if(featureScripCode == "" || featureScripCode==null){
            	featureScripCode == "RIIL";
            	featureExId = 29
            }
     
            document.getElementById(previousScrip+"analyy").innerHTML =  loadingimg;
            SupportDWR.getExnid(featureScripCode, countryid, function(data1){
           
                var exchnid = data1.split("~~");
                featureExId = exchnid[0];
            
				 if(featureScripCode.indexOf("&") > -1){
						featureScripCode = featureScripCode.replace("&", "%26");
					}
                ana_requestxml = "<request><type>FetchCartData</type>" + "<sessionID>010811233</sessionID>" + "<params><param name=\"ecode\">" + featureExId + "</param>" + "<param name=\"stkname\">" + featureScripCode + "</param>" + "<param name=\"stdate\">mainchart</param>" + "<param name=\"endate\">" + selectedDate + "</param>" + "<param name=\"charttype\">CandleStick</param>" + "<param name=\"indparams\">2~3~10;24~3;30;32;33</param></params></request>";
                var analysisurl = "showAnalysisServlet?requestxml=" + ana_requestxml;
              
               // document.getElementById(prevScripSS+'ana').innerHTML ="<div class=\"loaderIMG\" style=\"text-align:center;\"><img height=\"24\" width=\"24\" src=\"images/ajax-loader.gif\"></div>";
                loadAnalysisDataFR(analysisurl, 0);
                if(featureScripCode.indexOf("%26") > -1){
						featureScripCode = featureScripCode.replace("%26", "&");
				}
            });
            featureFlag = false;
            //feaTabFlag = false;
        }else if(pageName == "StockScreener") {
        	getAnalysisScripCode = featureScrip;
        	if(featureScripCodeSS == "" || featureScripCodeSS==null){
            	featureScripCodeSS == "RIIL";
            	featureExId = 29
            }
      
            SupportDWR.getExnid(featureScripCodeSS, countryid, function(data1){
                var exchnid = data1.split("~~");
                featureExId = exchnid[0];
            
				 if(featureScripCodeSS.indexOf("&") > -1){
						featureScripCodeSS = featureScripCodeSS.replace("&", "%26");
					}
					
                ana_requestxml = "<request><type>FetchCartData</type>" + "<sessionID>010811233</sessionID>" + "<params><param name=\"ecode\">" + featureExId + "</param>" + "<param name=\"stkname\">" + featureScripCodeSS + "</param>" + "<param name=\"stdate\">mainchart</param>" + "<param name=\"endate\">" + selectedDate + "</param>" + "<param name=\"charttype\">CandleStick</param>" + "<param name=\"indparams\">2~3~10;24~3;30;32;33</param></params></request>";
                var analysisurl = "showAnalysisServlet?requestxml=" + ana_requestxml;
                document.getElementById(prevScripSS+'ana').innerHTML ="<div class=\"loaderIMG\" style=\"text-align:center;\"><img height=\"24\" width=\"24\" src=\"images/ajax-loader.gif\"></div>";
                loadAnalysisDataStockScreen(analysisurl, 0);
                if(featureScripCodeSS.indexOf("%26") > -1){
						featureScripCodeSS = featureScripCodeSS.replace("%26", "&");
				}
            });
            featureFlag = true;
            //feaTabFlag = false;
        }
}

var totalvalue = null;
function analysisParserFR(analysisRAW){


    //var analysistitle = "Analysis for  "+scripCode;
	var resp = new String(analysisRAW);	
	if (resp == "" || resp == null || resp == "null") {	

	} else {
		var totalana = resp.split("~");
		analysis = totalana[0];
	}
	document.getElementById(previousScrip+"analyy").innerHTML = analysis;
}





        