/**
 * @projectname     Zuza Hand Made
 * @version         0.0.2 2010.07.14
 * @copyright       Copyright (C) 2008 - 2010 All rights reserved.
 * @license         Comertial
 * @author          Székely Csaba / csaba@szekely.ro / http://www.csaba.szekely.ro
 * 
 * @desc            Script file for photo galery
 */


// displaying big image
function handleClick(clickTipe, param1, param2, param3, param4){
    // document root form hidden input
    var document_root = jQuery('#document_root').val();
    // setting ajax link to load    
    ajax_link = clickTipe == 'bigImage' ? document_root + '/modules/gallery/galleryHandler.php' + '?action=loadBig&img_id='+ param1 +'&gallery_id=' + param2 +'&limit=' + param3 +'&tumbonpage=' + param4 : document_root + '/modules/gallery/galleryHandler.php' + '?action=loadTumbnail&limit='+ param1 +'&gallery_id=' + param2 +'&tumbonpage=' + param3 ;
    // show ajax loading gif
    jQuery('.gallery_objects_container').html('<div class="img_loading_box"><img src="'+ document_root +'/templates/standard/img/ajax-loader-medium-transp.gif" alt="loading..." title="loading" /></div>');
    // calling ajax for big image
    jQuery.ajax({ 
        type: 'GET',
        url: ajax_link, 
        dataType: 'xml',
        // on succes handling returned data
        success: function(php_response) {    
            // setting returned values from db
            var resp_value          = jQuery(php_response).find('response value').text();
            // displaying error message 
            jQuery('.gallery_objects_container').html(resp_value);

            //get the top offset of the target anchor
            var target_offset   = jQuery("#gallery_title_line").offset();
            var target_top      = target_offset.top;

            //goto that anchor by setting the body scroll top to anchor top
            jQuery('html, body').animate({scrollTop:target_top}, 200);
            
        }, // end success
        // handling error on ajax call
        error: function(xhr, textStatus, errorThrown) {
            alert('An error occurred! ' + errorThrown  + '\n ' + xhr ) ;
        } // end error handling
    }); // end ajax     
}; //end function 
