// JavaScript Document
var inAction = false;
var oldBrow = null;
//var inElement = false;
var everypage = {
	
	
	
	
	
	
	init : function()
	{
		
		if( jQuery.browser.msie)
		{
			if( parseInt( jQuery.browser.version ) < 8 )
			{
				oldBrow = true;	
			}
		}
		
		jQuery('.page-search .inputcontainer .textinput').example('cerca');
		
		//jQuery('#confermaregistrazione').colorbox({html:'<p style="font-size:16px;font-family:Arial;">Registrazione avvenuta correttamente</p>',open:true});
		
		if( jQuery.browser.msie )
		{
			jQuery('.page-search').submit(function(){
				var tmpname = jQuery('.page-search .inputcontainer .textinput').attr('name');
				var tmpval = jQuery('.page-search .inputcontainer .textinput').val();
				var tmpaction = jQuery('.page-search').attr('action');
				var tmphref = tmpaction.replace('.aspx','.aspx?'+tmpname+'='+tmpval);
				window.location.href=tmphref;
				return false;
			});
		}
		
		jQuery('.area-riservata .fields .user-field .textinput').example('Nome utente');
		jQuery('.area-riservata .fields .password-field .textinput').example('Password');
		jQuery('.page-categories').mouseenter(function(){
			everypage.openPageCategories();
		}).mouseleave(function(){
			everypage.retirePageCategories();
		});
		
		/*jQuery(document).mousemove(function(e){
			var offset = jQuery('.page-categories').offset();
			var width = jQuery('.page-categories').width();
			var height = jQuery('.page-categories').height();
			//console.log( 'Elemento: x='+ parseInt( offset.left ) + ' y=' + parseInt( offset.top ) + ' --- Mouse: x='+ e.clientX + ' y=' +e.clientY );
			//console.log(parseInt(height));
			if( parseInt(offset.left) < parseInt( e.clientX ) &&  parseInt(e.clientX) < (parseInt(offset.left)+parseInt(width) )  && parseInt(offset.top) < parseInt( e.clientY ) &&  parseInt(e.clientY) < (parseInt(offset.top)+parseInt(height) ) )
			{
				inElement = true;
			}
			else
			{
				inElement = false;
			}
			console.log(inElement);	
		});*/
	},
	
	
	
	
	
	
	
	
	
	
	
	retirePageCategories	:	function()
	{
		if ( oldBrow )
		{
			jQuery('.page-categories .categories,.page-categories .categories .categoriesbg2,.page-categories .categories .categoriesbg2 .biglist').animate({'height': 144 },200,'easeInOutQuad');
		}
		else
		{
			jQuery('.page-categories .categories').animate({'height': 144 },200,'easeInOutQuad');
		}
		jQuery('.page-categories .categories-toggle').animate({'background-color': '#E6E6E6' },100,'linear').addClass('closed');
	},
	
	
	
	openPageCategories	:	function()
	{
		if ( oldBrow )
		{
			jQuery('.page-categories .categories,.page-categories .categories .categoriesbg2,.page-categories .categories .categoriesbg2 .biglist').animate({'height': 221 },200,'easeInOutQuad');
		}
		else
		{
			jQuery('.page-categories .categories').animate({'height': 221 },200,'easeInOutQuad');	
		}
		jQuery('.page-categories .categories-toggle').animate({'background-color': '#F08023' },100,'linear').removeClass('closed');
	}
	
	
	
	
};
