﻿/*
 * jQuery Cartiera giorgionee -> MainClass
 *
 * Copyright 2011, Marco Poglie
 * THINKPLACE scripts.
 * http://www.thinkplace.it
 * http://www.poglie.com
 * 
 */

(function($) {
	$(function() {
		var giorgione = function(element, options){
			/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
			//															OBJECT settings
			////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
			//Defaults are below
			var settings = $.extend({}, $.fn.giorgione.defaults, options);
	
			
			
			
			/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
			//															  INIT-VAR
			////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
			var _element = $(element); // l'oggetto selezionato
			
			var figli = _element.children();
			var lunghezzaElement = figli.length;
			
			// --------[OGGETTI]--------
			var header = $('#header');
			var content = $('#content');
			var footer = $('#footer');
			
			var bgFoto = $('#bg-foto');
			
			var bgPage = $('#bg-page');
			
			
			
			////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
			//															    INIT
			////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
			// 
			var init = function(setting){
				
				
				
				
				
				
				// ------------------------------------------------------- HEADER ------------------------------------------------------------------
				//
				// CallBack
				var funEntrato = function(){
					if($("#imm")) $("#imm").fadeOut(700, function() {});
					//
					//Trigger the afterLoad callback
					settings.afterLoad.call(this);
				}
				var funUscito = function(){
					
				}
				var clickBut = function(i, old_i){
					//window.alert(i);
					bgFoto.fadeOut(700);
					if(content && content.data('vars') && content.data('vars').nascondi) content.data('vars').nascondi(0, function(){
																											});
				}
				var clickQuit = function(i){
					//
					bgFoto.fadeIn(700);
					if(content && content.data('vars').mostra) content.data('vars').mostra(1000, function(){});
				}
				// Setting
				var objHead = {
									colorTx:'#009036',
									colorTxBg:'#FFFFFF',
									colorHover:'#222',
									colorBgSelect:'#009036',
									colorTcSelect:'#FFF',
										
									delay:1000,
									//
									altezzaChiuso: 200,
									altezzaAperto: 200,
									  //
									clickBut:clickBut,
									clickQuit:clickQuit,
									 // 
									aperto:funEntrato,
									chiuso:funUscito,
									//
									otherSelector:'#bg-page'
								};
				
				/***************************************/				
				// Costructor
				header.menuBarrHead(objHead);
				/***************************************/
				
				
				
				
				// ------------------------------------------------------- PANEL ------------------------------------------------------------------
				//
				// CallBack
				var initPanel = function(){
					accendiScala();
				}
				var clickBut = function(i, old_i){
					//window.alert(i);
					//
					bgFoto.fadeOut(700);
				}
				var clickQuit = function(i){
					//
					bgFoto.fadeIn(700);
					header.data('vars').mostra(1000);
				}
				var fuoriWindow = function(){
					header.data('vars').nascondi();	
				}
				var dentroWindow = function(){
					header.data('vars').mostra();	
				}
				// Setting
				var objPanel = {
									delay:1000,
									Hfoot: footer.outerHeight(true)-1,
									Hhead: 140,
									//
									staccoPanelHead:50,
									//
									onInit:initPanel,
									onFuoriWindow:fuoriWindow,
									onDentroWindow:dentroWindow,
									//
									altezzaChiuso:120,
									altezzaAperto:600,
									clickBut:clickBut,
									clickQuit:clickQuit,
									//
									colorTx:'#000000',
									colorTxBg:'#FFFFFF',
									colorHover:'#f8cc43',
									//
									otherSelector:''
									
									
								};
				/***************************************/
				// Costructor
				content.panelDown(objPanel);
				/***************************************/
				
				
				
				
				// ------------------------------------------------------- PIEDINO ------------------------------------------------------------------
				//
				// Setting
				var objFoot = {
								 	delay:200,
									altezza:60
								};
								
				/***************************************/
				// Costructor
				footer.barrFoot(objFoot);
				/***************************************/
				
				
				
				
				
				
				//
				// ------------------------------------------------------- BG-Foto ------------------------------------------------------------------
				//
				// Setting
				var objBG = { 
									delay:2500,
									slideshowSpeed: 6000,
									photos: [ {
														"title" : "Cartiera Giorgione",
														"image" : "sfondi/azienda.jpg",
														"url" : "images/sfondi",
														"firstline" : "Cartiera Giorgione",
														"secondline" : "Cartiera Giorgione"
													}, {
														"title" : "Cartiera Giorgione",
														"image" : "sfondi/mani.jpg",
														"url" : "images/sfondi",
														"firstline" : "Cartiera Giorgione",
														"secondline" : "Cartiera Giorgione"
													}, {
														"title" : "Cartiera Giorgione",
														"image" : "sfondi/rotoli.jpg",
														"url" : "images/sfondi",
														"firstline" : "Cartiera Giorgione",
														"secondline" : "Cartiera Giorgione"
													}, {
														"title" : "Cartiera Giorgione",
														"image" : "sfondi/ambiente3.jpg",
														"url" : "images/sfondi",
														"firstline" : "Cartiera Giorgione",
														"secondline" : "Cartiera Giorgione"
													}, {
														"title" : "Cartiera Giorgione",
														"image" : "sfondi/qualita2.jpg",
														"url" : "images/sfondi",
														"firstline" : "Cartiera Giorgione",
														"secondline" : "Cartiera Giorgione"
													}
												] 
					}
				
				/***************************************/
				// Costructor
				bgFoto.bgSliding(objBG);
				/***************************************/
				
				// Plugin ...
				//$('#background-foto').css({'display':'none'});
				//$('#background-foto').delay(400).fadeIn( 'slow');
																	
				/*$('#background-foto').crossSlide({
				  sleep: 2,
				  fade: 1
				  
				}, 	[
					  { src: 'images/f01.jpg' },
					  { src: 'images/f02.jpg' }
				  
					])*/
				
				
				/*var FullscreenrOptions = {  width: 1024, height: 768, bgID: '#background-foto' };
				jQuery.fn.fullscreenr(FullscreenrOptions);*/
	
	
				// ----------------------------------------------------------------------------------------------------------------------------------
				//window.alert('giorgione');
				
				scala();
			}
			
			////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
			//															RESIZING
			////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
			//
			var scala  = function(){
				
				if(content)	{
					content.data('vars').scala();	
					
				}
				if($('#map')){
					$('#map').width($(window).width());
					$('#map').height($(window).height());
				}
				
			}
			var accendiScala = function (){
					$(window).bind('resize', scala);
			}
			var spegniScala = function (){
					$(window).unbind('resize');
			}
			
			
			/*********************************************************[ PUBBLIC Data.vars ]**********************************************/
			var vars = {
				// vuoto ...
				
			};
			//_element.data('vars',vars)
			/***********************************************************************************************************************/
			
			
			////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
			//															GOOOOOOO
			////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
			//
			init(settings);
			
			
			// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
			return this;
		};
			
		$.fn.giorgione = function(options) {
		
			return this.each(function(key, value){
				var element = $(this);
				
				// Rientro anticipato dell'attrubuto se questo elemento ha già un plugin istanza
				if (element.data('giorgione')) return element.data('giorgione');
				
				// COSTRUTTORE: -----------------------------
				var giorgionews = new giorgione(this, options);
				// ------------------------------------------
				
				// memorizzo il l'istanza in data
				element.data('giorgione', giorgionews);
			});
	
		};
		
		//Default settings
		$.fn.giorgione.defaults = {
			delay: 0,
			
			afterLoad: function(){}
		};
		
		
	}); // end load js
})(jQuery);
