<?php
//error_reporting(E_ERROR|E_WARNING);
    /**
    Configuration options:
    zoomType='standard'
    The others admitted option values are 'reverse','drag','innerzoom'.

    zoomWidth=300
    The popup window width showing the zoomed area.

    zoomHeight=300   
    The popup window height showing the zoomed area.

    xOffset=10
    The popup window x offset from the small image. (always positive to move the popup window more on the right if position is "right" or more on the left if position is "left")

    yOffset=0
    The popup window y offset from the small image. (always positive to move the popup window more on the top if position is "top" or more on the bottom if position is "bottom"),

    position='right'
    The popup window position.Admitted values:'right' ,'left' ,'top' ,'bottom'

    preloadImages=true
    if set to true,jqzoom will preload large images.

    preloadText='Loading zoom'
    The text to show while preloading images.

    title=true
    Show a small title over the zoomed window it can be the anchor title and if not specified,it will get the small image title.

    lens=true
    if set to false,the small lens,over the image, won't show.

    imageOpacity=0.4   
    Set the image opacity when the 'zoomType' option is set to 'reverse'.

    showEffect='show'    
    The effect by which showing the popup window.Options available: 'show' ,'fadein'.

    hideEffect='hide'    
    The effect by which hiding the popup window.Options available: 'hide' ,'fadeout'.

    fadeinSpeed='slow'    
    Changes fade in speed,in case the showEffect option is set to 'fadein'.(options: 'fast','slow',number)

    fadeoutSpeed='2000'    
    Changes fade out speed,in case the hideEffect option is set to 'fadeout'.(options: 'fast','slow',number)
    */
    $g=&$GLOBALS;
    $g[HEADER]->addscriptfile(AM_PLUGIN_URL.'/jquery/js/jquery-1.6.1.min.js');
    $g[HEADER]->addscriptfile(AM_PLUGIN_URL.'/jquery/js/jquery-ui-1.8.13.custom.min.js');  
    $g[HEADER]->addscriptfile(AM_PLUGIN_URL.'/jqzoom/js/jquery.jqzoom-core.js');

    $g[HEADER]->addstylesheet(AM_PLUGIN_URL.'/jquery/css/ui-lightness/jquery-ui-1.8.13.custom.css');  
    $g[HEADER]->addstylesheet(AM_PLUGIN_URL.'/jqzoom/css/jquery.jqzoom.css'); 
    function am_jqzoom($smallImageUrl,$bigImageUrl,$options="{zoomType: 'standard'}",$title='',$class='MYCLASS')
    {
        $g=&$GLOBALS;
        $g[HEADER]->addfunction('am_jqzoomImage',"
        \$(document).ready(function(){
        $('.$class').jqzoom($options); 
        });
        ");
        $title=str_replace('"','&quot;',$title);
        $out="
        <div class='am_jqzoom_mainDv'>
        <a href=\"$bigImageUrl\" class=\"$class\" title=\"$title\">  
        <img src=\"$smallImageUrl\" title=\"$title\">  
        </a>  
        </div>
        ";
        return($out);
    }

    function am_jqzoomWithThumbs($galId,$galleryArr=array(array('smallimage'=>'','largeimage'=>'')),$options="{zoomType: 'standard'}",$title='',$class='MYCLASS')
    {
        $g=&$GLOBALS;
        $g[HEADER]->addfunction('am_jqzoomImage',"
        \$(document).ready(function(){
        $('.$class').jqzoom($options); 
        });
        ");
        $title=str_replace('"','&quot;',$title);
        $out="
        <div class='am_jqzoom_mainDv'>
        <a rel='gal$galId' href=\"{$galleryArr[0]['bigImage']}\" class=\"$class\" title=\"$title\">  
        <img src=\"{$galleryArr[0]['smallImage']}\" title=\"$title\">  
        </a>  
        </div>
        <br/>
        <div id='am_jqzoom_gal$galId' class='am_jqzoom_thumbDv'>
        <ul class=\"am_jqzoom_thumblist\">
        ";
        foreach($galleryArr as $k=>$galItem){
            if($k==0){
                $acClass=' class="zoomThumbActive" ';
            }
            else{        
                $acClass='';                        
            }
            $out.="
            <li><a $acClass href='javascript:void(0);' rel=\"{gallery: 'gal$galId', smallimage: '$galItem[smallImage]',largeimage: '$galItem[bigImage]' }\"><img src='$galItem[thumbImage]' /></a></li>           
            ";
        }
        $out.="
        </ul>
        <div style=\"clear:both;width:1px;height:1px;\"></div>
        </div>
        ";
        return($out);
    }

    class test
    {
        function test()  
        {

        }
        function index()
        {
            $g=&$GLOBALS;
            echo '<h1>Single image zoom</h1><hr />';
            echo am_jqzoom(
                $g[AM_SITE][hosturl].'/member_images/204x153thumbnail_12_Photo-0001.jpg',
                $g[AM_SITE][hosturl].'/member_images/12_Photo-0001.jpg',                
                "{zoomType:'innerzoom',title:false}",
                'Test Image'                
            );
           
            
            $gallery[]=array(
              'smallImage'=>"http://amcs/socialbu/member_images/204x153thumbnail_100_1731.JPG",
              'bigImage'=>"http://amcs/socialbu/member_images/100_1731.JPG",
              'thumbImage'=>"http://amcs/socialbu/member_images/102x76thumbnail_100_1731.JPG",
            );
            $gallery[]=array(
              'smallImage'=>"http://amcs/socialbu/member_images/204x153thumbnail_100_1726.JPG",
              'bigImage'=>"http://amcs/socialbu/member_images/100_1726.JPG",
              'thumbImage'=>"http://amcs/socialbu/member_images/102x76thumbnail_100_1726.JPG",
            );
            $gallery[]=array(
              'smallImage'=>"http://amcs/socialbu/member_images/204x153thumbnail_12_Photo-0001.jpg",
              'bigImage'=>"http://amcs/socialbu/member_images/12_Photo-0001.jpg",
              'thumbImage'=>"http://amcs/socialbu/member_images/102x76thumbnail_12_Photo-0001.jpg",
            );
            
           /* foreach($gallery as $item)
            {
                echo "<img src='$item[smallImage]' />";
                echo "<img src='$item[bigImage]' />";
                echo "<img src='$item[thumbImage]' />";
                echo "<hr/>";
            }*/
           echo '<h1>Gallery image zoom</h1><hr />';
           echo am_jqzoomWithThumbs(1,$gallery);
        }    
    }


