/*
OOOGUI - Obliquid Object Oriented Graphic User Interface

OOOGUI is a dynamic CMS that lets you define your data structure 
(objects, relations between objects, queries on objects), and lets
you create public and private HTML pages to view and modify your 
contents.  All through a WYSIWYG interface. 
OOOGUI is multilingual, manages role based permissions, and 
generates for you PHP and SMARTY code that you can customize on 
your needs.

Copyright (C) 2010 Federico Carrara (federico@obliquid.it)

For more information http://obliquid.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/




/* THINGS TO DO IMMEDIATELY */








/* THEN THINGS TO DO ON READY */


$(document).ready(
	function()
	{
		//allineamento elementi
		//centerContent();
		
		//animazioni
		
		/*
		//prima metto fuori schermo gli elementi che devono entrare
		$('h1, h2, h3, h4').parent().css('position', 'relative');
		//$('h1, h2, h3, h4').parent().css('overflow', 'toggle');
		$('h1, h2, h3, h4').css('position', 'relative');
		$('h1, h2, h3, h4').css('opacity', 0);
		$('h1, h2, h3, h4').each(function(){
			$(this).css('left', -$(this).textWidth() );
		});
		//provo anche animazioni sulle immagini
		$('figure').css('opacity', 0);
		
		
		//effetto sui link
		$("a").hover(function(){
			$(this).fadeOut(1).fadeIn(500);
		},function(){
			//do nothing
		});
		*/
		
		/*
		//sostituisco il link al dettaglio con un link al ceebox per le immagini generiche nelle liste relazionate
		ceeboxOnRelatedListLinks( [ ".prodottoDetail_immagineList_relationIdFrom4_instanceListBox",".caratteristicaDetail_immagineList_relationIdFrom15_instanceListBox" ] );
		*/
	}
);

	
	
	
//FINALLY THINGS TO DO ON LOAD (AFTER ALL IMAGES ARE LOADED)

	
$(window).load(
	function()
	{
		//ripeto allinemaneto elementi quando tutte le immagini sono state caricate
		//centerContent();

		/*
		//activate nivo slider
		$('#slider').nivoSlider({
			effect:'fade', //Specify sets like: 'fold,fade,sliceDown'
			slices:1,
			animSpeed:500, //Slide transition speed
			pauseTime:5000,
			startSlide:0, //Set starting Slide (0 index)
			directionNav:true, //Next & Prev
			directionNavHide:true, //Only show on hover
			controlNav:true, //1,2,3...
			controlNavThumbs:false, //Use thumbnails for Control Nav
			controlNavThumbsFromRel:false, //Use image rel for thumbs
			controlNavThumbsSearch: '.jpg', //Replace this with...
			controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
			keyboardNav:true, //Use left & right arrows
			pauseOnHover:true, //Stop animation while hovering
			manualAdvance:false, //Force manual transitions
			captionOpacity:0.8, //Universal caption opacity
			beforeChange: function(){},
			afterChange: function(){},
			slideshowEnd: function(){}, //Triggers after all slides have been shown
			lastSlide: function(){}, //Triggers when last slide is shown
			afterLoad: function(){} //Triggers when slider has loaded
		});
		*/
		
		
		//animazioni
		/*
		//poi inizio l'animazione di ingresso nella pagina
		$('h1').delay( 200 ).animate(
			{
				left: 0,
				opacity: 1
			}, 
			500
		);
		$('h2').delay( 400 ).animate(
			{
				left: 0,
				opacity: 1
			}, 
			500
		);
		$('h3').delay( 600 ).animate(
			{
				left: 0,
				opacity: 1
			}, 
			500
		);
		$('h4').delay( 800 ).animate(
			{
				left: 0,
				opacity: 1
			}, 
			500
		);
			
		//anche le immagini
		$('figure').delay( 1000 ).animate(
			{
				opacity: 1
			}, 
			500
		);
		*/
			
		//blinking su tutti i link
		//$('a').delay( 1000 ).fadeOut(10).fadeIn(10).fadeOut(10).fadeIn(10).fadeOut(10).fadeIn(10).fadeOut(10).fadeIn(10).fadeOut(10).fadeIn(10).fadeOut(10).fadeIn(10);
			
		/*
		$('h2').delay( 1000 ).animate
		(
			{
				left: 0,
				opacity: 1
			}, 
			1000,
			function()
			{
				$('h4').animate
				(
					{
						left: 0,
						opacity: 1
					}, 
					1000
				);
			}
		);
			
		$('h1, h2, h3, h4').each(function(){
			$(this).animate(
				{
					left: 0,
					opacity: 1
				}, 
				2000
			);
		});
		*/
		
		/*
		$('h1, h2, h3, h4').animate(
			{
				left: 0,
				opacity: 1
			}, 
			2000
		);
		*/
		
		/*
		$('h1').fadeOut(200).fadeIn(500);
		$('h2').fadeOut(200).fadeIn(500);
		$('h3').fadeOut(200).fadeIn(500);
		$('h4').fadeOut(200).fadeIn(500);
		*/
		
		//$('h5').delay( 1800 ).fadeOut(300).fadeIn(300);
		//$('h6').delay( 2200 ).fadeOut(200).fadeIn(200);
	}
);
	
function centerContent()
{
	//allineo tutto, solo se non sono su IE
	if ( !window.aaaargh )
	{
		$('body > div').centerXY(); 
		$('body > div').centerXY();
		$('.vAlignMiddle').vAlignMiddle();
		$('.vAlignBottom').vAlignBottom();
	}
	
}

function ceeboxOnRelatedListLinks( genericImagesRelated )
{
	for ( var i in genericImagesRelated )
	{
		if ( $(genericImagesRelated[i]).length !== 0 )
		{
			// leggo l'url dell'<img> contenuto nell'<a> in questione
			imgUrl = $(genericImagesRelated[i]+' img').attr('src');
			// sostituisco le misure
			imgUrl = replaceQueryString(imgUrl,'width','');
			imgUrl = replaceQueryString(imgUrl,'height','');
			imgUrl = replaceQueryString(imgUrl,'widthheight','1000');
			imgUrl = imgUrl+'&allowZoom=no';
			// tutto questo url lo piazzo come href dell' <a>
			$(genericImagesRelated[i]).attr('href',imgUrl);			
			// aggiungo la property "rel='image'"
			$(genericImagesRelated[i]).attr('rel','image');			
			// aggiungo la classe css "popupImage"
			//$(genericImagesRelated[i]).addClass('popupImage');
			$(genericImagesRelated[i]).addClass('popupImageAddedAfter');
		}
		
	}
	//alla fine ri-attivo il ceebox
	$(".popupImageAddedAfter").ceebox({titles:false,margin:"20",padding:"10"});
	
}



