
	function addToCart(dod, homehref, prevod1)
	{
		// če ni nič izbrano, obvestim uporabnika naj nekaj izbere
		var ok = false;
		var cbs = document.getElementsByName("opcijacena");
		for (i=0; i<cbs.length; i++)
		{
			if (cbs[i].checked)
				ok = true;
		}
		
		if (ok)
		{
		    //if (dod && dod=="500")
		     //   document.forms['cart'].action = homehref + "/kosarica500";
		    var tt = document.getElementById("cartform");
		    tt.submit();
		    //document.forms['cart'].submit();
		}
		else
			alert(prevod1);
	}
	
	function ChangePriceGlobal(prevodeur)
	{
		var el = document.getElementsByName("opcijacena");
		var skupnacena = 0;
		for(i=0; i<el.length; i++)
		{
			if (el[i].checked)
			{
				var arr = el[i].value.split('_');
				var kolicina = document.getElementById("kolicina" + arr[0]);
				if (kolicina)
				{
					var cena = parseFloat(arr[1])
					var kos = parseInt(kolicina.value);
					//alert(cena + "_" + kos + "=" + cena*kos);
					skupnacena += cena * kos;
				}
			}
		}
		var elem=document.getElementById("vasacena");
		elem.innerHTML=addCommas(skupnacena.toFixed(2)) + " " + prevodeur;
	}
	
function addCommas(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? ',' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + '.' + '$2');
	}
	return x1 + x2;
}


function closePopup(id)
{
    var el = document.getElementById(id);
    if (el) el.style.display="none";
}

function Popup(url, width, height, name)
{	
	var win_width = width
	var win_height = height
	var loc_left = (screen.width/2) - (win_width/2)
	var loc_top = (screen.height/2) - (win_height/2)
	var style = "top=" + loc_top + ", left=" + loc_left +
	"toolbar=no,location=no,directories=no," + 
	"status=no,menubar=no,scrollbars=yes," + 
	"resizable=yes,copyhistory=no,width=" + win_width +
	",height=" + win_height
	
	var newwindow = window.open(url,name,style);
	if (window.focus) {newwindow.focus()}
}

function showHidePopupCart(show)
{
    var el = document.getElementById("popupcart");
    if (el)
    {
        var img = document.getElementById("kosaricapopuplink");
        if (img)
        {
            if (show) //img.className=="kosarica")
            {
                img.className = "kosarica kosaricadown";
                el.style.display="block";                                
            }
            else
            {
                img.className = "kosarica";            
                el.style.display="none";                
            }
        }
    }    
}

  function changeMotivnaVita(arr, arr2, arr3, arr4, kam, imgpath, steviloslik, showdirect) {
      
        var blendtime = 1200;
        if (showdirect==0 && manual) return;
        
        var st = motivnacounter;
        // preklop naprej
        if (kam==1) if (st<steviloslik-1) st++; else st=0;
        // preklop nazaj
        if (kam==-1) if (st>0) st--; else st=steviloslik-1;
        

        if (showdirect>0)
        {
            st = showdirect-1;
            blendtime = 100;
            manual = true;
        }
        
        motivnacounter = st;
        
        if (arr[st]) 
        {
            blendimageVita("motivna", "motivnaimg", imgpath + arr[st], blendtime);
        }
        
        var link = document.getElementById("motivnalink");
        if (link)
        {
            if (arr2[st])
                link.href = arr2[st];
            else
                link.href = "";

            if (arr3[st])
                link.title = arr3[st];
            else
                link.title = "";

        }

        var motimg = document.getElementById("motivnaimg");
        if (motimg) {
            if (arr4[st])
                motimg.alt = arr4[st];
            else
                motimg.alt = "";
        }
        
        // oznacim link
        for (var f=1; f<=steviloslik; f++)
        {
            var lnk = document.getElementById("bannerstevilkalink" + f);
            if (lnk) lnk.className = f==st+1 ? "selected" : "";
        }
    }

function blendimageVita(divid, imageid, imagefile, millisec) { 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 
     
    //set the current image as background 
    document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")"; 
     
    //make image transparent 
    changeOpacVita(0, imageid); 
     
    //make new image 
    document.getElementById(imageid).src = imagefile; 

    //fade in image 
    for(i = 0; i <= 100; i++) { 
        setTimeout("changeOpacVita(" + i + ",'" + imageid + "')",(timer * speed)); 
        timer++; 
    } 
} 


//change the opacity for different browsers 
function changeOpacVita(opacity, id) { 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
} 


function clearInput(el)
{
        el.value = "";
}
