<?php


$totalmark = $_SESSION['totalmark'];
$multiword = $_SESSION['multiword'];
$multidevice = $_SESSION['multidevice'];
$multislogan = $_SESSION['multislogan'];

$classes = $_SESSION['classes'];


$results2 = mysql_query("SELECT * FROM formclass ORDER BY CNo ASC");
$num_results2 = mysql_num_rows($results2);
for($p=1;$p<=$num_results2;$p++){
$row2 = mysql_fetch_array($results2);
$classz = $row2['classcode'];
$$classz  = $_SESSION[$classz];
}

if($_POST["Home"] == "Home")
{
	echo "<script language='javascript'>window.location='memberpage.php'</script>";
}
if($_POST["Previous"] == "Previous")
{
	echo "<script language='javascript'>window.location='eforms.php'</script>";
}
if($_POST["Next"] == "Next")
{	
	for($i=0;$i<11;$i++){
	$wordmarkword = "wordmark".$i;
	session_register($wordmarkword);
	$_SESSION[$wordmarkword] = $_POST['wordmark'.$i];
	$a = $_SESSION[$wordmarkword];	
	//echo "<script language='javascript'>alert ('$wordmarkword $a')</script>";
	}
	
	for($j=0;$j<11;$j++){
	$sloganmarkword = "sloganmark".$j;
	session_register($sloganmarkword);
	$_SESSION[$sloganmarkword] = $_POST['sloganmark'.$j];
	$b = $_SESSION[$sloganmarkword];
	//echo "<script language='javascript'>alert ('$sloganmarkword $b')</script>";
	}
	
	for($c=1;$c<11;$c++){
	$devicename = "devicemark{$c}";
	$tmp_file_name = $_FILES[$devicename]['tmp_name']; 
	$file_name = $_FILES[$devicename]['name']; 
	$file_dir = './image/form/'.$_POST['title'].'/';  
	if(is_dir($file_dir)) 
	{
	move_uploaded_file($tmp_file_name,$file_dir.$file_name); 
	$img_url = $file_dir.$file_name;
	session_register($devicename);
	if($img_url!='./image/form//'){
	$_SESSION[$devicename] = $img_url;
	}
	}
	}
	
	if($multidevice>0){
	for($d=11;$d>$_SESSION['multidevice'];$d--){
	$devicename = "devicemark{$d}";
	$tmp_file_name = $_FILES[$devicename]['tmp_name']; 
	$file_name = $_FILES[$devicename]['name']; 
	$file_dir = './image/form/'.$_POST['title'].'/';  
	if(is_dir($file_dir)) 
	{
	move_uploaded_file($tmp_file_name,$file_dir.$file_name); 
	$img_url = $file_dir.$file_name;
	session_register($devicename);
	$_SESSION[$devicename] = "";
	}
	}
	}
	
	include("connect.php");
	$results = mysql_query("SELECT * FROM formclass ORDER BY CNo ASC");
	$num_results = mysql_num_rows($results);
	for($t=1;$t<=$num_results;$t++){
	$row = mysql_fetch_array($results);
	$classz = $row['classcode'];
	session_register($classz);
	$_SESSION[$classz] = $_POST[$t];
	//$ap = $_SESSION[$classz];
	//echo "<script language='javascript'>alert ('$classz $_SESSION[$classz]')</script>";
	}
	echo "<script language='javascript'>window.location='eform3.php'</script>";
}


if($_SESSION['cmembers']!= null)
{
if($totalmark=="0"){
echo "<script language='javascript'>alert ('Oops, you forget select your trademark amount.')</script>";
echo "<script language='javascript'>window.location='eforms.php'</script>";
}
$username = $_SESSION['cmembers'];
?>
<html>
<head>
<title>Cimage - E-filling</title>
<link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8"/>
<script>
	function ajaxFileUpload(upload_field)
	{
		// Checking file type
		var re_text = /\.jpg|\.gif|\.jpeg|\.png|\.JPG|\.GIF|\.JPEG|\.PNG/i;
		var filename = upload_field.value;
		if (filename.search(re_text) == -1) {
		alert("File should be either jpg or gif or jpeg");
		upload_field.form.reset();
		return false;
	}
		document.getElementById('picture_preview1').innerHTML = '<div><img src="images/progressbar.gif" border="0" /></div>';
		upload_field.form.action = 'upload-formpicture.php';
		upload_field.form.target = 'upload_iframe';
		upload_field.form.submit();
		upload_field.form.action = '';
		upload_field.form.target = '';
		return true;
	}
</script>
	
<script>
	function ajaxFileUpload2(upload_field,num)
	{
	
		// Checking file type
		var re_text = /\.jpg|\.gif|\.jpeg/i;
		var filename = upload_field.value;
		if (filename.search(re_text) == -1) {
		alert("File should be either jpg or gif or jpeg");
		upload_field.form.reset();
		return false;
	}
		var p = num;
		document.getElementById("picture_preview"+p+"").innerHTML = '<div><img src="images/progressbar.gif" border="0" /></div>';
		upload_field.form.action = 'upload-formpicturenum.php?number='+p+'';
		upload_field.form.target = 'upload_iframe';
		upload_field.form.submit();
		upload_field.form.action = '';
		upload_field.form.target = '';
		return true;
	}
	</script>
	
</head>
<body>
<iframe name="upload_iframe" id="upload_iframe" style="display:none;"></iframe>
<!-- iframe used for ajax file upload-->
<form name="form" method="POST" autocomplete="on" enctype="multipart/form-data">	
<table border="0" width="100%" align="center">
<tr>
<td width="10%"><a href="memberpage.php"><img src="image/cimagelogo.jpg" alt="Cimage" title="Cimage" border="0"></a></td>
<td align="right" valign="bottom" width="80%"><font size="2px">Welcome to Cimage. You login as <a href="memberpage.php"><b><?php echo "$username" ?></b></a>. | <a href="memberlogout.php">Logout</a></font></td></td>
<td width="10%"><br/></td>
</tr>

<tr>
<td><br/></td>
<td>
<table width="100%">
<tr>
<td><?php include("memberheader.php") ?></td>
</tr>

<tr>
<td><hr/></td>
</tr>

<tr>
<td class="headtitle">E-form panel: Please slowly go through your new trademark process here and enjoy!</td>
</tr>

<tr>
<td><br/></td>
</tr>

<tr>
<td>
<table border="0" width="100%">
<tr>
<td valign="top" align="center" width="20%">
<ul id="step">
<li id="step1"><font color="white">STEP 1</font></li>
<li id="step2"><font color="white">STEP 2</font></li>
<li>STEP 3</li>
<li>STEP 4</li>
<li>STEP 5</li>
<li>STEP 6</li>
</ul>
</td>



<td>
<fieldset>
<legend>STEP 2 - Please enter your trademark details.</legend>
<table border="0" id="t1">

<?php
if($multiword>0){
echo "<tr>";
echo "<td colspan='2'>";
echo "- for a Word Mark, enter the text (eg. TOYOTA, PROTON).";
echo "</td>";
echo "</tr>";
for($p=1;$p<=$multiword;$p++){
echo "<tr>";
echo "<td>Word Mark $p: ";
echo "</td>";
echo "<td>";
$wordname = "wordmark{$p}";
if($_SESSION[$wordname]!=null){
$wordsource = $_SESSION[$wordname];
echo "<input type='text' name='wordmark{$p}' id='wordmark{$p}' size='34' value='$wordsource'>";
}else{
echo "<input type='text' name='wordmark{$p}' id='wordmark{$p}' size='34'>";
}
echo "</td>";
echo "</tr>";
}
echo "<tr><td colspan='2'><br/></td></tr>";
}

if($multislogan>0){
echo "<tr>";
echo "<td colspan='2'>";
echo "- for a Slogan Mark, enter the text (eg. Just Do It, I'm Lovin It).";
echo "</td>";
echo "</tr>";
for($p=1;$p<=$multislogan;$p++){
echo "<tr>";
echo "<td>Slogan Mark $p: ";
echo "</td>";
echo "<td>";
$sloganname = "sloganmark{$p}";
if($_SESSION[$sloganname]!=null){
$slogansource = $_SESSION[$sloganname];
echo "<input type='text' name='sloganmark{$p}' id='sloganmark{$p}' size='34' value='$slogansource'>";
}else{
echo "<input type='text' name='sloganmark{$p}' id='sloganmark{$p}' size='34'>";
}
echo "</td>";
echo "</tr>";
}
echo "<tr><td colspan='2'><br/></td></tr>";
}

if($multidevice>1){
echo "<tr>";
echo "<td colspan='2'>";
echo "- for a Device Mark (logo), upload your file (*.jpg, *.gif format only).";
echo "</td>";
echo "</tr>";
for($p=1;$p<=$multidevice;$p++){
echo "<tr>";
echo "<td valign='top'>Logo / Device Mark $p:";
echo "</td>";
echo "<td valign='top'><input type='file' name='devicemark{$p}' id='devicemark{$p}' size='34' onchange='return ajaxFileUpload2(this,$p);'></td>";
echo "<td width='300' height='150'>";
echo "<span id='picture_error{$p}'></span>";
$devicename = "devicemark{$p}";
if($_SESSION[$devicename]!=null){
$imagesource = $_SESSION[$devicename];
echo "<div id='picture_preview{$p}'><img src='$imagesource'></div>";
}else{
echo "<div id='picture_preview{$p}'><center><b>Image of logo / devicemark{$p}<br/>will preview here.</b></center></div>";
}
echo "</td>";
echo "</tr>";
}
echo "<tr><td colspan='2'><br/></td></tr>";
}
?>

<?php
if($multidevice == 1){
echo "<tr>";
echo "<td colspan='2'>";
echo "<b>- for a Device Mark (logo), upload your file (*.jpg, *.gif format only).</b>";
echo "</td>";
echo "</tr>";
?>
<tr>
<td valign="top"><b>Logo / Device Mark</b></td>
<td valign="top"><input type="file" name="devicemark1" id="devicemark1" value="<?php echo "$devicemark1"; ?>" onchange="return ajaxFileUpload(this);">
<?php
echo "</td>";
echo "<td valign='top'>";
echo "<span id='picture_error1'></span>";
if($_SESSION['devicemark1']!=null){
$imagesource = $_SESSION['devicemark1'];
echo "<div id='picture_preview1'><img src='$imagesource'></div>";
}else{
echo "<div id='picture_preview1' maxwidth='40' maxheight='40'></div>";
}
echo "</td>";
?>
</tr>
<?php
echo "<tr><td colspan='2'><br/></td></tr>";
}
?>


</table>
</fieldset>

<br/>

<tr>
<td></td>
<td align="right">
<input type="submit" name="Previous" value="Previous" style="width:100px;font-size:15px">
<input type="submit" name="Next" value="Next" style="width:100px;font-size:15px">
</td>
</tr>

</table>
</form>
</td>
</tr>

<tr>
<td colspan="3"><hr/></td>
</tr>

<tr>
<td colspan="3">
<?php
include("footerlink.php");
?>
</td>
</tr>
</td>
<td><br/></td>
</tr>
</table>
</body>
</html>
<?php
}else{
	echo "<script language='javascript'>alert ('You cannot access this page.')</script>";
	echo "<script language='javascript'>window.location='memberindex.php'</script>";
}
?>