window.status = 'Dobro došli na www.dom.com.hr!';


////  ajax

var xmlHttp;

function sForm(form,div){
		
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Vaš web preglednik ne podržava ovu funkciju.");
		return
	} 
	var url=form.action
	var varijabla = ""
	for(i=0; i<form.length;i++){
		if(form.elements[i].type != "radio" || form.elements[i].type != "checkbox")
			varijabla +="&"+form.elements[i].name+"="+form.elements[i].value
		 if( (form.elements[i].type == "radio" || form.elements[i].type != "checkbox") && form.elements[i].checked == true)
			varijabla +="&"+form.elements[i].name+"="+form.elements[i].value
	}
	varijabla = varijabla.substring(1);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState==0)	{ 
			document.getElementById(div).innerHTML='Greška, pokušajte ponovo!'; 
		} 
		if (xmlHttp.readyState>0)	{ 
			document.getElementById(div).innerHTML='<table width="100%" height="100%"><tr><td align="center"><img src="http://www.dom.com.hr/iamges/loading.gif" /></td></tr></table>'; 
		} 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")	{ 
			document.getElementById(div).innerHTML=xmlHttp.responseText 
		} 
		}
	xmlHttp.open("post",url);
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
	xmlHttp.send(varijabla);
} 

function nForm(){
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Vaš web preglednik ne podržava ovu funkciju.");
		return
	} 
	var url=nForm.arguments[0]
	var div = nForm.arguments[1]
	var varijabla = ""
	for (i = 2; i+1 < nForm.arguments.length; i+=2) {
		varijabla +="&"+nForm.arguments[i]+"="+nForm.arguments[i+1]
    }
	varijabla = varijabla.substring(1);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState==0)	{ 
			document.getElementById(div).innerHTML='Greška, pokušajte ponovo!'; 
		} 
		if (xmlHttp.readyState>0)	{ 
			document.getElementById(div).innerHTML='<table width="100%" height="100%"><tr><td align="center"><img src="http://dom.com.hr/images/loading.gif" /></td></tr></table>'; 
		} 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")	{ 
			document.getElementById(div).innerHTML=xmlHttp.responseText 
		} 
		}
	xmlHttp.open("post",url);
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
	xmlHttp.send(varijabla);
}

var f

function nFormX(){
	clearTimeout(f);
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Vaš web preglednik ne podržava ovu funkciju.");
		return
	} 
	var url=nFormX.arguments[0]+"_inc/allnew-inc.webizlog.php"
	var kategorija=nFormX.arguments[1]
	var div = "webizlogDiv"
	if(nFormX.arguments[3] != 0)
		var limit = nFormX.arguments[2]
	else
		var limit = parseFloat(document.getElementById("limitInput").value) + parseFloat(nFormX.arguments[2])
		
	var varijabla = "kategorijaID="+kategorija+"&limit="+limit
	//alert(limit)
	//alert(document.getElementById(div).getElementsByTagName("table").id)
	//alert(varijabla)
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState==0)	{ 
			document.getElementById(div).innerHTML='Greška, pokušajte ponovo!'; 
		} 
		if (xmlHttp.readyState>0)	{ 
			document.getElementById(div).innerHTML='<table width="100%" height="100%"><tr><td align="center"><img src="http://dom.com.hr/images/loading.gif" /></td></tr></table>'; 
		} 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")	{ 
			document.getElementById(div).innerHTML=xmlHttp.responseText 
		} 
		}
	limit = parseFloat(limit)+1;
	xmlHttp.open("post",url);
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
	xmlHttp.send(varijabla);
	f =setTimeout("nFormX('"+nFormX.arguments[0]+"',"+kategorija+",1,0)",8000);
}


function centerOnWindow(elemID) {
    // 'obj' is the positionable object
    var obj = getRawObject(elemID);
    // window scroll factors
    var scrollX = 0, scrollY = 0;
    if (document.body && typeof document.body.scrollTop != "undefined") {
        scrollX += document.body.scrollLeft;
        scrollY += document.body.scrollTop;
        if (document.body.parentNode && 
            typeof document.body.parentNode.scrollTop != "undefined") {
            scrollX += document.body.parentNode.scrollLeft;
            scrollY += document.body.parentNode.scrollTop;
        }
    } else if (typeof window.pageXOffset != "undefined") {
        scrollX += window.pageXOffset;
        scrollY += window.pageYOffset;
    }
	alert(obj)
    var x = Math.round((getInsideWindowWidth( )/2) - 
        (getObjectWidth(obj)/2)) + scrollX;
    var y = Math.round((getInsideWindowHeight( )/2) - 
        (getObjectHeight(obj)/2)) + scrollY;
    shiftTo(obj, x, y);
    show(obj);
}

function nastavi(id){
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
	alert ("Browser does not support HTTP Request");
	return
	} 
	var url = "http://www.dom.com.hr/_inc/new-inc.akcije.php";
	var varijabla = "akcija=nastavi&kid="+id;
	xmlHttp.onreadystatechange=stateChangedK;
	xmlHttp.open("post",url);
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
	xmlHttp.send(varijabla);
}

function stateChangedK() 
{ 
if (xmlHttp.readyState>0)
{ 
document.getElementById("container").innerHTML='<table width="380" height="280"><tr><td align="center"><img src="http://www.dom.com.hr/images/loading.gif" /></td></tr></table>'; 
//alert('ok')
} 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{ 
document.getElementById("container").innerHTML=xmlHttp.responseText 
kontakt.slideit();
//alert('ok')
} 
} 


function dcKlijent(poruka, id){
	//document.getElementById('f_kontaktForma').klijentID.value=id;
	//document.getElementById('f_kontaktForma').style.display="block";
	//document.getElementById('f_kontaktForma').odgovor.value = "Odgovor";
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
	alert ("Browser does not support HTTP Request");
	return
	} 
	var url = "akcije2.php";
	var varijabla = "tip=posjetitelj&porukaID="+poruka+"&klijentID="+id
	xmlHttp.onreadystatechange=stateChanged ;
	xmlHttp.open("post",url);
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
	xmlHttp.send(varijabla);
}

function stateChangedDCS() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{ 
document.getElementById("odgovori").innerHTML=xmlHttp.responseText 
//alert('ok')
} 
} 


function sendFormuAjax(form, d){
	
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request");
return
} 
var url=form.action
var varijabla = ""
for(i=0; i<d;i++){
	if(form.elements[i].type != "radio")
		varijabla +="&"+form.elements[i].name+"="+form.elements[i].value
	 if(form.elements[i].type == "radio" && form.elements[i].checked == true)
		varijabla +="&"+form.elements[i].name+"="+form.elements[i].value
}
o = sendFormuAjax.arguments[2]
varijabla = varijabla.substring(1);
//alert(varijabla)
if(o == "odgovori")
	xmlHttp.onreadystatechange=stateChangedDCS ;
else
	xmlHttp.onreadystatechange=stateChanged;
	
xmlHttp.open("post",url);
xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
xmlHttp.send(varijabla);
} 

function stateChanged() 
{ 
if (xmlHttp.readyState>0)
{ 
document.getElementById("container").innerHTML='<table width="380" height="280" align="center"><tr><td align="center"><img src="http://www.dom.com.hr/images/loading.gif" height="32" width="32" /></td></tr></table>'; 
//alert('ok')
} 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{ 
document.getElementById("container").innerHTML=xmlHttp.responseText 
//alert('ok')
} 
} 

function GetXmlHttpObject()
{ 
var objXMLHttp=null;
if (window.XMLHttpRequest)
{
objXMLHttp=new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
return objXMLHttp;
} 

////

function submitUpitAjax(id,name,broj){
	var klasa;
	var restoredArray;
	var tip;
	var mod;
	var i;
	var vrsta;
	var forma = document.getElementById(id);
	//window.alert(parseInt(broj));
	for(i=1; i<=parseInt(broj); i++){
		klasa = document.getElementById(name+"_"+i).className;
		restoredArray = klasa.split("_");
		vrsta = restoredArray[1];
		tip = restoredArray[2];
		mod = restoredArray[3];
	//	alert(document.getElementById(name+"_"+i).name + ' -- '+ klasa +' -- '+ vrsta);
		if(tip == 'obavezno' && mod == "off"){
			alert('Molimo popunite');
			document.getElementById(name+"_"+i).select();
			return false;
		}
		if(tip == 'obavezno' && mod == "on"){
			if(vrsta == "email"){
				if(!checkEmail(document.getElementById(name+"_"+i)))
					return false;
			}
			if(vrsta == "broj"){
				alert(typeof(document.getElementById(name+"_"+i).value));
				if(typeof(document.getElementById(name+"_"+i).value)!="number"){
				alert('Unos mora biti broj!');
				document.getElementById(name+"_"+i).select();
				return false;
				}
			}
				
		}
		if(mod == "off" && tip == 'neobavezno'){
			document.getElementById(name+"_"+i).value='';
		}
	}
	return true;
	//forma.submit();
	//alert('Kontakt forma se testira, \nte trenutačno nije u upotrebi!');
}


function submitKomentar(id,name,broj,k){
	var klasa;
	var restoredArray;
	var tip;
	var mod;
	var i;
	var vrsta;
	var forma = document.getElementById(id);
	//window.alert(parseInt(broj));
	for(i=1; i<=parseInt(broj); i++){
		klasa = document.getElementById(name+"_"+i).className;
		restoredArray = klasa.split("_");
		vrsta = restoredArray[1];
		tip = restoredArray[2];
		mod = restoredArray[3];
	//	alert(document.getElementById(name+"_"+i).name + ' -- '+ klasa +' -- '+ vrsta);
		if(tip == 'obavezno' && mod == "off"){
			alert('Molimo popunite');
			document.getElementById(name+"_"+i).select();
			document.getElementById(name+"_"+i).focus();
			return false;
		}
		if(tip == 'obavezno' && mod == "on"){
			if(vrsta == "email"){
				if(!checkEmail(document.getElementById(name+"_"+i)))
					return false;
			}
			if(vrsta == "broj"){
				if(!jeBroj(document.getElementById(name+"_"+i))){
					return false;
					}
	/*			if(typeof(document.getElementById(name+"_"+i).value)!="number"){
					alert('Unos mora biti broj!');
					document.getElementById(name+"_"+i).select();
					document.getElementById(name+"_"+i).focus();
					return false;
				}
		*/	}
		}
		if(mod == "off" && tip == 'neobavezno'){
			document.getElementById(name+"_"+i).value='';
		}
	}
	
	if(k==1)
	forma.submit();
	if(k==0)
	return true;
	//alert('Kontakt forma se testira, \nte trenutačno nije u upotrebi!');
}

function submitNew(id,name,broj){
	var forma;
	forma = document.getElementById(id);
	alert(forma.lenght)
	var brojElemenata = forma.lenght;
	var varijabla="";
	if( submitKomentar(id,name,broj,0) ){
		
		for(i=0; i<brojElemenata;i++){
			varijabla += "&"+forma.elements[i].name+"="+forma.elements[i].value;
		}
		
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null){
			alert ("Preglednik ne podržava HTTP zahtjev");
			return
			} 
		var url="forme/pretvorba.php"
		alert(varijabla);
		xmlHttp.onreadystatechange=stateChanged2;
		xmlHttp.open("POST",url,true);
		xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
		xmlHttp.send(varijabla);
	}
	
}

///*
function stateChanged2() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
//{ 

	document.getElementById("tstdv").innerHTML = xmlHttp.responseText;
	/*
if(xmlHttp.responseText == "ok")
	//document.getElementById("submitBT").disabled = false;
	//alert(xmlHttp.responseText)
} 
else{
	//document.getElementById("davidim")= xmlHttp.responseText
	
	}
*/	
} 

//*/
function switchInputDcs(polje, vrijednost, vrsta, tip){
	switch(tip){
		case 'neobavezno':
			if(polje.value == vrijednost || polje.className=='dcsinput_'+vrsta+'_'+tip+'_off'){
				polje.value='';
				polje.className='dcsinput_'+vrsta+'_'+tip+'_on';
				return true;
			}
			if(polje.value == '' || (polje.className=='dcsinput_'+vrsta+'_'+tip+'_on' && polje.value == '')){
				polje.value=vrijednost;
				polje.className='dcsinput_'+vrsta+'_'+tip+'_off';
				return true;
			}
		case 'obavezno'	:		
			if(polje.value == vrijednost){
				polje.value='';
				polje.className='dcsinput_'+vrsta+'_'+tip+'_on';
				return true;
			}
			if(polje.value == ''){
				polje.value=vrijednost;
				polje.className='dcsinput_'+vrsta+'_'+tip+'_off';
				return true;
			}
	}
}

function switchInput(polje, vrijednost, vrsta, tip){
	switch(tip){
		case 'neobavezno':
			if(polje.value == vrijednost || polje.className=='input_'+vrsta+'_'+tip+'_off'){
				polje.value='';
				polje.className='input_'+vrsta+'_'+tip+'_on';
				return true;
			}
			if(polje.value == '' || (polje.className=='input_'+vrsta+'_'+tip+'_on' && polje.value == '')){
				polje.value=vrijednost;
				polje.className='input_'+vrsta+'_'+tip+'_off';
				return true;
			}
		case 'obavezno'	:		
			if(polje.value == vrijednost){
				polje.value='';
				polje.className='input_'+vrsta+'_'+tip+'_on';
				return true;
			}
			if(polje.value == ''){
				polje.value=vrijednost;
				polje.className='input_'+vrsta+'_'+tip+'_off';
				return true;
			}
	}
}
function showZeroFilled(inValue) {
	if (inValue > 9) {
		return ":" + inValue
	}
	return ":0" + inValue
}

function showZeroFilledh(inValue) {
	if (inValue > 9) {
		return "" + inValue
	}
	return "0" + inValue
}
	
function showTheTime() {
	var now = new Date;
	var sat = document.getElementById('sat');
	
	//alert(sat.innerHTML);
	sat.innerHTML = showZeroFilledh(now.getHours()) +  showZeroFilled(now.getMinutes()) + showZeroFilled(now.getSeconds());
	setTimeout("showTheTime()",1000);
	}


function pozdrav1(){
	var now = new Date;
	if (now.getHours() <= 10 ) {
		document.write( '<span>Dobro jutro</strong>');
	}
	else if (now.getHours() <= 17 ) {
		document.write( '<strong>Dobar dan</strong>');
	}
	else {
		document.write( '<strong>Dobra večer</strong>');
	}
}

function dan(){
	var now = new Date
	var dayName = new Array ("nedjelja","ponedjeljak","utorak","srijeda","četvrtak","petak","subota");
	document.write( dayName[now.getDay()]);
}

function datum(){
	var now = new Date
	document.write(showZeroFilledh(now.getDate()) + " / " + showZeroFilledh(now.getMonth()+parseInt(1)) + " / " + now.getFullYear());
}


function checkEmail(fld){ // simple email check
  if(!fld.value.length||fld.disabled) return true; // blank fields are the domain of requireValue 
  var phony= /@(\w+\.)*example\.(com|net|org)$/i;
  if(phony.test(fld.value))
  { alert('Molimo unesite e-mail adresu.'); fld.focus(); fld.select(); return false; }
  var emailfmt= /^\w+([.-]\w+)*@\w+([.-]\w+)*\.\w{2,8}$/;
  if(!emailfmt.test(fld.value))
  { alert('E-mail adresa mora biti točna.'); fld.focus(); fld.select(); return false; }
  return true;
}


function provjeriSliku2(forma, tip){
	//alert(pathback)
	var unos = forma.value		
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Preglednik ne podržava HTTP zahtjev");
		return
		} 
	var url="../forme/validateImage.php"
	var varijabla = "keystring="+unos;
	//alert(varijabla);
	if(tip == "a")
		xmlHttp.onreadystatechange=stateChanged_a;
	if(tip == "b")
		xmlHttp.onreadystatechange=stateChanged_b;
	
	xmlHttp.open("POST",url,true);
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
	xmlHttp.send(varijabla);
} 

function stateChanged_a() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{ 
if(xmlHttp.responseText == "ok")
	document.getElementById("submitBT1").disabled = false;
	//alert(xmlHttp.responseText)
} 
} 
function stateChanged_b() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{ 
if(xmlHttp.responseText == "ok")
	document.getElementById("submitBT2").disabled = false;
	//alert(xmlHttp.responseText)
} 
} 

function provjeriSliku(forma,pathback){
	//alert(pathback)
	var unos = forma.value		
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Preglednik ne podržava HTTP zahtjev");
		return
		} 
	var url=pathback+"/forme/validateImage.php"
	var varijabla = "keystring="+unos;
	//alert(varijabla);
	xmlHttp.onreadystatechange=stateChanged1;
	xmlHttp.open("POST",url,true);
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
	xmlHttp.send(varijabla);
} 

function provjeriSlikuX(forma){
	//alert(pathback)
	var unos = forma.value		
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Preglednik ne podržava HTTP zahtjev");
		return
		} 
	var url="forme/validateImage.php"
	var varijabla = "keystring="+unos;
	//alert(varijabla);
	xmlHttp.onreadystatechange=stateChanged1;
	xmlHttp.open("POST",url,true);
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
	xmlHttp.send(varijabla);
} 


function stateChanged1() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{ 

	//document.getElementById("davidim").innerHTML = xmlHttp.responseText;
if(xmlHttp.responseText == "ok")
	document.getElementById("submitBT").disabled = false;
	//alert(xmlHttp.responseText)
} 
else{
//	document.getElementById("davidim")= xmlHttp.responseText
	}
} 

function overAdresar(adresar){
		restoredArray = adresar.id.split("_");
		upali = restoredArray[0];
		id = restoredArray[1];
		if(upali == "y"){
			adresar.className="adresarHeadDivOver";
		//	alert(id)
		}
	}

function outAdresar(adresar){
		restoredArray = adresar.id.split("_");
		upali = restoredArray[0];
		id = restoredArray[1];
		if(upali == "y"){
			adresar.className="adresarHeadDiv";
		//	alert(id)
		}
		//alert(upali)
	}

function upaliAdresar(adresar){
		//alert(adresar.id);
		restoredArray = adresar.id.split("_");
		upali = restoredArray[0];
		id = restoredArray[1];
	//	alert(id)
		if(upali == "y"){
			adresar.id = "n_"+id;
			adresar.className = "adresarHeadDivOver";
		}
		else{
			adresar.id = "y_"+id;
		//	adresar.className = "adresarHeadDiv";
		}
}









////
//Animated Collapsible DIV- Author: Dynamic Drive (http://www.dynamicdrive.com)
//Last updated Aug 1st, 07'. Fixed bug with "block" parameter not working when persist is enabled
//Updated June 27th, 07'. Added ability for a DIV to be initially expanded.

var uniquepageid=window.location.href.replace("http://"+window.location.hostname, "").replace(/^\//, "") //get current page path and name, used to uniquely identify this page for persistence feature

function animatedcollapse(divId, animatetime, persistexpand, initstate){
	this.divId=divId
	this.divObj=document.getElementById(divId)
	this.divObj.style.overflow="hidden"
	this.timelength=animatetime
	this.initstate=(typeof initstate!="undefined" && initstate=="block")? "block" : "contract"
	this.isExpanded=animatedcollapse.getCookie(uniquepageid+"-"+divId) //"yes" or "no", based on cookie value
	this.contentheight=parseInt(this.divObj.style.height)
	var thisobj=this
	if (isNaN(this.contentheight)){ //if no CSS "height" attribute explicitly defined, get DIV's height on window.load
		animatedcollapse.dotask(window, function(){thisobj._getheight(persistexpand)}, "load")
		if (!persistexpand && this.initstate=="contract" || persistexpand && this.isExpanded!="yes" && this.isExpanded!="") //Hide DIV (unless div should be expanded by default, OR persistence is enabled and this DIV should be expanded)
			this.divObj.style.visibility="hidden" //hide content (versus collapse) until we can get its height
	}
	else if (!persistexpand && this.initstate=="contract" || persistexpand && this.isExpanded!="yes" && this.isExpanded!="") //Hide DIV (unless div should be expanded by default, OR persistence is enabled and this DIV should be expanded)
		this.divObj.style.height=0 //just collapse content if CSS "height" attribute available
	if (persistexpand)
		animatedcollapse.dotask(window, function(){animatedcollapse.setCookie(uniquepageid+"-"+thisobj.divId, thisobj.isExpanded)}, "unload")
}

animatedcollapse.prototype._getheight=function(persistexpand){
	this.contentheight=this.divObj.offsetHeight
	if (!persistexpand && this.initstate=="contract" || persistexpand && this.isExpanded!="yes"){ //Hide DIV (unless div should be expanded by default, OR persistence is enabled and this DIV should be expanded)
		this.divObj.style.height=0 //collapse content
		this.divObj.style.visibility="visible"
	}
	else //else if persistence is enabled AND this content should be expanded, define its CSS height value so slideup() has something to work with
		this.divObj.style.height=this.contentheight+"px"
}


animatedcollapse.prototype._slideengine=function(direction){
	var elapsed=new Date().getTime()-this.startTime //get time animation has run
	var thisobj=this
	if (elapsed<this.timelength){ //if time run is less than specified length
		var distancepercent=(direction=="down")? animatedcollapse.curveincrement(elapsed/this.timelength) : 1-animatedcollapse.curveincrement(elapsed/this.timelength)
	this.divObj.style.height=distancepercent * this.contentheight +"px"
	this.runtimer=setTimeout(function(){thisobj._slideengine(direction)}, 10)
	}
	else{ //if animation finished
		this.divObj.style.height=(direction=="down")? this.contentheight+"px" : 0
		this.isExpanded=(direction=="down")? "yes" : "no" //remember whether content is expanded or not
		this.runtimer=null
	}
}


animatedcollapse.prototype.slidedown=function(){
	if (typeof this.runtimer=="undefined" || this.runtimer==null){ //if animation isn't already running or has stopped running
		if (isNaN(this.contentheight)) //if content height not available yet (until window.onload)
			alert("Pričekajte dok se dokument ne učita u potpunosti te kliknite ponovo")
		else if (parseInt(this.divObj.style.height)==0){ //if content is collapsed
			this.startTime=new Date().getTime() //Set animation start time
			this._slideengine("down")
		}
	}
}

animatedcollapse.prototype.slideup=function(){
	if (typeof this.runtimer=="undefined" || this.runtimer==null){ //if animation isn't already running or has stopped running
		if (isNaN(this.contentheight)) //if content height not available yet (until window.onload)
			alert("Pričekajte dok se dokument ne učita u potpunosti te kliknite ponovo")
		else if (parseInt(this.divObj.style.height)==this.contentheight){ //if content is expanded
			this.startTime=new Date().getTime()
			this._slideengine("up")
		}
	}
}

animatedcollapse.prototype.slideit=function(){
	if (isNaN(this.contentheight)) //if content height not available yet (until window.onload)
		alert("Pričekajte dok se dokument ne učita u potpunosti te kliknite ponovo")
	else if (parseInt(this.divObj.style.height)==0)
		this.slidedown()
	else if (parseInt(this.divObj.style.height)==this.contentheight)
		this.slideup()
}

// -------------------------------------------------------------------
// A few utility functions below:
// -------------------------------------------------------------------

animatedcollapse.curveincrement=function(percent){
	return (1-Math.cos(percent*Math.PI)) / 2 //return cos curve based value from a percentage input
}


animatedcollapse.dotask=function(target, functionref, tasktype){ //assign a function to execute to an event handler (ie: onunload)
	var tasktype=(window.addEventListener)? tasktype : "on"+tasktype
	if (target.addEventListener)
		target.addEventListener(tasktype, functionref, false)
	else if (target.attachEvent)
		target.attachEvent(tasktype, functionref)
}

animatedcollapse.getCookie=function(Name){ 
	var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
	if (document.cookie.match(re)) //if cookie found
		return document.cookie.match(re)[0].split("=")[1] //return its value
	return ""
}

animatedcollapse.setCookie=function(name, value){
		document.cookie = name+"="+value
}
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
var doneyet = 0;  // changes to 1 when the DOM is done loading
	
function checkstate()
{
	// Besides IE, Safari also can use document.readyState
	// but Safari does not support onreadystatechange, so
	// we will keep calling this function with progress_bar().
	
	// Check to see if document is not "complete" but
	// is loaded enough to be "interactive"
	if (document.readyState=="complete" ||
		document.readyState=="complete")
		doneyet = 1;

} // end function checkstate()

function saydone()
{
	doneyet = 1;
}  // end function saydone()

function checkstate()
	{
		// Besides IE, Safari also can use document.readyState
		// but Safari does not support onreadystatechange, so
		// we will keep calling this function with progress_bar().
		
		// Check to see if document is not "complete" but
		// is loaded enough to be "interactive"
		if (document.readyState=="complete" ||
			document.readyState=="complete")
			doneyet = 1;
	
	} // end function checkstate()


//
/*
function startajSve(){
	// If IE
	
	alert(doneyet)
	if(document.readyState)	
	{
		document.onreadystatechange=checkstate;
	}
	else if (document.addEventListener) // if Mozilla or Netscape
	{
		document.addEventListener("DOMContentLoaded", saydone, false);
	}
	
		
	alert(doneyet)
	if(doneyet==1){
		var collapse1=new animatedcollapse("odgDv", 3000, false);
		clearTimeout(timeoutID);
		alert('ok')
		collapse1.slideit();
	}
	else
		var timeoutID = setTimeout("startajSve()", 1000);

}

startajSve();
//*/
//window.onload=startajSve();

// Global variables
var isCSS, isW3C, isIE4, isNN4, isIE6CSS;

// Initialize upon load to let all browsers establish content objects
function initDHTMLAPI( ) {
    if (document.images) {
        isCSS = (document.body && document.body.style) ? true : false;
        isW3C = (isCSS && document.getElementById) ? true : false;
        isIE4 = (isCSS && document.all) ? true : false;
        isNN4 = (document.layers) ? true : false;
        isIE6CSS = (document.compatMode && document.compatMode.indexOf("CSS1") >= 0) ? 
            true : false;
    }
}

// Set event handler to initialize API
window.onload = initDHTMLAPI;
   
// Seek nested NN4 layer from string name
function seekLayer(doc, name) {
    var theObj;
    for (var i = 0; i < doc.layers.length; i++) {
        if (doc.layers[i].name == name) {
            theObj = doc.layers[i];
            break;
        }
        // dive into nested layers if necessary
        if (doc.layers[i].document.layers.length > 0) {
            theObj = seekLayer(document.layers[i].document, name);
        }
    }
    return theObj;
}
   
// Convert object name string or object reference
// into a valid element object reference
function getRawObject(obj) {
    var theObj;
    if (typeof(obj) == "string") {
        if (isW3C) {
            theObj = document.getElementById(obj);
			alert('ok')
        } else if (isIE4) {
            theObj = document.all(obj);
        } else if (isNN4) {
            theObj = seekLayer(document, obj);
        } 
		
    } else {
        // pass through object reference
        theObj = obj;
    }
	alert(theObj)
    return theObj;
}
   
// Convert object name string or object reference
// into a valid style (or NN4 layer) reference
function getObject(obj) {
    var theObj = getRawObject(obj);
    if (theObj && isCSS) {
        theObj = theObj.style;
    }
    return theObj;
}
   
// Position an object at a specific pixel coordinate
function shiftTo(obj, x, y) {
    var theObj = getObject(obj);
    if (theObj) {
        if (isCSS) {
            // equalize incorrect numeric value type
            var units = (typeof theObj.left == "string") ? "px" : 0;
            theObj.left = x + units;
            theObj.top = y + units;
        } else if (isNN4) {
            theObj.moveTo(x,y)
        }
    }
}
   
// Move an object by x and/or y pixels
function shiftBy(obj, deltaX, deltaY) {
    var theObj = getObject(obj);
    if (theObj) {
        if (isCSS) {
            // equalize incorrect numeric value type
            var units = (typeof theObj.left == "string") ? "px" : 0;
            theObj.left = getObjectLeft(obj) + deltaX + units;
            theObj.top = getObjectTop(obj) + deltaY + units;
        } else if (isNN4) {
            theObj.moveBy(deltaX, deltaY);
        }
    }
}
   
// Set the z-order of an object
function setZIndex(obj, zOrder) {
    var theObj = getObject(obj);
    if (theObj) {
        theObj.zIndex = zOrder;
    }
}
   
// Set the background color of an object
function setBGColor(obj, color) {
    var theObj = getObject(obj);
    if (theObj) {
        if (isNN4) {
            theObj.bgColor = color;
        } else if (isCSS) {
            theObj.backgroundColor = color;
        }
    }
}
   
// Set the visibility of an object to visible
function show(obj) {
    var theObj = getObject(obj);
    if (theObj) {
        theObj.visibility = "visible";
    }
}
   
// Set the visibility of an object to hidden
function hide(obj) {
    var theObj = getObject(obj);
    if (theObj) {
        theObj.visibility = "hidden";
    }
}
   
// Retrieve the x coordinate of a positionable object
function getObjectLeft(obj)  {
    var elem = getRawObject(obj);
    var result = 0;
    if (document.defaultView) {
        var style = document.defaultView;
        var cssDecl = style.getComputedStyle(elem, "");
        result = cssDecl.getPropertyValue("left");
    } else if (elem.currentStyle) {
        result = elem.currentStyle.left;
    } else if (elem.style) {
        result = elem.style.left;
    } else if (isNN4) {
        result = elem.left;
    }
    return parseInt(result);
}
   
// Retrieve the y coordinate of a positionable object
function getObjectTop(obj)  {
    var elem = getRawObject(obj);
    var result = 0;
    if (document.defaultView) {
        var style = document.defaultView;
        var cssDecl = style.getComputedStyle(elem, "");
        result = cssDecl.getPropertyValue("top");
    } else if (elem.currentStyle) {
        result = elem.currentStyle.top;
    } else if (elem.style) {
        result = elem.style.top;
    } else if (isNN4) {
        result = elem.top;
    }
    return parseInt(result);
}
   
// Retrieve the rendered width of an element
function getObjectWidth(obj)  {
    var elem = getRawObject(obj);
    var result = 0;
    if (elem.offsetWidth) {
        result = elem.offsetWidth;
    } else if (elem.clip && elem.clip.width) {
        result = elem.clip.width;
    } else if (elem.style && elem.style.pixelWidth) {
        result = elem.style.pixelWidth;
    }
    return parseInt(result);
}
   
// Retrieve the rendered height of an element
function getObjectHeight(obj)  {
    var elem = getRawObject(obj);
    var result = 0;
    if (elem.offsetHeight) {
        result = elem.offsetHeight;
    } else if (elem.clip && elem.clip.height) {
        result = elem.clip.height;
    } else if (elem.style && elem.style.pixelHeight) {
        result = elem.style.pixelHeight;
    }
    return parseInt(result);
}
   
// Return the available content width space in browser window
function getInsideWindowWidth( ) {
    if (window.innerWidth) {
        return window.innerWidth;
    } else if (isIE6CSS) {
        // measure the html element's clientWidth
        return document.body.parentElement.clientWidth;
    } else if (document.body && document.body.clientWidth) {
        return document.body.clientWidth;
    }
    return 0;
}
   
// Return the available content height space in browser window
function getInsideWindowHeight( ) {
    if (window.innerHeight) {
        return window.innerHeight;
    } else if (isIE6CSS) {
        // measure the html element's clientHeight
        return document.body.parentElement.clientHeight;
    } else if (document.body && document.body.clientHeight) {
        return document.body.clientHeight;
    }
    return 0;
}
