var xmlhttp;


function showNovostiArhivaNaslovi(txt, oddat, dodat)
{
	var browserName=navigator.appName;
	if (browserName=='Microsoft Internet Explorer')
		{
			txt=txt.replace('š','%C5%A1');
			txt=txt.replace('đ','%C4%91');
			txt=txt.replace('č','%C4%8D');
			txt=txt.replace('ć','%C4%87');
			txt=txt.replace('ž','%C5%BE');
			txt=txt.replace('Š','%C5%A0');
			txt=txt.replace('Đ','%C4%90');
			txt=txt.replace('Č','%C4%8C');
			txt=txt.replace('Ć','%C4%86');
			txt=txt.replace('Ž','%C5%BD');
		
		}
	var gdje=0;
	if (document.getElementById("rbNaslov").checked)  { gdje = gdje + 1; }
	if (document.getElementById("rbTekst").checked)   { gdje = gdje + 2; }
	if (gdje==0 && txt.length>0) { 	
			alert ('Nije odabrano mjesto pretrage (naslovi - tekst)');
			return;	}

	var vrsta=0;
	if (document.getElementById("rbVijesti").checked)   { vrsta = vrsta + 1; }
	if (document.getElementById("rbGlazba").checked)   { vrsta = vrsta + 2; }
	//if (document.getElementById("rbSport").checked)   { vrsta = vrsta + 4; }
	if (vrsta==0) {	alert ('Nije odabrana niti jedna grupa  (vijesti - glazba)');
					return;	}	
	
	oddat = oddat.substr(6,4) + oddat.substr(3,2) + oddat.substr(0,2);
	dodat = dodat.substr(6,4) + dodat.substr(3,2) + dodat.substr(0,2);


xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }


var url="novosti_arhiva_naslovi.php";
url=url+"?datumOd="+oddat+"&datumDo="+ dodat+"&vrsta="+vrsta+"&txt="+txt+"&gdje="+gdje ;
//alert (url);
//document.write(url);
xmlhttp.onreadystatechange=novosti_arhiva_naslovi_Changed;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);

}

function novosti_arhiva_naslovi_Changed()
{
if (xmlhttp.readyState==4)
	{  
		document.getElementById("divNovostiArhivaNaslovi").innerHTML=xmlhttp.responseText;
		$("a.NovostiArhivaLink").fancybox({
			
			'autoScale'			: true,
			'autoDimensions'    : true,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'type'				: 'ajax',
			'titleShow'			: false,
			'scrolling'			: 'no'
		
		});
		

	}
}



function showNovostiArhivaText(id)
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }

var url="novosti_arhiva_text.php";
url=url+"?ID="+id;
/*alert (url);*/
xmlhttp.onreadystatechange=novosti_arhiva_text_Changed;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function novosti_arhiva_text_Changed()
{
if (xmlhttp.readyState==4)
	{  
		document.getElementById("divNovostiArhivaText").innerHTML=xmlhttp.responseText; 
	}
}






function showNovostiPlus(ID, Vrsta, IDplus )
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }
var url2="novosti_plus.php";
url2=url2+"?id="+ID;
url2=url2+"&vrsta="+Vrsta;
url2=url2+"&idplus="+IDplus;

var IDdiv="divVijestiPlus"+IDplus;

xmlhttp.divid=IDdiv;
xmlhttp.onreadystatechange=NovostiPlusChanged;
xmlhttp.open("GET",url2,true);
xmlhttp.send(null);
}

function NovostiPlusChanged(IDdiv)
{
if (xmlhttp.readyState==4)
{
document.getElementById(xmlhttp.divid).innerHTML=xmlhttp.responseText;
}
}






function showProgram(dan)
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }
var url="program_show.php";
url=url+"?dan="+dan;
xmlhttp.onreadystatechange=ProgramChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function ProgramChanged()
{
if (xmlhttp.readyState==4)
{  document.getElementById("divProgramShow").innerHTML=xmlhttp.responseText; }
}





function showTopLista(y, m)
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }
var url="toplista_show.php";
url=url+"?y="+y;
url=url+"&m="+m;
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);

}

function stateChanged()
{
if (xmlhttp.readyState==4)
{
	document.getElementById("divTLShow").innerHTML=xmlhttp.responseText;
	$("a.TopListaLink").click(function() {
	    $.fancybox({
	        'padding'       : 0,
	        'autoScale'     : false,
	        'transitionIn'  : 'none',
	        'transitionOut' : 'none',
	        'title'         : this.title,
	        'width'         : 680,
	        'height'        : 495,
	        'href'          : this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
	        'type'          : 'swf',
	        'swf'           : {
	            'wmode'             : 'transparent',
	            'allowfullscreen'   : 'true'
	        }
	    });
		return false;
	});
}
}


function showTLGodina(y)
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }
var url="toplista_mjesec.php";
url=url+"?y="+y;
xmlhttp.onreadystatechange=GodinaChanged ;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
function GodinaChanged ()
{
if (xmlhttp.readyState==4)
{
	document.getElementById("divTLMjesec").innerHTML=xmlhttp.responseText;
}
}


function AnketaOdgovor()
{
var odgovor = -1;
for (var i=0; i < document.frmAnketa.radioanketa.length; i++)
   {
   if (document.frmAnketa.radioanketa[i].checked)
      {
       return document.frmAnketa.radioanketa[i].value;
      }
   }
if (odgovor==-1)
   { alert ("Niste odabrali odgovor!");
   return 0;}

}


function showAnketa(ID, myPath)
{

if (ID<0) {alert ("Već je glasovano! Ovaj glas neće biti pribrojan!");}
var odgovor = -1;
for (var i=0; i < document.frmAnketa.radioanketa.length; i++)
   {
   if (document.frmAnketa.radioanketa[i].checked)
      {
       odgovor = document.frmAnketa.radioanketa[i].value;
      }
   }
if (odgovor==-1)
   { alert ("Niste odabrali odgovor!");
   return;}

  

xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }
  
Set_Cookie('RZ-Anketa','ID', '600' , '/', '', '');
HideElement('AnketaGumbPosalji');

var url="anketa_save.php";
url=url+"?id="+ID;
url=url+"&a="+odgovor;
xmlhttp.onreadystatechange=AnketaChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
//popUpWindow('anketa_res.php?id='+ID, 100, 100, 600, 300);
}
function AnketaChanged ()
{
if (xmlhttp.readyState==4)
{
document.getElementById("divAnketa").innerHTML=xmlhttp.responseText;

}
}




function showAnketaShow(ID)
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }
var url2="anketa_show_ajax.php";
url2=url2+"?id="+ID;
xmlhttp.onreadystatechange=AnketaShowChanged;
xmlhttp.open("GET",url2,true);
xmlhttp.send(null);
}
function AnketaShowChanged ()
{
if (xmlhttp.readyState==4)
{
document.getElementById("divAnketaShow").innerHTML=xmlhttp.responseText;

}
}


function showNovostiShow(ID)
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }
var url="novosti_show_ajax.php";
url3=url3+"?ID="+ID;
xmlhttp.onreadystatechange=NovostiShowChanged;
xmlhttp.open("GET",url3,true);
xmlhttp.send(null);
}
function NovostiShowChanged ()
{
if (xmlhttp.readyState==4)
{
document.getElementById("divNovostiShow").innerHTML=xmlhttp.responseText;

}
}


function showNovostiGodina(y,id, vrsta)
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }
var url4="novosti_mjesec.php";
url4=url4+"?y="+y+ "&ID="+id+"&vrsta="+vrsta ;
xmlhttp.onreadystatechange=NGodinaChanged ;
xmlhttp.open("GET",url4,true);
xmlhttp.send(null);
}
function NGodinaChanged ()
{
if (xmlhttp.readyState==4)
{
document.getElementById("divNovostiMjesec").innerHTML=xmlhttp.responseText;
}
}








function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}

function HideElement(id)
{
	document.getElementById(id).style.display = 'none';
}

