<?

function ico($name="",$url="", $txt=""){
global $xpath;
$ret="";
//echo"----dupa|$name";
    if ($name){
	if ($url && $txt){
	    $ret ="<img border=\"0\" src=\"$xpath/ico/$name.gif\" width=\"16\" align=\"absmiddle\" height=\"16\" alt=\"$txt\">";
	    $ret .="<a href=\"$url\" > $txt</a>&nbsp;";
	} else if($url){
	    $ret ="<a href=\"mod.php?mod=billing&wp=login&op=$op\" >	";
	    $ret .="<img border=\"0\" src=\"$xpath/ico/$name.gif\" width=\"16\" align=\"absmiddle\" height=\"16\">";
	    $ret .="</a>&nbsp;";
	}else if ($txt){
	    $ret ="<img border=\"0\" src=\"$xpath/ico/$name.gif\" width=\"16\" align=\"absmiddle\" height=\"16\" alt=\"$txt\">&nbsp;";
	}else{
	    $ret ="<img border=\"0\" src=\"$xpath/ico/$name.gif\" width=\"16\" align=\"absmiddle\" height=\"16\">&nbsp;";	
	}
    }
    return $ret;
}



function isfile($name){
    $is=(@fclose(@fopen($name, "r")));
    return($is);
}

function is_user($perm=""){
    
//    $perm=explode(",", $perm);

    if ($perm=="admin" OR $perm=="adm"){
	$perm=1;
    }
    if ($_SESSION[u_id]>0 AND $_SESSION[login]==1){
//echo"$_SESSION[u_id]==$_SESSION[u_perm]";
	if ($perm){
//	    if (($_SESSION[u_perm]==$perm[1] AND $perm[1]) || ($_SESSION[u_perm]==$perm[2] AND $perm[2]) || ($_SESSION[u_perm]==$perm[3] AND $perm[3]) || ($_SESSION[u_perm]==$perm[4] AND $perm[4]) || ($_SESSION[u_perm]==$perm[5] AND $perm[5])){
	    if ($_SESSION[u_perm]==$perm OR ($perm=='2' AND $_SESSION[u_perm]=='1')){	    
    		return $_SESSION[u_id];
	    }else{
		return 0;
	    }
	}else{
    	    return $_SESSION[u_id];
	}
    }else{
	return 0;
    }
}

function upload($file,$path){

}

function OpenTable(){
echo"<table border=\"0\" width=\"615\" cellspacing=\"0\" cellpadding=\"0\">\n";
echo"<tr>\n";
echo"<td width=\"100%\" valign=\"middle\" align=\"left\">";
}
function Close(){
echo"</td>\n";
echo"</tr>\n";
echo"</table>";
}


function refreshclose(){
?>
<script>
<!--
  window.opener.location.reload();
  window.close();
//-->
</script>
<?
}

function refresh(){
?>
<script>
<!--
  window.opener.location.reload();
//  window.close();
//-->
</script>
<?
}


function redirect($where){
?>
<script>
<!--
  window.location='<? echo $where;?>';
//  window.close();
//-->
</script>
<?
}

?>
