var ID;
var HOME='http://www.tweety-twello.nl/beheer';
//var CMSdiv = window.parent.CMSdiv;
var cmsDiv;
var muisX, muisY, e;

var isNN,isIE;

if (parseInt(navigator.appVersion.charAt(0))>=4) {
	isNN=(navigator.appName=="Netscape")?1:0;
	isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;
}

if(isNN) {
//	document.onmousemove = captureMousePosition;
	document.captureEvents(Event.MOUSEMOVE);
  document.onmousemove = captureMousePosition;
}

function captureMousePosition(e) {
		muisX= e.pageX;
		muisY= e.pageY;
}

/*
function showCMSdiv(id, location)
{
	//		var iFrm = window.parent.content.frameElement.contentWindow.event;
	cmsDiv = document.getElementById('CMSdiv');
	HideAllDivs()
	cmsDiv.style.left = event.clientX;
	cmsDiv.style.top = event.y;
	cmsDiv.style.visibility ="visible";
	cmsDiv.style.display ="inline";

//	alert(parent.frames[0].document.body.scrollTop);

var obj = document.body.scrollTop;
//var obj = parent.frames['content'].self.document.body.scrollTop ;
		var s = cmsDiv.style.top+"\n";
		for(var property in obj) {
			s += " | " + property + "=" + obj[property];
		}
		alert(obj);
	ID = id;
	LOCATION= location;
}
*/

function giveObjectInfo(cell) {
	var obj = cell;
	var s;
	for(var property in obj) {
			if(property!='outerHTML' || property!='innerHTML' ) {
					s += " | " + property + "=" + obj[property];
			}
	}
	alert(s);
	alert(cell.offsetLeft);
}

function showCMSdiv(id, location, e)
{
	if(isIE) {
		HideAllDivs('CMSdiv');
		document.getElementById('CMSdiv').style.left = event.clientX;
		document.getElementById('CMSdiv').style.top = event.clientY+document.body.scrollTop;
		document.getElementById('CMSdiv').style.visibility ="visible";
		document.getElementById('CMSdiv').style.display ="inline";
		ID = id;
		LOCATION= location;
	} else {
		HideAllDivs('CMSdiv');
		document.getElementById('CMSdiv').style.left = muisX;
		document.getElementById('CMSdiv').style.top = muisY;
		document.getElementById('CMSdiv').style.visibility ="visible";
		document.getElementById('CMSdiv').style.display ="inline";
		ID = id;
		LOCATION= location;
	}
	fadeIn(0, 'CMSdiv');
}

function fadeIn(o, divname) {
	op = o+10;
	div = divname;
	document.getElementById(divname).style.filter='progid:DXImageTransform.Microsoft.Alpha(opacity='+op+')';
	if(op!=100) {
		setTimeout("fadeIn(op, div)",20);
	}
}

function fadeOut(o, divname) {
	op = o-10;
	div = divname;
	document.getElementById(divname).style.filter='progid:DXImageTransform.Microsoft.Alpha(opacity='+op+')';
	if(op!=0) {
		setTimeout("fadeOut(op, div)",20);
	}else {
		cmsDiv = document.getElementById(divname);
		cmsDiv.style.visibility ="hidden";
		cmsDiv.style.display ="none";
	}
}

function HideAllDivs(divname) {
		cmsDiv = document.getElementById(divname);
		cmsDiv.style.visibility ="hidden";
		cmsDiv.style.display ="none";
}


function EditObject()
{
	var winprops = "width=550, height=600, location=no, menubar=no, resizable=no, scrollbars=no, status=no, toolbar=no";
 	window.open(HOME+"/edit.php?id="+ID+"&action=edit", "", winprops);
}

function moveObject()
{
		window.location.href= "?moveID="+ID;
}

function makeMove(location)
{
	var winprops = "width=200, height=100, location=no, menubar=no, resizable=no, scrollbars=no, status=no, toolbar=no";
 	window.open(HOME+"/process.php?location="+location+"&action=move", "newObject", winprops);
}

function newObject()
{
	var winprops = "width=550, height=500, location=no, menubar=no, resizable=no, scrollbars=no, status=no, toolbar=no";
 	window.open(HOME+"/edit.php?action=new"+"&location="+LOCATION, "", winprops);
}
function confirmDelete(type, id)
{
	if(type=="image") {
		var x = confirm('Weet u zeker dat u deze afbeelding ('+id+') wilt werwijderen?');
		if(x == true)	{
			deleteObject(type, id); //= "process.php?action=unbound&id="+ID;document.location.href = "process.php?action=delImg&id="+id;
		}
	} else if(type=="wObject") {
		var x = confirm('Weet u zeker dat u dit website-object uit de pagina wilt werwijderen?');
		if(x == true)	{
			deleteObject(type, ID);
		}
	}
}

function deleteObject(type, id) {
	var winprops = "width=350, height=150, location=no, menubar=no, resizable=no, scrollbars=yes, status=no, toolbar=no";
	if(type=="wObject") {
		window.open(HOME+"/process.php?action=unlink&id="+id, "Verwijderen", winprops);
	} else if(type=="image") {
		window.open(HOME+"/process.php?action=delImg&id="+id, "Verwijderen", winprops);
	}
}

function bound2(bound2wObjectID) {
	var winprops = "width=200, height=100, location=no, menubar=no, resizable=no, scrollbars=no, status=no, toolbar=no";
 	window.open(HOME+"/process.php?bound2ID="+bound2wObjectID+"&action=bound2", "newObject", winprops);
}

function setType(type)
{
	newType=type;
	switch(type)
	{
		case '1':
			document.getElementById('i').style.visibility='hidden';
			document.getElementById('i').style.display='none';
			break;
		case '2':
			document.getElementById('i').style.visibility='visible';
			document.getElementById('i').style.display='inline';
			break;
		case '3':
			document.getElementById('i').style.visibility='visible';
			document.getElementById('i').style.display='inline';
			break;
		case '4':
			document.getElementById('i').style.visibility='visible';
			document.getElementById('i').style.display='inline';
			break	;
		case '5':
			document.getElementById('i').style.visibility='visible';
			document.getElementById('i').style.display='inline';
			break;
		default:
			break;
	}
}


function editImage(image, dir)
{
	var winprops = "width=800, height=500, location=no, menubar=no, resizable=no, scrollbars=yes, status=no, toolbar=no";
	window.open(HOME+"/imageEditor/bewerkAfbeelding.php?image="+image+"&dir="+dir+"&first=true", "editimage", winprops);
}

function showImages()
{
	var winprops = "width=450, height=500, location=no, menubar=no, resizable=no, scrollbars=yes, status=no, toolbar=no";
 	window.open(HOME+"/images.php", "Kiesplaatje", winprops);
//	showModelessDialog("http://www.vanmourik-verfenwand.nl/previewimagedir.php?picture="+picture,window,"status:false;dialogWidth:475px;dialogHeight:700px");
}

function manageImages()
{
	var winprops = "width=450, height=500, location=no, menubar=no, resizable=no, scrollbars=yes, status=no, toolbar=no";
 	window.open(HOME+"/manage_images.php", "Beheerplaatjes", winprops);
//	showModelessDialog("http://www.vanmourik-verfenwand.nl/previewimagedir.php?picture="+picture,window,"status:false;dialogWidth:475px;dialogHeight:700px");
}

function showWaitWindow()
{
	window.showModalDialog(HOME+"/waitwindow.php", 'Een ongeblik gedult aub...', 'dialogHeight:150px; dialogWidth:350px; dialogTop: px; dialogLeft: px; edge: Sunken; center: Yes; help: No; resizable: Yes; status: No; scroll: No;');
}

function logout() {
	var winprops = "width=200, height=100, location=no, menubar=no, resizable=no, scrollbars=no, status=no, toolbar=no";
 	window.open(HOME+"/process.php?action=logout", "newObject", winprops);
}

function showPano(img)
{
//	document.getElementById('mov').stopAutoPan();
	var winprops = "width=420, height=320, location=no, menubar=no, resizable=no, scrollbars=no, status=no, toolbar=no";
	window.open("http://www.hole-in1.nl/360/?movie="+img, "360_graden_panorama_foto", winprops);
}
