doResize = true;

function FixSize() {
	var myW = Sirina() - 100;
	var myH = Visina() - 100;
	
	var maxW = Math.floor(myW/68) * 68;
	//var maxW = (Math.floor(myW/68) - Fix) * 68;
	//var maxH = (Math.floor(myH/68) - Fix) * 68;
	//var maxH = (Math.floor(myH/68) - 1) * 68;
	var maxH = Math.floor(myH/68) * 68;
	
	var test1 = document.getElementById('wire-frame').offsetHeight;
	var test2 = document.getElementById('wire-frame').offsetWidth;
	if ((test1 > maxH) && doResize) {
		var maxH = Math.ceil(test1/68) * 68;
		//var maxH = Math.floor(test1/68) * 68;
	}
	if ((test2 > maxW) && doResize) {
		var maxW = Math.ceil(test2/68) * 68;
		//var maxW = Math.floor(test2/68) * 68;
	}
	var width = screen.width;
	if (width < 1280) {
		document.getElementById('logo').style.backgroundImage = 'url(images/logo-small.gif)';
	}
	else {
		document.getElementById('logo').style.backgroundImage = 'url(images/logo.gif)';
	}
	
	//mTop = Math.ceil((myH - maxH) / 2) - 4;
	//alert(mTop);

	var tableW = maxW + 100;
	var tableH = maxH + 100;
	document.getElementById('maintable').style.width = tableW + 'px';
	document.getElementById('maintable').style.height = tableH + 'px';
	
	document.getElementById('body-tag').style.width = tableW + 'px';
	document.getElementById('body-tag').style.height = tableH + 'px';
	
	//document.getElementById('body-tag').style.marginTop = mTop+'px';

	document.getElementById('wire-left').style.height = maxH + 'px';
	document.getElementById('wire-right').style.height = maxH + 'px';
	document.getElementById('wire-top').style.width = maxW + 'px';
	document.getElementById('wire-bottom').style.width = maxW + 'px';
	doResize = false;
	//alert(tableH);
}

function FixReSize() {
	var myW = Sirina() - 100;
	var myH = Visina() - 100;
	
	var maxW = Math.floor(myW/68) * 68;
	var maxH = Math.floor(myH/68) * 68;
	
	var test1 = document.getElementById('wire-frame').offsetHeight;
	var test2 = document.getElementById('wire-frame').offsetWidth;
	if (test1 > maxH) {
		var maxH = Math.ceil(test1/68) * 68;
	}
	if (test2 > maxW) {
		var maxW = Math.ceil(test2/68) * 68;
	}
	var width = screen.width;
	if (width < 1280) {
		document.getElementById('logo').style.backgroundImage = 'url(images/logo-small.gif)';
	}
	else {
		document.getElementById('logo').style.backgroundImage = 'url(images/logo.gif)';
	}
	
	var tableW = maxW + 100;
	var tableH = maxH + 100;
	document.getElementById('maintable').style.width = tableW + 'px';
	document.getElementById('maintable').style.height = tableH + 'px';
	
	document.getElementById('body-tag').style.width = tableW + 'px';
	document.getElementById('body-tag').style.height = tableH + 'px';
	

	document.getElementById('wire-left').style.height = maxH + 'px';
	document.getElementById('wire-right').style.height = maxH + 'px';
	document.getElementById('wire-top').style.width = maxW + 'px';
	document.getElementById('wire-bottom').style.width = maxW + 'px';
}

function Sirina() {
var winW = 630;

if (parseInt(navigator.appVersion)>3) {
 if (navigator.appName=="Netscape") {
  winW = window.innerWidth;
 }
 if (navigator.appName.indexOf("Microsoft")!=-1) {
  winW = document.body.offsetWidth;
 }
}
return winW;
}

function Visina() {
var winH = 460;

if (parseInt(navigator.appVersion)>3) {
 if (navigator.appName=="Netscape") {
  winH = window.innerHeight;
 }
 if (navigator.appName.indexOf("Microsoft")!=-1) {
  //winH = document.body.offsetHeight;
  winH = document.documentElement.clientHeight;
 }
}
return winH;
}

function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			if (oldonload) {
				oldonload();
			}
			func();
		}
	}
}
function addResizeEvent(func) {
	var oldresize = window.onresize;
	if (typeof window.onresize != 'function') {
		window.onresize = func;
	} else {
		window.resize = function() {
			if (oldonresize) {
				oldonresize();
			}
			func();
		}
	}
}
addResizeEvent(FixReSize);
addLoadEvent(FixSize);

function DoSwitch(id,no) {
	var i;
	var end = no + 1;
	for (i = 1; i < end; i++) {
		var hidden = 'style' + i;
		document.getElementById(hidden).style.display = 'none';
	}
	document.getElementById('loading').style.display = 'block';
	window.setTimeout("HideShow('"+id+"')",1000);
}
function ReLoad() {
	if (document.images) {
		var randomnumber=Math.floor(Math.random()*1001)
		document.getElementById('test').src = "test.php?id=" + randomnumber;
	}
}
function Hide(id) {
document.getElementById(id).style.visibility = 'hidden';
}
function HideShow(id) {
document.getElementById('loading').style.display = 'none';
document.getElementById(id).style.display = 'block';
}

function Change(id,name) {
document.getElementById (id).style.backgroundImage = 'url(data/9/1/'+name+'.jpg)';
}

function ChangeD(id,name) {
document.getElementById (id).style.backgroundImage = 'url(data/9/3/'+name+'.jpg)';
}

function ChangeN() {
document.getElementById ('price').src = 'data/3/1/image.png';
}

var persistmenu="no"
var persisttype="sitewide"

if (document.getElementById){ 
document.write('<style type="text/css">\n')
document.write('.submenu{display: none;}\n')
document.write('</style>\n')
}

function SwitchMenu(obj){
if(document.getElementById){
var el = document.getElementById(obj);
var ar = document.getElementById("masterdiv").getElementsByTagName("span");
if(el.style.display != "block"){
for (var i=0; i<ar.length; i++){
if (ar[i].className=="submenu")
ar[i].style.display = "none";
	document.getElementById('banners').style.display = "none";
}
el.style.display = "block";
}else{
el.style.display = "none";
	document.getElementById('banners').style.display = "block";
}
}
}

function get_cookie(Name) { 
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { 
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function onloadfunction(){
if (persistmenu=="yes"){
var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
var cookievalue=get_cookie(cookiename)
if (cookievalue!="")
document.getElementById(cookievalue).style.display="block"
}
}

function savemenustate(){
var inc=1, blockid=""
while (document.getElementById("sub"+inc)){
if (document.getElementById("sub"+inc).style.display=="block"){
blockid="sub"+inc
break
}
inc++
}
var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
var cookievalue=(persisttype=="sitewide")? blockid+";path=/" : blockid
document.cookie=cookiename+"="+cookievalue
}

if (window.addEventListener)
window.addEventListener("load", onloadfunction, false)
else if (window.attachEvent)
window.attachEvent("onload", onloadfunction)
else if (document.getElementById)
window.onload=onloadfunction

if (persistmenu=="yes" && document.getElementById)
window.onunload=savemenustate
