function fnshowlightboxeffectVendor(url)
{
   document.loginform.action = url ;
	
	Lightbox.enmStopResetSession = 0;
	
	Lightbox.hideCloseButton = 0;
	
	Lightbox.showBoxByID('copy',620,320);
		
	return false;
}

function fnshowlightboxeffectAffiliate(url)
{
   document.loginform.action = url;
	
	Lightbox.enmStopResetSession = 0;
	
	Lightbox.hideCloseButton = 0;
	
	Lightbox.showBoxByID('copy',620,320);
		
	return false;
}

function fnshowlightboxeffectSignup(url)
{
  
    document.loginform.action = url;
	//alert("1");
	Lightbox.enmStopResetSession = 0;
	//alert("11");
	Lightbox.hideCloseButton = 0;
	//alert("111");
	Lightbox.showBoxByID('copySignup',620,320);
	//alert("1111");	
	return false;
}

// JavaScript Document
var isNext = 0;
var intTop = 0;
var intHeight = 0;
var Lightbox = { 
 lightboxType : null,
 lightboxCurrentContentID : null,
 refreshAfterClose : 0,
 hideCloseButton : 0,
 enmStopResetSession : 1,
 
 
 showBoxString : function(content, boxWidth, boxHeight){
  this.setLightboxDimensions(boxWidth, boxHeight);
  this.lightboxType = 'string';
  var contents = document.getElementById('boxContents');
  contents.innerHTML = content;
  this.showBox();
  return false;
 },


 showBoxImage : function(href) {
  this.lightboxType = 'image';
  var contents = document.getElementById('boxContents');
  var objImage = document.createElement("img");
  objImage.setAttribute('id','lightboxImage');
  contents.appendChild(objImage);
  imgPreload = new Image();
  imgPreload.onload=function(){
   objImage.src = href;
   Lightbox.showBox();
  }
  imgPreload.src = href;
  return false;
 },

 showBoxByID : function(id, boxWidth, boxHeight) {



  this.lightboxType = 'id';

  this.lightboxCurrentContentID = id;
  this.setLightboxDimensions(boxWidth, boxHeight);

  var element = document.getElementById(id);

  document.getElementById('boxContents').innerHTML='';

  var contents = document.getElementById('boxContents');
  contents.appendChild(element);

  //contents.innerHTML = contents;
 
  //Element.show(id); 
  document.getElementById(id).style.display = 'block';
 
  if (this.hideCloseButton)
   document.getElementById("close").style.display = 'none';
 
  this.showBox();
  return false;
 },

 showBoxByAJAX : function(href, boxWidth, boxHeight) {
  this.lightboxType = 'ajax';
  this.setLightboxDimensions(boxWidth, boxHeight);
  var contents = document.getElementById('boxContents');
  //var myAjax = new Ajax.Updater(contents, href, {method: 'get'});
  var ajaxIndex = ajaxObjects.length; 
  ajaxObjects[ajaxIndex] = new sack();
  //var strUrl = sitename+"/index.php?action=blockuseripajax&mode=ajax&ajax_action=ajaxblock&bt="+strspamflag+"&aid="+intActId;
  var strUrl = href;    
  ajaxObjects[ajaxIndex].requestFile = strUrl;
  ajaxObjects[ajaxIndex].onCompletion = function()
             { 
               var lookup = (ajaxObjects[ajaxIndex].response);
               contents.innerHTML = lookup;
             };
  ajaxObjects[ajaxIndex].runAJAX();
  
  this.showBox();
  return false;
 },
 
 setLightboxDimensions : function(width, height) {
  var windowSize = this.getPageDimensions();
  if(width) {
   if(width < windowSize[0]) {
    document.getElementById('box').style.width = width + 'px';
   } else {
    document.getElementById('box').style.width = (windowSize[0] - 50) + 'px';
   }
  }
  if(height) {
   if(height < windowSize[1]) {
    document.getElementById('box').style.height = height + 'px';
   } else {
    document.getElementById('box').style.height = (windowSize[1] - 50) + 'px';
   }
  }
 },


 showBox : function() {
  //Element.show('overlay');
  document.getElementById("overlay").style.display='block';
  this.center('box');
  return false;
 },
 
 
 hideBox : function(){
  if (this.hideCloseButton)
  {
   document.getElementById("close").style.display = '';
   this.hideCloseButton = 0;
  }
  
  if(this.refreshAfterClose==1 || isNext)
  {
   isNext = 0;
   window.location.reload( true ); 
  }
  else
  {
   var contents = $('boxContents');
   if (this.enmStopResetSession == 1)
   {
    var ajaxIndex = ajaxObjects.length; 
    ajaxObjects[ajaxIndex] = new sack();
    ajaxObjects[ajaxIndex].requestFile = sitename+"/index.php?action=setunsetsessionvars&mode=ajax&ajax_action=resetsessionparams";
    ajaxObjects[ajaxIndex].onCompletion = function(){
                 ajaxObjects[ajaxIndex].response;
                }; // Specify function that will be executed after file has been found
    ajaxObjects[ajaxIndex].runAJAX();
   }
   
   var contents = document.getElementById('boxContents');
   if(this.lightboxType == 'id') {
    var body = document.getElementsByTagName("body").item(0);
 
    //Element.hide(this.lightboxCurrentContentID);
    document.getElementById(this.lightboxCurrentContentID).style.display='none';
    body.appendChild(document.getElementById(this.lightboxCurrentContentID));
   }
   try
   {
    document.getElementById("ajax_listOfOptions").style.display="none";
    document.getElementById("ajax_listOfOptions_iframe").style.display="none";
    
   }
   catch(err)
   {
    //
   }
   contents.innerHTML = '';
   document.getElementById('boxContents').innerHTML = '';
   document.getElementById('box').style.width = null;
   document.getElementById('box').style.height = null;
   //Element.hide('box');
   document.getElementById('box').style.display='none';
   //Element.hide('overlay');
   document.getElementById('overlay').style.display='none';
   return false;
  }
 },
 
 hideParentBox : function(){
  if (this.hideCloseButton)
  {
   document.getElementById("close").style.display = '';
   this.hideCloseButton = 0;
  }
  
  if(this.refreshAfterClose==1 || isNext )
  {
   isNext = 0;
   parent.window.location.reload( true ); 
  }
  else
  {
   //var contents = parent.document.getElementById('boxContents');
   if(this.lightboxType == 'id')
   {
    var body = document.getElementsByTagName("body").item(0);
    try{
    document.getElementById(this.lightboxCurrentContentID).style.display='none';
    body.appendChild(document.getElementById(this.lightboxCurrentContentID));
    }
    catch(e)
    {
     parent.document.getElementById(this.lightboxCurrentContentID).style.display='none';
    }
   }
   
   parent.document.getElementById('box').style.width = null;
   parent.document.getElementById('box').style.height = null;
   parent.document.getElementById('box').style.display='none';
   parent.document.getElementById('overlay').style.display='none';
   //parent.document.getElementById('boxContents').innerHTML = null;
   return false;
  }
 },
 
 // taken from lightbox js, modified argument return order
 getPageDimensions : function(){
  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(windowWidth,windowHeight,pageWidth,pageHeight) 
  return arrayPageSize;
 },
 
 center : function(element){
  try{
   element = document.getElementById(element);
  }catch(e){
   return;
  }
  var windowSize = this.getPageDimensions();
  var window_width  = windowSize[0];
  var window_height = windowSize[1];
  
  document.getElementById('overlay').style.height = windowSize[3] + 'px';
  
  element.style.position = 'absolute';
  element.style.zIndex   = 10000;
 
  var scrollY = 0;
 
  if ( document.documentElement && document.documentElement.scrollTop ){
   scrollY = document.documentElement.scrollTop;
  }else if ( document.body && document.body.scrollTop ){
   scrollY = document.body.scrollTop;
  }else if ( window.pageYOffset ){
   scrollY = window.pageYOffset;
  }else if ( window.scrollY ){
   scrollY = window.scrollY;
  }
 
  var elementDimensions = this.getDimensionsLightBox(element);
  var setX = ( window_width  - elementDimensions.width  ) / 2;
  var setY = ( window_height - elementDimensions.height ) / 2 + scrollY;
 
  setX = ( setX < 0 ) ? 0 : setX;
  setY = ( setY < 0 ) ? 0 : setY;
 
  element.style.left = setX + "px";  
  element.style.top  = setY + "px"; // comment this line and uncomment fnSetTop if u want top animation;
  
  //element.style.overflow = 'hidden';
  //fnSetTop(element.id,setY); // VIKRANT CHANGE
  //fnSetHeight(element.id,parseInt(element.style.height)); // VIKRANT CHANGE
  
  element.style.display=''
 },
 
 getDimensionsLightBox: function(element) {
 
   if (element.style.display != 'none')
      return {width: element.offsetWidth, height: element.offsetHeight};

    // All *Width and *Height properties give 0 on elements with display none,
    // so enable the element temporarily
    var els = element.style;
    var originalVisibility = els.visibility;
    var originalPosition = els.position;
    els.visibility = 'hidden';
    els.position = 'absolute';
    els.display = '';
    var originalWidth = element.clientWidth;
    var originalHeight = element.clientHeight;
    els.display = 'none';
    els.position = originalPosition;
    els.visibility = originalVisibility;
    return {width: originalWidth, height: originalHeight};
  },

 
 
 init : function() {      
  var lightboxtext = '<div id="overlay" style="display:none"></div>';
  lightboxtext += '<div id="box" style="display:none">';
  lightboxtext += '<img id="close" src="images/close.gif" onClick="Lightbox.hideBox()" alt="Close" title="Close this window" />';
  lightboxtext += '<div id="boxContents"></div>';
  lightboxtext += '</div>';
  var body = document.getElementsByTagName("body").item(0);
  new Insertion.Bottom(body, lightboxtext);
 }
}


