var show = function(settings){
    
	this.settings = jQuery.extend({
                
    },settings); 
	   
    /*-------------------------------------------------------------------------------------------
    ---------------------------------------------------------------------------------------------
    ----------------------------------------------------------------------------- SHOW SYSTEM PARAMS */
    
    this.languageSelect = function(extra){
        new call({
            url : PH_R+'system/j-system-language-select.php',
			applicationName : 'system',
			applicationSubName : 'language',
            dialog : {width:200, modal:true}
            },extra);    
    }
	
	this.countrySelect = function(extra){                     
        new call({
            url : PH_R+'system/j-system-country-select.php',
			applicationName : 'system',
			applicationSubName : 'location',
            dialog : {width:700, modal:true}
            },extra);
	}
    
    
    /*-------------------------------------------------------------------------------------------
    ---------------------------------------------------------------------------------------------
    ----------------------------------------------------------------------------- LOGIN */
    
    this.login = function(extra){
        
        extra = jQuery.extend({ 
           
           obj : 'user',
           action : 'login-open-form'
            
        },extra);
        
        core.user.action(extra,{
                            applicationName : 'user-login',
                            applicationSubName : 'login',
                            responseView : true,     
                            waitLoading : false,
                            myDialog : { action: 'open', app: 'login' }
                            });
        
    }
    
    
    /*-------------------------------------------------------------------------------------------
    ---------------------------------------------------------------------------------------------
    ----------------------------------------------------------------------------- MODULE */
    
    
    
    this.module = function(selector,extra,settings){
        if (selector){
            var dialogParams = false;  
        }
        else{
            var dialogParams = { modal: true, width: 800 }; 
        }
        
        extra = jQuery.extend({  
            
            module_name : 'module-undefined',
            module_title : 'no title'
            
        },extra);
        
        settings = jQuery.extend({  
            
            url : PH_R+'module/j-'+extra.module_name+'.php',
            applicationName : 'module',
            applicationSubName : extra.module_name,
            responseElement : selector,
            multiOpen : true,
            tasked : true,
            dialog : dialogParams
            
        },settings);
        
        //extra = jQuery.extend({ module_name : 'error-nofind', module_title: 'no title' },extra_plus);
                             
        /*
        new call({
            url : PH_R+'module/j-module-'+extra.module_name+'.php',
            applicationName : 'module',
            applicationSubName : extra.module_name,
            responseElement : selector,
            multiOpen : true,
            tasked : true,
            module : extra.module,
            dialog : dialogParams
            },extra);
        */
        
        new call(settings,extra);
            
    }
    
    this.mediaDetails = function(selector,extra,settings){
        
        if (selector){
            var dialogParams = false;  
        }
        else{
            var dialogParams = { modal: true, width: 800 }; 
        }
        
        extra = jQuery.extend({ },extra);
        
        settings = jQuery.extend({ 
           
           url : PH_R+'details/j-details-media.php',
           applicationName : 'system',
           applicationSubName : 'location',
           responseElement : selector,
           multiOpen : true,
           tasked : false,
           dialog : dialogParams 
            
        },settings);
                             
        new call(settings,extra);
            
    }
    
    /*-------------------------------------------------------------------------------------------
    ---------------------------------------------------------------------------------------------
    ----------------------------------------------------------------------------- IMAGES ROTATOR */
    
    var imagesRotator_Data = false;
    var imagesRotator_Current = false;
    var imagesRotator_Max = false;
    var imagesRotator_El = false;
    var imagesRotator_Data_Cache = new Array();
    
    this.imagesRotator = function(el){
    
        var num = $(el).attr("num");
        var mediagrp_id = $(el).attr("adv_id");
        var media_id = $(el).attr("advfile_id");
        imagesRotator_El = el;
        
        // controlla se è in cache
        
        if(imagesRotator_Data_Cache[mediagrp_id]){
        
            var data = imagesRotator_Data_Cache[mediagrp_id];
        
            if(data.length > 0){
                            
                imagesRotator_Data = data;
                imagesRotator_Current = num;
                imagesRotator_Max = data.length;
                core.show.imagesRotator_Start();
                
                return true;
                                
            }
                            
            
        }
                
        $.ajax({
                    url : PH_R+'accessories/get-images-json.php',
                    type : 'POST',
                    data : { num : num , adv_id : mediagrp_id , advfile_id : media_id },
                    mode : 'abort',
                    dataType : 'json',
                    beforeSend : function(){
                        
                    },
                    success : function(data){
                        //console.log(data);
                        
                        
                        
                        imagesRotator_Data_Cache[mediagrp_id] = data;
                        
                        if(data){
                            if(data.length > 0){
                            
                                imagesRotator_Data = data;
                                imagesRotator_Current = num;
                                imagesRotator_Max = data.length;
                                core.show.imagesRotator_Start();
                                
                            }
                        }
                        
                    }
        });
        
    
    }
    
    this.imagesRotator_Start = function(){
        
        var data_i = 0;
        
        if(imagesRotator_Current == 1){
           $(imagesRotator_El).attr("src",imagesRotator_Data[0]);
           imagesRotator_Current++;
           core.show.imagesRotator_Start(); 
        }
        
        $(imagesRotator_El).animate({left : '0px'},800,function(){
            
            if(imagesRotator_Current > imagesRotator_Max){ 
                imagesRotator_Current = 1;
            }
            
            data_i = imagesRotator_Current - 1;
            $(imagesRotator_El).attr("src",imagesRotator_Data[data_i]);
            
            imagesRotator_Current++;
            core.show.imagesRotator_Start();
            
        });    
        
    }
    
    /* START IMAGE ROTATOR */
    
    $('.images-rotator').live('mouseover mousein mouseenter mouseout mouseleave',function(event){
        
                    
        if(event.type == 'mouseover' || event.type == 'mousein' || event.type == 'mouseenter'){
            $('.images-rotator').stop();
            core.show.imagesRotator(this);
        }
        
        if(event.type == 'mouseout' || event.type == 'mouseleave'){
            $('.images-rotator').stop();
            $(this).attr('src',$(this).attr("src_start"));            
        }
        
    
    });
    
    /*-------------------------------------------------------------------------------------------
    ---------------------------------------------------------------------------------------------
    ----------------------------------------------------------------------------- FINE IMAGES ROTATOR */
    
    this.keywords = function(selector,extra,settings){
        
        if (selector){
            var dialogParams = false;  
        }
        else{
            var dialogParams = { modal: true, width: 800 }; 
        }
        
        extra = jQuery.extend({ },extra);
        
        settings = jQuery.extend({ 
           
           url : PH_R+'list/j-list-keywords.php',
           applicationName : 'system',
           applicationSubName : 'location',
           responseElement : selector,
           multiOpen : false,
           tasked : true,
           dialog : dialogParams 
            
        },settings);
                             
        new call(settings,extra);
            
    }
    
    this.chart = function(selector,extra,settings){
    
        
        if (selector){
            var dialogParams = false;  
        }
        else{
            var dialogParams = { modal: true, width: 800 }; 
        }
        
        extra = jQuery.extend({ },extra);
        
        settings = jQuery.extend({ 
           
           url : PH_R+'chart/j-show-chart.php',
           applicationName : 'system',
           applicationSubName : 'chart',
           responseElement : selector,
           multiOpen : true,
           tasked : false,
           dialog : dialogParams 
            
        },settings);
                             
        new call(settings,extra);
        
    
    }
    
    
    
}
