	
	function centerPop(url,name,width,height,scroll){
		var x = (screen.availWidth - width)/2;
		var y = (screen.availHeight - height)/2;
		scroll = (scroll)?'yes':'no';
		popper = window.open(url,name,'toolbar=no,location=no,status=no,menubar=no,scrollbars='+
					scroll+',resizable=no,width='+width+',height='+
					height+',screenX='+x+',screenY='+y+',top='+y+',left='+x);
	
		//setTimeout('popper.focus()', 250);
		// setTimeout('self.close()', 5000);
		
		return popper;
	}
	
	function centerPopModal(url,name,width,height,scroll){
		var x = (screen.availWidth - width)/2;
		var y = (screen.availHeight - height)/2;
		scroll = (scroll)?'yes':'no';
		popper = window.showModalDialog(url,name,'toolbar=no,location=no,status=no,menubar=no,scrollbars='+
					scroll+',resizable=no,width='+width+',height='+
					height+',screenX='+x+',screenY='+y+',top='+y+',left='+x);
	
		//setTimeout('popper.focus()', 250);
		// setTimeout('self.close()', 5000);
	}

	function findCenterScreen(w, h)
	{
		var x = (screen.availWidth - w)/2;
		var y = (screen.availHeight - h)/2;

		return [ x, y ];
	}

	
	function showHelp(name)
	{
		centerPop('/help/topic/name/' + name, 'help', '535', '600', 'yes');
	}
	
	function openPMB(url)
	{
		var uniqueName = 'pmb_';
		centerPop(url, uniqueName, '535', '650', 'yes');
	}
	
	
	function cleanUpUrl(obj)
	{
		if(! obj.value.match(/^https?:\/\//i) )
		{
			obj.value = 'http://' + obj.value;
		}
	}
	
	function textCounter(field, countfield, maxlimit)
	{
		if (field.value.length > maxlimit) // if too long...trim it!
			field.value = field.value.substring(0, maxlimit);
			// otherwise, update 'characters left' counter
		else 
			countfield.innerHTML = maxlimit - field.value.length;
	}
	
	function sizeIFrame(helpFrame) {
	// var helpFrame = jQuery("#");
		var innerDoc = (helpFrame.get(0).contentDocument) ? helpFrame.get(0).contentDocument : helpFrame.get(0).contentWindow.document;
		helpFrame.height(innerDoc.body.scrollHeight + 35);
	}
	
	function showHideDivByCheck(obj, divName)
	{
		var div = $('#' + divName);
		
		if(obj.checked)
		{
			div.show();
		}
		else
		{
			div.hide();
		}
	}
	
		
//	function doIframe(){
//		o = document.getElementsByTagName('iframe');
//		for(i=0;i<o.length;i++){
//			if (/\bautoHeight\b/.test(o[i].className)){
//				setHeight(o[i]);
//				addEvent(o[i],'load', doIframe);
//			}
//		}
//	}
//	
	function setHeight(e){
		//alert(e.height());
		//return;
		if(e[0].contentDocument){
			// alert('c');
			e.height(e[0].contentDocument.body.offsetHeight + 35);
			//e.height = e.contentDocument.body.offsetHeight + 35;
			// alert(e.height());
			// alert(e.contentDocument.body.offsetHeight);
			//e.height = e.contentDocument.body.offsetHeight + 35;
			//alert(e.contentDocument.body.offsetHeight);
		} else {
			alert('ignored, for now');
			// e.height = e.contentWindow.document.body.scrollHeight;
		}
	}
