/*$(document).ready(function(){$('#anon-message').dialog({autoOpen:false});$('.resource a').click(function(){var a=$(this).parent().children().first().css('background-image');a=a.substr(5,a.length-7);$('#anon-message .anon-message-img').remove();$('#anon-message').prepend('<img class="anon-message-img" src="'+a+'" align="left" />');$('#anon-message').dialog({'autoOpen':true,'resizable':false,'width':600,'modal':true,'buttons':{'Register':function(){window.location='/register'},'Close':function(){$(this).dialog('close')},},'title':$(this).parent().children().first().next().text()});return false});$('.resource a').each(function(){if(jQuery.trim($(this).parent().find(".tooltip_desc").html())==""){return}$(this).qtip({position:{corner:{tooltip:'rightMiddle',target:'leftMiddle'},},show:{delay:500,solo:true,effect:{type:'fade'}},style:{border:{width:1,radius:7,color:'#D8F0FA'},title:{'font-size':'120%','background':'#EEF7FD'},tip:'rightMiddle','background':'#EEF7FD','font-size':'110%',width:200},content:{text:$(this).parent().find(".tooltip_desc").html(),title:{text:$(this).parent().find(".tooltip_title").html()}},name:'light'})})});

*/
$(document).ready(function(){
	$('#anon-message').dialog({ autoOpen: false });
	
	$('.resource a').click( function() {
		var img = $(this).parent().children().first().css('background-image');
		//img = img.substr(5,img.length - 7);
		img = img.replace(/url\("*|"*\)$/ig, "");
		$('#anon-message .anon-message-img').remove();
		
		$('#anon-message').prepend('<img class="anon-message-img" src="'+img+'" align="left" />');
		
		$('#anon-message').dialog({ 
					'autoOpen': true, 
					'resizable': false, 
					'width': 600, 
					'modal': true, 
					'buttons': {
							'Register': function() {
								window.location ='/register';
							},
							'Login': function() {
								window.location ='/login';
							},
							'Close': function() {
								$(this).dialog('close');
							}
						},
					'title': $(this).parent().children().first().next().text() });
		return false;
	});
	
	$('.resource a').each( function() {
		if(jQuery.trim($(this).parent().find(".tooltip_desc").html()) == "")
		{
			return;
		}
		$(this).qtip({ 
			position: {
				corner: {
					tooltip: 'rightMiddle', 
					target: 'leftMiddle'
				}
			},
			show: {
				delay: 500,
				solo: true,
				effect: {
					type: 'fade'
				}
			},
			style: {
				border: {
					width:1,
					radius:7,
					color: '#D8F0FA'
				},
				title: {
					'font-size': '120%',
					'background': '#EEF7FD'
				},
				tip: 'rightMiddle',
				'background': '#EEF7FD',
				'font-size': '110%',
				width: 200
			},
			content: {
				text: $(this).parent().find(".tooltip_desc").html(),
				title: {
					text:$(this).parent().find(".tooltip_title").html()
				}
			},
			name: 'light'
		});
	});
});
