// JScript File :- Added By Amita Vashisht 

function ShowDialogforLogin(path)
{     
  GCTWindow.openRefresh(path,'',590,300,'true');
}

var gctWindow = null;
var gctCallBack = null;
var gctIsCallBack = null;
var gctOverlay = null;
var GCTWindow = new GCTWINDOW();
var IsEffect = 'false';
function GCTWINDOW ()
{
 this.open = OpenWindow;
 this.openRefresh = OpenWindowWithParentRefresh;
 this.close = closeGCTWindow ;
 this.closeRefresh = closeWithRefresh;
 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');
        document.body.appendChild(gctOver);
        gctwin = document.createElement('div');
        document.body.appendChild(gctwin);
        
        gctOver.setAttribute('id','GCTOVERLAY');	
        gctwin.setAttribute('id','GCTWINDOW');
        gctOver.style.position = 'absolute';
        gctOver.style.zindex = 3001;
        gctwin.style.position = 'absolute';
        gctwin.style.zindex = 3002;
        gctwin.style.opacity = 0;
        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)";
    
    }
    else
    {
      gctOver = document.getElementById('GCTOVERLAY');
      gctwin = document.getElementById('GCTWINDOW');
    }
	    gctOver.className = 'GctOverlay';
        gctwin.className = '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,0);
    if(document.body.offsetHeight > window.screen.height)
    gctOver.style.height = document.body.offsetHeight + 'px';
    else
    gctOver.style.height =  window.screen.height + 'px';
     // gctOver.style.height = document.body.scrollHeight + "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 + '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'  />";
	gctwin.innerHTML += "<iframe id='GCTIFrame' class='GctWindowFrame' height='" + height + "' width='" + width + "' frameborder='0'  />";
	opacity(gctWindow ,0,100,1000);
	document.getElementById('GCTIFrame').src = url;
	window.scrollTo(0,0);
}


function KeyDownHandler(btn)
{
// process only the Enter key
if (event.keyCode == 13)
{
// cancel the default submit
event.returnValue=false;
event.cancel = true;
// submit the form by programmatically clicking the specified button
btn.click();
}
}



function OpenWindowWithParentRefresh (url,title,width,height,modal) 
{
    var gctOver = null;
    var gctwin = null;
    if (document.getElementById('GCTOVERLAY') == null)
    {
        gctOver = document.createElement('div');
        document.body.appendChild(gctOver);
        gctwin = document.createElement('div');
        document.body.appendChild(gctwin);
        
        gctOver.setAttribute('id','GCTOVERLAY');	
        gctwin.setAttribute('id','GCTWINDOW');
        gctOver.style.position = 'absolute';
        gctOver.style.zindex = 3001;
        gctwin.style.position = 'absolute';
        gctwin.style.zindex = 3002;
        gctwin.style.opacity = 0;
        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)";
    
    }
    else
    {
      gctOver = document.getElementById('GCTOVERLAY');
      gctwin = document.getElementById('GCTWINDOW');
    }
	    gctOver.className = 'GctOverlay';
        gctwin.className = '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,0);
    //alert(document.body.clientWidth+', '+window.screen.width+', '+document.body.offsetWidth)
    if(document.body.offsetHeight > window.screen.height)
    gctOver.style.height = document.body.offsetHeight + 'px';
    else
    gctOver.style.height =  window.screen.height + 'px';
     // gctOver.style.height = document.body.scrollHeight + "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 = (document.body.clientHeight - height)/4 + 'px';
    gctwin.style.top = 200 + 'px';
    gctwin.style.left = (document.body.clientWidth - 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'  />";
	gctwin.innerHTML = "<iframe id='GCTIFrame' class='GctWindowFrame' height='" + height + "' width='" + width + "' frameborder='0'  />";
	opacity(gctWindow ,0,100,1000);
	document.getElementById('GCTIFrame').src = url;
	window.scrollTo(0,0);
}

var fireFox = navigator.userAgent.indexOf("Firefox")>-1;
var LocFire =  location.href;
function OpenCustomWindow (htm,title,width,height,modal) {
    var LocCal = LocFire.indexOf("EventCalender/scheduler.aspx?")>-1; 
    var GctCalWin = htm.indexOf("GctCalenderWindow")>-1;
    var gctOver = null;
    var gctwin = null;
   if (document.getElementById('GCTOVERLAY') == null)
    {
        gctOver = document.createElement('div');
        document.body.appendChild(gctOver);
        gctwin = document.createElement('div');
        document.body.appendChild(gctwin);
        gctOver.setAttribute('id','GCTOVERLAY');
        gctwin.setAttribute('id','GCTWINDOW');
        gctOver.style.position = 'absolute';
        gctOver.style.zindex = 3001;
        gctwin.style.position = 'absolute';
        gctwin.style.zindex = 3002;
        gctwin.style.opacity = 0;
        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)";
    }
    else
    {
      gctOver = document.getElementById('GCTOVERLAY');
      gctwin = document.getElementById('GCTWINDOW');
    }
	  gctOver.className = 'GctOverlay';
        gctwin.className = 'GctWindow';
    gctWindow = 'GCTWINDOW';
    gctOverlay = 'GCTOVERLAY';  
    if(modal == 'True' || modal == 'true')
    {
    gctOver.style.display = '';
     if(IsEffect == 'true') 
    opacity(gctOverlay ,0,70,0);
    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';
   //  gctOver.style.height = document.body.scrollHeight + "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.innerHTML = ""; //"<div class='GctTitleRow'><span unselectable='on' class='GctTitle'>" + title +"</span></div>" + htm;
	gctwin.style.width = width + 'px';
    gctwin.style.height = height + 'px'; 
    if(fireFox && LocFire && GctCalWin)
    {
    window.scrollTo(0,0);
    gctwin.style.top = ((window.screen.height - height)/4) - 10 + 'px';
    gctwin.style.left = ((document.body.clientWidth - width  )/3) + 150 + 'px';
    }
    else{ 
	gctwin.style.top = (window.screen.height - height)/3 + 'px';
    gctwin.style.left = (document.body.clientWidth - width  )/2 + 'px';}
	 if(IsEffect == 'true') 
	opacity(gctWindow ,0,100,1000);
	else
	{
	var object = document.getElementById(gctWindow).style; 
	object.opacity = (100 / 100);
	object.MozOpacity = (100 / 100);
	object.KhtmlOpacity = (100 / 100);
	object.filter = "alpha(opacity=" + 100 + ")";
	}
	window.scrollTo(0,0);
}

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,1000);
   opacity(gctWindow,100,0,1000);
   }
    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,1000);
     opacity(gctWindow,100,0,1000);
    }
    else
    {
    document.getElementById(gctOverlay).style.display = 'none';
    document.getElementById(gctWindow).style.display = 'none';
    }
   }
  
}

function closeWithRefresh()
{ 
   if(gctWindow != null)
   {
    if(IsEffect == 'true') 
    {
     opacity(gctOverlay,50,0,1000);
     opacity(gctWindow,100,0,1000);
    }
    else
    {
    document.getElementById(gctOverlay).style.display = 'none';
    document.getElementById(gctWindow).style.display = 'none';
    }
   }
   if(document.getElementById(gctWindow).style.display = 'none')
   {
    window.parent.RefreshPage();
   }
  
}
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 CloseWind()   
{  
    window.parent.GCTWindow.close(''); 
}

function DisplayMaternityPopUp(path) {

    window.onload = function() { GCTWindow.open(path, 'Sign Up: Step 1 - myBeautyBestFriend', 450, 330, 'true') };
}