﻿// JScript File

/* To Update the Text in the Perform action button while choosing the action from the ComboBox */
function UpdatePerfromActionText(ComboObject,ButtonObject)
{
    var objCbo = document.getElementById(ComboObject);
    var objBtn = document.getElementById(ButtonObject);
    
    if(objCbo!=null && objBtn!=null)
        objBtn.value = objCbo.options[objCbo.selectedIndex].text.substring(objCbo.options[objCbo.selectedIndex].text.indexOf('|')+1,objCbo.options[objCbo.selectedIndex].text.length);   
}

/* To Show the Bill document for the Ported Number Grids */
function ShowBillDocWindow(LnpID)
{
    window.modal('ManageQuoteLnpDoc.aspx?LnpID='+LnpID,'width=300,height=115,toolbars=0,statusbar=no,resizable=0');
}

/* To Zoom the Worklfow image */
function ZoomImage()
{
alert("ABC");
    if(document.forms[0].hfImageHeight.value==0)
    {
        document.forms[0].hfImageHeight.value = document.forms[0].ctl00_ContentPlaceHolder_imgProcessDiagram.height;
        document.forms[0].hfImageWidth.value = document.forms[0].ctl00_ContentPlaceHolder_imgProcessDiagram.width;
    }
    document.forms[0].ctl00_ContentPlaceHolder_imgProcessDiagram.width = (document.forms[0].hfImageWidth.value * document.forms[0].cboZsize.value)/100.00;
    document.forms[0].ctl00_ContentPlaceHolder_imgProcessDiagram.height = (document.forms[0].hfImageHeight.value * document.forms[0].cboZsize.value)/100.00;
}

/* To Show the Contract for the products */
function ShowContractWindow(QuoteDetailID)
{
    ContractWindowShowed = true;
    var rwWFlog = window.radopen('ProductContract.aspx?QuoteDetailId='+QuoteDetailID,"radwinContract");
    rwWFlog.SetSize(600,310);
}

// To Display the Calender.
function ShowCalender(ElementName)
{
    //window.open('Common/Calender.aspx?ElementName=ctl00_ContentPlaceHolder_txtDateofbirth','','height=220,width=226,resizable=no,scrollbars=no,screenX=250,screenY=250,menubar=no');    
    window.open('Common/Calender.aspx?ElementName=' + ElementName,'','height=220,width=226,resizable=no,scrollbars=no,menubar=no');
}

function FindItemPrice(objQuantity, objUnitPrice, objDiscount, objItemPrice)
{
    var Quantity = parseFloat(document.getElementById(objQuantity).value);
    var UnitPrice = parseFloat(document.getElementById(objUnitPrice).value);
    var Discount = parseFloat(document.getElementById(objDiscount).value);
    
    if(! (Quantity>0))
        Quantity=0.0;
        
    if(! (UnitPrice>0))
        UnitPrice=0.0;
        
    if(! (Discount>0))
        Discount=0.0;	
        
    var TempValue = parseFloat(Quantity * UnitPrice);
    TempValue = TempValue - TempValue*(Discount/100);
    
    
    
    document.getElementById(objItemPrice).value = TempValue;
    TempValue = document.getElementById(objItemPrice).value;
    if(TempValue.indexOf('.')<0)
        TempValue = TempValue + '.00';
    
    document.getElementById(objItemPrice).value = TempValue;
            
    //document.getElementById(objItemPrice).value = (parserFloat((Quantity*UnitPrice))-parseFloat((Quantity*UnitPrice*(Discount/100))));
}

/* Shrink Panel Functions */
function WriteShrinkPanelTitleNew(containerName,Title,PanelWidth)
{
    /*
    <div class="ShrinkPanelTitle">
        <table width="100%">
            <tr>
                <td align="left">
                    &nbsp;
                    Prospect &amp; Quotes:</td>
                <td align="right">
                    <a href="javascript:ShowHideObject('divQuoteList','200px')" title="Show/Hide"><img src="Images/ShrinkButton.gif" alt="Shrink" style="border-style:none;" /></a>&nbsp;</td>
            </tr>
        </table>
    </div>
    */
    
    document.write('<div class="ShrinkPanelTitle" style="width:' + PanelWidth + ';">');
    document.write('<table width="100%">');
    document.write('<tr>');
    document.write('<td align="left">&nbsp;' + Title + '</td>');
    document.write('<td align="right">');
    document.write('<a href="javascript:ShowHideObject(\'' + containerName + '\')" title="Show/Hide"><img src="Images/ShrinkButton.gif" alt="Shrink/Expand" style="border-style:none;" /></a>&nbsp;</td>');
    document.write('</tr>        </table>    </div>');
}

function WriteShrinkPanelTitle(containerName,Title)
{
    /*
    <div class="ShrinkPanelTitle"><table width="100%"><tr><td align="left">&nbsp;Prospect &amp; Quotes:</td>
                <td align="right">
                    <a href="javascript:ShowHideObject('divQuoteList','200px')" title="Show/Hide"><img src="Images/ShrinkButton.gif" alt="Shrink" style="border-style:none;" /></a>&nbsp;</td>
            </tr></table></div>
    */
    
    document.write('<div class="ShrinkPanelTitle">');
    document.write('<table width="100%">');
    document.write('<tr>');
    document.write('<td align="left">&nbsp;' + Title + '</td>');
    document.write('<td align="right">');
    document.write('<a href="javascript:ShowHideObject(\'' + containerName + '\')" title="Show/Hide"><img src="Images/ShrinkButton.gif" alt="Shrink/Expand" style="border-style:none;" /></a>&nbsp;</td>');
    document.write('</tr>        </table>    </div>');
}

function ShowHideObject(objContainer)
{
    var obj = document.getElementById(objContainer);
       
    if ( obj.style.display != "none" ) 
    {
        obj.style.display = 'none';
    }
    else 
    {
        obj.style.display = '';
    }
}

function ShowHideObjectOld(objContainer,objHeight)
{
    var obj = document.getElementById(objContainer);
    
    if ( obj.style.display != "none" ) 
    {
        obj.style.display = 'none';
    }
    else 
    {
        obj.style.display = '';
    }
}

function ShowHidePanel(panelName)
{
    var objPanel = document.getElementById(panelName);    
    if(objPanel!=null)
    {
        if(objPanel.className=='VisiblePanel')
            objPanel.className='HiddenPanel';
        else
            objPanel.className='VisiblePanel';
    }
    
}

function ShowLeftMenu(ContainerID,Sender)
{
    var objPanel = document.getElementById(ContainerID);
    var objSender = document.getElementById(Sender);
    objPanel.className='VisibleMenuPanel';
    objSender.className='HiddenPanel';
}

function HideLeftMenu(ContainerID,Sender)
{
    var objPanel = document.getElementById(ContainerID);
    var objSender = document.getElementById(Sender);
    objPanel.className='HiddenMenuPanel';
    objSender.className = 'HiddenMode'
}


function ToggleMenu(ContainerID,Sender)
{
    alert('ToggleMenu');
    var objPanel = document.getElementById(ContainerID);
    var objSender = document.getElementById(Sender);
    
    if(objPanel!=null)
    {
        if(objPanel.className=='VisiblePanel')
        {
            objPanel.className='HiddenPanel';
            objSender.className = 'HiddenMode'
        }
        else
        {
            objPanel.className='VisiblePanel';
            objSender.className='ShowMode';
        }
    }
}

function ShowNewQuote()
{
    var objPanel = document.getElementById('ctl00_ContentPlaceHolder_panelNewQuote');
    if(objPanel!=null)
        objPanel.className='VisiblePanel';
    
    objPanel = document.getElementById('ctl00_ContentPlaceHolder_btnNewQuote');
    if(objPanel!=null)
        objPanel.className='HiddenPanel';
    
}

function HideNewQuote()
{
    var objPanel = document.getElementById('ctl00_ContentPlaceHolder_panelNewQuote');
        if(objPanel!=null)
            objPanel.className='HiddenPanel';
            
    objPanel = document.getElementById('ctl00_ContentPlaceHolder_btnNewQuote');
    if(objPanel!=null)
        objPanel.className='VisiblePanel';
}

// To Set ExpireDate Automatically
function SetExpireDate(SourceName,ElementName)
{           
    var newDate = new Date(orderDate.getFullYear(), orderDate.getMonth(), parseInt(orderDate.getDay()) + parseInt(29)); 
}


