﻿// JScript File
var gctWindow = null;
var gctCallBack = null;
var gctIsCallBack = null;
var gctOverlay = null;
var GCTWindow = new GCTWINDOW();
var IsEffect = 'true';
function GCTWINDOW ()
{
 this.open = OpenWindow;
 this.close = closeGCTWindow ;
 this.customOpen = OpenCustomWindow;
 this.noEffect = function() { IsEffect = 'false'};
 this.SetPosition = ReposGCTWindow;
}

function OpenWindow (url,title,width,height,modal) 
{
    var gctOver = null;
    var gctwin = null;
    if (document.getElementById('GCTOVERLAY') == null)
    {
        gctOver = document.createElement('div');
        gctOver.setAttribute('id','GCTOVERLAY');	
        document.body.appendChild(gctOver);
        
        gctwin = document.createElement('div');
        gctwin.setAttribute('id','GCTWINDOW');
        document.body.appendChild(gctwin);
       
        gctOver.style.position = 'absolute';
        gctOver.style.zindex = 3001;
        gctwin.style.position = 'absolute';
        gctwin.style.zindex = 3002;
        gctwin.style.opacity = 100;
        gctwin.style.MozOpacity = 0;
        gctwin.style.KhtmlOpacity = 0;
        gctwin.style.filter = "alpha(opacity=0)";
        gctOver.style.left = '0px';
        gctOver.style.top = '0px';    
        gctOver.style.opacity = 0;
        gctOver.style.MozOpacity = 0;
        gctOver.style.KhtmlOpacity = 0;
        gctOver.style.filter = "alpha(opacity=0)";
        gctOver.className = 'GctOverlay';
        gctwin.className = 'GctWindow';
    }
    else
    {
      gctOver = document.getElementById('GCTOVERLAY');
      gctwin = document.getElementById('GCTWINDOW');
    }
    gctWindow = 'GCTWINDOW';
    gctOverlay = 'GCTOVERLAY'; 
    gctwin.style.width = width + 'px';
    gctwin.style.height = height + 'px';
    
    if(modal == 'True' || modal == 'true' )
    {
    gctOver.style.display = '';
   
    opacity(gctOverlay ,0,50,500);
    if(document.body.offsetHeight > window.screen.height)
    gctOver.style.height = document.body.offsetHeight + 'px';
    else
     gctOver.style.height = window.screen.height + 'px';
     
    if(document.body.offsetWidth > window.screen.width)
     gctOver.style.width = document.body.offsetWidth + 'px';
    else
     gctOver.style.width =  window.screen.width - 23 + 'px';
    } 
    gctOver.innerHTML += "<!--[if lte IE 6.5]><iframe class='GCTMask'></iframe><![endif]-->";
	gctwin.style.display = '';  
	gctwin.style.top = (window.screen.height - height)/3 - 20 + 'px';
    gctwin.style.left = (window.screen.width - width)/2 + 'px';
   	height -= 18;
	gctwin.innerHTML = "<div  class='GctTitleRow' ><span unselectable='on' class='GctTitle'>" + title +"</span><span class='GctClose' unselectable='on' onClick='closeWindow();'><b>Close</b></span></div><iframe id='GCTIFrame' class='GctWindowFrame' height='" + height + "' width='" + width + "' frameborder='0'  />";
	opacity(gctWindow ,0,100,500);
	document.getElementById('GCTIFrame').src = url;
}
function OpenCustomWindow (htm,title,width,height,modal) 
{
    var gctOver = null;
    var gctwin = null;
    if (document.getElementById('GCTOVERLAY') == null)
    {
        gctOver = document.createElement('div');
        gctOver.setAttribute('id','GCTOVERLAY');	
        document.body.appendChild(gctOver);
        
        gctwin = document.createElement('div');
        gctwin.setAttribute('id','GCTWINDOW');
        document.body.appendChild(gctwin);
       
        gctOver.style.position = 'absolute';
        gctOver.style.zindex = 3001;
        gctwin.style.position = 'absolute';
        gctwin.style.zindex = 3002;
        gctwin.style.opacity = 100;
        gctwin.style.MozOpacity = 0;
        gctwin.style.KhtmlOpacity = 0;
        gctwin.style.filter = "alpha(opacity=0)";
        gctOver.style.left = '0px';
        gctOver.style.top = '0px';    
        gctOver.style.opacity = 0;
        gctOver.style.MozOpacity = 0;
        gctOver.style.KhtmlOpacity = 0;
        gctOver.style.filter = "alpha(opacity=0)";
        gctOver.className = 'GctOverlay';
        gctwin.className = 'GctWindow';
    }
    else
    {
      gctOver = document.getElementById('GCTOVERLAY');
      gctwin = document.getElementById('GCTWINDOW');
    }
    gctWindow = 'GCTWINDOW';
    gctOverlay = 'GCTOVERLAY';  
    if(modal == 'True' || modal == 'true')
    {
    gctOver.style.display = '';
     if(IsEffect == 'true') 
    opacity(gctOverlay ,0,50,500);
    else
	{
	var object = document.getElementById(gctOverlay).style; 
	object.opacity = (100 / 100);
	object.MozOpacity = (100 / 100);
	object.KhtmlOpacity = (100 / 100);
	object.filter = "alpha(opacity=" + 100 + ")";
	}
    if(document.body.offsetHeight > window.screen.height)
     gctOver.style.height = document.body.offsetHeight + 'px';
    else
     gctOver.style.height =  window.screen.height + 'px';
     
    if(document.body.offsetWidth > window.screen.width)
     gctOver.style.width = document.body.offsetWidth + 'px';
    else
     gctOver.style.width =  window.screen.width - 23 + 'px';
    } 
    gctOver.innerHTML += "<!--[if lte IE 6.5]><iframe class='GCTMask'></iframe><![endif]-->";
	gctwin.style.display = '';
	gctwin.innerHTML = "<div  class='GctTitleRow' ><span unselectable='on' class='GctTitle'>" + title +"</span><span class='GctClose' unselectable='on' onClick='closeWindow();'><b>Close</b></span></div>" + htm;
	gctwin.style.width = width + 'px';
    gctwin.style.height = height + 'px';  
	gctwin.style.top = (window.screen.height - height)/3 + 'px';
    gctwin.style.left = (window.screen.width - width)/2 + 'px';
	 if(IsEffect == 'true') 
	opacity(gctWindow ,0,100,500);
	else
	{
	var object = document.getElementById(gctWindow).style; 
	object.opacity = (100 / 100);
	object.MozOpacity = (100 / 100);
	object.KhtmlOpacity = (100 / 100);
	object.filter = "alpha(opacity=" + 100 + ")";
	}
	
}

function ReposGCTWindow(left,top)
{
    var gctwin = document.getElementById(gctWindow);
    gctwin.style.top = top + 'px';
    gctwin.style.left = left + 'px';
} 

function closeGCTWindow(callbackfunction)
{
   if(gctWindow != null)
   {
    if(IsEffect == 'true') 
    {
   opacity(gctOverlay,50,0,500);
   opacity(gctWindow,100,0,500);
   }
    else
    {
    document.getElementById(gctOverlay).style.display = 'none';
    document.getElementById(gctWindow).style.display = 'none';    
    }
   }
   if(callbackfunction != '')
   eval(callbackfunction + "();");
}
        
function closeWindow()
{ 
   if(gctWindow != null)
   {
    if(IsEffect == 'true') 
    {
     opacity(gctOverlay,50,0,500);
     opacity(gctWindow,100,0,500);
    }
    else
    {
    document.getElementById(gctOverlay).style.display = 'none';
    document.getElementById(gctWindow).style.display = 'none';
    }
   }
}

function opacity(id, opacStart, opacEnd, millisec) 
{
	var speed = Math.round(millisec / 100);
	var timer = 0;

	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;		}	} 
	else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++)			{
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;		}	}
	
}
 var ov = 'false';
 var op = 'false';
function changeOpac(opacity, id)
{
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
	
    if (id == gctOverlay && ov == 'true' && opacity == 0)    {   
        document.getElementById(gctOverlay).style.display = 'none';
	  ov = 'mid';     }
    if (id == gctWindow && op == 'true' && opacity == 0)    {   
        document.getElementById(gctWindow).style.display = 'none';
	  op = 'mid';    }
    if (id == gctWindow && op != 'mid')    {    op = 'true';   }
    else if(id == gctWindow && op == 'mid') { op ='false'; } 
    if (id == gctOverlay && ov != 'mid')    {    ov = 'true';   }
    else if(id == gctOverlay && ov == 'mid') { ov ='false'; } 
}


//function DisableAndWaiting(id,validationGroup)
//{
//   var el = document.getElementById(id);
//   if(window.Page_ClientValidate)
//    { 
//        if (Page_ClientValidate(validationGroup)) 
//        {  
//            el.disabled = true;
//            el.className += " disabled_button";
//            if(el.href != "")
//            {
//                el.innerHTML = 'Loading...';
//                if(navigator.appVersion.indexOf("MSIE 6")>-1 )
//                {
//                var href = el.href;
//                while(href.indexOf('%20') > -1 ) {   href = href.replace('%20',' ');   }
//                eval(href);
//                }
//                else
//                eval(el.href);
//            }
//            el.removeAttribute('href');
//        }
//    }
//    else
//    {
//       el.disabled = true;
//       el.className += " disabled_button";
//       if(el.href != "")
//       {
//           el.innerHTML = 'please wait...';
//            if(navigator.appVersion.indexOf("MSIE 6")>-1 )
//            {
//            var href = el.href;
//            while(href.indexOf('%20') > -1 ) {   href = href.replace('%20',' ');   }
//            eval(href);
//            }
//            else
//            eval(el.href);
//              el.removeAttribute('href');
//       }
//    }
//}


