$(document).ready(function(){
	$("a.lightbox").fancybox({
		'titleShow'     : true,
		'titlePosition' : 'inside',
		'autoDimensions'	: true,
		'centerOnScroll'	: true
	});
	
	$("a[rel=lightbox]").fancybox({
		'titleShow'     : true,
		'autoDimensions'	: true,
		'centerOnScroll'	: true,
		'titlePosition' : 'inside',
		'overlayColor' : '#000',
		'overlayOpacity' : 0.9 
	});
	
	
	$('#frmlogin').submit(function(){
		$.ajax({
			type: $(this).attr("method"),
			url: $(this).attr("action"),
			cache: false, 
			dataType: 'json',
			data: $('#frmlogin').serialize(),
			success: function(data){
				if(data.login=='ok'){
					window.location =data.redir;
					
				}else{
					ProcessUI(data.error);
					setTimeout($.unblockUI, 2000);
				}
			}
		}); 		
		return false;
		 
    });		
	
});

function ProcessUI(msg){
	if(msg==""){msg='Process...';}
	$.blockUI({ 
		message: '<div class="bui">'+msg+'</div>',
		css: { 
			padding:       '20px',
			margin:         0,
			width:          '300px',
			left:	 		($(window).width() -  270 ) / 2 +'px', 
			top:         	($(window).height() -  200 ) / 2 +'px', 
			textAlign:     'center', 
			color:          '#000', 
			border:         'none', 
			backgroundColor: 'none', 
			cursor:         'default' 
		},
		overlayCSS:{ 
			backgroundColor: '#000', 
			opacity: 0.8
		}, 
		fadeIn:  200, 
		fadeOut:  200
	}); 			
}

/*-################################################################*/
function addToFavorites(title,url){
	title=document.title; 
	url=document.location.href;
	if (window.sidebar){ // firefox
		window.sidebar.addPanel(title, url, "");
	}else if(window.opera && window.print){ // opera
		var elem = document.createElement('a');
		elem.setAttribute('href',url);
		elem.setAttribute('title',title);
		elem.setAttribute('rel','sidebar');
		elem.click();
	}else if(window.external){// ie
		window.external.AddFavorite(url, title);
	}else{ 
		alert("Sorry! Your browser doesn't appear to support this function."); 
	} 
}	
/*-################################################################*/


