function changeLinks() {
for ($i=0;$i<document.links.length;$i++) {
	if (document.links[$i].protocol=="http:") {
		if (document.links[$i].href.indexOf(document.location.hostname)<0) {
			document.links[$i].target="_blank";
			}
		}
	}
}

function picedit($index,$smallpic,$bigpic,$podpis,$opis) {
$o=event.srcElement;
if ($o!==null) {
	showMe($index,$smallpic);
	document.forms[0].picindex.value=$index;
	document.forms[0].srcfile.value=$smallpic;
	document.forms[0].srcbfile.value=$bigpic;
	document.forms[0].podpis.value=$podpis;
	document.forms[0].opis.value=$opis;
	document.forms[1].picindex.value=$index;
	}
event.cancelBubble=true;
}

function showMe($index,$picsmall) {
$ten=document.getElementById("pic"+$index);
$oc=document.getElementsByTagName("input");
document.forms[0].reset();
for ($i=0;$i<$oc.length;$i++) {
	if ($oc[$i].type=="checkbox") {
		$oc[$i].checked=false;
		}
	}
	$ten.checked=true;
	document.images[0].src="../"+$picsmall;
}

function selectother($whichone) {
//$answer=window.open("picView.php?m="+$whichone,null,"dialogWidth:600px;dialogHeight:400px;toolbar='no';personalbar='no';statusbar='no';scrollbars='yes';locationbar='no'");
$answer=window.open("picView.php?m="+$whichone,null,"width=600,height=400,toolbar=no,personalbar=no,statusbar=no,scrollbars=yes,locationbar=no");
if ($answer!==null) {
	if ($answer.length>0) {
		alert($anwser);
		}
	}

}

function setasstartup($newid) {
if ($newid>0) {
	$frm=document.forms["start"];
	if ($frm!=null) {
		$frm.startid.value=$newid;
		$frm.submit();
		}
	}
}

function saveSerwis($id) {
if (document.forms[0].stitle.value.length>0) {
	document.forms[0].submit();
	}
}

function saveStreet() {
	if (document.forms[0].ulid.value>=0) {
		document.forms[0].submit();
		}
	}
	
function delStreet() {
	if (window.confirm("czy na pewno chcesz usun±æ tê ulicê ze spisu?")==true) {
		document.forms[0].action="index.php?u=true";
		document.forms[0].deleteit.value=true;
		document.forms[0].submit();
		}
	}
	
function viewIt($filename,$poziomo,$max) {
	$o=null;
	if ($filename.length>0) {
		if ($poziomo==1) {
			$t=document.images[0].offsetTop+50;
			$l=((window.document.body.offsetWidth-640)/2)-50;
			$o=window.open("onServer/picViewer.php?pic="+$filename+"","imgviewer","statusbar=no,toolbar=no,menubar=no,personalbar=no,scrollbars=yes,left="+$l+",top="+$t+",width=750,height=600");
			} else {
			if ($max==1) {
				$t=0;
				$l=0;
				$o=window.open("onServer/picViewer.php?pic="+$filename+"","imgviewer","statusbar=no,toolbar=no,menubar=no,personalbar=no,scrollbars=yes,left="+$l+",top="+$t+",width="+screen.availWidth+",height="+screen.availHeight+"");
				} else {
				$t=document.images[0].offsetTop+75;
				$l=((window.document.body.offsetWidth-420)/2)-75;
				$o=window.open("onServer/picViewer.php?pic="+$filename+"","imgviewer","statusbar=no,toolbar=no,menubar=no,personalbar=no,scrollbars=yes,left="+$l+",top="+$t+",width=640,height=600");
				}
			}
		if ($o!=null) {
			$o.focus();
			}
		}
	event.cancelBubble=true;
	}
	
function showUl($which,$ulid) {
	if ($ulid>0) {
		if (document.images.length==2) {
			$t=document.images[0].offsetTop+100;
			$l=((window.document.body.offsetWidth-420)/2)-75;
			$picname=window.showModalDialog("picUlView.php?t="+$which,"imgviewer","statusbar=no,toolbar=no,menubar=no,personalbar=no,left="+$l+",top="+$t+",width=640,height=420");
			if ($picname!=null && $picname.length>0) {
				switch($which) {
					case "rzut":
						$im=document.getElementById("imgrzut");
						if ($im!==null) {
							document.forms[0].rzutname.value=$picname;
							$im.src="../"+$picname;
							}
						break;
					case "plan":
						$im=document.getElementById("imgplan");
						if ($im!==null) {
							document.forms[0].planname.value=$picname;
							$im.src="../"+$picname;
							}
						break;
					}
				}
			} else {
			$picname=window.showModalDialog("picUlView.php?t="+$which,"imgviewer","statusbar=no,toolbar=no,menubar=no,personalbar=no,width=640,height=420");
			alert($picname);
			if ($picname!=null && $picname.length>0) {
				$im=document.createElement("IMG");
				switch($which) {
					case "rzut":
						$imtd=document.getElementById("imgrzuttd");
						if ($im!==null) {
							document.forms[0].rzutname.value=$picname;
							$im.src="../"+$picname;
							}
						break;
					case "plan":
						$imtd=document.getElementById("imgplantd");
						if ($im!==null) {
							document.forms[0].planname.value=$picname;
							$im.src="../"+$picname;
							}
						break;
					}
				if ($imtd!=null) {
					$imtd.appendChild($im);
					}
				} 
			}
		}
	}
	
function addPlans() {
window.open("addPlans.php");
}

/*
function showimg() {
$s=event.srcElement;
if ($s!=null) {
	if ($s.tagName=="IMG") {
		if ($s.src.indexOf("artimg",0)>0) {
			viewIt($s.src);
			}
		}
	}
event.cancelBubble=true;
}
*/

function reklViewer() {
//$answer=window.open("picView.php?m="+$whichone,null,"dialogWidth:600px;dialogHeight:400px;toolbar='no';personalbar='no';statusbar='no';scrollbars='yes';locationbar='no'");
$answer=window.open("reklamaView.php?m=3",null,"width=600,height=400,toolbar=no,personalbar=no,statusbar=no,scrollbars=yes,locationbar=no");
if ($answer!==null) {
	if ($answer.length>0) {
//		alert($anwser);
		}
	}

}

function clearForm() {
if (document.forms[1]!==null) {
	$tb=document.getElementById("piclist");
	if ($tb!==null) {
		for($j=1;$j<$tb.rows.length;$j++) {
			$tb.rows[$j].style.backgroundColor="#FFFFFF";
			}
		}
	document.forms[1].reset();
	}
}

function delPic() {
if (document.forms[1].pid.value.length>0) {
	document.forms[1].delpic.value="true";
	document.forms[1].submit();
	} else {
	alert("nie mam co usun±æ");
	}
}

function applyForm($id) {
$otxt=document.getElementById($id);
$sTmp=new String();
$aTmp=new Array();
$tb=event.srcElement;
$tr=event.srcElement;
clearForm();
while($tr.tagName!=="TR") {
	$tr=$tr.parentElement;
	}

while($tb.tagName!=="TABLE") {
	$tb=$tb.parentElement;
	}
if ($tb!==null) {
	for($j=1;$j<$tb.rows.length;$j++) {
		$tb.rows[$j].style.backgroundColor="#FFFFFF";
		}
	}
if ($tr!==null) {
	$tr.style.backgroundColor="#FFFFCC";
	}
if ($otxt!=null) {
	$sTmp=$otxt.value;
	$aTmp=$sTmp.split("|");
	if ($aTmp.length>0 && document.forms[1]!==null) {
		document.forms[1].pid.value=$aTmp[0];
		document.forms[1].smallpic.value=$aTmp[1];
		document.forms[1].bigpic.value=$aTmp[2];
		document.forms[1].autor.value=$aTmp[3];
		document.forms[1].podpis.value=$aTmp[4];
		document.forms[1].opis.value=$aTmp[5];
		}
	
	}
}

function getpicture(isbig) {
//window.open('../admin/edi/listFiles.php');
//$answer=window.open("picView.php?m="+$whichone,null,"width=600,height=400,toolbar=no,personalbar=no,statusbar=no,scrollbars=yes,locationbar=no");
$tmpProps=new String();
$tmpProps="dialogHeight:600px;dialogWidth:800px;center:yes;edge:sunken;toolbar:no,personalbar:no,statusbar:no,scrollbars:yes,locationbar:no";
if (isbig==true) {
	$answer=window.showModalDialog("edi/listFiles.php?m=1",null,$tmpProps);
	} else {
	$answer=window.showModalDialog("edi/listFiles.php?m=0",null,$tmpProps);
	}
if ($answer!=null) {
	if ($answer.length>0) {
		if (isbig==true) {
			$input=document.getElementById("bigpic");
			if ($input!=null) {
				$input.value=$answer;
				}
			} else {
			$input=document.getElementById("smallpic");			
			if ($input!=null) {
				$input.value=$answer;
				}
			}
		}
	}
}