//**********************************************
// Advanced HTML Editor Image Gallery AddOn
// Version: 1.02
//
// (c) 2004 DMXzone.com
// by George Petrov, Camillah Ringes
//
//**********************************************
if (!document.getElementById && !document.all && !document.layers)event = "";
var dmxTT;
var ImagePreload;
var dmxTT_width;
var dmxTT_OffX;
var dmxTT_OffY;
var dmxTT_FollowMouse = true;
var contentList = new Array();
var winList = new Array();
var OnTop = true;
var queryString = location.search.substring(1,location.search.length);
var view = '';
	
if (document.images && ImagePreload) {
	var imageList = new Array();
	for (var i=0; i<contentList.length; i++) {
  	imageList[i] = new Image();
		imageList[i].src = contentList[i][0];
  }
}
function dmxTT_get(dmx_event,id) {
	if (!dmxTT) return;
	var content = dmxTT_config(id);
	dmxTT_exec(dmx_event,content);
}

function dmxTT_config(num) {
	var content = "";
	if (document.layers) {
		// outer table for border
		content += '<table class="dmxTT_border" cellspacing="0"><tr><td>';
		// for background color and padding
		content += '<table class="dmxTT_bgcolor" cellspacing="0"><tr><td>';
		content += '<table class="dmxTT_content">';
		if (contentList[num][0]) content += '<tr><td><img class="dmxTT_img" src="' + contentList[num][0] + '"></td></tr>';
		content += '<tr><td valign="top"><span class="dmxTT_content">' + contentList[num][1] + '</span></td></tr></table>' + '</td></tr></table></td></tr></table>';
	} else {
		content +=  '<div class="dmxTT_content">';
		if (contentList[num][0]) content +=  '<img class="dmxTT_img" src="' + contentList[num][0] + '<br />';
		content += contentList[num][1] + '</div>';
	}
	return content;
}

function dmx_insert(filepath,wdth,hght) {	
	window.opener.document.getElementById('txtFileName').value= filepath;
	window.opener.document.getElementById('txtHeight').value= hght;
	window.opener.document.getElementById('txtWidth').value= wdth;
	window.opener.fIs_libWin();
	window.opener.updateImage();
}

function dmx_view(wdth,hght,filepath,filename) {
	if(view) view.close();
	if(wdth>94 || hght>94) {
		leftPos = (screen.width) ? (screen.width - wdth)/2 : 0;
		topPos = (screen.height) ? (screen.height - hght)/2 : 0;
		settings ='height='+ hght +',width='+ wdth +',top='+ topPos +',left='+ leftPos +',directories=no,location=no,menubar=no,resizable=no,scrollbars=no,scrollbars=no,titelbar=no,toolbar=no';
		path = "view_image.php?viewimg="+filepath+"&name="+filename+"&hght="+hght+"&wdth="+wdth;
		view = window.open(path, 'bigImg', settings);
	}
}

function ChangeOnTop() {
	if (OnTop) OnTop = false;
	else if (!OnTop) {
		OnTop = true;
		self.focus();
		}
}

function FocusMe() {
	if (OnTop) setTimeout("self.focus()",600);
}


function initLib() {
	var body = document.body;
	var xwin = getWinWidth();
	var ywin = getWinHeight();
	var ybody = body.offsetHeight;
	var xbody = body.offsetWidth;
	if (!document.all) {
		window.innerHeight = ybody;
		window.innerWidth = xbody;
	} else {
		if (xbody + 10 < xwin) {
			xbody = xwin;
		} else {
			xbody += 10;
		}
		window.resizeTo(xbody, ybody + 35 )
	}
}
