function popupImage(imageID,colwidth) {
	windowwidth = 760;
	windowheight = 520;	
	var left = (window.screen.availWidth - windowwidth)/2;
	var top = (window.screen.availHeight - windowheight)/2;
	popupimage = window.open('/cms/_pages/popupimage.php?id='+imageID,'popupimage','left=' + left + ',top=' + top + ',width='+ windowwidth + ',height=' + windowheight + ',status=0,menubar=1');
	popupimage.focus();
}


function galleryFullsizeImage(pluginTreeID,size,legendextraspace,legendposition,number,cellTreeID) {

	var windowWidth = size + 25;
	var windowHeight = Math.floor(size / 9 * 5) + 120;
	if (legendposition == 2) {
		windowHeight += legendextraspace;
	} else if (legendposition == 1) {
		windowWidth += legendextraspace;
	}
	var left = (window.screen.availWidth - windowWidth)/2;
	var top = (window.screen.availHeight - windowHeight)/2;
	var page = "/cms/_pages/imageGalleryFullsize.php?pluginTreeID="+pluginTreeID+"&cellTreeID="+cellTreeID+"&width="+windowWidth+"&height="+windowHeight+"&size="+size+"&number="+number;
	var name = "imagegallery"
	imagegallery = this.open(page, name, "height="+windowHeight+",width="+windowWidth+",left="+left+",top="+top+",status=no,toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no");
	imagegallery.focus();
}

function searchWindow(query) {
	var url = "/cms/_pages/search/index.php";
	if (query) url += "?query=" + query;
	var width = 600;
	var height = 400;
	var windowname = "search";
	var RandLinks = (window.screen.availWidth - width)/2;
	var RandOben = (window.screen.availHeight - height)/2;
	OpenWin = this.open(url, windowname, "left="+RandLinks+",top="+RandOben+",toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,height="+height+",width="+width);
	OpenWin.focus();
}

function printPage(sid,layoutwidth,querystring) {
	if(querystring == null) {
		var url = '/index.php?sid=' + sid + '&print=1';
	} else {
		var url = '/index.php?' + querystring + '&print=1';
	}
	var width = layoutwidth + 56;
	var height = 420;
	var windowname = "printpage";
	var RandLinks = (window.screen.availWidth - width)/2;
	var RandOben = (window.screen.availHeight - height)/2;
	OpenWin = this.open(url, windowname, "left="+RandLinks+",top="+RandOben+",toolbar=no,menubar=yes,location=no,scrollbars=yes,resizable=no,height="+height+",width="+width);
	OpenWin.focus();
}

function mnoGoSearch(query,width,height) {
	var url = "/functions/search/index.php?query="+query;
	if(width == null)
		var width = 610;
	if(height == null)
		var height = 480;
	var windowname = "mnoGoSearch";
	var RandLinks = (window.screen.availWidth - width)/2;
	var RandOben = (window.screen.availHeight - height)/2;
	OpenWin = this.open(url, windowname, "left="+RandLinks+",top="+RandOben+",toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,height="+height+",width="+width);
	OpenWin.focus();		
}

function fieldvalidation(fieldid,fieldvalue,validationstring,message) {
	var err = false;
	if(fieldvalue != "") {
		matches = validationstring.exec(fieldvalue);
		if(matches != null) {
			if(matches[0] != fieldvalue)
				err = true;
		} else {
			err = true;
		}
	}

	if(err == true) {
		document.getElementById('fieldvalues[f'+fieldid+']').className = 'forms formserror';
	} else {
		document.getElementById('fieldvalues[f'+fieldid+']').className = 'forms';
	}
	
}