﻿

var browserName = navigator.appName;
var browserType = 0;

if(browserName.search("Microsoft") != -1)
    browserType = "1";
if(browserName.search("Netscape") != -1)
    browserType = "2";
    
var isIE6 = (navigator.userAgent.toLowerCase().indexOf('msie 6') != -1);



var recRedirectUrl = "";
    
    
function LightShowPage(url,width, height,redirectUrl)
{
        recRedirectUrl = redirectUrl;

        var bgDiv = document.createElement('div');
        bgDiv.setAttribute('id','LightPopupBGDiv');
        bgDiv.setAttribute('class','LightPopupBGDiv');
        
        var pageSizeArray = new Array();
        pageSizeArray = getPageSize();
        var pageWidth = pageSizeArray[0];
        var pageHeight = pageSizeArray[1];
        
        bgDiv.style.height = pageHeight + "px";
        bgDiv.style.width = pageWidth + "px";
        bgDiv.style.zIndex = 1500;
       
        document.body.appendChild(bgDiv);
        
//        var centerDiv = document.createElement('div');        
        var centerDiv = document.getElementById("loginformdiv");
        document.getElementById("loginformdiv").style.display = "";

        //centerDiv.setAttribute('id','LightBoxCenterDiv');
        centerDiv.setAttribute('class','LightBoxCenterDiv');
        centerDiv.style.position = "absolute";
        centerDiv.style.left = getScreenCenterX() - parseInt(width/2) + "px";
        centerDiv.style.top = getScreenCenterY() - parseInt(height/2) + "px";
        centerDiv.style.width = parseInt(width) + 10 + 'px';
        centerDiv.style.height = parseInt(height) + 'px';
        centerDiv.style.overflow = "hidden";
        centerDiv.style.zIndex = 1501;
               
//                
//  
//        var centerContendDiv = document.createElement('div');
//        centerContendDiv.setAttribute('id','LightBoxCenterContentDiv');
//        centerContendDiv.style.width = parseInt(width) + 'px';
//        centerContendDiv.style.height = (parseInt(height) - 50) + 'px';
//        centerContendDiv.style.zIndex = 1510;
//        
//        //Dirty ie6 fix for div space usage therefore disconnecting topRoundedDiv and centerContendDiv
//        if(isIE6)
//        {
//        centerContendDiv.style.position = 'relative';
//        centerContendDiv.style.top = '-60px';
//        }
//        
//        
//        
//        //Tejas - add your div name here
//        centerContendDiv.appendChild(document.getElementById("loginformdiv"));
//        
//        centerDiv.appendChild(centerContendDiv);
//        
//        document.body.appendChild(centerDiv);    
        
       
        
        
         
}

function HidePop()
{

    if(document.getElementById("loginformdiv") != null)
    {
        document.getElementById("loginformdiv").style.display = 'none';
        //document.body.removeChild(document.getElementById("loginformdiv"));
        
        //document.getElementById("LightBoxCenterDiv").style.display = 'none';
//        document.body.removeChild(document.getElementById("LightBoxCenterDiv"));
    }

    if(document.getElementById("LightPopupBGDiv") != null)
    {
        document.getElementById("LightPopupBGDiv").style.display = 'none';
        //document.body.removeChild(document.getElementById("LightPopupBGDiv"));
    }
    
   //Code to redirect the parent once the light box is closed
//        if(recRedirectUrl == " ")
//          {
//                       
//          }
//          else
//          if(recRedirectUrl == "self")
//          {
//            window.parent.location.href = window.parent.location;
//          }
//          else
//            {
//               window.parent.location.href = recRedirectUrl;
//            } 


}



/* Supporting functions */

//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function getScreenCenterY() {
var y = 0;

y = getScrollOffset()+(getInnerHeight()/2);

return(y);
}

function getScreenCenterX() {
return(document.body.clientWidth/2);
}

function getInnerHeight() {
var y;
if (self.innerHeight) // all except Explorer
{
y = self.innerHeight;
}
else if (document.documentElement && document.documentElement.clientHeight)
// Explorer 6 Strict Mode
{
y = document.documentElement.clientHeight;
}
else if (document.body) // other Explorers
{
y = document.body.clientHeight;
}
return(y);
}

function getScrollOffset() {
var y;
if (self.pageYOffset) // all except Explorer
{
y = self.pageYOffset;
}
else if (document.documentElement && document.documentElement.scrollTop)
// Explorer 6 Strict
{
y = document.documentElement.scrollTop;
}
else if (document.body) // all other Explorers
{
y = document.body.scrollTop;
}
return(y);
}

