function openOrc(id) {
	window.open("./bud-show.php?budgetId=" + id, "_blank", "left=20,top=20,width=700,height=550,toolbar=1,resizable=1,scrollbars=1");
}

function openCustomer(id) {
	window.open("./bud-customer.php?budgetId=" + id, "_blank", "left=20,top=20,width=700,height=550,toolbar=0,resizable=1,scrollbars=1");
}

function openDetails(id) {
	window.open("./posDetails.php?id=" + id, "_blank", "width=380,height=480,toolbar=0,status=0,resizable=1,scrollbars=0,top=100,left=100");
}

function openRequest(id) {
	window.open("./bud-request.php?budgetId=" + id, "_blank", "left=20,top=20,width=700,height=550,toolbar=1,resizable=1,scrollbars=1");
}

function openPrint(id) {
	window.open("./bud-print.php?budgetId=" + id, "_blank", "width=700,height=550,status=0,menubar=0,toolbar=1,location=0,directories=0,resizable=1,scrollbars=1,top=20,left=20");
}

function openForum(id) {
	window.open("./bud-forum.php?budgetId=" + id, "_blank", "width=700,height=500,status=0,resizable=1,scrollbars=1,top=50,left=50");
}

function openChat() {
	window.open("./chat/frameJoin.html", "_blank", "width=380,height=480,toolbar=0,status=0,resizable=0,scrollbars=0,top=100,left=100");
}

function openAdm() {
	window.open("./chat/frameAdmin.html", "_blank", "width=600,height=480,toolbar=0,status=0,resizable=0,scrollbars=0,top=100,left=100");
}

function openPic(id) {
	window.open("./zoom.php?photoId=" + id, "_blank", "width=200,height=200,status=0,menubar=0,toolbar=0,location=0,directories=0,resizable=1,scrollbars=0,top=0,left=100");
}

function dummyF() {

}

function moreFields(read, write) {
	counter++;
	var newFields = document.getElementById(read).cloneNode(true);
	newFields.id = '';
	newFields.style.display = 'block';
	var newField = newFields.childNodes;
	for (var i=0;i<newField.length;i++)
	{
		var theName = newField[i].name
		if (theName)
			newField[i].name = theName + counter;
	}
	var insertHere = document.getElementById(write);
	insertHere.parentNode.insertBefore(newFields,insertHere);
};

function hide(element) {
	var x = document.getElementById(element);
	x.style.display = "none";

	x = document.getElementById("link_" + element);
	x.href = "javascript:unhide('" + element + "');";

	x = document.getElementById("img_" + element);

	var img = new Image(9, 9);
	img.src = "images/arr-less.gif";
	x.src = img.src;
}

function unhide(element) {
	var x = document.getElementById(element);
	x.style.display = 'block';

	x = document.getElementById("link_" + element);
	x.href = "javascript:hide('" + element + "');";

	x = document.getElementById("img_" + element);

	var img = new Image(9, 9);
	img.src = "images/arr-more.gif";
	x.src = img.src;
}

var _menustate = false;
var counter = 0;

function setMenuState(state) {
	_menustate = state;

	if (state == false)
		hideMenus();
}

function showMenu(menu) {
	hideMenus(true);

	_menustate = true;

	var ul = document.getElementById('subnavigation-' + menu);
	ul.style.display = 'block';
}

function hideMenus(now) {
	var menus = document.getElementById('subnavigationwrapper').getElementsByTagName('ul');
	for (var i = 0; menu = menus[i]; i++)
		hideMenu(menu.id.replace(/^subnavigation-/, ''), now);
}

function hideMenu(menu, now) {
	if (document.getElementById('subnavigation-' + menu).style.display == 'block' && _menustate == false) {
		if (now)
			_hideMenu(menu);
		else
			setTimeout(function() { _hideMenu(menu); }, 1000);
	}
}

function _hideMenu(menu) {
	if (_menustate == false) {
		var ul = document.getElementById('subnavigation-' + menu);
		ul.style.display = 'none';
	}
}

function fixFooter() {
	var wrapper = document.getElementById('container');
	var wrapperh = wrapper.offsetHeight + 165;
	var pageh = getWindowHeight();

	if (wrapperh < pageh) {
		wrapper.style.height = (pageh - document.getElementById('footer').offsetHeight - 165) + 'px';
	}
}

function getWindowHeight() {
	if (typeof(window.innerHeight) == 'number')
	return window.innerHeight;

	else if (document.documentElement && document.documentElement.clientHeight)
	return document.documentElement.clientHeight;

	else if (document.body && document.body.clientHeight)
	return document.body.clientHeight;
}

function resizeWrapper() {
	fixFooter();

	var footer = document.getElementById('footer');
	footer.style.visibility = 'visible';
}

function googlesearch() {
	document.getElementById('googleq').value = 'site:sismatec.com.br ' + document.getElementById('googleq').value;
	document.getElementById('googleform').submit();
}

window.onload = function() {
	hideMenus(true);

	resizeWrapper();
};

window.onresize = resizeWrapper;
window.status='Sismatec Indústria e Comércio de Equipamentos Hospitalares Ltda - 0800 413735';