
var fct_get_que = function () 
{
	if(typeof arr_que == 'undefined') return;
	
	//if(!window.jQuery){ setTimeout('fct_get_que()',500);  return; }   //alert('not jquery');
	
	get_que(arr_que);
	
	function get_que(arr)
	{
		var wdebug = (typeof arr['debug'] != 'undefined' && arr['debug']);
		var tg = false;
		if(typeof arr['id_tag_rezultate'] != 'undefinded' && arr['id_tag_rezultate']!='' && document.getElementById(arr['id_tag_rezultate']))
			tg = arr['id_tag_rezultate'];
		else{
			document.write('<div id="tag_rez_que">.</div>');
			tg = "tag_rez_que";
		}
		//if(wdebug) alert('Nu exista tag pentru rezultate.'); return; 
	
		if(typeof arr['html_wait'] == 'undefined') arr['html_wait'] = '';
		
		if(tg) write2tg(tg,arr['html_wait']);
		
		//var arr2str='', k;
		//for(k in arr) if(arr[k]!='') arr2str += '/'+k+'/'+arr[k].replace(/[^-a-z 0-9]+/gi,'_'); //a-z 0-9~%.:_\-; //'&'+k+'='+arr[k];		
		
		//$.ajax({
		jQuery.ajax({
		  type: 'POST',
		  url: 'http://www.orange.ro/asistenta/widget_questions/index/'+new Date().getTime(),
		  data: (arr),
		  cache: false,
		  contentType: 'application/x-www-form-urlencoded',
		  ifModified: false,  //Allow the request to be successful only if the response has changed since the last request.
		  timeout: 60000,
		  success: 
		  	function(msgx)
		  	{
		  		//alert(msgx);   //alert(msgx.length);
		  		try{ if(tg) write2tg(tg,''); }catch(e){ }
				if(msgx.substr(0,2)!='ok') return;
				msgx=msgx.substr(2);  //alert(msgx);
		
				var ret={}, htm='';
				msgx = replace35(msgx);
				try{ eval(msgx); }catch(e){ }
				if(typeof ret['ok'] == 'undefined' || ret['ok']!='1') return;
				
				if(typeof ret['html'] != 'undefined' && ret['html'] != '') htm = ret['html'];
				else if(wdebug && ret['err']!='') htm = ret['err'];
				//if(htm!='') tg ? $(tg).html(htm) : document.write(htm);
				write2tg(tg,htm);
			},
		   error: function(){ if(tg) write2tg(tg,'....'); },
		   dataType: 'text'
		});	
		
	}
	
	function write2tg(tgx, htm){  try{  if(document.getElementById(tgx)) document.getElementById(tgx).innerHTML = htm;  }catch(e){ }  }
	
	function replace35(msgx){ return msgx.replace(/[\n\r]+/gi,' '); }	
}

//$(document).ready(fct_get_que());
$(window).bind("load", function(){ fct_get_que(); });
//$(window).load( function() { /*do something onload */});
//$(function() { /*do something on dom ready */});

//window.onload = fct_get_que;

