/**
* @developer:	Erik van der Veen
* @package:		CMSe
* @copyright:	(C) 2006 Eforceone.nl
*/

// JavaScript Document for CMSe Administration
var numboxes = 0;
var numdisabledObjs = 0;
var disabledObjs = new Array();

window.onload=function()
{
	initWindowColumns();
}

function minimizeBox (boxnumber)
{
	var obj = document.getElementById('windowContent' + boxnumber);
	var imgobj = document.getElementById('windowMinimizeImg' + boxnumber);
	
	if (obj.style.display == 'none')
	{
		obj.style.display = '';
		imgobj.src = site_url + 'admin/images/minimize.gif';
		imgobj.alt = txtstr[0];
	}else
	{
		obj.style.display = 'none';
		imgobj.src = site_url + 'admin/images/maximize.gif';
		imgobj.alt = txtstr[1];
	}
}

function Disable(obj)
{
	disabledObjs[numdisabledObjs] = obj;
	obj.disabled = true;
	numdisabledObjs ++;
	return true;
}

function UndoDisable()
{
	for (i = 0; i < numdisabledObjs; i++)
	{
		disabledObjs[i].disabled = false;
	}
}

function initWindowColumns()
{	
	if (document.getElementById('windowContainerIcons') != null)
	{
		sections = ['windowContainerIcons'];

		Sortable.create('windowContainerIcons',{tag:'div',overlap:'horizontal',containment: sections,only:'windowFrame',handle:'windowTitlebar',constraint:false,onUpdate:function(){SavePosition()}});		
	}
	
	if (document.getElementById('windowContainer3') != null)
	{
		sections = ['windowContainer1', 'windowContainer2', 'windowContainer3'];
	
		Sortable.create('windowContainer1',{tag:'div',dropOnEmpty: true, containment: sections,only:'windowFrame',handle:'windowTitlebar',constraint:false});		
		Sortable.create('windowContainer2',{tag:'div',dropOnEmpty: true, containment: sections,only:'windowFrame',handle:'windowTitlebar',constraint:false});		
		Sortable.create('windowContainer3',{tag:'div',dropOnEmpty: true, containment: sections,only:'windowFrame',handle:'windowTitlebar',constraint:false});
	}
	else if (document.getElementById('windowContainer2') != null)
	{
		sections = ['windowContainer1', 'windowContainer2', 'windowContainer3'];
	
		Sortable.create('windowContainer1',{tag:'div',dropOnEmpty: true, containment: sections,only:'windowFrame',handle:'windowTitlebar',constraint:false});		
		Sortable.create('windowContainer2',{tag:'div',dropOnEmpty: true, containment: sections,only:'windowFrame',handle:'windowTitlebar',constraint:false});
	}
	else if (document.getElementById('windowContainer1') != null)
	{
		sections = ['windowContainer1'];

		Sortable.create('windowContainer1',{tag:'div',dropOnEmpty: true, containment: sections,only:'windowFrame',handle:'windowTitlebar',constraint:false});		
	}
	
	if (document.getElementById('menuBar') != null)
	{
		var dragmenu = new Draggable('menuBar');
		dragmenu.destroy();
	}
}

function popUp(URL, id, width, height)
{
	day = new Date();
	id += day.getTime();
	
	width = (width == null) ? width = "520" : width;
	height = (height == null) ? height = "600" : height;
	
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,status=1,menubar=0,resizable=1,dialog=1,modal=1,width=" + width + ",height=" + height + ",left = 100,top = 100');");
};


var errFunc = function(t)
{
	alert(txtstr[7] + ' ' + t.status + ' - ' + t.statusText + '\n' + txtstr[8]);
};

/*  -= FLASH OBJECT ACTIVATION =-  */

function CreateControl(DivID, MIMETYPE, ObjectID,
                       WIDTH, HEIGHT, URL, BGCOLOR)
{	
  var d = document.getElementById(DivID);
  d.innerHTML = 
    '<object type="' + MIMETYPE + '" data="' + URL + '" style="width: ' + WIDTH + 'px; height: ' + HEIGHT + 'px;" id="' + ObjectID + '">' +
	'<param name="allowScriptAccess" value="sameDomain" />'+
	'<param name="movie" value="' + URL + '" />' +
    '<param name="quality" value="high" />' +
    '<param name="bgcolor" value="' + BGCOLOR + '" />' +
    '<param name="menu" value="false" />' +
	'<param name="wmode" value="transparent" />' +
    '<'+ '/object>';
};

function PrintEmail(name, domain, tld, href)
{
	if (href != '')
	{
		if (href == 'mailto')
		{
			return '<a href="mailto:' + name + '@' + domain + '.' + tld + '">' + name + '@' + domain + '.' + tld + '</a>';
		}
		else
		{
			return '<a href="' + href + '">' + name + '@' + domain + '.' + tld + '</a>';
		};
	}
	else
	{
		return name + '@' + domain + '.' + tld;	
	}
};
