function getById(id) {
	return document.getElementById(id);
}

function uploader_init () {
        uploader = new clUploadData('upl.php');
}

function uploader_go (id,pre) {
if(!pre) pre='nNews';
pre=get_by_id(pre);
if(pre) {
	pre.innerHTML = '<p class="wcontent"><b>Загрузка...</b></p>';
	pre.style.display='block';
}
        uploader.upload(id);
}


var uploader;


function get_by_id(id) {
	var itm = null;
	if (document.getElementById){
		itm = document.getElementById(id);
	}
	else if (document.all){
		itm = document.all[id];
	}
	else if (document.layers){
		itm = document.layers[id];
	}
	return itm;
}

function print_to_div(id, text) {
	var d = get_by_id(id);
	if (d) {d.innerHTML = text;}
}

function close_div(id) {
	var d = get_by_id(id);
	if (d) {
		d.innerHTML = '';
		d.style.top = -999;
		d.style.left = -999;
	}
}



function clUploadData ( thesrc ) {
	// устанавливаем адрес подгрузки
	this.src = thesrc;
	// подгружаться будет методом GET
	this.src += "?";
	//тип подгружаемого элемента - text/javascript
	this.type = "text/javascript";
	this.oldScript  = document.createElement("SCRIPT");
	this.oldScript.type = this.type;
	this.callId = 0;
	document.body.appendChild(this.oldScript);
	this.upload = function ( theparams ) {
		//Параметры передаются в виде par1=val1&par2=val2&...
		var tParams = theparams || "";
		var newScript = document.createElement("SCRIPT");
		newScript.type = this.type;
		this.callId += 1;
		newScript.src  = this.src + "callid=" + String(this.callId) + "&" + tParams;
		// alert(newScript.src);
		document.body.replaceChild(newScript,this.oldScript);
		this.oldScript = newScript;
	}
}

function ge(){
	var ea;
	for( var i = 0; i < arguments.length; i++ ){
		var e = arguments[i];
		if( typeof e == 'string' ) e = document.getElementById(e);
		if( arguments.length == 1 ) return e;
		if( !ea ) ea = new Array();
		ea[ea.length] = e;
	}
	return ea;
}



