/**

   © 2006 Copyright A-Vision

**/


/**

   Some dummy function (if you need a function but not really)

**/
function dummy()
{
}

/*
 Find the absolute Left position of an object
*/
function findPosX(obj)
{
 var curleft = 0;
 if (obj.offsetParent) {
  while (obj.offsetParent) {
   curleft += obj.offsetLeft;
   curleft -= obj.scrollLeft;
	 obj = obj.offsetParent;
	}
 }
 else if (obj.x) 
  curleft += obj.x;
 return curleft;
}
/*
 Find the absolute Top position of an object
*/
function findPosY(obj)
{
 var curtop = 0;
 if (obj.offsetParent) {
  while (obj.offsetParent) {
	 curtop += obj.offsetTop;
	 curtop -= obj.scrollTop;
	 obj = obj.offsetParent;
	}
 }
 else if (obj.y)
  curtop += obj.y;
 return curtop;
}

/**

   This could be a replacement of alert and confirm

**/
function MsgOpen( myHeader, myMessage, myColor, myFunction)
{
 normalMsg = false;
 if ( document.frames[0]) {
//  normalMsg = ie;
 }
 if ( !normalMsg) {
  var re= /<\S[^>]*>/g; // Remove all HTML tags
  myMessage = myMessage.replace(re,""); 
  if ( typeof(myFunction)=='string') {
   if ( myMessage.indexOf("?") >= 0) {
    if ( confirm( myMessage)) {
     eval( myFunction);
    }
   }
   else {
    alert( myMessage);
    eval(myFunction);
   }
  }
  else {
   alert( myMessage);
  }
  return;
 }
}

/**

   Open an image in a separate window

**/
function viewimage( image)
{
 pic = image.src
 window.open("viewimage.php?name="+escape(pic)+"",null, "width=665,height=515,directories=no,location=no,resizable=yes");
}

/**

   Shows help information

**/
function cmsHelp( helpCode)
{
 width = 500;
 height = 400;

 if ( op) {
  window.open("helpinfo.php?code="+helpCode,null,"width="+width+",height="+height+",directories=no,resizable=yes,toolbar=no,location=no,menubar=no,scrollbars=no,status=no");
  return;
 }

 helpclose();
 iframe = top.document.createElement("iframe");
 iframe.frameBorder = 0;
 iframe.style.position = "absolute";
 iframe.style.width = width+"px";
 iframe.style.height = height+"px";
 iframe.style.top = eval( (top.document.body.offsetHeight-height)/2) + "px";
 iframe.style.left = eval( (top.document.body.offsetWidth-width)/2) + "px";
 iframe.style.border = "1px solid navy";
 iframe.style.borderTop = "20px solid navy";
 iframe.src = "helpinfo.php?code="+helpCode;
 iframe.scrolling = "no";
// iframe.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=95)";
 iframe.id = "helpinfoframe";

 shadow = top.document.createElement("div");
 shadow.style.position = "absolute";
 shadow.style.width = width+"px";
 shadow.style.height = eval(height+20)+"px";
 shadow.style.top = eval( (top.document.body.offsetHeight-height)/2 +10) + "px";
 shadow.style.left = eval( (top.document.body.offsetWidth-width)/2 +10) + "px";
 shadow.style.background = "#888";
 shadow.style.borderTop = "20px solid black";
 shadow.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=80)";
 shadow.id = "helpinfoshadow";

 top.document.body.appendChild( shadow);
 top.document.body.appendChild( iframe);
}
function helpclose()
{
 shadow = top.document.getElementById("helpinfoshadow");
 if ( shadow) {
  top.document.body.removeChild( shadow);
 }
 iframe = top.document.getElementById("helpinfoframe");
 if ( iframe) {
  top.document.body.removeChild( iframe);
 }
}

/**

   Shows help information

**/
function cmsInfo( objInfo)
{
 width=125;

 if (( objInfo.title != "")) {
//  frameId = self.name;
//  frameTop = findPosY( parent.document.getElementById(frameId));
//  frameLeft = findPosX( parent.document.getElementById(frameId));
  frameTop = 0;
  frameLeft = 0;

  div = document.createElement('DIV');
  created = new Date();
  createdID = created.getHours()+""+created.getMinutes()+""+created.getSeconds()+"_"+created.getMilliseconds();
  objInfo.infoID = "info_"+createdID;
  div.id = objInfo.infoID;
  div.innerHTML = "<div style='font-size:10px;font-family:sans-serif;text-align:justify;padding:5px;'>"+objInfo.title+"</div>";

  t = frameTop + findPosY( objInfo) + 13;
  if ( t < 5) {
   t = 5;
  }
  l = frameLeft + findPosX( objInfo) - width - 5;
  if ( l < 5) {
   l = frameLeft + findPosX( objInfo) + objInfo.offsetWidth + 5;
  }

  div.style.position = "absolute";
//  div.style.height = height+"px"; // Do it automatically
  div.style.width = width+"px";
  div.style.top = t+"px";
  div.style.left = l+"px";
  div.style.backgroundColor = "#ffa";
  div.style.border = "1px solid navy";
  div.style.cursor = "default";
  div.style.zIndex = 9999;
  div.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=93)";
  div.onclick = function() { cmsInfoOff( this.id); };
  div.onmouseover = function() { cmsInfoOff( this.id); };
  div.onmouseout = function() { cmsInfoOff( this.id); };
  div.fromObject = objInfo;

  document.body.appendChild( div);

  objInfo.title = "";
 }
 else {
  cmsInfoOff( objInfo.infoID);
 }
}
function cmsInfoOff( objInfoID)
{
 div = document.getElementById( objInfoID);
 if ( div) {
  if ( div.fromObject) {
   var re= /<\S[^>]*>/g; 
   div.fromObject.title = div.innerHTML.replace(re,"");
   div.fromObject = null;
  }
  document.body.removeChild( div);
 }
}

/**

   Shows save box

**/
function cmsSave( extraText)
{
 width=200;

 if ( extraText != "") {
  extraText = "<br>"+extraText;

  div = top.document.createElement('DIV');
  div.id = "_savebox";
  div.innerHTML = "<div style='font-size:12px;font-family:sans-serif;text-align:justify;padding:5px;text-align:center;'><b>SAVING</b>"+extraText+"</div>";

  t = top.document.body.offsetHeight/2;
  l = (top.document.body.offsetWidth-width)/2;

  div.style.position = "absolute";
//  div.style.height = height+"px"; // Do it automatically
  div.style.width = width+"px";
  div.style.top = t+"px";
  div.style.left = l+"px";
  div.style.backgroundColor = "#afa";
  div.style.border = "1px solid #484";
  div.style.cursor = "default";
  div.style.zIndex = 9999;
  div.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=80)";
  div.onclick = function() { cmsSave(""); };

  top.document.body.appendChild( div);
 }
 else {
  div = top.document.getElementById("_savebox");
  if ( div) {
   top.document.body.removeChild( div);
  }
 }
}
