function goTo(address){
	window.location = address;
}
function submitForm(formId){
	document.getElementById(formId).submit();
}
function showHint(elementID){	
	object = document.getElementById(elementID);
	ref = document.getElementById('row_'+elementID);
	posy = getPosY(ref);
	posx = getPosX(ref);
	object.style.display = "";
	object.style.top = (posy - 250)+'px';
	object.style.left = (posx - 100)+'px';
}
function hideHint(elementID){
	object = document.getElementById(elementID);
	object.style.display = "none";
	object.style.top = 0+'px';
	object.style.left = 0+'px';
}
function getPosX( obj ) {
  var curleft = 0;
  if( obj ) {
    if( document.getElementById || document.all ) {
      while( obj.offsetParent ) {
        curleft += obj.offsetLeft;
        obj = obj.offsetParent;
      }
    } else
      if( document.layers )
        curleft += obj.x;
  }
  return curleft;
}
function getPosY( obj ) {
  var curtop = 0;
  if( obj ) {
    if( document.getElementById || document.all ) {
      while( obj.offsetParent ) {
        curtop += obj.offsetTop;
        obj = obj.offsetParent;
      }
    } else
      if( document.layers )
        curtop += obj.y;
  }
  return curtop;
}
function compute() {
	var form = document.getElementById('calculator');
	price  = form.price.value;
	agency_perc = form.agency_perc.value;
	type = form.type.selectedIndex;
	agency = (price * agency_perc) / 100;
	agency_vat = agency * 0.22;

	tax = price * 0.02;

	notar = 0.0;

	if (type != 4) {
		if ((price > 0) && (price <= 3000))			notar = 50.0;
		if ((price > 3000) && (price <= 10000))		notar = (100 + ((price - 3000)*0.03))/2;
		if ((price > 10000) && (price <= 30000))	notar = (310 + ((price - 10000)*0.02))/2;
		if ((price > 30000) && (price <= 60000))	notar = (710 + ((price - 30000)*0.01))/2;
		if ((price > 60000) && (price <= 1000000))	notar = (1010 + ((price - 60000)*0.005))/2;
		if (price > 1000000)						notar = (5710 + ((price - 1000000)*0.0025))/2;
	} else {
		if ((price > 0) && (price <= 3000))			notar = 100.0;
		if ((price > 3000) && (price <= 10000))		notar = (100 + ((price - 3000)*0.03));
		if ((price > 10000) && (price <= 30000))	notar = (310 + ((price - 10000)*0.02));
		if ((price > 30000) && (price <= 60000))	notar = (710 + ((price - 30000)*0.01));
		if ((price > 60000) && (price <= 1000000))	notar = (1010 + ((price - 60000)*0.005));
		if (price > 1000000)						notar = (5710 + ((price - 1000000)*0.0025));
	}
	


	notar_vat = notar * 0.22;

	if (type == 0)
		just = 0.0;
	else
		just = 200.0;

	add = tax + notar + notar_vat + agency + agency_vat + just;
	form.agency.value = (Math.round(agency * 100) / 100) + ' PLN';
	form.notar.value = (Math.round(notar * 100) / 100) + ' PLN';
	form.notar_vat.value = (Math.round(notar_vat * 100) / 100) + ' PLN';
	form.agency_vat.value = (Math.round(agency_vat * 100) / 100) + ' PLN';
	form.just.value = (Math.round(just * 100) / 100) + ' PLN';
	form.tax.value = (Math.round(tax * 100) / 100) + ' PLN';
	form.sum_add.value = (Math.round((add) * 100) / 100) + ' PLN';
	form.sum.value = (Math.round(((price * 1.0) + add) * 100) / 100) + ' PLN';
}
function showHideElement(elementId){
	var element = document.getElementById('newSOHolder'+elementId);
	var elementActionDescription = document.getElementById('oHActionDescription'+elementId);
	var elementImage = document.getElementById("oHImage"+elementId);
	elementActionDescription.innerHTML = element.style.display == "none" ? "schowaj" : "pokaż";
	element.style.display = element.style.display == "none" ? "" : "none";	
	elementImage.src = element.style.display == "none" ? "../images/downArrow.gif" : "../images/upArrow.gif";
}
function setCategoryId(categoryId){
	document.getElementById('categoryId').value = categoryId;
}
function setClass(object, newClassName){
	object.className = newClassName;
}