
// ----------------------- popin manager class -------------------------------
// class instance is created at the bottom of this page

function popinmanagerclass()
{
    this.mousex = 100 
	this.mousey = 100 
	this.lastclickid = -1
	this.lastChooserType = ""
	this.usedimming = true;
	this.init()
}

popinmanagerclass.prototype.init = function()
{
    var sty = 'z-index:1023;position:absolute;left:0;top:0;height:100%;width:100%;background-color:white;visibility: hidden;filter: alpha(opacity=40);-moz-opacity:.40;opacity:.40;';
    var str = '<div name="popinmanagerdimmerdiv" id="popinmanagerdimmerdiv" style="' + sty + '" onclick="popinmanager.hidepopin();"></div>';
    sty = 'z-index:1024;position:absolute;top:100px;left:100px;width:500px;height:280px;visibility:hidden;background-color:white;border-top:1px solid #333333;border-left:1px solid #333333;border-right:2px solid #333333;border-bottom:2px solid #333333;';
    str += '<iframe style="' + sty + '" id="popinmanageriframe" name="popiniframe" scrolling="no" src="/sharedincludes/class_popinmanagerEmpty.htm" noresize frameborder="0"></iframe>';
    document.write (str)
}

popinmanagerclass.prototype.empty = function() {}

popinmanagerclass.prototype.setusedimming = function(booval){this.usedimming = booval; }

popinmanagerclass.prototype.setxy = function(e) {
	if (document.all) { // grab the x-y pos.s if browser is IE
		mousex = event.clientX + document.body.scrollLeft
		mousey = event.clientY + document.body.scrollTop
	} else {  // grab the x-y pos.s if browser is NS
		mousex = e.pageX
		mousey = e.pageY
	}  
	// catch possible negative values in NS4
	if (mousex < 0){mousex = 0}
	if (mousey < 0){mousey = 0}  
	return true
}

//showpopin	. call x/y with : -1 (centered) 'm' (centered on mousepos) , anyval (specific location)
popinmanagerclass.prototype.showpopin = function(url, x, y, w, h) {
    var sty = document.getElementById('popinmanageriframe').style
    var wh = this.getwidthheightarray()
    var clientwh = this.getclientwidthheightarray()
    var lt = this.getscrolllefttoparray()
    if (x == 'm')
    { x = mousex - (w / 2) }
    else
    { if (x == -1) { x = (clientwh[0] / 2) - (w / 2) + lt[0]; } }

    if (y == 'm')
    { y = mousey - (h / 2) }
    else
    { if (y == -1) { y = (clientwh[1] / 2) - (h / 2) + lt[1]; } }


    document.getElementById('popinmanageriframe').src = url
    sty.left = x + 'px';
    sty.top = y + 'px';
    sty.width = w + 'px';
    sty.height = h + 'px';
    sty.visibility = 'visible';

    if (this.usedimming) {
        var dimsty = document.getElementById('popinmanagerdimmerdiv').style
        dimsty.width = wh[0] + 'px';
        dimsty.height = wh[1] + 'px';
        dimsty.visibility = 'visible';
    }
    if (FLVhideall) { FLVhideall() } //hide flv below - to avoid bleeding
}



//resizepopin	    
popinmanagerclass.prototype.resizepopin = function(w,h)
{
   
    if (document.getElementById('popinmanageriframe'))
    {
        var sty = document.getElementById('popinmanageriframe').style;
        sty.width = w + 'px';
        sty.height = h + 'px';
        //alert('w ' + w + ' after ' + document.getElementById('popinmanageriframe').style.width)
    }
}

popinmanagerclass.prototype.movepopinto = function(w, h) {
    if (document.getElementById('popinmanageriframe')) {
        var sty = document.getElementById('popinmanageriframe').style;
        sty.left = w + 'px';
        sty.top = h + 'px';
    }
}

popinmanagerclass.prototype.getpopinleft = function() {
    if (document.getElementById('popinmanageriframe')) {
        return parseInt(document.getElementById('popinmanageriframe').style.left);
    }
}

popinmanagerclass.prototype.getpopintop = function() {
    if (document.getElementById('popinmanageriframe')) {
        return parseInt(document.getElementById('popinmanageriframe').style.top);
    }
}

//hidepopin
popinmanagerclass.prototype.hidepopin = function() {
    document.getElementById('popinmanagerdimmerdiv').style.visibility = 'hidden';
    document.getElementById('popinmanageriframe').src = '/sharedincludes/class_popinmanagerEmpty.htm';
    document.getElementById('popinmanageriframe').style.visibility = 'hidden';
    if (FLVshowall) { FLVshowall() } //show flv below again - hidden on showpopin to avoid bleeding
}

popinmanagerclass.prototype.popinishidden = function() {
    return (document.getElementById('popinmanageriframe').style.visibility == 'hidden') ? true : false;
}

popinmanagerclass.prototype.getwidthheightarray = function () {
  var x = 0, y = 0;
  if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {
    //DOM compliant
     x = document.body.scrollWidth
     y = document.body.scrollHeight
  } else if( document.documentElement && ( document.documentElement.scrollWidth || document.documentElement.scrollHeight ) ) {
    //IE6 standards compliant mode
    y = document.documentElement.scrollHeight;
    x = document.documentElement.scrollWidth;
  }
  return [ x, y ];
}

popinmanagerclass.prototype.getclientwidthheightarray = function()
{
  var w = -1, h = -1;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    w = window.innerWidth;
    h = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    w = document.documentElement.clientWidth;
    h = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    w = document.body.clientWidth;
    h = document.body.clientHeight;
  }
  return [ w , h ]
}

popinmanagerclass.prototype.getscrolllefttoparray = function () {
  var x = 0, y = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    y = window.pageYOffset;
    x = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    y = document.body.scrollTop;
    x = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    y = document.documentElement.scrollTop;
    x = document.documentElement.scrollLeft;
  }
  return [ x, y ];
}


//autocreate object - after declarations
var popinmanager = new popinmanagerclass()













