var $j = jQuery.noConflict();

// OCJENA VIJESTI-----------

function sc_vid(nn,id,sc){
new Ajax.Request('/bizadvance/get/article_score.php?nn='+nn+'&id='+id+'&sc='+sc,{onComplete:overscore});	
}
function overscore(req){
oc = req.responseText;
//alert(oc);
document.getElementById("oc_vv").innerHTML = oc;
document.getElementById("glasanje").innerHTML = "<span class=\"overvoting\">Hvala na glasanju !</span>";
}
function novote(){
document.getElementById("glasanje").innerHTML = "<span class=\"overvoting\">vec ste glasali za ovu vijest..</span>";
}


// ------------ NAJ sidebar
$j("a[rel='swtch']").live("click", function(){
klasa_on = $j("a[rel='swtch'][rev='yes']").attr("class");
id_on = $j("a[rel='swtch'][rev='yes']").attr("id");
klasa_on_d = klasa_on.split("_h");




$j("a[rel='swtch'][rev='yes']").removeClass();
$j("a[rel='swtch'][rev='yes']").addClass(klasa_on_d[0]);
$j("a[rel='swtch'][rev='yes']").attr({rev:"no"});
klasa = $j(this).attr("class");
n_klasa = klasa+"_h";
n_klasa = n_klasa+'';
$j(this).removeClass();
$j(this).addClass(n_klasa);
$j(this).attr({rev:"yes"});
id_onwards = $j(this).attr("id");
article_id_najnaj = $j(".nv_komentari_hh").attr("rev");
//alert(klasa);
new Ajax.Updater("innerlists_nvr","/bizadvance/bring_info.php",{method: 'post',postBody:'najnajbring_najcit='+article_id_najnaj+'&klasa='+klasa,onComplete:complete_feedback_naj});


/*$j("div[class='"+id_on+"']").css({display:"none"});
$j("div[class='"+id_onwards+"']").css({display:"block"});*/
}); 


function complete_feedback_naj(req){
done_feedback = req.responseText;
//alert(done_feedback);
}

// --------------- komentari

$j(".posaljikomentar").live("click", function(){
ime_k = $j("input[name='nv_komentar_ime']").val();
komentar_k = $j("textarea[name='nv_komentar_cc']").val();
if(ime_k=="" || komentar_k==""){
alert("molimo uneite sve informacije: ime i komentar");	
}else{
$j("input[name='nv_komentar_ime']").val("");
$j("textarea[name='nv_komentar_cc']").val("");
article_id = $j(".nv_komentari_hh").attr("rev");
$j(".nv_komentari_inner").html('<div class="loader"><img src="/bizadvance/article/43.gif"/></div>');
new Ajax.Request("/bizadvance/article/get.php",{method: 'post',postBody:'komentar_snimi=yes&ime_k='+ime_k+'&komentar_k='+komentar_k+'&article_id='+article_id,onComplete:complete_feedback});

new Ajax.Request("/bizadvance/bring_info.php",{method: 'post',postBody:'mv_spec=komentar&smv_idbroj='+smv_id+'&mv_large='+komentar_k,onComplete:chmvm});

}
}); 

function complete_feedback(req){
done_feedback = req.responseText;
//alert(done_feedback);
$j(".nv_komentari_inner").html(done_feedback);
}



// ------------------- OCJENA KOMENTARA

$j("div[class='badcomment']").live("click", function(){
revid = $j(this).attr("rev");
cocjena = $j("div[class='zbrojocjenekom'][rev='"+revid+"']").attr("rel");
klk = $j(this);
newocjenak = parseInt(cocjena) - 1;
klkoc = "bad"
new Ajax.Request("/bizadvance/ocjenakoment.php",{method: 'post',postBody:'revid='+revid+'&opercc='+newocjenak,onComplete:showmeend});
});
	
	
function showmeend(req){
if(req.responseText=="ista"){
}else{
if(newocjenak<0){
$j("div[class='zbrojocjenekom'][rev='"+revid+"']").css({color:"#900"});	
}
if(newocjenak==0){
$j("div[class='zbrojocjenekom'][rev='"+revid+"']").css({color:"#666"});	
}
if(newocjenak>0){
$j("div[class='zbrojocjenekom'][rev='"+revid+"']").css({color:"#093"});	
newocjenak = "+"+newocjenak;
}
klk.replaceWith("<div class='thanks'>hvala</div>");
$j("div[class='zbrojocjenekom'][rev='"+revid+"']").html(newocjenak);
if(klkoc=="bad"){
$j("div[class='goodcomment'][rev='"+revid+"']").remove();
}else{
$j("div[class='badcomment'][rev='"+revid+"']").remove();
}
}
}
	
	
$j("div[class='goodcomment']").live("click", function(){
revid = $j(this).attr("rev");
cocjena = $j("div[class='zbrojocjenekom'][rev='"+revid+"']").attr("rel");
klk = $j(this);
newocjenak = parseInt(cocjena) + 1;
klkoc = "good"
new Ajax.Request("/bizadvance/ocjenakoment.php",{method: 'post',postBody:'revid='+revid+'&opercc='+newocjenak,onComplete:showmeend});
});			
			
			
// -------- DLCMNT			
function dcm(idc){
idcf = idc;
new Ajax.Request('/bizadvance/get/delnewscomment.php?cid='+idc,{onComplete:delcmcomp});		
}
function delcmcomp(req){
document.getElementById("comn"+idcf).style.display="none";		
}


// ------------------------- OLD IMPORTS

function search_adart() {	
var pretraga = document.getElementById('keywordss').value; 
if(document.getElementById('s_results_ad').innerHTML==""){
document.getElementById('s_results_ad').innerHTML = '<br/>ucitavam rezultate..'; 
}
new Ajax.Updater('s_results_ad', '/bizadvance/reg_pretraga.php?keywords='+pretraga+'&wh=upp');
}


function offtra(){
document.getElementById('s_results_ad').innerHTML="";
}

function kolumne(){
document.getElementById("extrainfo_up").style.display="block";	
document.getElementById("ex_content").innerHTML=document.getElementById("clancikolumne").innerHTML;
document.getElementById("ex_information").innerHTML='<div class="ex_inf_l">advance.hr : kolumne</div><div class="ex_inf_r"><a href="javascript:;" onclick="kolumneoff()">X</a></div><div class="divider"></div>';
}
function extra(){
document.getElementById("extrainfo_up").style.display="block";	
document.getElementById("ex_content").innerHTML=document.getElementById("extrainfofooter").innerHTML;
document.getElementById("ex_information").innerHTML='<div class="ex_inf_l">advance.hr : dodatne kategorije</div><div class="ex_inf_r"><a href="javascript:;" onclick="kolumneoff()">X</a></div><div class="divider"></div>';
}
 
function login_dets(){
document.getElementById("extrainfo_up").style.display="block";	
document.getElementById("ex_content").innerHTML=document.getElementById("login_dets").innerHTML;
document.getElementById("ex_information").innerHTML='<div class="ex_inf_l">&nbsp;</div><div class="ex_inf_r"><a href="javascript:;" onclick="kolumneoff()">X</a></div><div class="divider"></div>';
}


function kolumneoff(){	
document.getElementById("extrainfo_up").style.display="none";		
document.getElementById("ex_content").innerHTML="";
document.getElementById("ex_information").innerHTML="";
} 



function lvad(lv_id,lv_br){
//alert(lv_id);
//alert(lv_br);
new Ajax.Request('/bizadvance/get/outad.php',{method: 'post',postBody:'lv_id='+lv_id+'&lv_br='+lv_br,onComplete:shod});	

}
function shod(req){
//alert(req.responseText);	
}



// ----------- SLIKA ADLIGHT

$j("#wrapper").prepend('<div id="adlight"></div>');

$j("#adlight").bind("click", function(e){
$j(this).css({display:"none"});
});

$j(".povecajsliku_nv,.povecajsliku_nvmain").bind("click", function(e){
															   
bp_src = $j(".povecajsliku_nvmain img").attr("src");
bp_src_r = bp_src.split("_dump/l_");
if(bp_src_r[1]==undefined){
bp_src_r = bp_src.split("_dump/m_");	
}
bp_src = bp_src_r[0]+'_dump/'+bp_src_r[1];
//bp_naslov = $j("h1").html();
dokuh = $j(document).height();
$j("#adlight").css({display:"block",height:dokuh+"px"});
$j("#adlight").html('<div style="margin-left:150px;margin-top:60px;"><img src="'+bp_src+'" /></div>');
//wexpba = $j(".exbp").width();
//alert(wexpba);
//$j(".opisslike_bp").css({width:"500px"});
//$j(".opisslike_bp").html(bp_naslov);
return false;	
});

//------------------------------------------------- VREMENSKA PROGNOZA ----------------------------------------


//- sljedeci - navigacija
$j("a[class='nxtvrcity']").live("click", function(){												   
prognozacitynew_id = $j(this).attr("rel");
if(prognozacitynew_id>=18){
prognozacitynew_id = 0;	
}

new Ajax.Updater("vremenska_innercity","/bizadvance/bring_info.php",{method: 'post',postBody:'prognozacitynew='+prognozacitynew_id});
});

//TRAZILICA
function search_adart() {
$j(".wrapper").prepend('<div id="s_results_ad"></div>');
$j("#s_results_ad").html("<br/>ucitavam rezultate..");
new Ajax.Updater('s_results_ad', '/bizadvance/reg_pretraga.php?keywords='+$j("#keywordss").val()+'&wh=upp');
new Ajax.Request('/bizadvance/get/ppinfo.php?hreflink=trazilica&where=srch&ipadresa='+addr+'&aftertime=0');	
}
function offtra(){
$j("#s_results_ad").remove();
}

//------------------------------------------------- SPECIFIC MV ----------------------------------------
smv_id= $j(".nv_komentari_hh").attr("rev");
$j(".povecajsliku_nv").live("click", function(){
new Ajax.Request("/bizadvance/bring_info.php",{method: 'post',postBody:'mv_spec=slika'+'&smv_idbroj='+smv_id,onComplete:chmvm});
});
$j("#naj_nov").live("click", function(){
new Ajax.Request("/bizadvance/bring_info.php",{method: 'post',postBody:'mv_spec=naj_nov'+'&smv_idbroj='+smv_id,onComplete:chmvm});
});
$j("#naj_kom").live("click", function(){
new Ajax.Request("/bizadvance/bring_info.php",{method: 'post',postBody:'mv_spec=naj_kom'+'&smv_idbroj='+smv_id,onComplete:chmvm});
});
$j("#naj_cit").live("click", function(){
new Ajax.Request("/bizadvance/bring_info.php",{method: 'post',postBody:'mv_spec=naj_cit'+'&smv_idbroj='+smv_id,onComplete:chmvm});
});
$j(".up_info a").live("click", function(){
glasocjena = $j(this).html();									
new Ajax.Request("/bizadvance/bring_info.php",{method: 'post',postBody:'mv_spec=glas'+glasocjena+'&smv_idbroj='+smv_id,onComplete:chmvm});
});
$j(".nv_prosiri").live("click", function(){
new Ajax.Request("/bizadvance/bring_info.php",{method: 'post',postBody:'mv_spec=prosiri'+'&smv_idbroj='+smv_id,onComplete:chmvm});
});
$j(".pro_cijeli a").live("mousedown", function(e){										 
new Ajax.Request("/bizadvance/bring_info.php",{method: 'post',postBody:'mv_spec=cjcla'+'&smv_idbroj='+smv_id,onComplete:chmvm});
});
function chmvm(req){
//alert(req.responseText);	
}



//FLASH BANNER
if($j("#flashedBB").length > 0){
flblnk = 'http://www.advance.hr/bizadvance/pcentrala_banner.swf';	
var so_na = new SWFObject(flblnk, "mymovie", "300", "282", "8");
so_na.addParam("wmode", "opaque");
setTimeout(function(){so_na.write("flashedBB");},100);
}