// http://www.katipo.co.nz/clients/helpdesk/javascript/js-messenger.html
// 16 Oct 2008
//
// messenger(width,height,message,bgcolor,action,options)
// simple_messenger(size,message,bgcolor)
// url_messenger(width,height,url,options)
//
// <a href='#' onclick="messenger(120,130,'This is <b>messenger</b>','#668899'); return false">
// <a href="#" onclick="messenger(130,150,'Search for <br><input type=text size=10 name=q>','http://www.google.com/search'); return false"> 
//
// <a href='#' onclick="messenger(120,200,'<h1>Non Resizable</h1><p>with scrollbars.','#ffff99','options:scrollbars'); return false">
//
// <a href='#' onclick="messenger(280,110,'<h1>Resizable</h1><p>with location bars.','#ffff99','options:location,resizable'); return false"> 
//
// Example:  <a href=\"javascript:messenger(430,300,'$cdescription','#FFF5F5','options:scrollbars')\">$cnumm</a>
//
// --------------------------------------
//
// open in a popup window (this is where it could be modified to allow ALL popup params to be set in the link addition page and passed here to give more variety to popup windows) 
// $txt = "<a href=\"#\" onclick=\"javascript: window.open('". $mitem->link ."', '/* window title here */', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=auto,resizable=no,width=780,height=550'); return false\" class=\"$menuclass\" ". $id .">". $mitem->name ."</a>\n"; 
//

function simple_messenger(size,etc, bgcolor){
 if (!bgcolor) bgcolor='#ffffff';	
 win=window.open("","mess","height="+size+",width="+size+",screenX=200,screenY=50,top=50,left=200");
 win.focus();
 win.document.close();
 win.document.write("<body bgcolor='" + bgcolor + "'><p>");
 win.document.write(etc);
// win.document.write("<center><form><input type=button onclick='self.close()' value=OK></form></center>");
 win.document.write("</body></html>");
}



function messenger(X,Y,etc,bgcolor,action, options){
	random=Math.round(Math.random()*10000)
	if (!self.name) self.name='window'+ random
	if (!options){
		options='options:resizable';
		if(action && action.substring(0,6)=='option'){
			options=action;
			action=0;
		}
		if(bgcolor && bgcolor.substring(0,6)=='option'){
			options=bgcolor;
			bgcolor=0;	
		}
	}
	if (!action && bgcolor && bgcolor.charAt(0)!='#'){action=bgcolor;bgcolor='#ffffff'}
	if (!bgcolor) bgcolor='#ffffff';	
	win=window.open("","w"+random,"height="+Y+",width="+X+","+options.substring(8)+",left=150,top=50,screenX=150,screenY=50");
	if (!win.opener) win.opener = self;
	win.document.writeln("<html><body bgcolor='"+ bgcolor +"' text='#000000'><form method=get name=fork target='" + window.name + "' action='" + action + "'><font size=3><p><br>")
	win.document.writeln(etc);
	if (action){
		win.document.write("<center><p><input type=button onclick='fork.submit();self.close()' value=' OK '>&nbsp;")
	 	win.document.writeln("<input type=button onclick='self.close()' value=cancel>");
	}
//	else {win.document.writeln("<center><p><input type=button onclick='self.close()' value=' OK '>")}
	else {win.document.writeln("<center>")}
	win.document.writeln("</center></font></form></body></html>");
	win.document.close();

}



function url_messenger(X,Y,url,options){
	random=Math.round(Math.random()*10000)
	if (!self.name) self.name='window'+ random
	if (!options || options != options.toString){
		options='options:resizable';
	}
	win1=window.open(url,"w"+random,"height="+Y+",width="+X+","+options.substring(8)+",left=150,top=50,screenX=150,screenY=50");
	if (!win1.opener) win1.opener = self;

}



