<script type="text/javascript">
<?php $pageurl_add ="index.php?module=productphotogallery&action=add&swf=swf"; ?>
function uploadimage()
{
        if(document.getElementById("album").value == "")
	{ 
            alert("Please Select Album");
            document.getElementById("album").focus();
            return false;
	}
        if(document.getElementById("file1").value == "")
	{ 
            alert("Please Select Image");
            document.getElementById("file1").focus();
            return false;
	}
        if(document.getElementById('file1').value != "")
          {
           if(!LimitAttach(document.getElementById('file1').value ))
            {
                alert("Only .bmp, .gif, .jpg, .png Image Formats are supported.");
                document.getElementById('file1').focus();
                return false;
            }
         }

        document.getElementById('h_save').value ='T';
        document.uploadphoto.submit();
  return true;
}

function LimitAttach(file,id)
    {
       allowSubmit = false;
        if (!file) return false;

	var extArray = new Array(".jpg",".jpeg",".png",".bmp",".gif");

        while (file.indexOf("\\") != -1)
            file = file.slice(file.indexOf("\\") + 1);
        ext = file.slice(file.indexOf(".")).toLowerCase();
        for (var i = 0; i < extArray.length; i++) {
            if (extArray[i] == ext) { allowSubmit = true; break; }
        }
        if (allowSubmit) return true;
        else
        return false;
    }
</script>
<script type="text/javascript">
function showhideflashhtml(id)
{
    if(id == 1)
    {
        document.getElementById('tblhtml').style.display = '';
        document.getElementById('tblflash').style.display = 'none';
        document.getElementById('upfile').style.display = 'none';
        document.getElementById('upfiles').style.display = '';
        
    }
    else if(id == 2)
    {
        document.getElementById('tblhtml').style.display = 'none';
        document.getElementById('tblflash').style.display = '';
        document.getElementById('upfile').style.display = '';
        document.getElementById('upfiles').style.display = 'none';
    }
}
var swfu;

SWFUpload.onload = function ()
{
	var  settings =
                {
		flash_url : "modules/productphotogallery/html/js/swfupload.swf",
		upload_url: "<?php echo $pageurl_add;?>",
		post_params: {
			"PHPSESSID" : "<?=session_id();?>",
			"groupid" : "<?=$configObj->glSessionObj->value('group_id');?>",
			"HELLO-WORLD" : "Here I Am",
			".what" : "OKAY"
		},
		file_size_limit : "100 MB",
		file_types : "*.*",
		file_types_description : "All Files",
		file_upload_limit : 100,
		file_queue_limit : 0,
		custom_settings : {
			progressTarget : "fsUploadProgress",
			cancelButtonId : "btnCancel",
			modulecode : "<?=$productphotogalleryObj->modulecode?>",
			moduleglcode : "<?=$productphotogalleryObj->moduleglcode?>"
		},
		debug: true,

		// Button Settings
		button_image_url : "html/images/browse-to-upload.jpg",
		button_placeholder_id : "spanButtonPlaceholder",
		button_width: 150,
		button_height: 23,

		swfupload_loaded_handler : swfUploadLoaded,
		file_queued_handler : fileQueued,
		file_queue_error_handler : fileQueueError,
		upload_progress_handler : uploadProgress,
		upload_success_handler : uploadSuccess,
		upload_complete_handler : uploadComplete,

		minimum_flash_version : "9.0.28",
		swfupload_load_failed_handler : swfUploadLoadFailed
	};
	swfu = new SWFUpload(settings);
}

function uploadfile()
{
    
   if(document.getElementById("album-multi").value == "")
	{ 
            alert("Please Select Album");
            document.getElementById("album").focus();
            return false;
	}
    
    swfu.addPostParam('chr_defaultimage','N');
    swfu.addPostParam('chr_publish','Y');
    swfu.addPostParam('h_save','T');
    swfu.addPostParam('album',document.getElementById("album-multi").value);
    swfu.startUpload();
    return true;
}

</script>
<?php  
$pageurl ="index.php?module=productphotogallery";
//echo "<pre>";
//print_r($albumArr);
?>
<div class="breadcrumbs"><a href="index.php">Home</a>&nbsp;>&nbsp;  <a href="index.php?module=productphotogallery">Photo Gallery </a>&nbsp;>&nbsp;<a href="index.php?module=productphotogallery">Manage Photo Gallery</a>&nbsp;>&nbsp;<span class="current">Add Photos</span>  </div>
<div class="add-new-user-title">
<h2><img src="<?=GLOBAL_ADMIN_IMAGES_PATH?>/add-new-user-icon.png">Add Photos</h2></div>
<div class="web-booking-main">
<div class="grid-list-subtitle-bg" style="margin-top:10px; cursor:pointer" onClick="javascript:expandcollapsepanel('asignbannerdisplay');" >
<input type="hidden" name="int_displayorder" id="int_displayorder" value="1">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
            <td align="left" valign="top" class="grid-td-left" >Photo Uploading</td>
            </tr>
            </table>
            </div>
            <div class="information-white-bg" id="asignbanner">
            <div id="asignbannerdisplay">
            <table width="100%" cellspacing="0" cellpadding="0" border="0">
                <input type="hidden" id="h_save" name="h_save" value="T" />
                
                <tr>
                <td width="100%">
                    <table width="100%" cellpadding="0" cellspacing="0" border="0">
                <tr>
                <td>&nbsp;</td>
                </tr>
                <td valign="top" align="center">
               <tr><td colspan="2">
               <table width="100%" border="0" cellpadding="0" cellspacing="8" id="tblhtml" style="display:none" >
               <form action="index.php?module=productphotogallery&view=productphotogallery&action=add" method="post" name="uploadphoto" id="uploadphoto" enctype="multipart/form-data" onSubmit="return uploadimage();" >
	               <input type="hidden" name="int_displayorder" id="int_displayorder" value="1">
                   <input type="hidden" id="h_save" name="h_save" value="T" />
                   <input type="hidden" name="hidchr_publish" id="hidchr_publish" value="">
                   <input type="hidden" name="chr_default" id="chr_default" value="">
                  
                   <tr>
                       <td>
                           Select Photo Album
                       </td> 
                       <td>
                           <select name="album" id="album">
                               <option value="">--Select Album--</option> 
                           <?php 
                                if(!empty($albumArr)){    
                                  foreach($albumArr as $album){
                           ?>
                                      <option value="<?php echo $album['int_glcode']; ?>"><?php echo $album['var_title']; ?></option>
                           <?php
                                  }
                                }
                            ?>
                           </select>           
                       </td>
                   </tr>
                 
                 <tr>
                   <td class="add-new-user-text" align="left" colspan="2"><u>Select Photo to upload :</u></td>
                   </tr>
                       <tr>
                           <td class="add-new-user-text" align="left" width="244">Image : <span style="color:#1979AC;">(Require)</span></td>
                        <td align="left" valign="top"  class="add-new-user-text">
                        <input name="Filedata" id="file1" type="file"/> <div style="color:#1979AC; font-family:verdana; ">(Width * Height)=<?php echo'('.PHOTOGALLERY_THUMB_WIDTH.'px ' ?>  x  <?php echo ''.PHOTOGALLERY_THUMB_HEIGHT.'px'.')' ?></div>
                            <table>
                                <tr>
                                    <td>
                                        <div style="color:#1979AC; font-family:verdana; ">(Only .bmp, .gif, .jpg, .png Image Formats are supported.)</div>
                                    </td>
                                </tr>
                            </table>
                        </td>
                        </tr>
                        <tr>
                        <td colspan="2" align="left">
                            <span class="add-new-user-text" style="color: red">
                        For Multi-File upload <a href="#" onclick="showhideflashhtml('2');">Click Here</a>
                      </span>
                    </td>
                 </tr>
               </form>
             </table>
            <table width="100%" border="0" cellpadding="2" cellspacing="3" id="tblflash" >
              <form action="index.php?module=productphotogallery&view=productphotogallery&action=add" method="post" name="form1" id="form1" enctype="multipart/form-data" onSubmit="return uploadfile();">
               <input type="hidden" name="int_displayorder" id="int_displayorder" value="1">
                   <input type="hidden" id="h_save" name="h_save" value="T" />
                   <input type="hidden" name="hidchr_publish" id="hidchr_publish" value="">
                   <input type="hidden" name="chr_default" id="chr_default" value="">
                    
                  <tr>
                  <td class="add-new-user-text" align="left" width="270"></td>
                    <td align="left" valign="top"></td>
                     </tr>
                     
                     <tr>
                       <td>
                           Select Photo Album
                       </td> 
                       <td>
                           <select name="album" id="album-multi">
                               <option value="">--Select Album--</option> 
                           <?php 
                                if(!empty($albumArr)){    
                                  foreach($albumArr as $album){
                           ?>
                                      <option value="<?php echo $album['int_glcode']; ?>"><?php echo $album['var_title']; ?></option>
                           <?php
                                  }
                                }
                            ?>
                           </select>           
                       </td>
                   </tr>
                     
                     
                        <tr>
                            <td align="left" width="270" class="add-new-user-text"><B>Select photos to upload :</B></td>
                            <td>
                            <p>
                                <span class="add-new-user-text" id="spanButtonPlaceholder"></span><span style="color:#1979AC; font-family:verdana;"> [Only .bmp, .gif, .jpg, .jpeg, .png Image Formats are supported.]</span>
                            <br/>
                            </p>
                            <div id="divSWFUploadUI">
                            <div class="fieldset  flash" id="fsUploadProgress">
                        <span class="legend">Upload Queue</span>
                        </div>
                        <p id="divStatus" class="form_titles" style="display:none;">0 Files Uploaded</p>
                        </div>
                        </td>
                        </tr>
                        <tr>
                       <td colspan="2" id="trfinalvisible" style="display:none;" align="left">
                        <span class="add-new-user-text">
                        Add/Edit Caption Of uploaded Image OR To Crop Image.
                        <a href="index.php?module=productphotogallery">
                        Browse PhotoList.
                    </a>
                  </span>
                 </td>
            </tr>
            <tr>
            <td colspan="2" align="left">
            <span class="add-new-user-text" style="color:#FF0000">
            If you have problems with Multi-File uploader, Try single file uploader instead.
            <a href="#" onclick="showhideflashhtml('1');" class="phototext">Click Here</a>
            </span>
            </td>
            </tr>
            <tr>
            <td align="left">
            <noscript>
            <div style="background-color: #FFFF66; border-top: solid 4px #FF9966; border-bottom: solid 4px #FF9966; margin: 10px 25px; padding: 10px 15px;">
            We're sorry.  SWFUpload could not load.  You must have JavaScript enabled to enjoy SWFUpload.
            </div>
            </noscript>
            <div id="divLoadingContent" class="content" style="background-color: #FFFF66; border-top: solid 4px #FF9966; border-bottom: solid 4px #FF9966; margin: 10px 25px; padding: 10px 15px; display: none;">
            SWFUpload is loading. Please wait a moment...
            </div>
            <div id="divLongLoading" class="content" style="background-color: #FFFF66; border-top: solid 4px #FF9966; border-bottom: solid 4px #FF9966; margin: 10px 25px; padding: 10px 15px; display: none;">
            SWFUpload is taking a long time to load or the load has failed.  Please make sure that the Flash Plugin is enabled and that a working version of the Adobe Flash Player is installed.
            </div>
            <div id="divAlternateContent" class="content" style="background-color: #FFFF66; border-top: solid 4px #FF9966; border-bottom: solid 4px #FF9966; margin: 10px 25px; padding: 10px 15px; display: none;">
            We're sorry.  SWFUpload could not load.  You may need to install or upgrade Flash Player.
            Visit the <a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash">Adobe website</a> to get the Flash Player.
            </div>
            </td>
         </tr>
	</form>
	</table>
    </td>
    </tr>
              <tr>
        </table>
        <div class="clear"></div>
           <div class="add-new-user-button" style="padding-bottom: 30px;">
          <input border="0" type="image" hspace="5" height="25" width="108" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('btnsaveande','','html/images//save-exit-button-hover.jpg',1)" src="html/images//save-exit-button.jpg" alt="save-exit" name="upfile" id="upfile" value="1"  onclick="uploadfile();">
          <input border="0" type="image" hspace="5" height="25" width="108" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('btnsaveande','','html/images//save-exit-button-hover.jpg',1)" src="html/images//save-exit-button.jpg" alt="save-exit" name="upfiles" id="upfiles" value="2"  onclick="javascript: uploadimage(); return false;" style="display: none;">
        <input border="0" type="image" hspace="5" height="25" width="81" src="html/images//cancel-button.jpg" alt="cancel" name="Image35" id="Image35" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image35','','html/images//cancel-button-hover.jpg',1)" onclick="javascript:location.href='<?=$productphotogalleryObj->urlwithpara?>'; return false;" />
       </div>
     </table>
    </div>
  </div>
</div>
