var IframeId = "OverLayIFrame";var OverlayDivId = "modal";
(function (b) { var a = { width: 800, height: 600, overlayOpacity: 0.85, id: OverlayDivId, src: function (c) { return jQuery(c).attr("href") }, fadeInSpeed: 0, fadeOutSpeed: 0 }; b.modal = function (c) { return _modal(this, c) }; b.modal.open = function () { _modal.open() }; b.modal.close = function () { _modal.close() }; b.fn.modal = function (c) { return _modal(this, c) }; _modal = function (c, d) { this.options = { parent: null, overlayOpacity: null, id: null, content: null, width: null, height: null, modalClassName: null, imageClassName: null, closeClassName: null, overlayClassName: null, src: null }; this.options = b.extend({}, options, _defaults); this.options = b.extend({}, options, a); this.options = b.extend({}, options, d); this.close = function () { jQuery("." + options.modalClassName + ", ." + options.overlayClassName).fadeOut(a.fadeOutSpeed, function () { jQuery(this).unbind().remove() }) }; this.open = function () { if (typeof options.src == "function") { options.src = options.src(c) } else { options.src = options.src || _defaults.src(c) } var e = /^.+\.((jpg)|(gif)|(jpeg)|(png)|(jpg))$/i; var f = ""; if (e.test(options.src)) { f = '<div id="ModalImage" class="' + options.imageClassName + '"><img src="' + options.src + '"/></div>' } else { f = '<iframe style="width:' + options.width + 'px;height:' + options.height + 'px;" onload="setHeightWidthIframe()" id="'+ IframeId +'" frameborder="0" scrolling="auto" allowtransparency="true" src="' + options.src + '">&lt/iframe>' } options.content = options.content || f; if (jQuery("." + options.modalClassName).length && jQuery("." + options.overlayClassName).length) { jQuery("." + options.modalClassName).html(options.content) } else { 
$overlay = jQuery((_isIE6()) ? '<iframe src="BLOCKED SCRIPT\'&lt;html&gt;&lt;/html&gt;\';" id="'+ IframeId +'" scrolling="auto" frameborder="0" class="' + options.overlayClassName + '"></iframe><div id="ModalIframe"  class="' + options.overlayClassName + '"></div>' : '<div id="ModalIframe"  class="' + options.overlayClassName + '"></div>'); $overlay.hide().appendTo(options.parent); $modal = jQuery('<div id="' + options.id + '" class="' + options.modalClassName + '" style="width:' + options.width + "px; height:" + options.height + "px; margin-top:0; margin-left:-" + (options.width / 2) + 'px;">' + options.content + "</div>"); $modal.hide().appendTo(options.parent); $close = jQuery('<a class="' + options.closeClassName + '"></a>'); $close.appendTo($modal); var g = _getOpacity($overlay.not("iframe")) || options.overlayOpacity; $overlay.fadeTo(0, 0).show().not("iframe").fadeTo(a.fadeInSpeed, g); $modal.fadeIn(a.fadeInSpeed); $close.click(function () { jQuery.modal().close() }); $overlay.click(function () { jQuery.modal().close() }) } }; return this }; 
_isIE6 = function () { if (document.all && document.getElementById) { if (document.compatMode && !window.XMLHttpRequest) { return true } } return false }; _getOpacity = function (c) { $sender = jQuery(c); opacity = $sender.css("opacity"); filter = $sender.css("filter"); if (filter.indexOf("opacity=") >= 0) { return parseFloat(filter.match(/opacity=([^)]*)/)[1]) / 100 } else { if (opacity != "") { return opacity } } return "" }; _defaults = { parent: "body", overlayOpacity: 85, id: OverlayDivId, content: null, width: 800, height: 600, modalClassName: "modal-window", imageClassName: "modal-image", closeClassName: "close-window", overlayClassName: "modal-overlay", src: function (c) { return jQuery(c).attr("href") } } })(jQuery);

//
//  getPageSize()
//
function getPageSize(ClassNameId) {
      
   var xScroll, yScroll;
        
  if (window.innerHeight && window.scrollMaxY) {	
  	xScroll = window.innerWidth + window.scrollMaxX;
  	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
  	if(document.documentElement.clientWidth){
  		windowWidth = document.documentElement.clientWidth; 
  	} else {
  		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 = xScroll;		
  } else {
  	pageWidth = windowWidth;
  }
  //alert(ClassName);
  var idStyle=document.getElementById(ClassNameId);
  idStyle.style.height= pageHeight +'px';
  idStyle.style.width= pageWidth +'px';
  return [pageWidth,pageHeight];
}

function point_it(e, numberItem){
	var posx = 0;
	var posy = 0;
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) 	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY) 	{
		posx = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
		posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
	}

	//if(numberItem > 1){
	// document.getElementById("modal").style.marginTop = (posy-250)+'px' ;
	//}
  //else
  //{
	// document.getElementById("modal").style.marginTop = (posy-230)+'px' ;
	//}
	
	
 
	var modal = document.getElementById(OverlayDivId);
  var WidthX = modal.style.width.replace('px', '');
  var heightY = modal.style.height.replace('px', '');
  //var left = (screen.width/2)-(WidthX/2);
  //var top = (screen.height/2)-(heightY/2);
  //modal.style.marginTop = (posy-heightY)+'px' ;
  //modal.style.left = left;
  //modal.style.top = top;
  modal.style.marginTop = '0' ;
  modal.style.marginLeft = '0' ;
  showdeadcenterdiv(WidthX,heightY,OverlayDivId) 
}

	
	
function showdeadcenterdiv(Xwidth,Yheight,divid) 
  {
  // First, determine how much the visitor has scrolled
  
  var scrolledX, scrolledY;
  if( self.pageYoffset ) {
    scrolledX = self.pageXoffset;
    scrolledY = self.pageYoffset;
  } else if( document.documentElement && document.documentElement.scrollTop ) {
    scrolledX = document.documentElement.scrollLeft;
    scrolledY = document.documentElement.scrollTop;
  } else if( document.body ) {
    scrolledX = document.body.scrollLeft;
    scrolledY = document.body.scrollTop;
  }
  
  // Next, determine the coordinates of the center of browser's window
  
  var centerX, centerY;
  if( self.innerHeight ) {
    centerX = self.innerWidth;
    centerY = self.innerHeight;
  } else if( document.documentElement && document.documentElement.clientHeight ) {
    centerX = document.documentElement.clientWidth;
    centerY = document.documentElement.clientHeight;
  } else if( document.body ) {
    centerX = document.body.clientWidth;
    centerY = document.body.clientHeight;
  }
  
  // Xwidth is the width of the div, Yheight is the height of the
  // div passed as arguments to the function:
  var leftoffset = scrolledX + (centerX - Xwidth) / 2;
  var topoffset = scrolledY + (centerY - Yheight) / 2;
  // The initial width and height of the div can be set in the
  // style sheet with display:none; divid is passed as an argument to // the function
  var o=document.getElementById(divid);
  var r=o.style;
  r.position='absolute';
  r.top = topoffset + 'px';
  r.left = leftoffset + 'px';
  r.display = "block";
}



function setHeightWidthIframe() {
    var h = 0;
    var w = 0;
    if(document.all ) {
         h = parent.document.frames[IframeId].document.body.scrollHeight;
         h += 20;
         parent.document.all.OverLayIFrame.style.height = h + 'px';
         w = parent.document.frames[IframeId].document.body.scrollWidth;
         w += 20;
         parent.document.all.OverLayIFrame.style.width = w + 'px';
         
    } else if ( document.getElementById) {
         h = parent.document.getElementById(IframeId).contentDocument.height;
         h += 60;
         parent.document.getElementById(IframeId).style.height = h + 'px';
         w = parent.document.getElementById(IframeId).contentDocument.width;
         w += 60;
         parent.document.getElementById(IframeId).style.width = w + 'px';
    }
     parent.document.getElementById(OverlayDivId).style.height = h + 'px';
     parent.document.getElementById(OverlayDivId).style.width = w + 'px';
} 
 
