function javaPopupPrint( wParent, sPath, sName)
{				// 3 1/8"	= 300 px		(2*12px gap 	= 276px)
				// 2 7/16"= 226 px 		(2* 6px gap		= 214px)
				// 2 1/4"	= 216 px 		(2* 4px gap		= 208px)
				var xWidth=317; //plus 17 for scrollbars
				var xHeight=600;
				
        xTop = (screen.availHeight - xHeight) /2;
        xLeft = (screen.availWidth - xWidth ) /2;
        
        if (wParent==null){        
	        mywin=window.open( sPath, sName, 'width=' + xWidth + ',height=' + xHeight + ',top=' + xTop + ', left=' + xLeft + ',titlebar=no,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=no,directories=no,channelmode=no');
        } else {
	       	mywin=wParent.open( sPath, sName, 'width=' + xWidth + ',height=' + xHeight + ',top=' + xTop + ', left=' + xLeft + ',titlebar=no,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=no,directories=no,channelmode=no');
	    	}
	mywin.focus();
}

function javaPopupMain( wParent, sPath, sName, wndWidth, wndHeight, XScale, YScale, hasTitle, hasStatus)
{

        var xTop = ((YScale - 1) / (2 * YScale));
        var xLeft = ((XScale - 1) / (2 * XScale));
        
        xTop = (wndHeight * xTop);
        xLeft = (wndWidth * xLeft);
        
        var xWidth = (wndWidth / XScale);
        var xHeight = (wndHeight / YScale);
        if (wParent==null){        
	        mywin=window.open( sPath, sName, 'width=' + xWidth + ',height=' + xHeight + ',top=' + xTop + ', left=' + xLeft + ',status=' + hasStatus + ',toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,directories=no,channelmode=no');
        } else {
	       	mywin=wParent.open( sPath, sName, 'width=' + xWidth + ',height=' + xHeight + ',top=' + xTop + ', left=' + xLeft + ',status=' + hasStatus + ',toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,directories=no,channelmode=no');
	    	}
	mywin.focus();
	return mywin;
}

function javaPopupR( wParent, sPath, sName )
{
	return javaPopupMain( wParent, sPath, sName, screen.availWidth, screen.availHeight, 2, 2, 'no', 'no');
}
function javaPopup( wParent, sPath, sName )
{
	javaPopupMain( wParent, sPath, sName, screen.availWidth, screen.availHeight, 2, 2, 'no', 'no');
}
function javaPopupBig( wParent, sPath, sName )
{
	javaPopupMain( wParent, sPath, sName, screen.availWidth, screen.availHeight, 1.3, 1.3, 'no', 'no');
}
function javaFullWindow( sPath, sName )
{
	var pw=window.open( sPath, sName, 'width=' + (screen.availWidth-10) + ',height=' + (screen.availHeight-57) + ',top=' + 0 + ', left=' + 0 + ',status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,directories=no,channelmode=no');
	pw.focus();
}
function javaOpenWindow( sPath, sName ){
	var pw=window.open( sPath, sName );
}
function processPic( name ){
	//get button value...
	btn=window.document.getElementById(name+"_btn1");
	if (btn.value=="Upload"){
		javaPopup(window, 'man_upload.php?f='+encodeURIComponent(name), '_blank');
	} else {
		btn.value="Upload";
		
		processSaveUndo( 0, window, name );
		
		fld=window.document.getElementById(name);
		fld.value='';

		window.document.getElementById(name+"_icon").value='images/nopic.gif';
		window.document.getElementById(name+"_img").src='images/nopic.gif';
		window.document.getElementById(name+"_show").value='';
		var lnk=window.document.getElementById(name+"_lnk");
		lnk.href='';
		lnk.removeAttribute('href');
		window.document.getElementById(name+"_real").value='';
		window.document.getElementById(name+"_new").value='';
	}
	
}

function processSaveUndo ( dir, win, name ){
	var fld=win.document.getElementById(name);

	if (fld.value!==''){
		sep=String.fromCharCode(255);
	
		myundo=fld.value;
		fld.value='';
		fld=win.document.getElementById(name+"_icon");
		myundo=myundo+sep+fld.value;
		fld.value='images/nopic.gif';
		fld=win.document.getElementById(name+"_show");
		myundo=myundo+sep+fld.value;
		fld.value='';
		fld=win.document.getElementById(name+"_real");
		myundo=myundo+sep+fld.value;
		fld.value='';
		fld=win.document.getElementById(name+"_new");
		myundo=myundo+sep+fld.value;
		fld.value='';
		
		sundo=win.document.getElementById(name+"_undo");
		

		if (sundo.value==''){
			sundo.value=myundo;
		} else {
			sundos= sundo.value.split(String.fromCharCode(254));
			found=0;
			for (i=0; i<sundos.length; i++){
				if (sundos[i]==myundo){
					found=1;
					break;
				}
			}
			if (found==0){
				if (dir==0)
					sundos.unshift(myundo);
				else
					sundos[sundos.length]=myundo;
			}
			
			sundo.value=sundos.join(String.fromCharCode(254));			

		}
	}
		processUndoState(win, name);
}

function processUndo( name ){
	//see if undo is empty or not
	var sundo=window.document.getElementById(name+"_undo");
	if (sundo.value=='')
		return;
	processSaveUndo(1, window, name);
	
	// else...
	// check if we have this in undo
		sep=String.fromCharCode(255);

	sundos= sundo.value.split(String.fromCharCode(254));
	
	sarr = sundos.shift().split(sep);
	window.document.getElementById(name).value=sarr[0];
	window.document.getElementById(name+"_icon").value=sarr[1];
	window.document.getElementById(name+"_img").src=sarr[1];
	window.document.getElementById(name+"_show").value=sarr[2];

	var lnk=window.document.getElementById(name+"_lnk");
	lnk.href=sarr[2];
	if (sarr[2]=='') lnk.removeAttribute('href');
		
	window.document.getElementById(name+"_real").value=sarr[3];
	window.document.getElementById(name+"_new").value=sarr[4];
	
	if (sundos=='')
		sundo.value='';
	else
		sundo.value=sundos.join(String.fromCharCode(254));
		
	btn=window.document.getElementById(name+"_btn1");
	if (sarr[0]=='')
		btn.value='Upload';		
	else
		btn.value='Delete';		

	processUndoState(window, name);
	
}

function processUndoState( win, name ){
	btn=win.document.getElementById(name+"_btn2");
	sundo=win.document.getElementById(name+"_undo");
	if (sundo.value=='')
		btn.disabled='disabled';		
	else
		btn.disabled='';		
}

function processUpload( win, name, fname, show, icon, real ){
	processSaveUndo(0, win, name);
	
	win.document.getElementById(name).value=fname;
	win.document.getElementById(name+'_icon').value=icon;
	win.document.getElementById(name+'_img').src=icon;
	win.document.getElementById(name+'_show').value=show;
	win.document.getElementById(name+'_lnk').href=show;
	win.document.getElementById(name+'_real').value=real;
	win.document.getElementById(name+'_new').value=1;

	win.document.getElementById(name+'_btn1').value='Delete';	
}

function expandImg(win, id){
	img=win.document.getElementById('img'+id);

	if (img){
		if (img.style.position==''){
			img.style.position='relative';
			img.style.width='';
		} else {
			img.style.position='';
			img.style.width=(img.width/2)+'px';
		}

		img2=win.document.getElementById('imgz'+id);
		if (img2){
			if (img.style.position=='')
				img2.src='images/ftl_attach.gif';
			else 
				img2.src='images/ft_attach.gif';
		}

	}
}

function expandFixImg(win, id, rsrc){
	img=win.document.getElementById('img'+id);
	if (img){
		if (!img.complete){
			var img1=new Image();
			img1.src=rsrc;
			img.style.width=(img1.width / 2)+'px';
		}else
			img.style.width=(img.width / 2)+'px';
	}
}

function unsetOpener(){
	if (window.opener){
		if (! window.opener.closed) {
			//window.opener.blur();
			window.opener.focus();
		}
		window.opener=null;
	} 
}
function closeWindow(){
	if (window.onunload) window.onunload=null;
	unsetOpener();
	window.close();
}


function popCloseWindow(id, url){
	if (id){
		var wptimer=eval('window.wptimer_'+id);
		if (wptimer){
			clearTimeout(wptimer);
			wptimer=null;
		}
		var closeit=0;
		var wpclose=eval('window.wpclose_'+id);
		if (wpclose) {
			if (wpclose.closed) {
				window.blur();
				window.focus();
				closeit=1;
			}
			
			wpclose=null;
		}

		if (url!=''){
			/*if (window.wpdummy==1) {
				if (closeit){
					window.location.href=url;
					window.wpdummy=null;
				} else window.close();
			} else*/
			 if (closeit)
				javaPopup(window, url, '_blank');
		}
	}
}
function unloadWindow(url){
	if (window.onunload) window.onunload=null;
	if (window.opener){
		if (window.opener.closed){
			window.opener=null;
		} else {
			var id=Math.floor(Math.random()*10000000);
			eval('window.opener.wpclose_'+id+'=window;');
			wptimer=window.opener.setTimeout('popCloseWindow('+id+', "'+url+'")', 200);
			eval('window.opener.wptimer_'+id+'='+wptimer+';');
		}
	}
}

function executeOn( time, func ){
		window.setTimeout(func+'(this)', time*1000);
}

function reloadWindow( timer ){
	if (timer) window.clearTimeout(timer);
	window.location.reload();
}

function unloadChild(child, url){
	if (window.onunload) window.onunload=null;
	if (child) {
		child.wptimer=child.setTimeout('popCloseChildWindow("'+url+'")', 200);
	}
}
function popCloseChildWindow(url){
	if (window.wptimer)	{
			clearTimeout(window.wptimer);
			window.wptimer=null;
	}
	if (window.wop){
		if (window.wop.closed){
			if (url!='') {
				window.location.href=url;
				return;
			} 
		} else {
			window.wop.blur();
			window.wop.focus();
		}
	}
	window.opener=null;
	window.close();	
}


function post_form( id, str ){
	var el=document.getElementById(id);
	if (el) el.value=str;

	var frm=document.forms[0];
	if (frm)
		frm.submit();
}
function post_edit(){
	var el=document.getElementById('form_reedit');
	if (el) el.value='REEDIT';
}

function hide_div( id ){
	var div=document.getElementById(id);
	if (div) {
		if (div.style) {
			div.style.display='none';
		}
	}
}

function show_div( id ){
	var div=document.getElementById(id);
	if (div) {
		if (div.style) {
			div.style.display='';
		}
	}
}
function showhide_div( id ){
	var div=document.getElementById(id);
	if (div) {
		if (div.style) {
			if (div.style.display=='none') div.style.display=''; else div.style.display='none';
		}
	}
}

function select_option ( id ){
		var cnt = document.getElementById('opt_'+id);
		if (cnt){
			cnt.checked=1;
		}
}


function has_selected ( id, max, dir ){
	var cnt = null;
	for (i=0; i<max; i++){
		cnt = document.getElementById(id+i);
		if (cnt){
				if ( (cnt.type) && (cnt.type=='radio') ) {
					if (cnt.checked) {
						cnt=document.getElementById('n');
						if (cnt) cnt.value=dir;
						document.forms[0].submit();
						return false;
					}
				}
		}
	}
	return window.confirm('Are you sure?!\r\n\r\nYou want to go to another Question without providing an answer for this one?');
	//window.alert('Please select a valid value.');
	//return false;
}
function has_value ( id, dir ){
	cnt = document.getElementById(id);
	if (cnt){
			if (cnt.value!='') {
						cnt=document.getElementById('n');
						if (cnt) cnt.value=dir;
						document.forms[0].submit();
						return false;
			}
	}
	return window.confirm('No answer is provided!\r\n\r\nare you sure you want to go away from this page?');
	//window.alert('Please enter a valid value.')
	//return false;
}
