﻿// JScript File
//function fnShowHideData(id)
//{
//    if(id==1)
//    {
//		document.getElementById("tr1").style.display="";
//		document.getElementById("tr2").style.display="none";
//	}
//	else
//	{
//	    document.getElementById("tr1").style.display="none";
//		document.getElementById("tr2").style.display="";
//	}
//}

function ShowHideTipForCleansingCost()
    {
        var divTipForCleansingCost = document.getElementById('divTipForCleansingCost');
        if(divTipForCleansingCost.style.display != "none")
            divTipForCleansingCost.style.display = "none";
        else
            divTipForCleansingCost.style.display = "";
    }
    
function ShowDataFormat()
{
    if(document.getElementById("divDataFormat").style.display=="none")
        document.getElementById("divDataFormat").style.display="";
    else
        document.getElementById("divDataFormat").style.display="none";
}

function HideTipBlock()
{
    document.getElementById('divIpTip').style.display = 'none';
}

function ShowTipBlock(header,tip,e)
{

//    var xMousePos;
//    var yMousePos;
//    
//    var eve = window.event;
//    
//            if(e.pageX || e.pageY)
//            {
//                xMousePos=e.pageX;
//                yMousePos=e.pageY;
//                
//            }
//            else if(e.clientX || e.clientY)
//            {
//                xMousePos=e.clientX;
//                yMousePos=e.clientY; 
//                
//            }
            
    document.getElementById('divIpTip').style.display = "";
    document.getElementById('divIpTip').style.position="absolute";
//    document.getElementById('divIpTip').style.top =(parseInt(yMousePos));
//    document.getElementById('divIpTip').style.left = xMousePos;
    document.getElementById('spanIpTipHeader').innerHTML = tip;
    document.getElementById('spanIpTipBody').innerHTML = header;
    
}

function ShowTipForOwnDB()
{
    document.getElementById('divOwnDBTip').style.display = "";
    document.getElementById('divOwnDBTip').style.position="absolute";
}

function HideTipForOwnDB()
{
    document.getElementById('divOwnDBTip').style.display = 'none';
}

function ShowTipDataProfiling()
{
    document.getElementById('divDataProfiling').style.display = "";
    document.getElementById('divDataProfiling').style.position="absolute";
}

function HideTipDataProfiling()
{
    document.getElementById('divDataProfiling').style.display = 'none';
}

function fnShowHideTip(id)
{
	var tabid = document.getElementById("tip"+id);
	if (tabid!=null)
	{
	    if(tabid.style.display=='none')				
		    tabid.style.display="";
	    else
	        tabid.style.display="none";
	}
		
}

function fnShowHideLive(id)
{
	var tabid = document.getElementById("live"+id);
	if (tabid!=null)
	{
	    if(tabid.style.display=='none')				
		    tabid.style.display="";
	    else
	        tabid.style.display="none";
	}
		
}

function windowOpener(windowHeight, windowWidth, windowName, windowUri)
{
    var centerWidth = (window.screen.width - windowWidth) / 2;
    var centerHeight = (window.screen.height - windowHeight) / 2;

    newWindow = window.open(windowUri, windowName, 'resizable=0,scrollbars=1, width=' + windowWidth + 
        ',height=' + windowHeight + 
        ',left=' + centerWidth + 
        ',top=' + centerHeight);

    newWindow.focus();
    return newWindow.name;
}

function windowOpenerImg(windowHeight, windowWidth, windowName, windowUri)
{
    var centerWidth = (window.screen.width - windowWidth) / 2;
    var centerHeight = (window.screen.height - windowHeight) / 2;

    newWindow = window.open(windowUri, windowName, 'resizable=0,scrollbars=1, width=' + windowWidth + 
        ',height=' + windowHeight + 
        ',left=' + centerWidth + 
        ',top=' + centerHeight);

    newWindow.focus();
    return newWindow.name;
}

function DeleteMessage()
{
   return confirm('Are you sure you want to delete this record?');
   
}

 function fnSelectAllCheckBox(oChkBox,chkName) // select/deselect all checkbox that begin with the id passed
{
	var oCntls = document.forms[0].elements;
	var oCntlsLength = oCntls.length;
	for(i=0;i<oCntlsLength;i++)
	{

		oChk = oCntls[i];
		if (oChk.type == "checkbox")
		{
			if (oChk.id.indexOf(chkName) >= 0)
			{
				oChk.checked = oChkBox.checked;
			}	
		}
	}
}


function fnDeselect(chkName) // deselect select all chkbox
{
	var oCntls = document.forms[0].elements;
	var oCntlsLength = oCntls.length;
	var chkd=true;
	
	for(i=0;i<oCntlsLength;i++)
	{

		oChk = oCntls[i];
		if (oChk.type == "checkbox")
		{
			if ((oChk.id.indexOf(chkName) >= 0) && (oChk.checked==false))
			{
				chkd=false;
				break;
			}	
		}
	}
	
	document.getElementById("chk_A1").checked=chkd;
}


function goToIndustryAddTemplate()
{
    var parentIndId;
    
    parentIndId=parseFloat(document.getElementById('<%= hdnIndId.ClientID%>').value);

    if(parentIndId > 0)
        windowOpener(500,500, 'AddTemplate','../Template/TemplatePopUp.aspx?pind=' + parentIndId);
}

function goToEnterpriseAddTemplate(EnterpriseID)
{
        windowOpener(500,680, 'AddTemplate','../Template/TemplatePopUp.aspx?EID=' + EnterpriseID);
}
function fnRefresh()
{
     window.close(); 
     window.opener.document.forms[0].submit();
}


function left(str, n)
{
        if (n <= 0)     // Invalid bound, return blank string
                return "";
        else if (n > String(str).length)   // Invalid bound, return
                return str;                // entire string
        else   // Valid bound, return appropriate substring
                return String(str).substring(0,n);
}


function right(str, n)
{
        if (n <= 0)     // Invalid bound, return blank string
           return "";
        else if (n > String(str).length)   // Invalid bound, return
           return str;                     // entire string
        else {   // Valid bound, return appropriate substring
           var iLen = String(str).length;
           return String(str).substring(iLen, iLen - n);
        }
}

function mid(str, start, len)
{
        // Make sure start and len are within proper bounds
        if (start < 0 || len < 0) return "";

        var iEnd, iLen = String(str).length;
        if (start + len > iLen)
                iEnd = iLen;
        else
                iEnd = start + len;

        return String(str).substring(start,iEnd);
}

//returns true if endDate > startDate otherwise returns false
function compareDateValidate(startDate,endDate)
{
    retVal=true;
    var arrCurDdMmYyyy=startDate.split('/');
    var arrSelDdMmYyyy=endDate.split('/');
    
    var curDay=parseFloat(arrCurDdMmYyyy[0]);
    var curMonth=parseFloat(arrCurDdMmYyyy[1]);
    var curYear=parseFloat(arrCurDdMmYyyy[2]);
    
    var selDay=parseFloat(arrSelDdMmYyyy[0]);
    var selMonth=parseFloat(arrSelDdMmYyyy[1]);
    var selYear=parseFloat(arrSelDdMmYyyy[2]);
    
    if(selYear < curYear)
        retVal=false;
    else if(selYear == curYear)
    {
        if(selMonth < curMonth)
            retVal=false;
        else if(selMonth == curMonth)
        {
            if(selDay < curDay)
                retVal=false;
        }   
    }	        
    return retVal;
}

function checkTextAreaMaxlength(object,e,maxlength)
{
    var key;
    
    if(navigator.appName.lastIndexOf("Microsoft Internet Explorer") > -1)
        key=e.keyCode;
    else
        key=e.which;    
        
    //alert('key=' + key);    

    if(key != 0 && key != 8 && key != 13 && key != 9)
        if(object.value.length >= maxlength) return false;    
}

function CheckKeyAndDisableKeypress(object,e)
{
    var key;
    
    if(navigator.appName.lastIndexOf("Microsoft Internet Explorer") > -1)
        key=e.keyCode;
    else
        key=e.which;    
        
    //alert('key=' + key);    

    if(!(key == 0 || key == 8 || key == 9 || key == 13))
        return false;
}

function ShowHideTab(tabId)
{
	    navRoot = document.getElementById("menuDiv");
	    
	    for (i=0; i<navRoot.childNodes.length; i++) {
		    node = navRoot.childNodes[i];
		    //alert('nodeName=' + node.nodeName);
		    if (node.nodeName=="UL") {
		    
		        //alert('nodeId=' + node.id + "\ntabId=" + tabId); 
		        if(node.id != tabId)
		        if(node.style.display == "")
                    node.style.display='none';
		    }
	    }
    //}

    //alert(document.getElementById(tabId).style.display);

    if(document.getElementById(tabId).style.display == "")
        document.getElementById(tabId).style.display='none';
    else
        document.getElementById(tabId).style.display="";    
}

var fadeSteps = 20; 
var fadeDelay = 20; 
var loopPrepend = true; 
var fadeStep = 0; 
var fadeElem; 

function fadeIn() { 
	if(fadeStep > fadeSteps){ 
       return;
    } else{
    	setOpacity(fadeElem, (fadeStep/fadeSteps)); 
    	fadeStep++; 
    	window.setTimeout("fadeIn()", fadeDelay); 
	}
} 

function setOpacity( el, opacity){ 
    if(el.style.opacity != undefined){ 
        el.style.opacity = opacity; 
    }else if( el.style.MozOpacity != undefined){ 
        el.style.MozOpacity = opacity; 
    }else if ( el.style.filter != undefined){ 
        el.style.filter="alpha(opacity=" + Math.round(opacity * 100) + ")"; 
    } 
}

function showDiv(divId)
    {
          
          if(document.getElementById(divId).style.display == "none")
          {
              document.getElementById(divId).style.display = "";
              fadeStep = 0; 
              fadeElem = document.getElementById(divId);
              fadeIn();
             
         }
          return false;
    } 
