/* wersja 1.31 - 26.6.2008. godzina 17:55*/

function zmien_tlo(id) 
{
color='#B8BAC4';

element = document.getElementById(id);
//event.cancelBubble = true;
//oldcolor = element.currentStyle.background;
element.style.background = color;
} 

function usun_tlo(id) 
{
color='#FFFFFF';

element = document.getElementById(id);
element.style.background = color;
} 


function MM_swapImgRestore() 
{ 

  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() 
{ 
  var d=document; 
  if(d.images)
	{ 
		if(!d.MM_p) d.MM_p=new Array();
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
		if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}
	}
}

function MM_findObj(n, d) 
{
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() 
{
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
  if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function clearSearchField(field_h) {
	field_h.style.color = '#000000';
	field_h.value = "";
}
function followLink(path) {
	window.document.location.href = path;
}
function showhideBox(boxName) {
	var caller = document.getElementById("sh_"+boxName);
	var callee = document.getElementById(boxName + "Box");
	if(callee.style.display == "block") {
		callee.style.display = "none";
		caller.replaceChild(document.createTextNode("+"), caller.firstChild);
	} else {
		callee.style.display = "block";
		caller.replaceChild(document.createTextNode("–"), caller.firstChild);
	}
}



function formtool_count_chars(textField, countField, maxlen,show_alert)
{
//alert(textField.value);
    if (textField != null && textField.value != null)
		{
			if (textField.value.length > maxlen)
				{
					if(show_alert) 
						alert('Pole opis nie może przekroczy&#263;' +  maxlen + '  znaków.');
						textField.value = textField.value.substring(0, maxlen);
				} 
				else 
				{
					countField.value = textField.value.length;
				}
		}
}	





function getMatchingRecords_PodkatPasazu(key, dataFile, KategoriaID, PodkategoriaID, id_passage_stores)
{
//alert(kategoriaID);
//alert(podkategoriaID);
if ((KategoriaID!='') && ((document.getElementById('KategoriaPomoc').value!=KategoriaID) || (document.getElementById('PodkategoriaPomoc').value!=PodkategoriaID)) )
{
//alert('aa');
	document.getElementById('KategoriaPomoc').value=KategoriaID;
	document.getElementById('PodkategoriaPomoc').value=PodkategoriaID;
	
	var el = document.getElementById(key);

/*	if (document.all) 
	{
    	var xmlhttp = new ActiveXObject("MSXML2.XMLHttp");
	} 
	else 
	{
		var xmlhttp = new XMLHttpRequest();
		xmlhttp.overrideMimeType('text/xml');
	}*/

	var file=dataFile+"?key="+key+"&KategoriaID="+KategoriaID+"&PodkategoriaID="+PodkategoriaID+"&id_passage_stores="+id_passage_stores;

				try {
						if (netscape.security.PrivilegeManager.enablePrivilege) 
						{
							netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserRead');
						}
					}
				catch (ex) 
				{ // eat it
				
				}

	xmlhttp = false;
	
        if (window.XMLHttpRequest) { // Mozilla, Safari,...
            xmlhttp = new XMLHttpRequest();
            if (xmlhttp.overrideMimeType) {
                xmlhttp.overrideMimeType('text/xml');
                // Przeczytaj o tym wierszu poniżej
            }
        } else if (window.ActiveXObject) { // IE
            try {
                xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!xmlhttp) {
            alert('Poddaję się :( Nie mogę stworzy&#263; instancji obiektu XMLHTTP');
            return false;
        }
        xmlhttp.onreadystatechange = function() { alertContents(xmlhttp); };
        xmlhttp.open('GET', file, false);
        xmlhttp.send(null);
	

//	xmlhttp.open("GET", file, false);
//	xmlhttp.send(null);

	if(xmlhttp.status == 200)
	{
		el.innerHTML = xmlhttp.responseText;
	} 
	else 
	{
		alert("Error: "+xmlhttp.status);
	}
}	
}




function alertContents(http_request) {

  if (http_request.readyState == 4) {

    if (http_request.status == 200) {

      //alert(http_request.responseText);

    }
    else {

      alert('Wystąpił problem z zapytaniem.');
    }
  }

}





function MakeSubmitForm ()
{

document.PassageAddStore.submit();

}

function MakeSubmitNewsletterForm()
{

document.NewsletterForm.submit();

}

function MakeSubmitDowolnyForm ()
{

document.DowolnyForm.submit();

}



function MakeSubmitAdminForm ()
{

document.getElementById('PodkategoriaPomoc').value=document.getElementById('PodkategoriaID').value;

document.PassageStore.submit();

}

function MakeSubmitSzukaj()
{
	document.Szukaj_form_sz.submit();
}

function MakeSubmitRegisterLogin()
{
	document.RegisterLogin.submit();
}

function MakeSubmitNewPost(pole,wartosc)
{
	document.getElementById('krok_poprzedni').value='tak';
	document.getElementById(pole).value=wartosc;
	document.newpost.submit();
}

function potwierdz_tak_nie(formName,id)
{
	if (confirm('Czy chcesz obserwowa&#263; tę aukcję?'))
	{
		//eval('document.'+formName+'.'+fieldName+'.value="'+Value+'"');
	}	
}

function wopen(page,w,h) { window.open(page,"_blank","width="+w+",height="+h+",menubar=no,toolbar=no,resizable=no"); }



function ukryj_pole(typ)
{
  document.getElementById(typ).style.visibility='hidden';
  
}

function pokaz_pole(typ)
{
  document.getElementById(typ).style.visibility='visible';
}


function zaznaczPolaOfertyPracyForm(pole1,pole2,pole3,pole4)
{

for (var i = 0; i < parseInt(document.getElementById(pole1).value); i++)
{
for (var j = 0; j < parseInt(document.getElementById(pole2).value); j++)
{
if (parseInt(document.getElementById(pole3+j).value)==parseInt(document.getElementById(pole4+i).value))
{
document.getElementById(pole3+j).checked = true ;
}
} 
}

}

function wstaw_wartosc_w_pole(pole,wartosc)
{
	document.getElementById(pole).value=wartosc;
}


function wstaw_wartosc_w_pole2(pole, wartosc, pole1, wartosc1)
{
	if (document.getElementById(pole1).value==wartosc1)
	{
		document.getElementById(pole).value=wartosc;
	}	

}

function wstaw_wartosc_w_pole3(pole, wartosc, pole1, wartosc1)
{
	if (document.getElementById(pole1).value!=wartosc1)
	{
		document.getElementById(pole).value=wartosc;
	}	

}


function wstaw_wartosc_w_pole4(pole,wartosc)
{
	document.getElementById(pole).value=document.getElementById(pole).value+wartosc;
}




//zmienianie type=password na text i na odwrot - poczatek

//Variable to save prompt messages
var fieldPrompts = new Array();

function inputFocus(fieldObj) {
if (fieldObj.className=='inputPrompt') {
if (fieldObj.id=='data_haslo_form_id') {
//change field type and reset obj reference
changeInputType('data_haslo_form_id', 'password');
fieldObj = document.getElementById('data_haslo_form_id');
}
fieldPrompts[fieldObj.id] = fieldObj.value;
fieldObj.value = '';
fieldObj.className = 'inputStd';
fieldObj.select();
fieldObj.focus();
}
}

function inputBlur(fieldObj) {
if (fieldObj.value=='') {
if (fieldObj.id=='data_haslo_form_id') {
//change field type and reset obj reference
changeInputType('data_haslo_form_id', 'text');
fieldObj = document.getElementById('data_haslo_form_id');
}
fieldObj.value = fieldPrompts[fieldObj.id];
fieldObj.className = 'inputPrompt';
}
}

function inputFocus2(fieldObj) 
{
if (fieldObj.className=='inputPrompt') {
if (fieldObj.id=='data_haslo_form_id') 
{
//change field type and reset obj reference
changeInputType('data_haslo_form_id', 'password');
fieldObj = document.getElementById('data_haslo_form_id');
}
fieldPrompts[fieldObj.id] = fieldObj.value;
fieldObj.value = '';
fieldObj.className = 'inputStd';
fieldObj.select();
fieldObj.focus();
}
}

function inputBlur2(fieldObj) {
if (fieldObj.value=='') {
if (fieldObj.id=='data_haslo_form_id') {
//change field type and reset obj reference
changeInputType('data_haslo_form_id', 'text');
fieldObj = document.getElementById('data_haslo_form_id');
}
fieldObj.value = fieldPrompts[fieldObj.id];
fieldObj.className = 'inputPrompt';
}
}




function changeInputType(objID, oType) {
var oldObject = document.getElementById(objID);
var newObject = document.createElement('input');
newObject.type = oType;
if(oldObject.value) newObject.value = oldObject.value;
if(oldObject.size) newObject.size = oldObject.size;
if(oldObject.name) newObject.name = oldObject.name;
if(oldObject.id) newObject.id = oldObject.id;
if(oldObject.onfocus) newObject.onfocus = oldObject.onfocus;
if(oldObject.onblur) newObject.onblur = oldObject.onblur;
if(oldObject.className) newObject.className = oldObject.className;
oldObject.parentNode.replaceChild(newObject,oldObject);
return;
}

function setPrompts() { //Run onload of the page
document.getElementById('data_login_form_id').value = 'login';
document.getElementById('data_login_form_id').className = 'inputPrompt';
//document.getElementById('altfield').className = 'inputPrompt';

changeInputType('data_haslo_form_id', 'text');
document.getElementById('data_haslo_form_id').value = 'hasło';
document.getElementById('data_haslo_form_id').className = 'inputPrompt';
}

//zmienianie type=password na text i na odwrot - koniec



function zmien_action_job_form(formname,typename,formaction,formactionWT)
{

	var myRegExp = /transport/;
	var string1 = typename;
	var matchPos1 = string1.search(myRegExp);

	if (matchPos1 != -1)
	{	
		eval('document.'+formname+'.'+'action='+'"'+formactionWT+'"');	
	}
	else
	{
		eval('document.'+formname+'.'+'action='+'"'+formaction+'"');
	}	

}


function dorob_diva()
{
	var bname = navigator.appName;
	if (bname == "Microsoft Internet Explorer")								
	{
		document.writeln('<div style="#position:relative;#top: 25%;display: table-cell; vertical-align: middle;">');
	}
	else
	{
		document.writeln('<div style="#position: absolute; #top: 50%;display: table-cell; vertical-align: middle;">');
	}
}






function zmien_tlo_div(id) 
{
	color='#FFFFFF';
	color_a='588FC2';

	element = document.getElementById(id);
	element.style.background = color;
	
	element_a = document.getElementById(id+'_a');
	element_a.style.color = color_a;

} 

function usun_tlo_div(id) 
{
	color='#588FC2';
	color_a='#FFFFFF';	
	
	element = document.getElementById(id);
	element.style.background = color;

	element_a = document.getElementById(id+'_a');
	element_a.style.color = color_a;

}


function zmien_adres1(url_param) 
{ 
	var el = document.getElementById(key);

	if (document.all) 
	{
    	var xmlhttp = new ActiveXObject("MSXML2.XMLHttp");
	} 
	else 
	{
	  	var xmlhttp = new XMLHttpRequest();
	}

	var file=url_param;

	xmlhttp.open("GET", file, false);
	xmlhttp.send(null);

	if (xmlhttp.status == 200)
	{
		//ok
	}
    
} 


function zmien_adresZ(element,url_param)
{
	
	element.href='#';
	location.target='_blank';
	location.href=url_param;

}


function zmien_adres(element,url_param)
{
	
	element.href=url_param;
	location.target='_blank';
	location.href='#';

}


function zmien_adres_ukryty_carstock(element,url_param_id)
{
	url_param_dodany = 'http://www.forumtransportu.pl/carstock_click_link.php?id=' + url_param_id;
	element.href=url_param_dodany;
	location.target='_blank';
	location.href='#';

}


function przesunWLewo(id_param,szerokosc_banera,przesun_w_dol)
{
    document.getElementById(id_param).style.left=screen.width*0.5-szerokosc_banera*0.5;
    
    //document.getElementById(id_param).style.top=screen.height/120;
}

function ZmienPrzezroczystosc(id_param,jaka)
{
    document.getElementById(id_param).style.opactiy=jaka;
}

function ustaw_prawidlowo_warstwy(id_param1,id_param2,id_param3)
{
    id_param1.style.display = 'none';
    document.getElementById(id_param2).style.display='none';
    document.getElementById(id_param3).style.opacity=1;
}




function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  
  var tablica = new Array();
  
  tablica['X']=scrOfX;
  tablica['Y']=scrOfY;
  return tablica;
}

function SetDivPosition(id_param)
{
tab=getScrollXY();

document.getElementById('toplayer_center'+id_param).style.top=3+tab['Y']+'px';

}


		function helpline(typ)
		{
		//alert(typ);
		var help_line = {
			'b': 'Pogrubienie: [b]tekst[/b]',
			'i': 'Pochylenie: [i]tekst[/i]',
			'u': 'Podkre&#347;lenie: [u]text[/u]',
			'q': 'Cytat: [quote]tekst[/quote]',
			'c': 'Kod: [code]kod[/code]',
			'l': 'Lista: [list]lista[/list])',
			'o': 'Lista uporządkowana: [list=]tekst[/list]',
			'p': 'Obrazek: [img]http://adres_www_obrazka[/img]',
			'w': 'Link: [url]http://adres_www[/url] or [url=http://adres_www]tekst[/url]',
			's': 'Kolor: [color=red]tekst[/color]  Podpowiedź: możesz również opisa&#263; kolor HEXami',
			'f': 'Rozmiar: [size=85]ma&#322;a[/size]',
			'y': 'Filmik youtube: nie wklejaj samego adresu url, wklej kod z pola Umie&#347;&#263; na youtube.pl [youtube]kod z tagami m.in. object[/youtube])',
			'e': 'Lista: dodaj element',
			'd': 'Animacja Flash: [flash=szeroko&#347;&#263;,wysoko&#347;&#263;]http://adres_www[/flash]',
			't': '{ BBCODE_T_HELP }',
			'tip': 'Podpowiedź: Żeby szybko zastosowa&#263; style, wystarczy zaznaczy&#263; tekst i klikną&#263; na odpowiedni przycisk.'
					}
		//alert(help_line[typ]);
      document.getElementById('podpowiedz_id').innerHTML=help_line[typ];
		}
		
		function bbstyle(numerek)
		{
		var bbcode = new Array();
		var bbtags = new Array('[b]','[/b]','[i]','[/i]','[u]','[/u]','[quote]','[/quote]','[code]','[/code]','[list]','[/list]','[list=]','[/list]','[img]','[/img]','[url]','[/url]','[youtube]','[/youtube]','[flash=]', '[/flash]','[size=]','[/size]');
		var imageTag = false;

      document.getElementById('entry_text_iid').value=document.getElementById('entry_text_iid').value+bbtags[numerek]+bbtags[numerek+1];
		}




/**
* Color pallette
*/
function colorPalette(dir, width, height)
{
	var r = 0, g = 0, b = 0;
	var numberList = new Array(6);
	var color = '';

	numberList[0] = '00';
	numberList[1] = '40';
	numberList[2] = '80';
	numberList[3] = 'BF';
	numberList[4] = 'FF';

	document.writeln('<table cellspacing="1" cellpadding="0" border="0">');
	var licznik=-1;
	var dziel=14;

	for (r = 0; r < 5; r++)
	{
		if (dir == 'h')
		{
			document.writeln('<tr>');
		}

		for (g = 0; g < 5; g++)
		{
			
			
			for (b = 0; b < 5; b++)
			{

			if ((dir == 'v' && licznik==dziel ) || licznik==-1)
			{
				licznik=0;
				document.writeln('<tr>');
			}
				
				color = String(numberList[r]) + String(numberList[g]) + String(numberList[b]);
				document.write('<td bgcolor="#' + color + '">');
				//document.write('<a href="#" onclick="bbfontstyle(\'[color=#' + color + ']\', \'[/color]\'); return false;" onmouseover="helpline(\'s\');"  onmouseout="helpline(\'tip\');">&nbsp;&nbsp;&nbsp;</a>');
				document.write('<input type="button" style="background-color:#'+color+';" onclick="wstaw_wartosc_w_pole4(\'entry_text_iid\',\'[color=#' + color + '][/color]\');" onmouseover="helpline(\'s\');"  onmouseout="helpline(\'tip\');">');
				
				document.writeln('</td>');

			if (dir == 'v' && licznik==dziel)
			{
				licznik=0;
				document.writeln('</tr>');
			}
			else
			{
				licznik=licznik+1;
			}

				}
//<img src="images/spacer.gif" width="' + width + '" height="' + height + '" alt="#' + color + '" title="#' + color + '" />
		}

		if (dir == 'h')
		{
			document.writeln('</tr>');
		}
	}
	document.writeln('</table>');
}

