<?php


$jpg_file_name = $_GET['jpg_file_name'];
$jpg_file_name_tmp = $_GET['jpg_file_name_tmp'];
//@$marktype = $_GET['marktype'];
$ruid = $_GET['ruid'];
$patid = $_GET['patid'];

?>


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=euc_jp">
<title></title>

<script language='JavaScript'>
<!--




function getMouseX(e){
  if(window.opera)
          return e.clientX
  else if(document.all)   
          return document.body.scrollLeft+event.clientX
  else if(document.layers||document.getElementById)
          return e.pageX
}
function getMouseY(e){
  if(window.opera)   
          return e.clientY
  else if(document.all)   
          return document.body.scrollTop+event.clientY
  else if(document.layers||document.getElementById)
          return e.pageY
}

function linkIt(theField) {
	location.replace(theField[theField.selectedIndex].value);
}


function linkradio(theField) {
	location.replace(theField.value);
}


  function mdwn(e){
	location.replace( "marking_tmp.php?pointx=" + getMouseX(e) + "&pointy=" + getMouseY(e) + "&jpg_file_name=" + "<?php echo $jpg_file_name?>&jpg_file_name_tmp=<?php echo $jpg_file_name_tmp?>&ruid=<?php echo $ruid?>&patid=<?php echo $patid ?>&marktype=ul" );
  }
  function mdwn2(e){
  	location.replace(mdwn(e))
  }
  

//-->
</script>

<body BACKGROUND="./img/yellow.jpg">


<?php
$size = 512;

//print("$patid<br>");


print("<A ><IMG SRC=$jpg_file_name  name=\"IMG\" WIDTH=\"$size\" ></a>");
			system("rm -f $jpg_file_name_tmp");
			system("cp -f $jpg_file_name $jpg_file_name_tmp");


			exec("/usr/bin/identify -format \"%w,%h\" $jpg_file_name_tmp",$img_size);

			$size_array = split(",",$img_size[0]);
			$tmp_width = $size_array[0];
			$tmp_height = $size_array[1];
			
			$convert_width = 512;
			$convert_height = $tmp_height * 512 / $tmp_width;
//			print("<br>$convert_height<br>");


exec("/usr/bin/iconvert -geometry $convert_width x $convert_height $jpg_file_name_tmp $jpg_file_name_tmp");

			

$marktype = "ul";
print("<br>Current Arrow direction is <font color=red><b>Left</b></font><br>");


//print("<form action=marking_tmp.php method=post>");


	if($marktype == "ul"){
print("<input type=\"radio\" name=\"marktype\" checked=\"checked\" value=\"ul\"><img src=./img/lu.jpg width=18 height=18>");
	}
	else{
	print("<input type=\"radio\" name=\"marktype\" value=\"ur\" onClick=\"javascript:location.replace( 'marking_tmp.php?jpg_file_name=$jpg_file_name&jpg_file_name_tmp=$jpg_file_name_tmp&ruid=$ruid&patid=$patid&marktype=ul' )\" ><img src=./img/lu.jpg width=18 height=18>");
	}

	if($marktype == "ur"){
	print("<input type=\"radio\" name=\"marktype\" checked=\"checked\" value=\"ur\"><img src=./img/ru.jpg width=18 height=18>");
	}
	else{
	print("<input type=\"radio\" name=\"marktype\" value=\"ur\" onClick=\"javascript:location.replace( 'marking_tmp.php?jpg_file_name=$jpg_file_name&jpg_file_name_tmp=$jpg_file_name_tmp&ruid=$ruid&patid=$patid&marktype=ur' )\" ><img src=./img/ru.jpg width=18 height=18>");
	}

	if($marktype == "dl"){
	print("<input type=\"radio\" name=\"marktype\" checked=\"checked\" value=\"dl\"><img src=./img/ld.jpg width=18 height=18>");
	}
	else{
	print("<input type=\"radio\" name=\"marktype\" value=\"ur\" onClick=\"javascript:location.replace( 'marking_tmp.php?jpg_file_name=$jpg_file_name&jpg_file_name_tmp=$jpg_file_name_tmp&ruid=$ruid&patid=$patid&marktype=dl' )\" ><img src=./img/ld.jpg width=18 height=18>");
	}	

	if($marktype == "dr"){
	print("<input type=\"radio\" name=\"marktype\" checked=\"checked\" value=\"dr\"><img src=./img/dr.jpg width=18 height=18>");
	}
	else{
	print("<input type=\"radio\" name=\"marktype\" value=\"ur\" onClick=\"javascript:location.replace( 'marking_tmp.php?jpg_file_name=$jpg_file_name&jpg_file_name_tmp=$jpg_file_name_tmp&ruid=$ruid&patid=$patid&marktype=dr' )\" ><img src=./img/rd.jpg width=18 height=18>");
	}

	if($marktype == "sround"){
	print("<input type=\"radio\" name=\"marktype\" checked=\"checked\"  value=\value=\"sround\">small circle");
	}
	else{
	print("<input type=\"radio\" name=\"marktype\" value=\"ur\" onClick=\"javascript:location.replace( 'marking_tmp.php?jpg_file_name=$jpg_file_name&jpg_file_name_tmp=$jpg_file_name_tmp&ruid=$ruid&patid=$patid&marktype=sround' )\" >small circle");
	}

	if($marktype == "mround"){
	print("<input type=\"radio\" name=\"marktype\" checked=\"checked\"  value=\"mround\">middle circle");
	}
	else{
	print("<input type=\"radio\" name=\"marktype\" value=\"ur\" onClick=\"javascript:location.replace( 'marking_tmp.php?jpg_file_name=$jpg_file_name&jpg_file_name_tmp=$jpg_file_name_tmp&ruid=$ruid&patid=$patid&marktype=mround' )\" >middle circle");

	}

	if($marktype == "lround"){
	print("<input type=\"radio\" name=\"marktype\" checked=\"checked\"  value=\"lround\">big circle");
	}
	else{
	print("<input type=\"radio\" name=\"marktype\" value=\"ur\" onClick=\"javascript:location.replace( 'marking_tmp.php?jpg_file_name=$jpg_file_name&jpg_file_name_tmp=$jpg_file_name_tmp&ruid=$ruid&patid=$patid&marktype=lround' )\" >big circle");

	}

	if($marktype == "up"){
	print("<input type=\"radio\" name=\"marktype\" checked=\"checked\"  value=\"up\"><img src=./img/up.jpg width=18 height=18>");
	}
	else{
	print("<input type=\"radio\" name=\"marktype\" value=\"ur\" onClick=\"javascript:location.replace( 'marking_tmp.php?jpg_file_name=$jpg_file_name&jpg_file_name_tmp=$jpg_file_name_tmp&ruid=$ruid&patid=$patid&marktype=up' )\" ><img src=./img/up.jpg width=18 height=18>");
	}

	if($marktype == "down"){
	print("<input type=\"radio\" name=\"marktype\" checked=\"checked\"  value=\"down\"><img src=./img/down.jpg width=18 height=18>");
	}
	else{
	print("<input type=\"radio\" name=\"marktype\" value=\"ur\" onClick=\"javascript:location.replace( 'marking_tmp.php?jpg_file_name=$jpg_file_name&jpg_file_name_tmp=$jpg_file_name_tmp&ruid=$ruid&patid=$patid&marktype=down' )\" ><img src=./img/down.jpg width=18 height=18>");
	}


	if($marktype == "rt"){
	print("<input type=\"radio\" name=\"marktype\" checked=\"checked\"  value=\"rt\"><img src=./img/rt.jpg width=18 height=18>");
	}
	else{
	print("<input type=\"radio\" name=\"marktype\" value=\"ur\" onClick=\"javascript:location.replace( 'marking_tmp.php?jpg_file_name=$jpg_file_name&jpg_file_name_tmp=$jpg_file_name_tmp&ruid=$ruid&patid=$patid&marktype=rt' )\" ><img src=./img/rt.jpg width=18 height=18>");
	}


	if($marktype == "lt"){
	print("<input type=\"radio\" name=\"marktype\" checked=\"checked\"  value=\"lt\"><img src=./img/lt.jpg width=18 height=18>");
	}
	else{
	print("<input type=\"radio\" name=\"marktype\" value=\"ur\" onClick=\"javascript:location.replace( 'marking_tmp.php?jpg_file_name=$jpg_file_name&jpg_file_name_tmp=$jpg_file_name_tmp&ruid=$ruid&patid=$patid&marktype=lt' )\" ><img src=./img/lt.jpg width=18 height=18>");
	}

// html portion


?>




?>


<script language='JavaScript'>
  document.IMG.onmousedown = mdwn
</script>

<br><B>Click to loaction of marking area</B>


<?php

print("<form action=marking_tmp.php method=post>");
print("Comment:<br><input type=text name=comment size=50>");
?>
<input type=hidden name=jpg_file_name value="<?php echo $jpg_file_name; ?>">
<input type=hidden name=jpg_file_name_tmp value="<?php echo $jpg_file_name_tmp; ?>">
<input type=hidden name=ruid value="<?php echo $ruid; ?>">
<input type=hidden name=patid value="<?php echo $patid; ?>">
<input type=hidden name=pointx value="-500">
<input type=hidden name=pointy value="-500">
<input type=hidden name=marktype value="<?php echo $marktype; ?>">
<?php
print("<input type=submit value=Set comment>");
print("</form>");
?>


<form action=marking_update.php method=post>
<input type=hidden name=jpg_file_name_tmp value=<?php echo $jpg_file_name_tmp; ?>>
<input type=hidden name=jpg_file_name value=<?php echo $jpg_file_name; ?>>
<input type=hidden name=ruid value=<?php echo $ruid; ?>>
<input type=submit value="Attach the image to report.">
</form>

<form action=marking_select_report.php method=post>
<input type=hidden name=jpg_file_name_tmp value="<?php echo $jpg_file_name_tmp; ?>">
<input type=hidden name=patid value="<?php echo $patid; ?>">
<input type=submit value="Select report for attaching image">
</form>


</body>
</html>

