
function openRegistrationFormWindow(){
	powerbelt_register_window_ref = open('index.php?page=RegisterForm', 'powerbelt_register_window', 'width=760, height=650, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, screenX=5, left=5, screenY=10, top=10, status=yes'); return false;
}

function closeCartAndLoginIfNeeded() {
	if (powerbelt_login_window_ref != null) {
		powerbelt_login_window_ref.close();
	}
	if (powerbelt_cart_window_ref != null) {
		powerbelt_cart_window_ref.close();
	}
}

var openMainMenuIndex = -1;

function setupMenuInit(n) {
	if (n != undefined) {
		openMainMenuIndex = n;
	}
}


function preloadMainPageImages() {
	var imageList = new Array();
	for(var i in menuCategoryMap) {
		var im = serverPath + "/images/mainpage/" + i + ".jpg";
		//alert(im);
		imageList.push(im);
	}
	MM_preloadImages(imageList);
}

function switchLanguage(dst) {
	if (canSwitchLanguage) {
		var u = 'http://' + dst + switchUrl;
		document.location.href = u;
	}
}

function setCartButtonEnablement(v) {
	showdiv(v?'cartButtonEnabled':'cartButtonDisabled');
}


function updateCartButton() {
	hidediv('cartButtonDisabled');
	showdiv('cartButtonEnabled');
}

function printOrder(id){
	powerbelt_print_order_window_ref = open('index.php?page=PrintPrevOrder&id=' + id, 'powerbelt_print_order_window', 'width=760, height=650, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, screenX=5, left=5, screenY=10, top=10, status=yes'); return false;
}

function getElementPosition(elemID){
	var offsetTrail = document.getElementById(elemID);
	var offsetLeft = 0;
	var offsetTop = 0;
	while (offsetTrail){
		offsetLeft += offsetTrail.offsetLeft;
		offsetTop += offsetTrail.offsetTop;
		offsetTrail = offsetTrail.offsetParent;
	}
	if (navigator.userAgent.indexOf('Mac') != -1 && typeof document.body.leftMargin != 'undefined'){
		offsetLeft += document.body.leftMargin;
		offsetTop += document.body.topMargin;
	}
	return {left:offsetLeft,top:offsetTop};
}

function getWindowSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return {w:myWidth,h:myHeight};
}