var Hledat = new Array();
Hledat[Hledat.length] = new Array("searchstring", "value.length > 2", "The string must be at least 3 characters long!");

var xmlNewsData;
var xmlWeatherData;
function callAjax(url, queryStr) {
   // cekaci ramecek
   //jQ("#id_loadingWindow").css( {display: 'block', visibility: 'visible' });	
//  alert('start AJAXu: '+url);
  jQ.ajax({
   type: "GET",
   async: true,
   url: url,
   data: queryStr,
   dataType: "xml",
   success: function(dgData){
        xmlNewsData = dgData;
   	    runNewsData();
    } ,
   error: function(xmlObject, errorMsg, exception) { 
    //alert('chybka AJAXu');
   } 
 });
}

function runNewsData(attempt) {
    var item;
    if (!xmlNewsData) return;
    if (!attempt) attempt = 0;
    var news = jQ(xmlNewsData).find('/news/footernews');
    var pocet = news.length;
    if (pocet) {
        if (attempt >= pocet) attempt = 0;
        jQ("#news1").fadeOut(100);
        jQ("#news2").fadeOut(100);
        jQ("#news1").empty();
        jQ("#news2").empty();
        if (item = news[attempt]) {
            if (jQ(item).find('link').attr('href')) link = ' <a href="'+jQ(item).find('link').attr('href')+'">'+'More'+'</a>';
            else link = '';
            jQ("#news1").append('<p><strong>'+jQ(item).find('nadpis').text()+':</strong> '+jQ(item).find('text').text()+link+'</p>');
            jQ("#news1").fadeIn(1500);
        }
        attempt++;
        if (item = news[attempt]) {
            if (jQ(item).find('link').attr('href')) link = ' <a href="'+jQ(item).find('link').attr('href')+'">'+'More'+'</a>';
            else link = '';
            jQ("#news2").append('<p><strong>'+jQ(item).find('nadpis').text()+':</strong> '+jQ(item).find('text').text()+link+'</p>');
            jQ("#news2").fadeIn(1500);
        }
        if (pocet > 2) {
            attempt++;
            var x = window.setTimeout('runNewsData('+attempt+');', 10000);
        }      
    }
    return true;
}

function mobileRedirect(){
    var nmpar = 'nomobile';
    var r = new RegExp("[\\?&]"+nmpar+"=([^&#]*)");
    var res = r.exec(window.location.href);
    if (res != null && res[1] == 'true') document.cookie = nmpar+'=true;';
    r = new RegExp(";?" + nmpar + "=([^;]*)");
    res = r.exec(document.cookie);
    var is_mobile = (res == null || res[1] != 'true');
    if (screen && (screen.width > 801 || screen.height > 801)) is_mobile = false;
    if (is_mobile) window.location = "http://m.prg.aero";
}