<!--
/*=====================================================================
							ARRAY SEARCH
  =====================================================================*/
function arraySearch(needle,haystack)
	{
		for (i=0; i <= haystack.length; i++)
		{
			if (haystack[i] == needle)
			{
				return i;
			}
		}
		return -1;
	}


/*=====================================================================
							SHOW/HIDE LAYER
  =====================================================================*/
function showandhide(div1,div2)
{
	// prvega prikažemo, drugega skrijemo
	if (div1 != '')
	{
		document.getElementById(div1).style.display = 'block';
	}
	if (div2 != '')
	{
		document.getElementById(div2).style.display = 'none';
	}
}


/*=====================================================================
						HIDE PAYMENT OPTION CASH
  =====================================================================*/
// funkcija, ki deaktivira opcijo plačila po povzetju, če imamo drug naslov
function checkCashOption(forma)
{
	if (forma.deliveryAddress[1].checked)
	{
		forma.payment[0].disabled = true; // opcija plačila po povzetju je neaktivna
	}
	else
	{
		forma.payment[0].disabled = false; // opcija plačila po povzetju je aktivna
	}
}


/*=====================================================================
								SHOW TAB
  =====================================================================*/
var oldID = 1;
function showTab(ID)
{
	// ID
	if (!$('tabContent'+ID))
	{
		ID = 1;
	}

	// skrijemo trenutno prižganega
	if ($('tabContent'+oldID))
	{	
		var change = new Fx.Morph($('tabContent'+oldID),  {
			duration: 'short', // 250
			onStart: function()
			{
				// višina starega
				heightOld = $('tabContent'+oldID).getSize().y;
			},
			onComplete: function()
			{
				// ugasnemo starega
				$('tabContent'+oldID).setStyle('display', 'none');
				$('tabContent'+oldID).setStyle('height', heightOld);
				$('tab'+oldID).className = '';
				oldID = ID;
				
				// prižgemo novega
				$('tab'+ID).className = 'on';
				$('tabContent'+ID).setStyle('display', 'block');
				heightNew = $('tabContent'+ID).getSize().y;
				$('tabContent'+ID).setStyle('height', 15);
				$('tabContent'+ID).setStyle('opacity', 0);
				var show = new Fx.Morph($('tabContent'+ID),  {
					duration: 'short',
					onComplete: function()
					{
						$('tabContent'+ID).setStyle('height', heightNew);
					}
				});
				show.start({'height': heightNew, 'opacity': 1});
			}
		});
		change.start({'height': 15, 'opacity': 0});
	}	
}


/*=====================================================================
							SHOW PRINT ICON
  =====================================================================*/
document.write ('<style>');
document.write ('#print {display:block;}');
document.write ('</style>');


/*=====================================================================
							INITIALIZE FOCUS
  =====================================================================*/
function initializeFocus(forma)
{
	for (i = 0; i<forma.length; i++)
	{
		forma[i].onfocus = function() {
			this.parentNode.className = 'focused';
		};
		forma[i].onblur = function() {
			this.parentNode.className = '';
		};
	}
}


/*=====================================================================
							RESIZE TEXT
  =====================================================================*/
function textUp()
{
	if (textSize < 1)	// 1 je najvisja stopnja
	{ 
		textSize = textSize + 1;
		replaceCSS(textSize);
	}
}

function textDown()
{
	if (textSize > -1) // -1 je najnizja stopnja
	{
		textSize = textSize - 1;
		replaceCSS(textSize);
	}
}

function replaceCSS(textSize)
{
	var i, a;
	for (i = 0; (a = document.getElementsByTagName("link")[i]); i++)
	{
		if (a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("rel").indexOf("alt") != -1 && a.getAttribute("title"))
		{
			a.disabled = true;
			if (textSize == -1 && a.getAttribute("title") == "small")
			{
				a.disabled = false; // mali fonti
			}
			else if (textSize == 1 && a.getAttribute("title") == "large")
			{
				a.disabled = false; // veliki fonti
			}
		}
	}
}

function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

// ko zapustimo stran, se zapiše v cookie izbrana velikost - ce je razlicna od default
window.onunload = function(e)
{
	if (textSize != 0) createCookie("textSize", textSize, 365);
	else createCookie("textSize","",-1);
}

// preberemo cookie ko se stran louda in ce ni default velikost, zamenamo stylesheet
if (document.cookie.indexOf("textSize") != -1) // preverimo, ce obstaja cookie
{
	textSize = parseInt(readCookie("textSize"));
	replaceCSS(textSize);
}
else
{
	var textSize = 0;
}
// -->
