function menuOn(object, fileName, language, extension){
	object.src = "/images/"+language+"/"+fileName+"_on"+"."+extension;
}
function menuOff(object, fileName, language, extension){
	object.src = "/images/"+language+"/"+fileName+"_off"+"."+extension;
}
function showHide(objectId){
	var obj = document.getElementById(objectId);
	var obj1 = document.getElementById(objectId+"_1");
	var obj2 = document.getElementById(objectId+"_2");
	if(obj.style.display == ""){
		obj.style.display = "none";
		obj2.src = "/images/arrowBottomWhite.png";
	}else{
		obj.style.display = "";
		obj2.src = "/images/arrowTopWhite.png";
	}
}
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-500)+'px';
	object.style.left = (posx - 200)+'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 goTo(address){
	window.location = address;
}

function showSpecial(ID){
	var target = document.getElementById('soh_main');
	var source = document.getElementById('soh_'+ID);
	target.innerHTML = source.innerHTML;
	/*clearTimeout(time);*/
	time = setTimeout('next(' + ID + ');', 10000);
}
function next(id) {
	id = id + 1;
	if (id > max) {
		id = 1;
	}
	showSpecial(id);
}


function changeBackgroundColor(ID, color){
	var dh1 = document.getElementById("dh1_"+ID);
	var dh2 = document.getElementById("dh2_"+ID);
	var dh3 = document.getElementById("dh3_"+ID);
	dh1.style.backgroundColor = color;
	dh2.style.backgroundColor = color;
	dh3.style.backgroundColor = color;
}
function setClass(object, newClassName){
	object.className = newClassName;
}
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 zmienOferteInwest(ID){
	  $('#startInwest').load('/pl/startInwest.php', {ofertaInwest : ID});
	}

