﻿
function fadeIn4(id, steps, duration,  offsety, offsetx, width, messageID){ 

    var element = document.getElementById(id)
    var fadeInComplete;
     var myWidth = document.getElementById(messageID+"3").offsetWidth;
     var x = getAbsoluteX2(element);
	var y = getAbsoluteY2(element);
	y+=offsety
	x+=offsetx
 id=messageID
 document.getElementById(id).style.top=y + "px"
 document.getElementById(id).style.left=x + "px"
 document.getElementById(id).style.width=width + "px"//y + "px"
 document.getElementById(id).style.visibility="visible"
// id=messageID+"2"
// document.getElementById(id).style.top=y + "px"
// document.getElementById(id).style.left=x + "px"
// document.getElementById(id).style.width=width + "px"//y + "px"
// document.getElementById(id).style.visibility="visible"

// need to take 1/2 the width of both the id and the message and then need to set as hidden
 id=messageID+"3";
 document.getElementById(id).style.visibility="visible"
     var myWidth = document.getElementById(messageID+"3").offsetWidth;
     if (myWidth == 0) 
     {
        myWidth = document.getElementById(id).style.width
        myWidth = parseInt(myWidth)
     }
myWidth = (width/2) - (myWidth/2);
x = x + myWidth;
 document.getElementById(id).style.top=y + "px"
 document.getElementById(id).style.left=x + "px"
 id=messageID
    for (i = 0; i <= 1; i += (1 / steps)) 
    {
        if (document.getElementById(id+ "3") != null)
        {
            if (i<=.6)
            {
            setTimeout("setOpacity('" + id + "', " + i + ");setOpacity('" + id + "3', " + i + ")", i * duration); 
            }
            else
            {
            setTimeout("setOpacity('" + id + "3', " + i + ")", i * duration); 
            }
        }
        else
        {
            setTimeout("setOpacity('" + id + "', " + i + ");", i * duration); 
            if (i<=.6)
            {
            i=1
            }
        }
        fadeInComplete = i * duration;             
    }

}

 
        var _popup;
        function validate(myString){
            //  find the popup behavior
            //this._popup = $find('mdlPopup');
            // show the popup
            //this._popup.show();
            if (sessvars.checkLoading == true)
            {
            
                sessvars.checkLoading = false;
                if (myString.toString().toLowerCase().indexOf("dbtnsubmit")> -1)
                {
                window.location.hash="submitcompany.ascx";
                }
                else
                {
                    window.location.hash=myString;
                }
                recentHash = window.location.hash;
                var myWidth = document.getElementById('tdBody').offsetWidth;
                var myHeight = document.getElementById('tdBody').offsetHeight;
                
                document.getElementById('myLoading').style.width = myWidth + "px";
                document.getElementById('myLoading').style.height = myHeight + "px";
                
                if(myString.indexOf("dbtn") > -1)
                 {
                 
                        fadeIn4('updBody',500,500,0,0,myWidth,'myLoading');
                        window.scrollTo(0, 0);
                        __doPostBack(myString,myString)
                 }
                 else if(myString.indexOf("imagebutton4") > -1)
                 {
                     //myString.preventDefault();
                        fadeIn4('updBody',500,500,0,0,myWidth,'myLoading');
                        window.scrollTo(0, 0);
                    
                         __doPostBack('myPage1$imagebutton4','')
                     
                 }
                 else if(myString.indexOf("updateInfo") > -1)
                 {
                     //myString.preventDefault();
                        fadeIn4('updBody',500,500,0,0,myWidth,'myLoading');
                        window.scrollTo(0, 0);
                    
                         __doPostBack('myPage1$updateInfo','')
                     
                 }
                 else if(myString.indexOf("myPage1$") > -1)
                 {
                     //myString.preventDefault();
                        fadeIn4('updBody',500,500,0,0,myWidth,'myLoading');
                        window.scrollTo(0, 0);
                    
                         __doPostBack(myString,'')
                     
                 }
                 else if(myString.indexOf("myPage1_") > -1)
                 {
                     //myString.preventDefault();
                        fadeIn4('updBody',500,500,0,0,myWidth,'myLoading');
                        window.scrollTo(0, 0);
                    
                         __doPostBack(myString,'')
                     
                 }
                 else if(myString.indexOf("Logout") > -1) 
                 {
                
    //             myWidth = document.getElementById('container').offsetWidth;
    //             myHeight = document.getElementById('container').offsetHeight;
    //            document.getElementById('jsDisabled2').style.width = myWidth + "px";
    //            document.getElementById('jsDisabled2').style.height = myHeight + "px";
    //             fadeIn4('container',500,500,0,0,myWidth,'jsDisabled2');
    //                    var element = document.getElementById("jsDisabled2")
    //                    element.style.visibility="visible"
    //                    element.style.display = 'inline';
    //                    element.style.zoom = 1;
    //                    element.style.opacity = .60;
    //                    element.style.MozOpacity = .60;
    //                    element.style.KhtmlOpacity = .60;
    //                    element.style.filter = "alpha(opacity=" + (.60 * 100) + ");";
                        //__doPostBack('dbtnLogin','')
                        fadeIn4('updBody',500,500,0,0,myWidth,'myLoading');
                        window.scrollTo(0, 0);
                    
                        __doPostBack('UpdatePanel5',myString)
                 }
                 else
                 {
                        fadeIn4('updBody',500,500,0,0,myWidth,'myLoading');
                        window.scrollTo(0, 0);
                        
                        __doPostBack("updBody",myString)
                
                 }
                 
                 
    //            function goHere(  )
    //            {
    //            var x4 = document.getElementById("ddlType").value
    //            var x3 = document.getElementById("ddlCondition").value
    //            var x2 = document.getElementById("ddlSearch").value
    //            var x = document.getElementById("txtSearch").value
    //            __doPostBack('Search1', x2.toString() + "&" + x3.toString() + "&" + x.toString() + "!!!" + x4.toString()); //do a postback to updatepanel1.onload which calls "UpdatePanel1_Load"
    //            }   
                }       
        }
        function Finish(){ 
            fadeOut('myLoading', 1000, 2000, .60);
            
                         
        }
        
         function loadAll()
           {
         fadeOut('jsDisabled2', 1000, 2000, .60);
          // removeElement("jsDisabled2")
          }
          
          addLoadEvent(loadAll);
         
