if (document.images) {
	n1on = new Image();    n1on.src = "images/nav-home-on.gif";
	n2on = new Image();    n2on.src = "images/nav-about-on.gif";
	n3on = new Image();    n3on.src = "images/nav-info-on.gif";
	//n4on = new Image();    n4on.src = "images/nav-offline-on.gif";
	n4on = new Image();    n4on.src = "images/nav-akcija-on.gif";
	n5on = new Image();    n5on.src = "images/nav-contact-on.gif";
	n6on = new Image();    n6on.src = "images/cart_hover.gif";

	p1= new Image(); p1.src = "images/password-on.gif";
	p2= new Image(); p2.src = "images/login-on.gif";
	p3= new Image(); p3.src = "images/search-on.gif.gif";
}

function imgOn(imgName) {
	if (document.images) {
		oSrc=document[imgName].src;
		document[imgName].src = eval(imgName + "on.src");
	}
}

function imgOff(imgName) {
	if(oSrc){
		document[imgName].src = oSrc;
	}
}

var boxPre = "fancyBox ";

function focusInput(input){
	input.className = boxPre + input.id;
}

function blurInput(input){
	if(!input) return;
	if(!input.value || input.value == ""){
		input.className = boxPre + input.id + "Empty";
	}
	else
		input.className = boxPre + input.id;
}

function addToCart(productId){
	var fieldName = productId;
	if(!document.getElementById(fieldName) || document.getElementById(fieldName).value == ''){
		alert("Morate prvo uneti količinu!");
		return false;
	}
	else{
		var f = document.forms[listFormName];
		f.attributes['action'].value = 'cart.php';
		f.elements['action'].value = 'add';
		f.submit();
		return true;
	}
}

function enterPressed(e,field){
	var oEvent = window.event ? window.event : e;
	var key=oEvent.keyCode;
	if (key==13){
		addToCart(field.id);
		return false;
	}
}


function setProductsOrder(order) {
	var f = document.forms[listFormName];
	var o = f.elements['data[order]'];
	if (o.value == order)	o.value = order + ' DESC';
	else					o.value = order;

	f.submit();
}

function initFancyBoxes(){
	blurInput(document.getElementById('search'));
	blurInput(document.getElementById('login'));
	blurInput(document.getElementById('password'));
}
