// onmmouseover hover na srednjem meniju udzbenika
	var cOver = '#FFC7C7';
	var cNormal = '#FEE8EB';
	
	function hoverLine(what,color){
		what.style.backgroundColor=color;
	}

if (document.images) {
	var submitPrijavi0 = new Image();
	var submitPrijavi1 = new Image();
	var submitUlaz0 = new Image();
	var submitUlaz1 = new Image();
	var submitTrazi0 = new Image();
	var submitTrazi1 = new Image();
	var submitIspisi0 = new Image();
	var submitIspisi1 = new Image();
	var submitKolicine0 = new Image();
	var submitKolicine1 = new Image();
	var submitNaruci0 = new Image();
	var submitNaruci1 = new Image();
	
	var pomocnaVrh0 = new Image();
	var pomocnaVrh1 = new Image();
	var pomocnaNat0 = new Image();
	var pomocnaNat1 = new Image();
	var pomocnaNas0 = new Image();
	var pomocnaNas1 = new Image();
			
	submitPrijavi0.src = "../include/images/submitPrijavi0.gif";
	submitPrijavi1.src = "../include/images/submitPrijavi1.gif";
	submitUlaz0.src = "../include/images/submitUlaz0.gif";
	submitUlaz1.src = "../include/images/submitUlaz1.gif";
	submitTrazi0.src = "../include/images/submitTrazi0.gif";
	submitTrazi1.src = "../include/images/submitTrazi1.gif";
	submitIspisi0.src = "../include/images/submitIspisi0.gif";
	submitIspisi1.src = "../include/images/submitIspisi1.gif";
	submitKolicine0.src = "../include/images/submitKolicine0.gif";
	submitKolicine1.src = "../include/images/submitKolicine1.gif";
	submitNaruci0.src = "../include/images/submitNaruci0.gif";
	submitNaruci1.src = "../include/images/submitNaruci1.gif";
	
	pomocnaVrh0.src = "../include/images/pomocnaVrh0.gif";
	pomocnaVrh1.src = "../include/images/pomocnaVrh1.gif";
	pomocnaNat0.src = "../include/images/pomocnaNat0.gif";
	pomocnaNat1.src = "../include/images/pomocnaNat1.gif";
	pomocnaNas0.src = "../include/images/pomocnaNas0.gif";
	pomocnaNas1.src = "../include/images/pomocnaNas1.gif";

}	
//<a href="#" onclick="SearchFormCheck(); return false;" onMouseOver="image_on('submitTrazi');" onMouseOut="image_off('submitTrazi');"><img src="../include/images/submitTrazi0.gif" alt="" name="submitTrazi" border="0" height="22" width="54"></a>
function image_on (image) {
	if (document.images) {
		document[image].src = eval(image + '1.src');
	}
}
function image_off (image) {
	if (document.images) {
		document[image].src =  eval(image + '0.src');
	}
}


function Natrag() {
	history.back();
}
function Vrh() {
	window.scrollTo(0,0);
}

function LogirajSe(){
	fali = "";
	
	if (document.login.korisniciLogin.value == "") fali = fali + "\n- Korisničko ime";
	if (document.login.korisniciPass.value == "") fali = fali + "\n- Lozinku";
	if (fali != "") {
	   alert("Niste upisali sve potrebne podatke!" + "\n\n" + "Molimo upišite:" + fali)
	   return false;
	   }
	else
	 document.login.submit();
}

function formNarudzbaCheck(){
	fali = "";
	if (document.narudzba.ime.value == "") fali = fali + "\n- Ime";
	if (document.narudzba.prezime.value == "") fali = fali + "\n- Prezime";
	if (document.narudzba.adresa.value == "") fali = fali + "\n- Adresu";
	if (document.narudzba.mjesto.value == "") fali = fali + "\n- Mjesto";
	if (document.narudzba.postbroj.value == "") fali = fali + "\n- Poštanski broj";
	if (document.narudzba.drzava.value == "") fali = fali + "\n- Državu";
	if (document.narudzba.telefon.value == "") fali = fali + "\n- Telefon";
	if (fali != "") {
	   alert("Niste upisali sve potrebne podatke!" + "\n\n" + "Molimo upišite:" + fali)
	   return false;
	} else {
		DaLiSamUFrameu();
 		document.narudzba.submit();
	}
}

function DaLiSamUFrameu() {
    var x = top.frames.length;
    if (x > 0) {
        // nalazim se u t-comovom frameu
        document.forms.narudzba.htmall.value = "y";
    }
}

function NewsletterFormCheck(){
	fali = "";
	if (document.newsletter.eMail.value == "") fali = fali + "E-mail adresu";
	if (fali != "") {
	   alert("Niste upisali sve potrebne podatke!" + "\n\n" + "Molimo upišite " + fali)
	   return false;
	   }
	else
	 document.newsletter.submit();
}

function SearchFormCheck(){
	fali = "";
	pojam = document.search.pojam.value;
	if (pojam != '' && pojam.length > 2) {
		document.search.submit();
	} else {
	   alert("Pojam mora sadržavati bar tri znaka!");
	   return false;
   }
}
function AdvancedSearchFormCheck(){
	fali = "";
	document.advancedsearch.submit();
	/*
	pojam = document.advancedsearch.pojam.value;
	if (pojam != '' && pojam.length > 2) {
		document.advancedsearch.submit();
	} else {
	   alert("Pojam mora sadržavati bar tri znaka!");
	   return false;
   }
   */
}

function ToggleDisplay(id)
 {
	// zatvaram sve
	/*
		myElement = document.getElementById( 'containerOsnovna' );
		for( var c = 0; c < myElement.childNodes.length; c++ ) {
			if (myElement.childNodes[c].nodeName == 'DIV' && myElement.childNodes[c].className == 'details') {
				myElement.childNodes[c].style.display = 'none';
				myElement.childNodes[c].style.visibility = 'hidden';
			};
			if (myElement.childNodes[c].nodeName == 'DIV' && myElement.childNodes[c].className == 'header') {
				myElement.childNodes[c].style.color = '#fff';
			};
		};
	*/
   var elem = document.getElementById('d' + id);
   if (elem) {
		headerDiv = document.getElementById('h' + id);	// naslov
		
		if (elem.style.display != 'block') {
			elem.style.display = 'block';
			elem.style.visibility = 'visible';
			document.getElementById('h' + id).style.color = '#ED001F';
			document.getElementById('h' + id).style.fontWeight = 'bold';
			headerDiv.innerHTML = headerDiv.innerHTML.replace('»','&laquo;');
			document.getElementById('h' + id).style.borderBottom = '0px dashed #ED001F';
			
		} else {
			elem.style.display = 'none';
			elem.style.visibility = 'hidden';
			document.getElementById('h' + id).style.color = '#000';
			document.getElementById('h' + id).style.fontWeight = 'normal';
			headerDiv.innerHTML = headerDiv.innerHTML.replace('«','&raquo;');
			document.getElementById('h' + id).style.borderBottom = '1px dashed #ED001F';
		}
	}
}



function PageQuery(q) 
	{
		if(q.length > 1) this.q = q.substring(1, q.length);
		else this.q = null;
		this.keyValuePairs = new Array();
		if(q) {
		for(var i=0; i < this.q.split("&").length; i++) {
		this.keyValuePairs[i] = this.q.split("&")[i];
		}
		}
		this.getKeyValuePairs = function() { return this.keyValuePairs; }
		this.getValue = function(s) {
		for(var j=0; j < this.keyValuePairs.length; j++) {
		if(this.keyValuePairs[j].split("=")[0] == s)
		return this.keyValuePairs[j].split("=")[1];
		}
		return false;
		}
		this.getParameters = function() {
		var a = new Array(this.getLength());
		for(var j=0; j < this.keyValuePairs.length; j++) {
		a[j] = this.keyValuePairs[j].split("=")[0];
		}
		return a;
		}
		this.getLength = function() { return this.keyValuePairs.length; }
		}
		function queryString(key){
		var page = new PageQuery(window.location.search);
		return unescape(page.getValue(key));
	}		


function formatWhere()
{
	var qs = "";
	if (document.forms[0].proizvod.value != "")
		qs+="[vrstaproizvoda]="+document.forms[0].proizvod.value+" AND ";
	if (document.forms[0].skola.value != "")
		qs+="[vrstaskole]="+document.forms[0].skola.value+" AND ";
	if (document.forms[0].predmet.value != "")
		qs+="[predmet]="+document.forms[0].predmet.value+" AND ";
	
	if(qs!="")
	{
		qs = qs.substring(0,qs.length-5);
		document.location="shop.aspx?w7="+escape(qs);
	}
	else
	{
		document.location="shop.aspx";	// odabrano SVE
	}
}

function endIndex(str, vp)
{
	var endind;
	var endinds;

	endind  = str.indexOf("%", vp);
	endinds = str.indexOf(" ", vp);
	endindp = str.indexOf("+", vp);
	if (endind < 0)
		endind  = str.length;
	if (endinds < 0)
		endinds = str.length;
	if (endindp < 0)
		endindp = str.length;
	if (endinds < endind)
		endind = endinds;
	if (endindp < endind)
		endind = endindp;
		
	return endind;
}

function postaviKategorije()
{
	var w7 = queryString("w7");
	if (w7 == false) return;
	
	var vp;
	
	vp = w7.indexOf("vrstaproizvoda");
	if (vp > 0)
	{
		document.forms[0].proizvod.value = w7.substring(vp+16, endIndex(w7,vp));
	}
	vp = w7.indexOf("vrstaskole");
	if (vp > 0)
	{
		document.forms[0].skola.value = w7.substring(vp+12, endIndex(w7,vp));
	}
	vp = w7.indexOf("predmet");
	if (vp > 0)
	{
		document.forms[0].predmet.value = w7.substring(vp+9, endIndex(w7,vp));
	}
}

function FormatCurrency ( x, dec, sepDec, sepK ) {
	if ( x == null ) return null;
	if ( dec == null ) dec = 2;
	if ( sepDec == null ) sepDec = ",";
	if ( sepK == null ) sepK = ".";
	
	var s="", r="", r1, r2, p;
	if ( x < 0 ) {
	s = "-";
	x = Math.abs( x );
	}
	else if ( x == 0 ) {
	return "0" + ( dec > 0 ? sepDec + Math.pow( 10, dec ).toString().substr( 1 ) : "" )
	}
	x = Math.round( x * Math.pow( 10, dec ) ).toString();
	if ( dec > 0 ) {
	r = sepDec + x.substr( x.length - dec );
	x = x.substr( 0, x.length - dec );
	if( x.length == 0 ) r = "0" + r;
	}
	while ( x.length > 3 ) {
	if ( r.charAt( 0 ) == sepDec )
	r = x.substr( x.length - 3 ) + r;
	else
	if ( r != "" ) r = x.substr( x.length - 3 ) + sepK + r;
	else r = x.substr( x.length - 3 );
	x = x.substr( 0, x.length - 3 );
	}
	if ( x != "" ) {
	if ( r.charAt( 0 ) == sepDec ) r = x + r;
	else if ( r != "" ) r = x + sepK + r;
	else r = x;
	}
	return r;
}