﻿
function popitup(url)
{
	newwindow=window.open(url,'_blank');
	if (window.focus) {newwindow.focus()}
	return false;
}

/***********************************************
* Drag and Drop Script: © Dynamic Drive (http://www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/

var dragobject={
z: 0, x: 0, y: 0, offsetx : null, offsety : null, targetobj : null, dragapproved : 0,
initialize:function(){
document.onmousedown=this.drag
document.onmouseup=function(){this.dragapproved=0}
},
drag:function(e){
var evtobj=window.event? window.event : e
this.targetobj=window.event? event.srcElement : e.target
if (this.targetobj.className=="adminArea"){
this.dragapproved=1
if (isNaN(parseInt(this.targetobj.style.left))){this.targetobj.style.left=0}
if (isNaN(parseInt(this.targetobj.style.top))){this.targetobj.style.top=0}
this.offsetx=parseInt(this.targetobj.style.left)
this.offsety=parseInt(this.targetobj.style.top)
this.x=evtobj.clientX
this.y=evtobj.clientY
if (evtobj.preventDefault)
evtobj.preventDefault()
document.onmousemove=dragobject.moveit
}
},
moveit:function(e){
var evtobj=window.event? window.event : e
if (this.dragapproved==1){
this.targetobj.style.left=this.offsetx+evtobj.clientX-this.x+"px"
this.targetobj.style.top=this.offsety+evtobj.clientY-this.y+"px"
return false
}
}
}

dragobject.initialize();

  function ShowAdminArea(area, iframeName, iframeSrc, width, height) {
 
    var dsocleft=findScrollX();
    var dsoctop=findScrollY();
    var windowHeight = document.documentElement.clientHeight;
    var windowWidth = document.documentElement.clientWidth;
       

    if (document.getElementById(area + 'Admin')) {
      
    var adminElt = document.getElementById(area+'Admin');
    adminElt.style.display='';
    adminElt.style.position='absolute';
    }
    
    if (width > windowWidth)
    {
      width = windowWidth-50;
    }
    if (height > windowHeight)
    {
      height = windowHeight-75;
    }
   
    adminElt.style.left = Math.max(dsocleft+(windowWidth-width)/2,0);
    adminElt.style.top = Math.max(dsoctop + (windowHeight-height)/2,0);
    
      
    adminElt.style.height = height;
    adminElt.style.width = width;
    adminElt.style.zIndex = 100;
      
    // run findPosX, Y to find the actual positoin, adjust again (to negative) if outside screen
    //alert(findPosX(document.getElementById(area + 'Admin'))+" "+ width);
    if (findPosX(document.getElementById(area + 'Admin'))+width > windowWidth)
    {
    
      adminElt.style.left = -(-(windowWidth-width)/2+findPosX(document.getElementById(area + 'Admin')))+(windowWidth-width)/2;
    }
    
    if (frames[iframeName]) {
      frames[iframeName].location = iframeSrc;
    }
    //alert(findPosX(document.getElementById(area + 'Admin')));
    return false;
  }
  
  function HideAdminArea(area, iframeName) {
    var adminElt = document.getElementById(area+'Admin');
    if (adminElt) {
      adminElt.style.display='none';
      
      if (document.forms[0]) document.forms[0].submit();
      else document.location.reload();

      frames[iframeName].location='LoadingItem.aspx';
    }
  }
  
   function ShowViewArea(area, iframeName, iframeSrc, width, height) {
    //alert('start');
    var dsocleft= findScrollX();
    var dsoctop=findScrollY();
    //alert(dsocleft);
    //alert(dsoctop);
    var windowHeight = document.documentElement.clientHeight;
    var windowWidth = document.documentElement.clientWidth;

    if (document.getElementById(area + 'Admin')) {
   
      var adminElt = document.getElementById(area+'Admin');
     
      adminElt.style.display='block';
      }
     
    if (width > windowWidth)
    {
      width = windowWidth-50;
    }
    if (height > windowHeight)
    {
      height = windowHeight-100;
    }
    
    adminElt.style.left = Math.max(dsocleft+(windowWidth-width)/2,0);
    adminElt.style.top =  Math.max(dsoctop + (windowHeight-height)/2,0);
    adminElt.style.width = width;
    adminElt.style.height = height;
    adminElt.style.zIndex = 100;
         
   // run findPosX, Y to find the actual positoin, adjust again (to negative) if outside screen
   // if (dsocleft+width > windowWidth)
   // {
   //   adminElt.style.left = -(windowWidth - dsocleft-width)/2;
   // }
     if (findPosX(document.getElementById(area + 'Admin'))+width > windowWidth)
    {
    
      adminElt.style.left = -(-(windowWidth-width)/2+findPosX(document.getElementById(area + 'Admin')))+(windowWidth-width)/2;
    }
    if (frames[iframeName]) {
    //alert('setting frame location to ['+iframeSrc+']');
      frames[iframeName].location = iframeSrc;
    }
    return false;
  }
  
 function ShowParentViewArea(area, iframeName, iframeSrc, width, height) {
   //alert('start');
   //alert(iframeSrc);
    var dsocleft= findScrollX();
    var dsoctop=findScrollY();
    //alert(dsocleft);
    //alert(dsoctop);
    var windowHeight = parent.document.documentElement.clientHeight;
    var windowWidth = parent.document.documentElement.clientWidth;

    if (parent.document.getElementById(area + 'Admin')) {
   
      var adminElt = parent.document.getElementById(area+'Admin');
     
      adminElt.style.display='block';
      }
     
    if (width > windowWidth)
    {
      width = windowWidth-50;
    }
    if (height > windowHeight)
    {
      height = windowHeight-100;
    }
    
    adminElt.style.left = Math.max(dsocleft+(windowWidth-width)/2,0)-400;
    adminElt.style.top =  Math.max(dsoctop + (windowHeight-height)/2,0);
    adminElt.style.width = width;
    adminElt.style.height = height;
    adminElt.style.zIndex = 100;
         
   // run findPosX, Y to find the actual positoin, adjust again (to negative) if outside screen
   // if (dsocleft+width > windowWidth)
   // {
   //   adminElt.style.left = -(windowWidth - dsocleft-width)/2;
   // }
     if (findPosX(parent.document.getElementById(area + 'Admin'))+width > windowWidth)
    {
      adminElt.style.left = -(-(windowWidth-width)/2+findPosX(parent.document.getElementById(area + 'Admin')))+(windowWidth-width)/2;
    }
    //alert(iframeName);
    //alert(frames[iframeName]);
    if (parent.frames[iframeName]) {
      //alert('setting frame location to ['+iframeSrc+']');
      parent.frames[iframeName].location = iframeSrc;
    }
    return false;
  }
  function HideViewArea(area, iframeName, reload) {
    var adminElt = document.getElementById(area+'Admin');
    if (adminElt)
      adminElt.style.display='none';
    
    if (reload) {
     if (document.forms[0]) document.forms[0].submit();
      else document.location.reload();
    }

    frames[iframeName].location='LoadingItem.aspx';
  }
    
  
  function findScrollX() {
    var iebody=(document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body;

    return document.all? iebody.scrollLeft : pageXOffset;
  }
  
  function findScrollY() {
    var iebody=(document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body;

    return document.all? iebody.scrollTop : pageYOffset;
  }
  
  function findPosX(obj)
  {
	  var curleft = 0;
	  if (obj) {
	    if (obj.offsetParent)
	    {
		    while (obj.offsetParent)
		    {
			    curleft += obj.offsetLeft
			    obj = obj.offsetParent;
		    }
	    }
	    else if (obj.x)
		    curleft += obj.x;
		}
		
	  return curleft;
  }

  function findPosY(obj)
  {
	  var curtop = 0;
	  if (obj) {
      if (obj.offsetParent)
	    {
		    while (obj.offsetParent)
		    {
			    curtop += obj.offsetTop
			    obj = obj.offsetParent;
		    }
	    }
	    else if (obj.y)
		    curtop += obj.y;
		}

    return curtop;
}