

function sareni_redovi(id) {
	 if(document.getElementsByTagName){  
		   var table = document.getElementById(id);   
		   var rows = table.getElementsByTagName("tr");   
		   for(i = 0; i < rows.length; i++){  
		   		if(rows[i].firstChild.nodeName!='TH') {
					 if(i % 2 == 0){ 
						rows[i].className = "red1"; 
					 }else{ 
						rows[i].className = "red2"; 
					 }       
				} else {
						rows[i].className = "red0"; 
				}
			}
	 }
}



function disableIt(objekt,stanje) {
	// objekt- string - ime objekta, stanje = true/false
	x= new getObj(objekt);
	if(stanje) x.obj.disabled='disabled';
	else x.obj.disabled='';
}


function getObj(name)
		{
		  if (document.getElementById)
		  {
			this.obj = document.getElementById(name);
			this.style = document.getElementById(name).style;
		  }
		  else if (document.all)
		  {
			this.obj = document.all[name];
			this.style = document.all[name].style;
		  }
		  else if (document.layers)
		  {
			this.obj = document.layers[name];
			this.style = document.layers[name];
		  }
		}


function dajopisartikla(clickobj, id) {
	//OBJ bi trebao biti ARTIKL DIV
	//treba po DOM-u ići prema gore do div-a "class=izdvojeno_rez"
	//i onda treba napraviti novi div i appendati ga tom DIV-u 
	obj=clickobj;
	while ((obj.className!=='izdvojeno_rez_inner') && (obj.nodeName!=='HTML')){
		obj=obj.parentNode;
		}

	test=document.getElementById("tmk_opis_artikla_detalj_unique");
	if (obj.nextSibling.className=='dyn_opis') {//obj.nextSibling==test) {
		ugasiopisartikla();
		return;
	}
	if(test) { // ve postoji
		// treba zatvoriti stari
		ugasiopisartikla();
	}
	//OTVORI NOVI
	var opisdiv = document.createElement("DIV");
	opisdiv.id="tmk_opis_artikla_detalj_unique";
	opisdiv.className="dyn_opis";

	obj=clickobj;
	while ((obj.className!=='izdvojeno_rez_inner') && (obj.nodeName!=='HTML')){
		obj=obj.parentNode;
		}

	z=obj.parentNode;
	z.insertBefore(opisdiv, obj.nextSibling); //kao insert After
	// ovdje treba dinamiki izvui podatke
	izvadiopis(id);
}
function upisiopis() {
	unutra=opis.response;
	td=document.getElementById("tmk_opis_artikla_detalj_unique");//.firstChild;
	td.innerHTML=unutra;
}
function ugasiopisartikla() {
	obj=document.getElementById("tmk_opis_artikla_detalj_unique");
	obj.parentNode.removeChild(obj);
}
function odvojiopisartikla(naziv,id) {
//<a href="#" onClick="divwin=dhtmlwindow.open('divbox', 'div', 'somediv', '#4: DIV Window Title', 'width=450px,height=300px,left=200px,top=150px,resize=1,scrolling=1'); return false"><b>Create/ Open Window 4</b></a>
//divwin=dhtmlwindow.open('divbox', 'div', 'tmk_opis_artikla_detalj_unique', '#4: DIV Window Title', 'width=450px,height=300px,left=200px,top=150px,resize=1,scrolling=1');
ajaxwin=dhtmlwindow.open("ajaxbox", "ajax", "inc/php/dajopis2.php?id="+id, naziv, "width=380px,height=270px;left=300px,top=100px,resize=1,scrolling=1")
ugasiopisartikla();
}
///////////////////
function izvadiopis(id)	{
	opis.requestFile = 'inc/php/dajopis.php?id='+id;	// Specifying which file to get
	opis.onCompletion = upisiopis;	// Specify function that will be executed after file has been found
	opis.runAJAX();		// Execute AJAX function
	}
///////////////////

function openslika(slika,width,height,id)
	{
		window.open('inc/php/prikazislikusopisom.php?slikaID='+id+'&slika='+slika,'SServis','width='+width+', height='+height+', toolbar=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no');
		return false;
	}
function openslikabezopis(slika,width,height)
	{
		window.open('inc/php/prikazisliku.php?slika='+slika,'SServis','width='+width+', height='+height+', toolbar=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no');
		return false;
	}






///////////////////////////////////////////////////////////////////////////////////////////////////
//FUNCTION DEPO////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
/*
function addEvent(obj, evType, fn){
 if (obj.addEventListener){
    obj.addEventListener(evType, fn, true);
    return true;
 } else if (obj.attachEvent){
    var r = obj.attachEvent("on"+evType, fn);
    return r;
 } else {
    return false;
 }
}

function provjeriKlik(e){
		if (!e) var obj=window.event.srcElement;  	// razlieiti browser, razlieito kue event
		else var obj=e.target;						//

		while (obj.nodeName!='HTML' && obj.id!='popiskategorija') { //|| obj.attributes['id'].nodeValue!='popiskategorija'
				obj =obj.parentNode;
			}
		if (obj.id=='popiskategorija') return;
		else odznaci();
}


function izlistajAtribute(obj) {
	for( var x = 0; x < obj.attributes.length; x++ ) {
		if (obj.attributes[x].nodeValue!=null && obj.attributes[x].nodeValue!='' && obj.attributes[x].nodeValue!='inherit')
			{
				window.alert( 'The value of the >> '+ obj.attributes[x].nodeName +' << attribute is: ' +
				obj.attributes[x].nodeValue );
			}
	}

}

function highlight(obj, stanje) {
	if(stanje) {
		obj.style.backgroundColor='#ffffcc';
	} else {
	 	obj.style.backgroundColor='';
	}
}

function odznaci(){
		if (oznaceni_red!=0) {
			obj=document.getElementById('red'+oznaceni_red);
			highlight(obj, false);	
			oznaceni_red=0;
		}
}

function oznaci_upali(id) {
		if (oznaceni_red==0) {
			oznaceni_red=id;
			obj=document.getElementById('red'+oznaceni_red);
			highlight(obj, true);	
		} else {
			obj=document.getElementById('red'+oznaceni_red);
			highlight(obj, false);	
			oznaceni_red=id;
			obj=document.getElementById('red'+id);
			highlight(obj, true);
		}
}

function oznaci(id) {
	if (oznaceni_red==id) {
		obj=document.getElementById('red'+oznaceni_red);
		highlight(obj, false);	
		oznaceni_red=0;
	} else {
		if (oznaceni_red==0) {
			oznaceni_red=id;
			obj=document.getElementById('red'+oznaceni_red);
			highlight(obj, true);	
		} else {
			obj=document.getElementById('red'+oznaceni_red);
			highlight(obj, false);	
			
			oznaceni_red=id;
			obj=document.getElementById('red'+id);
			highlight(obj, true);
		}
	}
}



function highlight2(obj) {
	i=obj.getAttribute('oznaceno');
	if(i) {
	 	obj.style.backgroundColor='#000000';
		obj.removeAttribute('oznaceno');
	} else {
		obj.style.backgroundColor='#ffffcc';
		obj.setAttribute('oznaceno', true);	
	}
}


function daj_display(obj) {
			if (obj.currentStyle) // jel IE5+
				return obj.currentStyle['display'];
			else if (window.getComputedStyle)
				return window.getComputedStyle(obj,null).display;
				//return = window.getComputedStyle(obj,null).getPropertyValue('display');
}

function izlistajAtribute(obj) {
	for( var x = 0; x < obj.attributes.length; x++ ) {
		if (obj.attributes[x].nodeValue!=null && obj.attributes[x].nodeValue!='' && obj.attributes[x].nodeValue!='inherit')
			{
				window.alert( 'The value of the >> '+ obj.attributes[x].nodeName +' << attribute is: ' +
				obj.attributes[x].nodeValue );
			}
	}

}
*/