<?

if(!function_exists("modul_metatagi")){

	function modul_metatagi($id_strony) {

	   global $db_pref;
	   global $nazwa_strony;
	   global $logged_in;
	   global $poziom_dostepu; 
	   global $go; 
		global $subgo; 
		global $id_strony;

	   $naglowek_strony = NULL;
		
	   $sql = mysql_query ("SELECT naglowek FROM ".$db_pref."naglowki WHERE id_strony='".$id_strony."' AND subgo='".$subgo."' LIMIT 1;");
	   $row = mysql_fetch_array($sql);
	   $naglowek_strony = $row['naglowek'];
	   


		if($naglowek_strony==NULL){
		   $wykonaj = mysql_query ("SELECT naglowek FROM ".$db_pref."naglowki WHERE id_strony='".$id_strony."' AND subgo=NULL LIMIT 1;");
		   while($wiersz=mysql_fetch_array ($wykonaj)){
		   	$naglowek_strony = $wiersz['naglowek'];
		   }
		}			
		
		

	   if($naglowek_strony==NULL){
	      $wykonaj = mysql_query ("SELECT naglowek FROM ".$db_pref."serwis WHERE id='".$_SESSION['ID_serwisu']."';");
	      while($wiersz=mysql_fetch_array ($wykonaj)){
	         $naglowek_strony = $wiersz['naglowek'];
	      }
	   }



	  $out_mod = null;    

	     

	$out_mod = $naglowek_strony;



	if($logged_in==1 and $poziom_dostepu!=null){    

	$out_mod .= '  

		<script type="text/javascript" language="javascript">
		function createRequestObject() {
		    var ro;
		    var browser = navigator.appName;
		    if(browser == "Microsoft Internet Explorer"){
		        ro = new ActiveXObject("Microsoft.XMLHTTP");
		    }else{
		        ro = new XMLHttpRequest();
		    }
		    return ro;
		}

		var http = createRequestObject();

		function sndReq(msg,gdzie,co) {
		    http.open(\'get\', \'index.php?ajax&co=\'+co+\'&msg=\'+msg+\'&gdzie=\'+gdzie);
		    http.onreadystatechange = handleResponse;
		    http.send(null);
		}

		function handleResponse() {
		    if(http.readyState == 4){
		        var response = http.responseText;
		        var update = new Array();
		        if(response.indexOf(\'|\' != -1)) {
		            update = response.split(\'|\');
		            document.getElementById(update[0]).innerHTML = update[1];
		        }
		    }
		}
		</script>
';


	}

 

	  return $out_mod;

	}

}

$tpl->assign("meta_tagi",modul_metatagi($id_stronyy));

$out_mod=null;

?>