//================== Browser Identifier variables ==================
var isIE = (navigator.userAgent.indexOf("MSIE") > 1); 
var isMoz = (navigator.userAgent.indexOf("Mozilla/5.") == 0);
//======================================================
//function to confirm delete operation
//evt:event
function confirmDelete(evt)
{
    return window.confirm("Are you sure you want to delete this record?");
}

function mprint()
{
self.print()
}

 function ShowL(element)
 {  
  //   var id=code;
  if(element!=1 && element != null)
  {
    window.open("http://203.77.193.214/f.asp?s="+element);
    }
 }

//function ExportHTML()
//{   
//    popup = window.open('Display.html','Display', 'height=798px, width=2012px, left=0, top=0, menubar=1, scrollbars=1,resizable=1,toolbar=1,location=1,status=1');
//	var t=setTimeout("UpdateHtml()",5000);
//    // you may want to open to the image by passing the image in the URL   
//}

//function ExportHTML1()
//{   
//    popup = window.open('Display.html','Display', 'height=798px, width=2012px, left=0, top=0, menubar=1, scrollbars=1,resizable=1,toolbar=1,location=1,status=1');
//	var t=setTimeout("UpdateHtml1()",500);
//    // you may want to open to the image by passing the image in the URL   
//}

//function UpdateHtml()
//{
//        if (popup.document.readyState=='complete') {
//        popup.document.getElementById("DivHd").innerHTML = document.getElementById("DivHd").innerHTML;
//        popup.document.getElementById("divgrid").innerHTML = document.getElementById("DivGrid").innerHTML;
//        popup.document.getElementById("divsummary").innerHTML = document.getElementById("DivSummary").innerHTML;
//        popup.document.getElementById("divchart").innerHTML = document.getElementById("DivChart").innerHTML;
//        popup.document.getElementById("DivNote").innerHTML = document.getElementById("DivNote").innerHTML;
//        popup.document.getElementById("divimage").style.display = 'none';
//        }
//        else
//        {
//        var t=setTimeout("UpdateHtml()",1000);
//        }

//}


function RefreshandClose()
{
window.close(); 
opener.location.reload(true);
return;
}


function ParentRfsh()
{
    opener.location.reload(true);
    return;    
}


//open security and roles dialog
function openSendPassword()
{
        window.showModalDialog("SendPassword.aspx",'',
        "center:1;status:0;dialogWidth:400px;dialogHeight:270px;");
}

function showCreateLogin(ClientCode,ClientName)
{
		var d_width = (document.body.offsetWidth-450)/2;
		var d_height = (document.body.offsetHeight-220)/2;
		window.open("CreateLogin.aspx?ClientCode="+ClientCode+"&ClientName="+ClientName,'',
       "resizable=0,status=0,resizable=0,width=450,height=320,left="+d_width+",top="+d_height);
}

function showCreateEmployeeLogin(RMCode,RMName)
{
		var d_width = (document.body.offsetWidth-450)/2;
		var d_height = (document.body.offsetHeight-220)/2;
		window.open("CreateEmployeeLogin.aspx?RMCODE="+RMCode+"&RMName="+RMName,'',
       "resizable=0,status=0,resizable=0,width=450,height=320,left="+d_width+",top="+d_height);
}


function DownloadDocument(ClientName,FileName)
{
		var d_width = (document.body.offsetWidth-200)/2;
		var d_height = (document.body.offsetHeight-200)/2;
		window.open("DownloadDocument.aspx?ClientName="+ClientName+"&FileName="+FileName,'',
       "resizable=0,status=0,resizable=0,width=300,height=180,left="+d_width+",top="+d_height);
}

function showDetail(ID)
{
//    if(IsNumeric(ID)
//    {
		var d_width = (document.body.offsetWidth-50)/2;
		var d_height = (document.body.offsetHeight-20)/2;
		window.open("ViewEmpanelment.aspx?ID="+ID,'',
       "resizable=0,status=0,resizable=0,width=750,height=460,left=120,top=120");
 //  }
}
//function to change url of the window upon combo select
//elem : combobox
//useText : true if text is to be passed in url (if its 'false' value will be passed)
//url : Url to navigate 
function filter(elem, useText, url)
{
    if(elem.value != null && elem.value != "") 
       if(useText)window.location.href = url + elem.options[elem.selectedIndex].text;       
       else window.location.href = url + elem.value;
}

//function to make sure only numeric values are allowed in textbox
//evt : event
//use : OnKeyPress(event)
function ensureNumeric(evt)
{
  if (isIE)
	var key =  evt.keyCode;
  else if(isMoz)
	var key =  evt.charCode;

  if (key!=0 && (key <48 || key >57))
  {
    evt.returnValue = false; 
    return false;
  }
}

//function to check/uncheck all checkboxes as per the master
//elem : master checkbox
//use : onclick="changeAll(this);"
//NOTE: This function assumes that all the checkboxes have same 'name'(name="chkSel")
// and each one has an attribute 'keyval'(keyval="<ID>"). 
// - When the form is submitted you need to call a function 'reg_chkSel'. This function will 
// form a ';' separated string of 'keyval' attribute of the 'checked' checkboxs(name="chkSel")
function changeAll(elem)
{
  var check = elem.checked;
  var nm = document.forms[0].chkSel.length;
	for(var i=0; i<document.forms[0].chkSel.length; i++)
		document.forms[0].chkSel[i].checked = check;
}
//function to set the value of hidden variable(__hdnchksel) as per checkbox settings
//use : onmouseup="reg_chkSel();" - for the submit button of the page
function reg_chkSel()
{
    var nm = document.forms[0].chkSel.length;
    var ctrlArr = document.forms[0].chkSel;
    var idStr = "";
	
	//i=1 as the master checkbox is to be eliminated
	for(var i=1; i<ctrlArr.length; i++)
		if(ctrlArr[i].checked)
		    idStr += ctrlArr[i].getAttribute("keyval") + ";";
	
	if(idStr.length > 0)
	{
	    //set value in hidden control
	    document.getElementById("__hdnchksel").value = idStr;	
	        
	}	
}
//function to check whether whether the string in textbox is numberic or not
// user:onblur event(When the control leaves focus)
function checkNumeric(ctrl)
{
    // If control is null,then return
    if(ctrl==null)return;
    // Get text in textbox
    sText = ctrl.value;
    // If not number,then clear the textbox
    if(!IsNumeric(sText))
        ctrl.value = "";
}
//function to check whether the string passed is numeric or not
//use : onblur=
function IsNumeric(sText)
{
    // valid chars for in any number
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;
   // Check if any non-numeric char exists in the Textbox
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      // If index of char is -1,means char is not in Validchars string(So it is not a number)
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;   
   }
// Function to print the page
function printpage() 
{
    window.print();  
}
//function to limit the no. of input characters into the Textbox
//use : onkeyup(Event)
function trimMaxLength(ctrl,maxLen)
{
    try{
    var txt = ctrl;
    var content = ctrl.value.toString();
    var chars = maxLen - content.length;
    }
    catch(e){}
    //trim textbox
    if(content.length > maxLen)
    ctrl.value = content.slice(0,maxLen);  
}
function openManageUserSecurity(Id,Name)
{
        window.showModalDialog("ChangePassword.aspx?UserId="+Id+"&UName="+Name,'',
        "center:1;resizable:1;status:0;dialogWidth:400px;dialogHeight:300px");
}

//Toggle show/hide for a section
//It assumes that the image will have the id = '<divID>Img'
var showImgPath = "images/aroL.gif";
var hideImgPath = "images/aroB.gif";

function showHideDiv(element)
{
var divElem = document.getElementById(element);
var img = document.getElementById(divElem.id+"Img");

//if(divElem.style.display == "")
//	divElem.style.display = "block";
var showFlag = (divElem.style.display == "" || divElem.style.display == "block");
divElem.style.display = showFlag?"none":"block";
img.src = showFlag?showImgPath:hideImgPath;
}

//function to close the window onkeypress
function keyPressHandler(e) 
{
   var kC  = (window.event) ?    // MSIE or Firefox?
              event.keyCode : e.keyCode; 
   var Esc = (window.event) ?    
             27 : e.DOM_VK_ESCAPE // MSIE : Firefox
   if(kC==Esc) 
      window.close();
}
//function to select list item that matches key
//key to be matched
//source ddl
function selectDDLItem(key, ddl)
{
	if(key==null || key=="" || ddl == null) return;
	
	key = key.toUpperCase();
	var pos = 0;
	while(pos < ddl.options.length)
	{
		if(ddl.options[pos].value==key)
		 {
			ddl.selectedIndex = pos;
			break;
		 }
		 pos++;//increment counter           
	}
}


function toggleAllSites()
{
    var ids = siteIDs.split("|");
    var count = ids.length;
    
    for(var i=0; i < ids.length; i++)
    {
        var elem = "childItemsDiv" + ids[i].toString();
        showHideAllDiv(elem);
    }
    return false;
}

function selectAll(obj,id)
{
 	if(obj.checked==true)
    {
    	var ref = document.getElementById(id);
    	for(i=0;i<ref.options.length; i++)
    	ref.options[i].selected = true;
    }
    else
    {
        var ref = document.getElementById(id);
    	for(i=0;i<ref.options.length; i++)
    	ref.options[i].selected = false;
    }
}

function showHideAllDiv(element)
{
    var divElem = document.getElementById(element);
    var img = document.getElementById(divElem.id+"Img");
    var chkElem = document.getElementById(chkAllSitesElem);
    if(chkElem.checked)
    {
        divElem.style.display = "block";
        img.src = hideImgPath;
    }
    else
    {
        divElem.style.display = "none";
        img.src = showImgPath;
    }        
}


// Open Dialog for Valuation Report Schemewise    
//function openValuationReportSchemeWise()
//{
//        window.open("ValuationReportSchemeWiseDisplay.aspx",'',
//        "center=1,status=0,Width=2012px,Height=798px,menubar=1,scrollbars=1,resizable=1");
//        return false;
//        
//}

// Open Dialog for Valuation Report Schemewise    
//function openValuationReportClientWise()
//{
//        window.open("ValuationReportClientWiseDisplay.aspx",'',
//        "center=1,status=0,Width=2012px,Height=798px,menubar=1,scrollbars=1,resizable=1");
//        return false;
//}

function showHideSearchDiv(element)
{
var divElem = document.getElementById(element);
var img = document.getElementById(divElem.id+"Img");
var parentGridDiv = document.getElementById("parentGridDiv");

//if(divElem.style.display == "")
//	divElem.style.display = "block";
var showFlag = (divElem.style.display == "" || divElem.style.display == "block");
divElem.style.display = showFlag?"none":"block";
img.src = showFlag?showImgPath:hideImgPath;
//if(showFlag)
//    parentGridDiv.style.height = 358;
//else
//    parentGridDiv.style.height = 241;
}


//Open Show Dividend Detail Dialog
function ShowDividendDetail(SchemeCode,InitialUnits,TranDate,InvestorName,TranType,FolioNo,DateTo,DividendAmount)
{
       window.showModalDialog("DividendDetail.aspx?SchemeCode="+SchemeCode+"&InitialUnits="+InitialUnits+"&TranDate="+TranDate+"&TranType="+TranType+"&InvestorName="+InvestorName+"&FolioNo="+FolioNo+"&DateTo="+DateTo,'',
        "center:1;resizable:1;status:0;dialogWidth:420px;dialogHeight:375px");
}    
 
function openInvestorSummary()
{
         window.open("InvestorSummaryDisplay.aspx",'',
        "center=1,status=0,Width=2012px,Height=798px,menubar=1,scrollbars=1,resizable=1");
        return false;
}  


var swapAttr = "hoverSwapCSS";
function swapCSS(elem)
{
	if (elem == null)return;
	
	var tmp = elem.className;
	elem.className = elem.getAttribute(swapAttr);
	elem.setAttribute(swapAttr,tmp);
}

// Open Gainloss Report
//function openGainLossReport()
//{
//        window.open("GainLossReportDisplay.aspx",'',
//        "center=1,status=0,Width=2012px,Height=798px,menubar=1,scrollbars=1,resizable=1");
//        return false;    
//}


// Open ClientWise Gainloss Report

//function openClientWiseGainLossReport()
//{
//        window.open("ClientWiseGainLossReportDisplay.aspx",'',
//        "center=1,status=0,Width=2012px,Height=798px,menubar=1,scrollbars=1,resizable=1");
//        return false;    
//}


function DividendPayoutCheckBox(obj,id1,id2)
{
    if(obj.checked==true)
    {
        var ref = document.getElementById(id1);
    	for(i=0;i<ref.options.length; i++)
    	ref.options[i].selected = false;
    	
    	var ref1 = document.getElementById(id2);
    	ref1.checked = false;
    }
}

function DividendPayoutSelectAllCheckBox(obj,id1,id2,id3)
{
    if(obj.checked==true)
    {
        var ref = document.getElementById(id1);
    	for(i=0;i<ref.options.length; i++)
    	ref.options[i].selected = true;
    	
    	var ref1 = document.getElementById(id2);
    	ref1.checked = false;
    }
    else
    {
        var ref = document.getElementById(id1);
    	for(i=0;i<ref.options.length; i++)
    	ref.options[i].selected = false;
    }
}

function TransactionListBox(obj,id1,id2,id3)
{
    var ref = document.getElementById(id1);
    for(i=0;i<ref.options.length; i++)
    if(ref.options.selected = true)
    {
        var ref1 = document.getElementById(id2);
        ref1.checked = false;
        
        var ref2 = document.getElementById(id3);
        ref2.checked = false;
    }
}

//function openAssetSummary()
//{
//         window.open("AssetallocationDisplay.aspx",'',
//        "center=1,status=0,Width=2012px,Height=798px,menubar=1,scrollbars=1,resizable=1");
//        return false;
//}  

//function openTranReport()
//{
//         window.open("TransactioReportDisplay.aspx",'',
//        "center=1,status=0,Width=2012px,Height=798px,menubar=1,scrollbars=1,resizable=1");
//        return false;
//} 

//function openSchemeSummary()
//{
//         window.open("SchemeWiseSummaryDisplay.aspx",'',
//        "center=1,status=0,Width=2012px,Height=798px,menubar=1,scrollbars=1,resizable=1");
//        return false;
//} 

//function openAumSummary()
//{
// window.open("AumReportDisplay.aspx",'',
//        "center=1,status=0,Width=2012px,Height=798px,menubar=1,scrollbars=1,resizable=1");
//        return false;
//}

//function openCollectionSummary()
//{
// window.open("CollectionSummaryReportDisplay.aspx",'',
//        "center=1,status=0,Width=2012px,Height=798px,menubar=1,scrollbars=1,resizable=1");
//        return false;
//}

// Open Dialog for Dividend Income Statement
//function openDividendIncomeStatementReport()
//{
//        window.open("DividendIncomeStatementDisplay.aspx",'',
//        "center=1,status=0,Width=2012px,Height=798px,menubar=1,scrollbars=1,resizable=1");
//        return false;
//        
//}

//Open Show Dividend Detail Dialog
function ShowDivReinvestDetail(SchemeCode,FolioNo,DividendAmount)
{
       window.showModalDialog("DivReinvestHistory.aspx?SchemeCode="+SchemeCode+"&FolioNo="+FolioNo,'',
        "center:1;resizable:1;status:0;dialogWidth:440px;dialogHeight:400px");
}    

function ShowDivPayoutDetail(SchemeCode,FolioNo,DividendAmount)
{
       window.showModalDialog("DivPayoutHistory.aspx?SchemeCode="+SchemeCode+"&FolioNo="+FolioNo,'',
        "center:1;resizable:1;status:0;dialogWidth:440px;dialogHeight:400px");
}  

function showMutualfund()
{
		var d_width = (document.body.offsetWidth-200)/2;
		var d_height = (document.body.offsetHeight-180)/2;
		window.open("camsFundz.htm",'',
       "resizable=0,status=0,resizable=0,width=250,height=380,left="+d_width+",top="+d_height);
}

//Open SIP Renewal Report

//function openSIPRenewalReport()
//{
//        window.open("SIPReminderDisplay.aspx",'',
//        "center=1,status=0,Width=2012px,Height=798px,menubar=1,scrollbars=1,resizable=1");
//        return false;
//}

//Open SIP Transaction Report
//function openSIPTransactionReport()
//{
//        window.open("SIPTransactionReportDisplay.aspx",'',
//        "center=1,status=0,Width=2012px,Height=798px,menubar=1,scrollbars=1,resizable=1");
//        return false;
//}

//function openManualEntryReport()
//{
//        window.open("ManualEntryReportDisplay.aspx",'',
//        "center=1,status=0,Width=2012px,Height=798px,menubar=1,scrollbars=1,resizable=1");
//        return false;
//}


//function openAccountInsight()
//{
//        window.open("AccountInsightReportDisplay.aspx",'',
//        "center=1,status=0,Width=2012px,Height=798px,menubar=1,scrollbars=1,resizable=1");
//        return false;
//}

//function openSIPAccountReport()
//{
//        window.open("SIPAccountReportDisplay.aspx",'',
//        "center=1,status=0,Width=2012px,Height=798px,menubar=1,scrollbars=1,resizable=1");
//        return false;
//}



//function openFMPMaturityReminderReport()
//{
//        window.open("FMPMaturityReminderDisplay.aspx",'',
//        "center=1,status=0,Width=2012px,Height=798px,menubar=1,scrollbars=1,resizable=1");
//        return false;
//}




// Open Dialog for Valuation Report Schemewise    
function openValuationReportSchemeWise()
{
        window.open("ValuationReportSchemeWiseDisplay.aspx",'',
        "center=1,status=0,Width=2012px,Height=798px,menubar=1,scrollbars=1,resizable=1");
        return false;
        
}

// Open Dialog for Valuation Report Schemewise    
function openValuationReportClientWise()
{
        window.open("ValuationReportClientWiseDisplay.aspx",'',
        "center=1,status=0,Width=2012px,Height=798px,menubar=1,scrollbars=1,resizable=1");
        return false;

}

function openInvestorSummary()
{
         window.open("OldInvestorSummaryDisplay.aspx",'',
        "center=1,status=0,Width=2012px,Height=798px,menubar=1,scrollbars=1,resizable=1");
        return false;
}  

function openSchemeSummary()
{
         window.open("OldSchemeWiseSummaryDisplay.aspx",'',
        "center=1,status=0,Width=2012px,Height=798px,menubar=1,scrollbars=1,resizable=1");
        return false;
} 

// Open Dialog for Multiple Portfolio Print
function openMultiplePortfolioPrintReport()
{
        window.open("MultiplePortfolioPrintDisplay.aspx",'',
        "center=1,status=0,Width=2012px,Height=798px,menubar=1,scrollbars=1,resizable=1");
        return false;
}

function ExportHTML()
{
if(isIE)
{
popup = window.open('Display.html','', 'height=798px, width=2012px, left=0, top=0, menubar=1, scrollbars=1,resizable=1,toolbar=1,location=1,status=1');
}
else
{
popup = window.open('Display1.html','', 'height=798px, width=2012px, left=0, top=0, menubar=1, scrollbars=1,resizable=1,toolbar=1,location=1,status=1');
}
}



function Hide_Div(ddlid,divid,txtid)
{

   var ddl_id = GetClientId(ddlid);

   var Selection = document.getElementById(ddl_id).options[document.getElementById(ddl_id).selectedIndex].value;
        
   if(Selection == "between")        
      {
           document.getElementById(GetClientId(divid)).style.display = 'block';
           document.getElementById(txtid).value = "";
      }
   else
      {
           document.getElementById(GetClientId(divid)).style.display = 'none';
           document.getElementById(txtid).value = "0";
      }
        
}    


function GetClientId(strid)
{
     var count = document.getElementsByTagName ('*').length; //<-- gets all elements, instead of Forms as this only returns FORM elements
     var i=0;
     var eleName;

     for (i=0; i < count; i++ )
     {
       eleName=document.getElementsByTagName ('*')[i].id;

       pos=eleName.indexOf(strid);
       
       if(pos>=0) break;        
     }
    return eleName;
} 

//Open DealSlip Detail Dialog
function ShowDealSlipDetail(BillId,Payee)
{
       window.open("ViewDealSlip.aspx?BillId="+BillId,'',
        "center=1,status=0,Width=2012px,Height=798px,menubar=1,scrollbars=1,resizable=1,toolbars=0,top=0,left=0");        
}

//Export DealSlip Detail in Excel
function ExportDealSlip(BillId)
{
       window.open("ViewDealSlip.aspx?BillId="+BillId+"&Ex=Ex",'',
        "center=1,status=0,Width=2012px,Height=798px,menubar=1,scrollbars=1,resizable=1,toolbars=0,top=0,left=0");        
}

function showEditEmployeeEmail(RMCode,RMName,RMEmail)
{
		var d_width = (document.body.offsetWidth-450)/2;
		var d_height = (document.body.offsetHeight-220)/2;
		window.open("EditEmployeeEmail.aspx?RMCODE="+RMCode+"&RMName="+RMName+"&RMEmail="+RMEmail,'',
       "resizable=0,status=0,resizable=0,width=450,height=320,left="+d_width+",top="+d_height);
}

function ShowTrailDealSlipDetail(RmId,Payee,Brokerid)
{

       window.open("ViewTrailDealSlip.aspx?RmId="+RmId+"&BrokerId="+Brokerid,'',
        "center=1,status=0,Width=2012px,Height=798px,menubar=1,scrollbars=1,resizable=1,toolbars=0,top=0,left=0");        
}

function ShowQueryLogDetail(qid,queryid,qtype,QueryDate)
{
       window.showModalDialog("ViewQueryStatusLog.aspx?qid="+qid+"&queryid="+queryid+"&qtype="+qtype+"&QueryDate="+QueryDate,'',
        "center:1;resizable:1;status:0;dialogWidth:700px;dialogHeight:450px");
}

function ShowEQueryLogDetail(qid,queryid,qtype,QueryDate)
{
       window.showModalDialog("ViewEQueryStatusLog.aspx?qid="+qid+"&queryid="+queryid+"&qtype="+qtype+"&QueryDate="+QueryDate,'',
        "center:1;resizable:1;status:0;dialogWidth:700px;dialogHeight:450px");
}


function ActiveTrue()
{
var tr=document.getElementById('trActive');
tr.style.display= "block";
}

//Open new Trail DealSlip Detail Dialog
function ShowTrDealSlipDetail(BillId,Payee)
{
       window.open("ViewTrDealSlip.aspx?BillId="+BillId,'',
        "center=1,status=0,Width=2012px,Height=798px,menubar=1,scrollbars=1,resizable=1,toolbars=0,top=0,left=0");        
}
//Export trail DealSlip Detail in Excel
function ExportTrDealSlip(BillId)
{
       window.open("ViewTrDealSlip.aspx?BillId="+BillId+"&Ex=Ex",'',
        "center=1,status=0,Width=2012px,Height=798px,menubar=1,scrollbars=1,resizable=1,toolbars=0,top=0,left=0");        
}
              
              
              
                            