<!--

function updateChart(chartId,url) {
	//Get reference to chart object using Dom ID
	var chartObj = getChartFromId(chartId);
	//Update it's XML
	chartObj.setDataURL(url);
}

/**
 * Klasa do zarzadzanie listami rozwijalnymi, powiazanymi
 */
function Optioner(form, name){
    this._name = name;
    this._form = form;
    this._counter = 0;
    this._names = new Array();
    this._values = new Array();
    this._active = 0;
    this._selSet = false;
}

Optioner.prototype._active;
Optioner.prototype._name;
Optioner.prototype._form;
Optioner.prototype._counter;
Optioner.prototype._names;
Optioner.prototype._values;
Optioner.prototype._selNames;
Optioner.prototype._selSet;
Optioner.prototype._hidNames;
Optioner.prototype._hidSet;

Optioner.prototype.addArray = function(names, values){

    this._names[this._counter] = names;
    this._values[this._counter] = values;
    this._counter++;
}

Optioner.prototype.setNameChange = function(names){
    this._selNames = names;
    this._selSet = true;
}

Optioner.prototype.setHiddenChange = function(names){
    this._hidNames = names;
    this._hidSet = true;
}

Optioner.prototype.setArray = function(id){
    //pobieram selecta do zmiany wartosci
    var select = document[this._form][this._name];
    
    //czyszcze selecta
    for (i = select.options.length; i > 0; i--) {
        select.options[i - 1] = null;
    }
    //ustawiam nowe wartosci selecta (tabela o indeksie z parametru)
    for (i = 0; i < this._names[id].length; i++) {
        select.options[i] = new Option(this._names[id][i], this._values[id][i]);
    }
    
    //jesli ustawiona zmiana nazwy selecta, zmianiam nazwe
    if (this._selSet) {
        select.name = this._selNames[id];
    }
    //jesli ustawiona zmiana nazwy pola ukrytego, zmianiam nazwe
    if (this._hidSet) {
        document[this._form][this._hidNames[this._active]].name = this._hidNames[id];
    }
    
    //zmieniam aktywne id dla obiektu
    this._active = id;
}

Optioner.prototype.switchArray = function(){
    var nr = this._active + 1;
    
    if (nr == this._counter) {
        nr = 0;
    }
    this.setArray(nr);
}

/**
 * Klasa do ukrywania/pokazywania elementow list
 */
function SHList(active){
    this._active = active;
    document.getElementById(active).style.display = 'block';
}

SHList.prototype._active;

SHList.prototype.setVisible = function(id){

    document.getElementById(this._active).style.display = 'none';
    
    document.getElementById(id).style.display = 'block';
    
    this._active = id;
    
}

function resetAllForm(){
    resetForm('form_0');
    resetForm('form_1');
		resetForm('form_1_0');
		resetForm('form_1_1');
		resetForm('form_1_2');
		resetForm('form_1_3');
    resetForm('form_2');
		resetForm('form_2_0');
		resetForm('form_2_1');
    resetForm('form_3');
		resetForm('form_3_0');
		resetForm('form_3_1');
    resetForm('form_4');
		resetForm('form_4_0');
		resetForm('form_4_1');
    resetForm('form_5');
	resetForm('form_6');
    
}

function resetForm(formName){
	if (formName != null)
    	document[formName].reset();
}

function setValue(id, select){

    var name = select[select.selectedIndex].innerHTML;
    document.getElementById(id).value = name;
}

/**
 * Ustawia wartosc pola, jako sume wartosci dwoch innych obiektow
 * @param {String} form - nazwa formularza
 * @param {String} name - nazwa obiektu
 * @param {String} obj1 - nazwa obiektu 1
 * @param {String} obj2 - nazwa obiektu 2
 */
function setValueObject(form, name, obj1, obj2){
    var o1 = document[form][obj1];
    var o2 = document[form][obj2];
    
    for (var i = 0; i < o2.length; i++) {
        if (o2[i].checked) {
            var val = o2[i].value;
        }
    }
   
    document[form][name].value = parseInt(o1.value) + parseInt(val);

}

function switchFormHeader() {
	var form = document['form_4_1'];
	
	if (form.method == 'post' && form['P[id]'].selectedIndex != 0) {
		form.method = 'get';
		form.action = 'http://gielda.wp.pl/POD,2,domy_maklerskie.html';					
	} else if (document['form_4_1'].method == 'get' && form['P[id]'].selectedIndex == 0) {
		form.method = 'post';	
		form.action = 'http://gielda.wp.pl/domy_maklerskie.html';					
	}
}

function tscGetFlashVersion(){
	var tscFV=0;
	if(navigator.plugins && navigator.plugins.length){
		PWAx=navigator.plugins["Shockwave Flash"];
		if(PWAx){
			if(PWAx.description){
				PWAy=PWAx.description;
				tscFV=PWAy.charAt(PWAy.indexOf('.')-1);
			}
		}else if(navigator.plugins["Shockwave Flash 2.0"]){
			tscFV=2;
		}
	}else{
		for(var PWAi=10;PWAi>0;PWAi--){
			tscFV=0;
			try{
				var flash=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+PWAi);
				tscFV=PWAi;
				break;
			}catch(e){}
		}
	}
	return tscFV;
}

licz=0;
function otworz(nazwa,szer,wys) {
config='left=100,top=100,width='+szer+',height='+wys+',innerheight='+wys+',innerwidth='+szer+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no';
kitekSC='okno' + licz;
stadion=window.open('',kitekSC,config)
stadion.document.write('<HTML><HEAD>');
stadion.document.write('<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2">');
stadion.document.write('<TITLE>Wirtualna Polska - Foto-Galeria</title>');
stadion.document.write('<script language="javascript">');
stadion.document.write('setTimeout(');
stadion.document.write('"self.close()');
stadion.document.write(';",70000)');stadion.document.write('</');
stadion.document.write('script>');
stadion.document.write('</HEAD>');
stadion.document.write('<body bgcolor=white leftmargin=0 topmargin=0 marginheight=0 marginwidth=0>');
stadion.document.write('<DIV align=center><a href=# onclick="javascript:self.close();"><img src='+nazwa+' border=0></A></DIV>');
stadion.document.write('</body></html>');
stadion.focus();
licz+=1;
}

function ch_bx(id, n, a) { //change boxes(id, num of boxes, actual)
  if (!id) id = 't';
  if (!n) return(false);
  if (!a) a = 1;
  
  for (var i = 1; i <= n; i++) {   
    document.getElementById(id + i).style.display = 'none';
  }
  document.getElementById(id + a).style.display = 'block';
}

//kalkulator walutowy
function zmiana_sel2() {
	document.form_calc_0.sel3.selectedIndex = document.form_calc_0.sel2.selectedIndex;
	return;
}

function zmiana_sel3() {
	document.form_calc_0.sel2.selectedIndex = document.form_calc_0.sel3.selectedIndex;
	return;
}

function kasuj_waluty() {
 	document.form_calc_0.ilosc.value='';
        document.form_calc_0.wynik.value='';
	return;
}

function zamien_waluty() {
	var s1, s2;

	s1 = document.form_calc_0.sel1.selectedIndex;
	s2 = document.form_calc_0.sel2.selectedIndex;
	document.form_calc_0.sel1.selectedIndex = s2;
	document.form_calc_0.sel2.selectedIndex = s1;

	return;
}

function Numer(fieldName) {
	var txtNumber = '' + fieldName.value;
	fieldName.value = txtNumber.replace(',','.');
	txtNumber = '' + fieldName.value;
	if (isNaN(txtNumber) || txtNumber == "" || txtNumber.indexOf('-')!=-1)
	{
		alert("Wpisano nieprawidłową wartość!");
		fieldName.select();
		fieldName.focus();
		return false;
	}else 
	{ 
		fieldName.value= parseFloat(fieldName.value);
		return true;
	}
}

// kalkulator wynagrodzen

function delFormW() {
  document.getElementById('zarobki').value='';
  document.getElementById('rok_zarobki').selectedIndex=0;
}

function submitFormCalc1() {

  if(document.pressed == 'Oblicz') {
     document.form_calc_1.action ="http://podatki.wp.pl/kalkulator_wynagrodzen_wyniki.html";
  } else {
     document.form_calc_1.action ="http://podatki.wp.pl/kalkulator_wynagrodzen.html";
  }

	var obj1 = document.getElementById('zarobki');

	if (null == obj1) {
		return;
	}
	
        for (i = 1; i <=12; i++) {
		var obj2 = document.getElementById('zarobki' + i);

		if (null == obj2) {
			continue;
		}

		obj2.value = obj1.value;
	}
}
//kalkulator odsetek
function formReset() {
	document.getElementById("form_calc_2Body").reset();
}



function usun_zobowiazanie() {
	if (row_count > 1) {
		document.getElementById('form_calc_2Body').deleteRow(row_count--);
		document.getElementById('form_calc_2Body').deleteRow(row_count--);
		document.getElementById('form_calc_2Body').deleteRow(row_count--);
		document.getElementById('form_calc_2Body').deleteRow(row_count--);
		document.getElementById('form_calc_2Body').deleteRow(row_count--);
		document.getElementById('form_calc_2Body').deleteRow(row_count--);
		z_count--;
		ar.pop();
		ar.pop();
		ar.pop();
	}
}

function dodaj_zobowiazanie() {
	z_count++;
	var table_body = document.getElementById("form_calc_2Body");

	f01_row = document.createElement("tr");
	f01_row.setAttribute('class', 'r2');
	f01_row.setAttribute('id', 'row' + ++row_count);

	label_cell = document.createElement("td");
	label_cell.setAttribute('class', 'left');
	label_text = document.createTextNode("kwota zobowiązania:");
	label_cell.appendChild(label_text);
	f01_row.appendChild(label_cell);

	f02_row = document.createElement("tr");
	f02_row.setAttribute('class', 'r2');
	f02_row.setAttribute('id', 'row' + ++row_count);

	input_cell = document.createElement("td");
	input_cell.setAttribute('class', 'left');
	kwota_label = 'kwota' + z_count;
	myinput = document.createElement("input");
	myinput.setAttribute('type', 'text');
	myinput.setAttribute('class', 'val');
	myinput.setAttribute('id', kwota_label);
	myinput.setAttribute('name', kwota_label);
	myinput.setAttribute('size', '18');
	input_cell.appendChild(myinput);
	f02_row.appendChild(input_cell);

	f03_row = document.createElement("tr");
	f03_row.setAttribute('class', 'r2');
	f03_row.setAttribute('id', 'row' + ++row_count);

	label_cell = document.createElement("td");
	label_cell.setAttribute('class', 'left');
	label_text = document.createTextNode("data powstania:");
	label_cell.appendChild(label_text);
	f03_row.appendChild(label_cell);

	f04_row = document.createElement("tr");
	f04_row.setAttribute('class', 'r2');
	f04_row.setAttribute('id', 'row' + ++row_count);

	input_cell = document.createElement("td");
	input_cell.setAttribute('class', 'right');
	data_start_label = 'data_start' + z_count;
	myinput = document.createElement("input");
	myinput.setAttribute('type', 'text');
	myinput.setAttribute('class', 'val');
	myinput.setAttribute('id', data_start_label);
	myinput.setAttribute('name', data_start_label);
	myinput.setAttribute('size', '18');
	input_cell.appendChild(myinput);
	f04_row.appendChild(input_cell);

	calendar_cell = document.createElement("td");
	calendar = document.createElement('img');
	calendar.setAttribute('src', 'http://i.wp.pl/a/i/waluty/layout/cal_ico.gif');
	calendar.setAttribute('onclick', "rysuj2(document.getElementById('" + data_start_label + "'), event);");
	calendar.setAttribute('alt', 'Wybierz datę z kalendarza');
	calendar.setAttribute('border', '0');
	calendar.setAttribute('style', '""');
	calendar_cell.appendChild(calendar);
	f04_row.appendChild(calendar_cell);

	f05_row = document.createElement("tr");
	f05_row.setAttribute('class', 'r2');
	f05_row.setAttribute('id', 'row' + ++row_count);

	label_cell = document.createElement("td");
	label_cell.setAttribute('class', 'left');
	label_text = document.createTextNode("data ustania:");
	label_cell.appendChild(label_text);
	f05_row.appendChild(label_cell);

	f06_row = document.createElement("tr");
	f06_row.setAttribute('class', 'r2');
	f06_row.setAttribute('id', 'row' + ++row_count);

	input_cell = document.createElement("td");
	input_cell.setAttribute('class', 'right');
	data_end_label = 'data_end' + z_count;
	myinput = document.createElement("input");
	myinput.setAttribute('type', 'text');
	myinput.setAttribute('class', 'val');
	myinput.setAttribute('id', data_end_label);
	myinput.setAttribute('name', data_end_label);
	myinput.setAttribute('size', '18');
	input_cell.appendChild(myinput);
	f06_row.appendChild(input_cell);

	calendar_cell = document.createElement("td");
	calendar = document.createElement('img');
	calendar.setAttribute('src', 'http://i.wp.pl/a/i/waluty/layout/cal_ico.gif');
	calendar.setAttribute('onclick', "rysuj2(document.getElementById('" + data_end_label + "'), event);");
	calendar.setAttribute('alt', 'Wybierz datę z kalendarza');
	calendar.setAttribute('border', '0');
	calendar.setAttribute('style', '""');
	calendar_cell.appendChild(calendar);
	f06_row.appendChild(calendar_cell);

	table_body.appendChild(f01_row);
	table_body.appendChild(f02_row);
	table_body.appendChild(f03_row);
	table_body.appendChild(f04_row);
	table_body.appendChild(f05_row);
	table_body.appendChild(f06_row);

	ar.push(new Array('kwota zobowiązania:',  kwota_label, 'float', 0, 100000000, true));
	ar.push(new Array('data powstania:',  data_start_label, 'date', 0, 0, true));
	ar.push(new Array('data ustania:',  data_end_label, 'date', 0, 0, true));
}

function zlicz_zobowiazania() {
	form = document.getElementById('form_calc_2');
	input_hidden = document.createElement("input");
	input_hidden.setAttribute('type', 'hidden');
	input_hidden.setAttribute('name', 'count');
	input_hidden.setAttribute('value', z_count);
	form.appendChild(input_hidden);
	return true;
}


function submitFormCalc2() {

  if(document.pressed == 'Oblicz' && document.getElementById('form_calc_2U').checked==true) {
     document.form_calc_2.action = "http://podatki.wp.pl/kalkulator_odsetek_ustawowych_wyniki.html";
     document.form_calc_2._action.value = "CalculatorDataStatutoryInterest";
  } else if(document.pressed == 'Oblicz' && document.getElementById('form_calc_2P').checked==true) {
     document.form_calc_2.action = "http://podatki.wp.pl/kalkulator_odsetek_podatkowych_wyniki.html";
     document.form_calc_2._action.value = "CalculatorDataTaxInterest";
  }

}

function KasujFormCalc2() {
  document.getElementById('kwota1').value='';
  document.getElementById('data_start1').value='';
  document.getElementById('data_end1').value='';
}

// kalkulator kredytowy
function KasujFormCalc3() {
  document.getElementById('miesiecznyDochodRodziny').value='';
  document.getElementById('oprocentowanieKredytu').value='';
  document.getElementById('okresKredytowania').value='';
}

//kalkulator rat
function KasujFormCalc4_0() {
  document.getElementById('waluta4_0').selectedIndex=0;
  document.getElementById('kwotaKredytu').value='';
  document.getElementById('okresKredytowania4_0').value='';
  document.getElementById('oprocentowanieKredytu4_0').value='';
}
function KasujFormCalc4_1() {
  document.getElementById('waluta1_4_1').selectedIndex=0;
  document.getElementById('waluta2_4_1').selectedIndex=0;
  document.getElementById('kwotaKredytu1').value='';
  document.getElementById('okresKredytowania1').value='';
  document.getElementById('oprocentowanieKredytu1').value='';
  document.getElementById('okresKredytowania2').value='';
  document.getElementById('oprocentowanieKredytu2').value='';
}

//-->



// forum
// bbCode control by
// subBlue design
// www.subBlue.com

// Startup variables
var imageTag = false;
var theSelection = false;

// Check for Browser & Platform for PC & IE specific bits
// More details from: http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html
var clientPC = navigator.userAgent.toLowerCase(); // Get client info
var clientVer = parseInt(navigator.appVersion); // Get browser version

var is_ie = ((clientPC.indexOf("msie") != -1) && (clientPC.indexOf("opera") == -1));
var is_nav = ((clientPC.indexOf('mozilla')!=-1) && (clientPC.indexOf('spoofer')==-1)
                && (clientPC.indexOf('compatible') == -1) && (clientPC.indexOf('opera')==-1)
                && (clientPC.indexOf('webtv')==-1) && (clientPC.indexOf('hotjava')==-1));
var is_moz = 0;

var is_win = ((clientPC.indexOf("win")!=-1) || (clientPC.indexOf("16bit") != -1));
var is_mac = (clientPC.indexOf("mac")!=-1);

// Define the bbCode tags
bbcode = new Array();
bbtags = new Array('[b]','[/b]','[i]','[/i]','[u]','[/u]','[quote]','[/quote]','[code]','[/code]','[list]','[/list]','[list=]','[/list]','[img]','[/img]','[url]','[/url]');
imageTag = false;

// Shows the help messages in the helpline window
function helpline(help) {
	document.post.helpbox.value = eval(help + "_help");
}


// Replacement for arrayname.length property
function getarraysize(thearray) {
	for (i = 0; i < thearray.length; i++) {
		if ((thearray[i] == "undefined") || (thearray[i] == "") || (thearray[i] == null))
			return i;
		}
	return thearray.length;
}

// Replacement for arrayname.push(value) not implemented in IE until version 5.5
// Appends element to the array
function arraypush(thearray,value) {
	thearray[ getarraysize(thearray) ] = value;
}

// Replacement for arrayname.pop() not implemented in IE until version 5.5
// Removes and returns the last element of an array
function arraypop(thearray) {
	thearraysize = getarraysize(thearray);
	retval = thearray[thearraysize - 1];
	delete thearray[thearraysize - 1];
	return retval;
}

function emoticon(text) {
	var txtarea = document.post.message;
	text = ' ' + text + ' ';
	if (txtarea.createTextRange && txtarea.caretPos) {
		var caretPos = txtarea.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
		txtarea.focus();
	} else {
		txtarea.value  += text;
		txtarea.focus();
	}
}

function bbfontstyle(bbopen, bbclose) {
	var txtarea = document.post.message;

	if ((clientVer >= 4) && is_ie && is_win) {
		theSelection = document.selection.createRange().text;
		if (!theSelection) {
			txtarea.value += bbopen + bbclose;
			txtarea.focus();
			return;
		}
		document.selection.createRange().text = bbopen + theSelection + bbclose;
		txtarea.focus();
		return;
	}
	else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
	{
		mozWrap(txtarea, bbopen, bbclose);
		return;
	}
	else
	{
		txtarea.value += bbopen + bbclose;
		txtarea.focus();
	}
	storeCaret(txtarea);
}


function bbstyle(bbnumber) {
	var txtarea = document.post.message;

	donotinsert = false;
	theSelection = false;
	bblast = 0;

	if (bbnumber == -1) { // Close all open tags & default button names
		while (bbcode[0]) {
			butnumber = arraypop(bbcode) - 1;
			txtarea.value += bbtags[butnumber + 1];
			buttext = eval('document.post.addbbcode' + butnumber + '.value');
			eval('document.post.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
		}
		imageTag = false; // All tags are closed including image tags :D
		txtarea.focus();
		return;
	}

	if ((clientVer >= 4) && is_ie && is_win)
	{
		theSelection = document.selection.createRange().text; // Get text selection
		if (theSelection) {
			// Add tags around selection
			document.selection.createRange().text = bbtags[bbnumber] + theSelection + bbtags[bbnumber+1];
			txtarea.focus();
			theSelection = '';
			return;
		}
	}
	else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
	{
		mozWrap(txtarea, bbtags[bbnumber], bbtags[bbnumber+1]);
		return;
	}
	
	// Find last occurance of an open tag the same as the one just clicked
	for (i = 0; i < bbcode.length; i++) {
		if (bbcode[i] == bbnumber+1) {
			bblast = i;
			donotinsert = true;
		}
	}

	if (donotinsert) {		// Close all open tags up to the one just clicked & default button names
		while (bbcode[bblast]) {
				butnumber = arraypop(bbcode) - 1;
				txtarea.value += bbtags[butnumber + 1];
				buttext = eval('document.post.addbbcode' + butnumber + '.value');
				eval('document.post.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
				imageTag = false;
			}
		txtarea.focus();
		return;
	} else { // Open tags
	
		if (imageTag && (bbnumber != 14)) {		// Close image tag before adding another
			txtarea.value += bbtags[15];
			lastValue = arraypop(bbcode) - 1;	// Remove the close image tag from the list
			document.post.addbbcode14.value = "Img";	// Return button back to normal state
			imageTag = false;
		}
		
		// Open tag
		txtarea.value += bbtags[bbnumber];
		if ((bbnumber == 14) && (imageTag == false)) imageTag = 1; // Check to stop additional tags after an unclosed image tag
		arraypush(bbcode,bbnumber+1);
		eval('document.post.addbbcode'+bbnumber+'.value += "*"');
		txtarea.focus();
		return;
	}
	storeCaret(txtarea);
}

// From http://www.massless.org/mozedit/
function mozWrap(txtarea, open, close)
{
	var selLength = txtarea.textLength;
	var selStart = txtarea.selectionStart;
	var selEnd = txtarea.selectionEnd;
	if (selEnd == 1 || selEnd == 2) 
		selEnd = selLength;

	var s1 = (txtarea.value).substring(0,selStart);
	var s2 = (txtarea.value).substring(selStart, selEnd)
	var s3 = (txtarea.value).substring(selEnd, selLength);
	txtarea.value = s1 + open + s2 + close + s3;
	return;
}

// Insert at Claret position. Code from
// http://www.faqts.com/knowledge_base/view.phtml/aid/1052/fid/130
function storeCaret(textEl) {
	if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate();
}


