﻿
      
/*******************************************************************************************************************
Copyright © 2006 - 2011 XCINO Inc. All rights reserved.
http://www.xcino.com
Technical support: http://helpdesk@xcino.com
Info: info@xcino.com

Permission to use this code or any part of this code herein is not granted. You are not allowed to use or copy the code of this file, except as expressly authorized by XCINO Inc.
YOU MAY NOT
(1) Remove or modify this copyright notice.
(2) Re-distribute this code or any part of it.

YOU MAY
(1) Use this code on your website.
(2) Use this code as part of another product.

NO WARRANTY
This code is provided "as is" without warranty of any kind.
You expressly acknowledge and agree that use of this code is at your own risk.
*******************************************************************************************************************/


// JScript File
/*
*****************************************************************************
    Company   :         XCINO Inc.  
    File Name :         ProcessEquivUnitScript.js   
    Purpose   :         This Class implements the javascript functionality related to Process Equivalent Unit                          
    -----------------------------------------------------------------------
    Created By  :       Kunal mittal             Created On:     17-Feb-2009     

    Approved By:        Prasoon Abhinaw          Approved On:    17-Feb-2009   

    -----------------------------------------------------------------------
    Change History
      
    Last Updated By:Rajveer Rathore              Last Updated On:01-July-2011
                        
    Note:

    *****************************************************************************
*/


function ShowEquivelantMsg_bak(obj)
{
    var imageURL = obj.getAttribute("src");    
    var imageURLObj = new String(imageURL);
    var startindex = imageURLObj.indexOf('?');
    yPos = event.clientY;
    xPos = event.clientX;
    var imageURLQueryString = imageURLObj.substring(startindex);
    var windowURL = 'ViewEquivelantMsg.aspx'+imageURLQueryString;
    //ajax_showTooltip(window.event,windowURL,obj);
    window.open(windowURL,'Equ','directories=0,height=100,location=0,menubar=0,top='+yPos+',left='+xPos+',resizable=0,scrollbars=0,status=0,titlebar=0,toolbar=0,width=150,channelmode=0');
    //customFunctionCreateWindow(windowURL,200,200,100,100);
}
function HideMsgDev()
{
if(document.getElementById("MsgDiv"))
        {document.body.removeChild(document.getElementById("MsgDiv"));}
}

function ShowEquivelantMsg(obj,isSavingMsg)
{
    var width=110;
    var height=90;
    var imageURL = obj.getAttribute("src");
    //window.alert(imageURL);
    var imageURLObj = new String(imageURL);
    var startindex = imageURLObj.indexOf('?');      
    var yPos = event.clientY;
    //window.alert("y:"+yPos);
    //yPos =yPos - 50;
    var xPos = event.clientX;
    //window.alert("X:"+xPos);
    //xPos = xPos +30;
    var imageURLQueryString = imageURLObj.substring(startindex+1);
    var queryStringArray = Array();
    queryStringArray = imageURLQueryString.split('&');   
    var indexofconvertFactor = queryStringArray[0].indexOf('=');
    var convertFactor = queryStringArray[0].substring(indexofconvertFactor+1);     
    var indexofperiod = queryStringArray[1].indexOf('=');
    var period = queryStringArray[1].substring(indexofperiod+1);  
    var indexoftotaluse = queryStringArray[2].indexOf('=');
    var  totaluse= queryStringArray[2].substring(indexoftotaluse+1);  
    var indexofequivname = queryStringArray[3].indexOf('=');
    var  equivname= queryStringArray[3].substring(indexofequivname+1);  
    var indexofequivuom = queryStringArray[4].indexOf('=');
    var  equivuom = queryStringArray[4].substring(indexofequivuom+1);  
    var indexofequivconsummsg = queryStringArray[5].indexOf('=');
    var  equivconsummsg= queryStringArray[5].substring(indexofequivconsummsg+1);   
    var indexofequivsavemsg = queryStringArray[6].indexOf('=');
    var  equivsavemsg= queryStringArray[6].substring(indexofequivsavemsg+1);  
    var indexofdatapointdeftype = queryStringArray[7].indexOf('=');
    var  datapointdeftype= queryStringArray[7].substring(indexofdatapointdeftype+1);  
    var totalUseAfterConvert = Math.round(totaluse * convertFactor,2);
    var msg1 = totalUseAfterConvert +" " + equivuom +" of "+ equivname;
    var msg2 ="";
    var msg3="";
    if(isSavingMsg == true)
    {
        msg2 = equivsavemsg;
    }
    else
    {
       if(datapointdeftype =="P")
       {
            msg2 = equivsavemsg;
       }
       else
       {
            msg2 = equivconsummsg;
       }
   }
   msg3 =  period;
  
        var newDivElm = document.createElement("div");
        //Set Div ID Value
        newDivElm.setAttribute("id","MsgDiv");
        //Create Calendar Div in the same position where user click 
        //Set position value of Calendar Div
        newDivElm.style.position="absolute";
        //Set Top value of Calendar Div
        newDivElm.style.top =yPos+"px";
        //Set Left value of calendar div
        newDivElm.style.left=xPos+"px";
        //set Zindex of calendar 
        newDivElm.style.zIndex= 1;
        newDivElm.style.textAlign ="center";
        newDivElm.style.align="middle";
        newDivElm.style.display="block";
       var newImage = "url(images/balloon-2.png)";
       //newDivElm.style.width=width+"px";
       //newDivElm.style.height=height +"px";
       //newDivElm.style.backgroundImage =newImage;
       
       var emptyLine = document.createElement('br');
        newDivElm.appendChild(emptyLine);
        var emptyLine1 = document.createElement('br');
        newDivElm.appendChild(emptyLine1);
       // var emptyLine2 = document.createElement('br');
       // newDivElm.appendChild(emptyLine2);
        
       var body = document.getElementsByTagName("body")[0];
       //Create Table Element
       var tbl     = document.createElement("table"); 
       //Set ID of the Table
       tbl.setAttribute("id","Msgtable");     
       //Set CellPadding attribute of the Table   
       tbl.setAttribute("cellPadding", "0");
       //Set CellSpacing attribute of the Table
       tbl.setAttribute("cellSpacing", "0");   
       tbl.style.width=width+"px";
       tbl.style.height=height +"px";       
       //#e6e5ef  #ef8e31
       tbl.style.background="#ef8e31";
       
       var tblB    = document.createElement("tbody");
       //Set ID attribute of table body element
       tblB.setAttribute("id","msgTableBody");
       //Create First Row in the Table 
       //Header Row  contains three Cell
       //Previous Month Cell, Month Name - Year Cell, Next Month Cell      
      var firstRow = document.createElement("tr");       
      SetRowStyle(firstRow);
      var firstMsgCell = document.createElement("td");
      setCellStyle(firstMsgCell);
      var firstMsgText = document.createTextNode(msg1);
      firstMsgCell.appendChild(firstMsgText);
      firstRow.appendChild(firstMsgCell);
      tblB.appendChild(firstRow);
      
      var secondRow = document.createElement("tr");
      SetRowStyle(secondRow);   
      var secondMsgCell = document.createElement("td");
      setCellStyle(secondMsgCell);
      var secondMsgText = document.createTextNode(msg2);
      secondMsgCell.appendChild(secondMsgText);
      secondRow.appendChild(secondMsgCell);
      tblB.appendChild(secondRow);
      
      var thirdRow = document.createElement("tr");  
      SetRowStyle(thirdRow); 
      var thirdMsgCell = document.createElement("td");
      setCellStyle(thirdMsgCell);
      var thirdMsgText = document.createTextNode(msg3);
      thirdMsgCell.appendChild(thirdMsgText);
      thirdRow.appendChild(thirdMsgCell);
      tblB.appendChild(thirdRow);
      
       var fourthRow = document.createElement("tr");  
      SetRowStyle(fourthRow); 
      var closeCell = document.createElement("td");
      setCellStyle(closeCell);
      
      var closeButton = document.createElement("input");
      closeButton.setAttribute("type","button");
      closeButton.setAttribute("id","btnCloseMsg");
      closeButton.setAttribute("value","Close");
      closeButton.onclick=function()
      {
       if(document.getElementById("MsgDiv"))
       {document.body.removeChild(document.getElementById("MsgDiv"));}
      };
      SetCloseButtonStyle(closeButton)
      closeCell.appendChild(closeButton);
      fourthRow.appendChild(closeCell);
      tblB.appendChild(fourthRow);       
      tbl.appendChild(tblB);
      newDivElm.appendChild(tbl);
      body.appendChild(newDivElm);
      
      
}
 function SetCloseButtonStyle(closeButton)
   {
    closeButton.style.fontSize= "9pt";
    closeButton.style.fontFamily="Verdana";
    closeButton.style.height= "20";
    //closeButton.style.background=defaultHeaderRowBackground;
    closeButton.style.color= "#293273";
    //closeButton.style.border=1;
   }
 function SetRowStyle(row)
   {
      
       row.style.color= "#293273";
       row.style.fontWeight="bold";
       row.style.fontSize="9pt";
       row.style.fontFamily="Verdana";
   }
   function setCellStyle(msgCell)
   {
         msgCell.style.textAlign="center";     
   }
                                                 
                                                 
