/* Analytics */
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-17308329-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

/* Global func */
jQuery(document).ready(function(){
	var redirurl;
	$('#langcont').imgDropDown({title:$('#langlist').html()}).show();
	$("#artbtn").click(function(e){$("#artistForm").submit();return false;});
	$("#subscribe_btn").click(function(e){
					if(redirurl) $('#redir').val(redirurl);
					$("#subscribe").submit();
					return false;
				});
    $('#authform #ok').bind('click', function(){ $('#authform').submit(); return false; });
    $('#authformpp #ok').bind('click', function(){
											$('#logres').attr('class','').html('<img src="/images/loading_wg.gif"/>');
											$.post('/auth/login', $("#authformpp form").serialize(), 
												function(res){
													r = jQuery.parseJSON( res );
													if(r && r.success){
														if(redirurl) window.location = redirurl;
														else location.reload();
													}
													else if(r && (r.success === false)) $('#logres').html(r.msg).attr('class','msg error');
													else $('#logres').html('Internal error, please try again').attr('class','msg error');
												}
											);
											return false;
									});
    $('#authform input, #authformpp input').focus(function(){ if( $(this).val() == $(this).attr('title') ) $(this).val(''); });
    $('#authform input, #authformpp input').blur(function(){ if( $(this).val() == '' ) $(this).val( $(this).attr('title') ); });
	
	$('#send_btn').colorbox({title:true,scrolling:false});
	$(".logpp").colorbox({title:true,inline:true, href:"#authformpp", scrolling:false});
	$('.logpp').bind('click', function(){ if($(this).attr('url')) redirurl = $(this).attr('url'); });
});
