<html>
<head>
<title>Web management</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-7">
<link rel="stylesheet" href="../styles.css" type="text/css">
</head>
<script language="JavaScript">
<!--
function MM_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') {
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (val<min || max<val) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}
//-->
</script>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="10">
      <?php 
			include 'connect.php';
if ($submit) {
	$sql="UPDATE links SET  name='$name', name_en='$name_en', name_de='$name_de', url='$url', publish='$publish', priority='$priority' WHERE id='$id'";
	$result = mysql_query($sql);	
?>
<table width="700" border="1" cellspacing="0" cellpadding="0" align="center" class="webadmintext" bordercolor="#999999">
  <tr> 
    <td bgcolor="#666666" bordercolor="#666666"> 
      <div align="center" class="white">TO LINK ΑΛΛΑΞΕ</div>
    </td>
  </tr>
  <tr> 
    <td bordercolor="#FFFFFF">&nbsp;</td>
  </tr>
  <tr> 
    <td bordercolor="#FFFFFF"> 
      <div align="center"><b>
        <?php echo $url   ?>
        </b> </div>
    </td>
  </tr>
  <tr> 
    <td bordercolor="#FFFFFF">&nbsp; </td>
  </tr>
</table>
<meta http-equiv="refresh" content="0;URL=edit-link.php?id=<?php echo $id ?>">
<?php
} else {	
			$result = mysql_query("SELECT * FROM links WHERE id=$id",$dbh);
			$myrow=mysql_fetch_array($result); 
			$name=$myrow['name'];
			$name_en=$myrow['name_en'];
			$name_de=$myrow['name_de'];
			$url=$myrow['url'];
			$publish=$myrow['publish'];
			$priority=$myrow['priority'];
?>
<form name="forma" method="post" action="<?php echo $PHP_SELF ?>" enctype="multipart/form-data">
  <table width="700" border="1" cellspacing="0" cellpadding="0" align="center" class="webadmintext" bordercolor="#999999">
    <tr> 
      <td bgcolor="#666666" bordercolor="#666666"> 
        <div align="center" class="white">ΑΛΛΑΓΗ LINK</div>
      </td>
    </tr>
    <tr> 
      <td bordercolor="#FFFFFF">&nbsp; </td>
    </tr>
    <tr> 
      <td bordercolor="#FFFFFF"> 
        <table width="100%" border="0" cellspacing="1" cellpadding="2" class="webadmintext" bgcolor="#F2F2F2">
          <tr> 
            <td width="30%">Τίτλος - ελληνικά* 
              <input type="hidden" name="id" value="<?php echo $id ?>">
            </td>
            <td> 
              <input type="text" name="name" class="forms" size="60" value="<?php echo $name ?>">
            </td>
          </tr>
          <tr> 
            <td width="30%">Τίτλος - αγγλικά*</td>
            <td> 
              <input type="text" name="name_en" class="forms" size="60" value="<?php echo $name_en ?>">
            </td>
          </tr>
          <tr> 
            <td width="30%">Τίτλος - γερμανικά</td>
            <td> 
              <input type="text" name="name_de" class="forms" size="60" value="<?php echo $name_de ?>">
            </td>
          </tr>
          <tr> 
            <td width="30%">URL*</td>
            <td> http:// 
              <input type="text" name="url" maxlength="100" value="<?php echo $url ?>" class="forms" size="60">
            </td>
          </tr>
          <tr> 
            <td width="30%">Δημοσίευση στο site?</td>
            <td> 
              <?php if ($publish!=no) { ?>
              <select name="publish" class="forms">
                <option value="yes" selected>yes</option>
                <option value="no">no</option>
              </select>
              <?php }else{?>
              <select name="publish" class="forms">
                <option value="yes">yes</option>
                <option value="no" selected>no</option>
              </select>
              <?php } ?>
            </td>
          </tr>
          <tr> 
            <td width="30%">Αριθμός προτεραιότητας</td>
            <td> 
              <input type="text" name="priority" maxlength="11" value="<?php echo $priority ?>" class="forms" size="20">
            </td>
          </tr>
        </table>
      </td>
    </tr>
    <tr>
      <td bgcolor="#FFFFFF" bordercolor="#FFFFFF">&nbsp;</td>
    </tr>
    <tr bgcolor="#666666"> 
      <td bgcolor="#666666" bordercolor="#666666"> 
        <table width="300" border="0" cellspacing="0" cellpadding="0" align="center">
          <tr> 
            <td> 
              <div align="center"> 
                <input type="submit" name="submit" value="Καταχώρηση" class="button" onClick="MM_validateForm('name','','R','name_en','','R','url','','R');return document.MM_returnValue">
              </div>
            </td>
            <td> 
              <div align="center"> 
                <input type="reset" name="Submit2" value="Επαναφορά" class="button">
              </div>
            </td>
          </tr>
        </table>
      </td>
    </tr>
  </table>
</form>
<?php } ?>
<table width="700" border="0" cellspacing="0" cellpadding="4" align="center">
  <tr>
    <td>
      <div align="center"> <a href="javascript:history.go(-1);"><img src="back.gif" alt="πίσω" border="0"></a> 
        &nbsp; <a href="#top"><img src="top.gif" border="0" alt="πάνω"></a> 
      </div>
    </td>
  </tr>
</table>
</body>
</html>
