var preview;
if (document.images) {
	nodeOn = new Image();
	nodeOn.src = "images/plus.gif";
	nodeOff = new Image();
	nodeOff.src = "images/minus.gif";
}

// inicijalizacija stranice
function init() {
	var currentMenuID = document.getElementById("m"+currentID);
	
	document.getElementById("m1").style.borderBottomColor = "#003259";
	document.getElementById("m2").style.borderBottomColor = "#004A74";
	document.getElementById("m3").style.borderBottomColor = "#0079AA";
	document.getElementById("m4").style.borderBottomColor = "#009FD4";
	document.getElementById("m5").style.borderBottomColor = "#00B5ED";
	document.getElementById("m6").style.borderBottomColor = "#8EE0F9";
	
	for(var i=1;i<=6;i++) {
		document.getElementById("m"+i).style.fontWeight = "normal";
	}
	
	// ukoliko neka od stavki glavnog menija teba da bude selektovana
	if (currentID != "0") {
		currentMenuID.style.backgroundColor = "#FFD01F";
		currentMenuID.style.borderBottomColor = "#FFD01F";
		currentMenuID.style.fontWeight = "bold";
	}
}

window.onload = init;

// onmouseover i onmouseout event u glavnom meniju
function doMenu(mID,state) {
	if (!document.getElementById) return;
	
	var objElement = document.getElementById(mID);	
	if (mID.id != ("m"+currentID)) {
		if (state == true) {			
			mID.style.backgroundColor = "#E01212";
			mID.style.color = "#FFFFFF";
			mID.style.borderTopColor = "#E01212";			
		} else {
			mID.style.backgroundColor = "#FFFFFF";
			mID.style.color = "#000000";
			mID.style.borderTopColor = "#424242";
		}
	}
}

// onmousedown event u glavnom meniju
function goTo(pID) {
	menuArray = new Array(6);
	
	menuArray[1] = 'default.asp';
	menuArray[2] = 'products.sweets.asp';
	menuArray[3] = 'products.snacks.asp';
	menuArray[4] = 'prices.asp';
	menuArray[5] = 'actions.asp';
	menuArray[6] = 'contact.asp';
	
	document.location = menuArray[pID];
}

//add page to favorite function
function addToFavorites() {    
  if (window.external) {
	pageURLDefault = "http://www.banini.co.rs"
	var RegularExpression = /&raquo;/g;
	page_name = pageTitleFavorites.replace(RegularExpression, "-");

	if (pageURLFavorites != "") {
		external.AddFavorite(pageURLFavorites, page_name);
	} else {
		external.AddFavorite(pageURLDefault, page_name);
	}    
  }    
  else {        
    alert("Vaš čitač ne podržava ovu mogućnost!\nYour browser doesn't support this feature!");
  }
}


function doPreview(slika, naslov, levo, gore, sirina, visina, root) {
	metrika = 'left=' + levo + ',top=' + gore;
	metrika += ',width=' + sirina + ',height=' + visina;
	metrika += ',scrollbars=0,resizable=0, directories=0, status=0, menubar=0, location=0, toolbar=0';
 
	strHTML = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 Transitional//EN" "DTD/xhtml1-transitional.dtd">' +
			  '<html>' + 
			  '<head>' +
			  '<title>Banini AD :: ' + naslov + '</title>' +
			  '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">' +
			  '<meta http-equiv="imagetoolbar" content="no">' +
			  '<link rel="stylesheet" type="text/css" href="style/style.w.css">' +
			  '</head>' +
			  '<body>' +
			  '<div id="frame">' +
			  '<a href="javascript:window.close();">' +
			  '<img src="' + root + 'images/' + slika + '" border="0" alt="Zatvori prozor / Close Window">' +
			  '</a>' +
			  '</div>' +
			  '</body>' +
			  '</html>';
			  
	if (!preview || preview.closed) {
		preview = window.open("", "preview", metrika);
		preview.document.open();
		preview.focus();
		preview.document.write(strHTML);
		preview.document.close();
	} else {
		preview.close();
		preview = window.open("", "preview", metrika);
		preview.document.open();
		preview.focus();
		preview.document.write(strHTML);
		preview.document.close();
	}
}

function shDistributors(cID) {
	dID = document.getElementById("c" + cID);
	dID.style.display = (dID.style.display == 'none') ? "block" : "none";
	document.images["node"+cID].src = (document.images["node"+cID].src == nodeOn.src) ? nodeOff.src : nodeOn.src;
}

function shNews() {
	eID = document.getElementById("newslist");
	eID.style.display = (eID.style.display == 'block') ? "none" : "block";
	document.images["nodeNews"].src = (document.images["nodeNews"].src == nodeOn.src) ? nodeOff.src : nodeOn.src;
}