function changeSearch(where,label){
	document.formSearch.sin.value=where;
	document.getElementById('inputSubmit').firstChild.nodeValue=label;
}//changeSearch

function submitSearch(){
	if (document.formSearch.phrase.value==""){
		alert("Musisz wpisać jakieś kryterium wyszukiwania!");
	}//if
	else{
		document.formSearch.submit();
	}//else
}//submitSearch

function keywordSearch(phrase){
	document.formSearch.sin.value="all";
	document.getElementById('inputSubmit').firstChild.nodeValue="wszędzie";
	document.formSearch.phrase.value=phrase;
	document.formSearch.submit();
}//keywordSearch

function submitPedia(){
	if (document.formPedia.phrase.value==""){
		alert("Musisz wpisać jakieś kryterium wyszukiwania!");
	}//if
	else{
		document.formPedia.submit();
	}//else
}//submitPedia

function submitPediaLetter(letter){
	window.location="./?m=3&a=search&phrase="+letter.charAt(0)+"&type=start";
}//submitPediaLetter

function changeTab(prefix,to,max){
	for(i=1;i<=max;i++){
		if (i==to){
			document.getElementById(prefix+to).attributes.getNamedItem('class').value="active";
			document.getElementById("div"+prefix+to).attributes.getNamedItem('class').value="visible";
		}//if
		else{
			document.getElementById(prefix+i).attributes.getNamedItem('class').value="passive";
			document.getElementById("div"+prefix+i).attributes.getNamedItem('class').value="hidden";
		}//else
	}//for
}//changeTab

function bannerClicked(formname,act){
	ret=false;
	act=(((typeof(act)=="undefined")||act=="")?"out":act);
	if (act=="in"){
		ret=true;
		document.forms[formname].submit();
	}//if
	else{
		window.open(document.forms[formname].action,"","");
	}//else
	return ret;
}//bannerClicked


function toggleElement(divname,divstatus){
	if (divstatus=="on"){
		document.getElementById(divname).attributes.getNamedItem('class').value="visible";
		//document.getElementById(divname).style.display="block";
		//document.getElementById(divname).style.position="relative";
		if (divname=="map"){
			innermap=document.createElement("div");
			innermap.setAttribute("id","innermap");
			document.getElementById('map').appendChild(innermap);
			GoogleLoadChoose();
		}//if
		else if (divname=="emap"){
			innermap=document.createElement("div");
			innermap.setAttribute("id","innermap");
			document.getElementById('emap').appendChild(innermap);
			GoogleEditChoose();
		}//if
	}//if
	else{
		if (divname=="map"){
			GUnload();
			document.getElementById('map').removeChild(document.getElementById("innermap"));
		}//if
		else if (divname=="emap"){
			GUnload();
			document.getElementById('emap').removeChild(document.getElementById("innermap"));
		}//if
		document.getElementById(divname).attributes.getNamedItem('class').value="hidden";
		//document.getElementById(divname).style.display="none";
		//document.getElementById(divname).style.position="absolute";
	}//else
}//toggleDiv

function tooggleElementOnCheckbox(formname,checkname,divname){
	for(i=0;i<document.forms[formname].elements.length;i++){
		if (document.forms[formname].elements[i].name==checkname){
			if (document.forms[formname].elements[i].checked==true){
				toggleElement(divname,"on");
			}//if
			else{
				toggleElement(divname,"off");
			}//else
		}//if
	}//for
}//toggleDivOnCheckbox

function selectGab(){
	document.location="./?m=142&gab="+document.getElementById('gabselect').value;
}//selectGab

function addAttribute(elname,where,what){
	document.getElementById(elname).attributes.getNamedItem(where).value=what;
}//addAttribute

function setImage(elname,img){
	elname.attributes.getNamedItem("src").value=img;
}//setBgImage

function setBg(elname,img){
	elname.style.backgroundImage="url('"+img+"')";
}//setBg

/*--- WYSUWANE TABY ---*/

function atEndDo(what,tabId){
	if (what=='on'){
		tabOn=1;
		document.getElementById(tabId+"bg").style.backgroundImage="url('img/back_new_tab_lu.gif')";
		document.getElementById(tabId+"hid").attributes.getNamedItem('class').value="visibleContentt";
	}//if
	else if (what=='off'){
		tabOn=0;
		document.getElementById(tabId+"bg").style.backgroundImage="url('img/back_new_tab_ld.gif')";
	}//elif
}//atEndDOo

function moveTab(tabId){
	if (tabInMove==1){
		return;
	}//if
	if (tabOn==0){
		tabHeight(tabId,40,"atEndDo('on','"+tabId+"');");
	}//if
	else{
		document.getElementById(tabId+"hid").attributes.getNamedItem('class').value="hiddenContentt";
		tabHeight(tabId,15,"atEndDo('off','"+tabId+"');");
	}//else
}//moveTab

function tabHeight(tabId,newHeight,atEnd){
	tabInMove=1;
	elemHeight=document.getElementById(tabId).style.height;
	elemHeight=elemHeight.substr(0,elemHeight.length-2);
	if (Math.abs(elemHeight-newHeight)<dh){
		eval(atEnd);
		tabInMove=0;
		document.getElementById(tabId).style.height=newHeight+"px";
		return;
	}//if
	if (elemHeight>newHeight){
		nextHeight=(Math.round(elemHeight)-dh)+"px";
		contentHeight=(Math.round(elemHeight)-dh-15)+"px";
	}//elif
	else{
		nextHeight=(Math.round(elemHeight)+dh)+"px";
		contentHeight=(Math.round(elemHeight)+dh-15)+"px";
	}//else
	document.getElementById(tabId).style.height=nextHeight;
	document.getElementById(tabId+"ct").style.height=contentHeight;
	setTimeout("tabHeight(\""+tabId+"\","+newHeight+",\""+atEnd+"\");",50);
}//tabHeight

/*--- EZINE ARCHIWUM ---*/

function ezSelectYear(){
	ezyear=document.getElementById('selYr').value;
	for(i=(document.getElementById('selNr').childNodes.length-1);i>=0;i--){
		document.getElementById('selNr').removeChild(document.getElementById('selNr').childNodes[i]);
	}//for
	eval("ezylen=yearval"+ezyear+".length;");
	for(i=0;i<ezylen;i++){
		eznewopt=document.createElement("option");
		eval("eznewtext=document.createTextNode(yeartxt"+ezyear+"["+i+"]);");
		eznewopt.appendChild(eznewtext);
		eval("eznewopt.setAttribute('value',yearval"+ezyear+"["+i+"]);");
		document.getElementById('selNr').appendChild(eznewopt);
	}//for
}//ezSelectYear

function ezSelectNr(){
	eznr=document.getElementById('selNr').value;
	if (eznr!=""){
		window.open("http://dentonet.pl/eZine/ezin_nr/"+document.getElementById('selNr').value);
	}//if
}//ezSelectNr

/*--- DYMKI ---*/

function boubleOn(ev,divid,classs){
	if (navigator.appName=="Microsoft Internet Explorer"){
		localevent=window.event;
		localOffX=document.documentElement.scrollLeft;
		localOffY=document.documentElement.scrollTop;
	}//if
	else{
		localevent=ev;
		localOffX=window.pageXOffset;
		localOffY=window.pageYOffset;
	}//else
	document.getElementById(divid).attributes.getNamedItem('class').value=classs;
	document.getElementById(divid).style.top=(localevent.clientY+20+localOffY)+"px";
	document.getElementById(divid).style.left=(localevent.clientX+20+localOffX)+"px";
}//boubleOn

function boubleOff(ev,divid,classs){
	if (navigator.appName=="Microsoft Internet Explorer"){
		localevent=window.event;
	}//if
	else{
		localevent=ev;
	}//else
	document.getElementById(divid).attributes.getNamedItem('class').value=classs;
	document.getElementById(divid).style.top=0+"px";
	document.getElementById(divid).style.left=0+"px";
}//boubleOff

function boubleMove(ev,divid){
	if (navigator.appName=="Microsoft Internet Explorer"){
		localevent=window.event;
		localOffX=document.documentElement.scrollLeft;
		localOffY=document.documentElement.scrollTop;
	}//if
	else{
		localevent=ev;
		localOffX=window.pageXOffset;
		localOffY=window.pageYOffset;
	}//else
	document.getElementById(divid).style.top=(localevent.clientY+20+localOffY)+"px";
	document.getElementById(divid).style.left=(localevent.clientX+20+localOffX)+"px";
}//boubleMove

/*--- DYNAMICZNIE PODMIENIANE FORMULARZE ----*/

function initVariable(suffix,val,prefix){
	if (typeof(prefix)=='undefined'){
		prefix="value_";
	}//if
	eval("var "+prefix+suffix+"=\""+val+"\"");
}//initVariable

function saveForm(fromname){
	var element;
	var form=document.forms[fromname];
	for(i=0;i<form.elements.length;i++){
		element=form.elements[i];
		eval("disabled_"+element.name+"=element.disabled");
		switch(element.type){
			case "hidden":
			case "text":
			case "file":
			case "button":
			case "submit":
				eval("value_"+element.name+"=element.value");
				break;
			case "checkbox":
				eval("checked_"+element.name+"=element.checked");
				break;
			case "radio":
				if (element.checked){
					eval("value_"+element.name+"=element.value");					
				}//if
				eval("if (typeof(value_"+element.name+")=='undefined') { value_"+element.name+"='';  }");
				break;
			case "select-one":
				eval("index_"+element.name+"=element.selectedIndex");
				break;
		}//switch
	}//for
}//saveForm

function loadForm(toname){
	var element;
	var form=document.forms[toname];
	for(i=0;i<form.elements.length;i++){
		element=form.elements[i];
		eval("if (typeof(disabled_"+element.name+")!='undefined') { element.disabled=disabled_"+element.name+"; }");
		switch(element.type){
			case "hidden":
			case "text":
			case "file":
			case "button":
			case "submit":
				eval("if (typeof(value_"+element.name+")!='undefined') { element.value=value_"+element.name+"; }");
				break;
			case "checkbox":
				eval("if (typeof(checked_"+element.name+")!='undefined') { element.checked=checked_"+element.name+"; }");
				break;
			case "radio":
				eval("if (typeof(value_"+element.name+")!='undefined') { if (element.value==value_"+element.name+") { element.checked=true; } }")
				break;
			case "select-one":
				eval("if (typeof(index_"+element.name+")!='undefined') { element.selectedIndex=index_"+element.name+"; }");
				break;
		}//switch
	}//for
}//loadForm

function clearForm(toname){
	var element;
	var radioo;
	var form=document.forms[toname];
	for(i=0;i<form.elements.length;i++){
		element=form.elements[i];
		switch(element.type){
			case "hidden":
			case "text":
			case "file":
			case "button":
			case "submit":
				element.value="";
				break;
			case "checkbox":
				element.checked=false;
				break;
			case "radio":
				for(j=0;element.length;j++){
					element[i].checked=false;
				}//for
				break;
			case "select-one":
				element.selectedIndex=0;
				break;
		}//switch
	}//for
}//clearForm

function insertCode(where,what,fromname,toname){
	var dest=document.getElementById(where);
	var clone=document.getElementById(what).cloneNode(true);
	if ((fromname!=null)&&(fromname!="")){
		saveForm(fromname);
	}//if
	for (i=0;i<dest.childNodes.length;i++){
		dest.removeChild(dest.childNodes[i]);
	}//for
	dest.insertBefore(clone,null);
	if ((toname!=null)&&(toname!="")){
		loadForm(toname);
		if (typeof(document.forms[toname].tab)!='undefined'){
			document.forms[toname].tab.value=what;
		}//if
	}//if
}//insertExtended

/* ROGOWE TRÓJKĄCIKI */

function triangleCornerRB(where,size,color,topLayer){
	var bgDiv;
	var topDiv;
	var cornerDiv=document.createElement("div");
	cornerDiv.style.position="absolute";
	cornerDiv.style.bottom="0px";
	cornerDiv.style.right="0px";
	cornerDiv.style.width=size+"px";
	cornerDiv.style.height=size+"px";
	cornerDiv.style.overflow="hidden";
	cornerDiv.style.zIndex="5";
	for(i=0;i<size;i++){
		bgDiv=document.createElement("div");
		bgDiv.style.position="absolute";
		bgDiv.style.top=(size-i-1)+"px";
		bgDiv.style.left=i+"px";
		bgDiv.style.width="1px";
		bgDiv.style.height=(i+1)+"px";
		bgDiv.style.overflow="hidden";
		bgDiv.style.backgroundColor=color;
		cornerDiv.appendChild(bgDiv);
	}//for
	var topDiv=document.createElement("div");
	topDiv.style.position="absolute";
	topDiv.style.right="0px";
	topDiv.style.bottom="0px";
	topDiv.style.width=size+"px";
	topDiv.style.height=size+"px";
	topDiv.style.overflow="hidden";
	topDiv.style.zIndex="6";
	topDiv.innerHTML=topLayer;
	cornerDiv.appendChild(topDiv);
	document.getElementById(where).appendChild(cornerDiv);
}//triangleCornerRB

/* GOOGLE */

function GoogleDegToMS(deg){
	m=(deg-Math.floor(deg))*60.0;
	s=(m-Math.floor(m))*60.0;
	return Math.floor(deg)+"&deg; "+Math.floor(m)+"&apos; "+Math.floor(s)+"&quot; ";
}//GoogleDegToMS

function GoogleShowPosition(mark,cls){
	latlng=new GLatLng(document.forms[cls].lat.value,document.forms[cls].lng.value); //domyślne
	latlng=mark.getPoint();
	lat=latlng.lat();
	lng=latlng.lng();
	txt="";
	if (lat>=0){
		txt+=GoogleDegToMS(Math.abs(lat))+"N";
	}//if
	else{
		txt+=GoogleDegToMS(Math.abs(lat))+"S";
	}//else
	txt+=" &nbsp;";
	if (lng>=0){
		txt+=GoogleDegToMS(Math.abs(lng))+"E";
	}//if
	else{
		txt+=GoogleDegToMS(Math.abs(lng))+"W";
	}//else
	document.forms[cls].lat.value=lat;
	document.forms[cls].lng.value=lng;
	return txt;
}//GoogleShowPosition

function GoogleCrateInfoMarker(lat,lng,desc){
	var marker=new GMarker(new GLatLng(lat,lng));
	GEvent.addListener(marker,"click",function() { marker.openInfoWindowHtml(desc); });
	return marker;
}//GoogleCrateInfoMarker

function GoogleLoadChoose(){
	if (GBrowserIsCompatible()) {
		var map=new GMap2(document.getElementById("innermap"));
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());
		var center=new GLatLng(document.forms['addCards'].lat.value,document.forms['addCards'].lng.value);
		map.setCenter(center,Math.floor(document.forms['addCards'].zoom.value));
		GEvent.addListener(map,"zoomend",function(oldz,newz){ document.forms['addCards'].zoom.value=newz; });

		var marker=new GMarker(center,{draggable: true});
		GEvent.addListener(marker,"dragstart",function(){ map.closeInfoWindow(); });
		GEvent.addListener(marker,"dragend",function(){ marker.openInfoWindowHtml("Pozycja twojego gabinetu:<br />"+GoogleShowPosition(marker,'addCards')); });
		map.addOverlay(marker);
		marker.openInfoWindowHtml("Ustaw znacznik <b>dokładnie</b><br />w miejscu swojego gabinetu,<br /> przeciągając go przy pomocy myszy.");
	}//if
	else{
		alert("W tej przeglądarce mapka nie zadziała, użyj Konquerora, Firefoksa, Opery lub Safari");
	}//else
}//GoogleLoadChoose

function GoogleEditChoose(){
	if (GBrowserIsCompatible()) {
		var map=new GMap2(document.getElementById("innermap"));
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());
		var center=new GLatLng(document.forms['editCards'].lat.value,document.forms['editCards'].lng.value);
		map.setCenter(center,Math.floor(document.forms['editCards'].zoom.value));
		GEvent.addListener(map,"zoomend",function(oldz,newz){ document.forms['editCards'].zoom.value=newz; });

		var marker=new GMarker(center,{draggable: true});
		GEvent.addListener(marker,"dragstart",function(){ map.closeInfoWindow(); });
		GEvent.addListener(marker,"dragend",function(){ marker.openInfoWindowHtml("Pozycja twojego gabinetu:<br />"+GoogleShowPosition(marker,'editCards')); });
		map.addOverlay(marker);
		marker.openInfoWindowHtml("Ustaw znacznik <b>dokładnie</b><br />w miejscu swojego gabinetu,<br /> przeciągając go przy pomocy myszy.");
	}//if
	else{
		alert("W tej przeglądarce mapka nie zadziała, użyj Konquerora, Firefoksa, Opery lub Safari");
	}//else
}//GoogleEditChoose

function GoogleLoadSingleGab(lat,lng,addr){
	if (GBrowserIsCompatible()) {
		var map=new GMap2(document.getElementById("gabmap"));
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());
		var center=new GLatLng(lat,lng);
		map.setCenter(center,16);

		var marker=new GMarker(center);
		map.addOverlay(marker);
		marker.openInfoWindowHtml(addr);
	}//if
	else{
		alert("W tej przeglądarce mapka nie zadziała, użyj Konquerora, Firefoksa, Opery lub Safari");
	}//else
}//GoogleLoadSingleGab

function GoogleLoadAllGab(){
	if (GBrowserIsCompatible()) {
		var allgab=new Array();
		var map=new GMap2(document.getElementById("allgabmap"));
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());
		var center=new GLatLng(51.77,19.46);
		map.setCenter(center,6);
		var mgr=new GMarkerManager(map);
		for(i=0;i<GMyLat.length;i++){
			allgab[i]=GoogleCrateInfoMarker(GMyLat[i],GMyLng[i],GMyDesc[i]);
		}//for
		mgr.addMarkers(allgab,5);
		mgr.refresh();
	}//if
	else{
		alert("W tej przeglądarce mapka nie zadziała, użyj Konquerora, Firefoksa, Opery lub Safari");
	}//else
}//GoogleLoadAllGab
