// JavaScript Document

function showStatus( o ){
	var s = document.getElementById('div_status_info');
	s.innerHTML = o.title;
}
function hideStatus(){
	var s = document.getElementById('div_status_info');
	s.innerHTML = '&nbsp;';
}


function fullscreenShow(htmlSrc){
	var p = document.getElementById('div_fullscreen');
	var f = document.getElementById('div_fullscreen_frame');
	p.style.visibility = 'visible';
	f.style.visibility = 'visible';
	
	f.innerHTML = htmlSrc;
}
function fullscreenHide(){
	var p = document.getElementById('div_fullscreen');
	var f = document.getElementById('div_fullscreen_frame');
	p.style.visibility = 'hidden';
	f.style.visibility = 'hidden';
}





function AJAX_MakeObject(){
	var xmlhttp=false;
	try{
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	}catch(e){
		try{
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}catch(E){
			xmlhttp = false;
		}
	}
	
	if(!xmlhttp && typeof XMLHttpRequest!='undefined'){
		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}

function AJAX_Get(callback_function,url){
	var ajax=AJAX_MakeObject();
	
	ajax.open("GET", url,true);
	ajax.onreadystatechange=function(){
		callback_function(ajax);
	}
	
	ajax.send(null);
}


function AJAX_Post(callback_function,url,parameters){
	var ajax=AJAX_MakeObject();
	
	ajax.onreadystatechange=function(){
		callback_function(ajax);
	}
	
	ajax.open("POST", url,true);
	ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajax.setRequestHeader("Content-length", parameters.length);
	ajax.setRequestHeader("Connection", "close");
	ajax.send(parameters);
}
										  


function formatPreview( srcName ,path){
	
	var val = document.getElementById(srcName).value;
	
	var callback = function(ajax){
		
		if( ajax.readyState == 4){
			if( ajax.status ==  200){
				fullscreenShow(ajax.responseText);
			}
		}
	}
	
	
	if(path == null) path = '';
	AJAX_Get(callback, path + 'get.php?formatpreview=' + escape(val));
}


function showFormtaHelp(path){
	var callback = function(ajax){
		
		if( ajax.readyState == 4){
			if( ajax.status ==  200){
				fullscreenShow(ajax.responseText);
			}
		}
	}
	
	
	if(path == null) path = '';
	AJAX_Get(callback, path + 'get.php?formathelp=1');
}


function previewDownloadImage( imageid ){
	fullscreenShow('<CENTER><IMG SRC="image.php?id=' + imageid + '"></CENTER>');
}

