
window.addEvent('domready', function() {

    //
    //  Tips
    //
    var customTips = $$('.tipz');
    var toolTips = new Tips(customTips);


    //
    //  Attivo i place holder all'interno dei campi input
    //
    $$('*[rel=placeholder]').each(function(el, index) {

            new OverText(el);

    });
	
});


// eseguo il callback e faccio l'update di un target
function ajax_callback(requestUrl, targetId)
{
	var fadeIn = new Fx.Morph(targetId, {duration:250});

	var fadeOut = new Fx.Morph(targetId,{
	        duration: 250,
	        onComplete: function () {
			    var req = new Request.HTML({
			        url: requestUrl,
					evalResponse: true,
					evalScripts: true,
			        onSuccess: function(html) {
			            // Clear the text currently inside the results div.
			            $(targetId).set('text', '');
			            // Inject the new DOM elements into the results div.
			            $(targetId).adopt(html);
			        },
			        // Our request will most likely succeed, but just in case, we'll add an
			        // onFailure method which will let the user know what happened.
			        onFailure: function() {
			            $(targetId).set('text', 'The request failed.');
			        },
					onComplete: function() {
						fadeIn.start({opacity:1});
					}
			    }).send();

			}
	}).start({opacity:0});
}

// la modal è globale
var myStickyWin
function ajax_modal( requestUrl, parentField )
{
	
	myStickyWin = new StickyWin.Modal.Ajax({
		evalResponse: true,
		evalScripts: true,
		relativeTo: $('wrapper'),
		position: 'middleCenter',
		destroyOnClose: true,
		requestOptions: {
			method:'post'
		},
		modalOptions: {
			modalStyle: {
				'background-color':'#fff',
				'opacity':.8
		    }
		  }
	}).update(requestUrl	, {
		    data: { parentField: parentField }
	});

}

// -----------------------------------------------------------------------------------
// fading di un div
function fadeout(ctrl)
{
	if($(ctrl) != null)
	{
		new Fx.Morph(ctrl, {duration:2000}).start({opacity:0});
	}	
}
