
$(document).ready(function(){
	/*
	$("#stars-wrapper1").stars({ 
		//captionEl: $("#stars-wrapper1-cap"), 
		inputType: "select", 
		oneVoteOnly: true,
		callback: function(ui, type, value, thingID){
			$.get('/ajax/thing/rate/?thingID='+ $('#thingID').attr('value') +'&vote='+ value, function(data){
				$("#stars-thanks").html('Thanks for voting!');
				$("#rateCount").html(parseInt($("#rateCount").text())+1);
				setTimeout(function(){ $("#stars-thanks").fadeOut(1000) }, 2000);
			});
		} 
	});
	*/
	$("a[@href^='http']").attr('target','_blank');
	if ($('#captcha').exists()) $('#captcha').focus();
	
	//if (continue_signup == 1) tb_show("Sign up!", "/login/signup/complete_signup/?height=400&width=600&KeepThis=true&TB_iframe=true");
	if ($('#continuesignup').exists()) tb_show("Sign up!", "/login/signup/complete_signup/?height=400&width=600&KeepThis=true&TB_iframe=true");
});

$.fn.exists = function() { return this.length>0; };



//function to check valid email address
function is_valid_email(email){
	regex = /^[^@]+@[^@]+.[a-z]{2,}$/i;
	// search email text for regular exp matches
	if (email.search(regex) == -1) {
		return false;
	}
    return true; 
}


function submit_subscribe(f) {
	//if (is_valid_email($('#Email').val())) {
	if (is_valid_email(f.Email.value)) {
		subscribe = window.open('', 'subscribe', 'width=480,height=540');
		f.submit();
		return true;
	} else {
		alert('A valid e-mail address is required.\nPlease amend and retry.');
	}
}

function toggle_hometab(tab) {
	//alert(tab);
	tabs = new Array('wanted', 'emailed', 'commented');
	for (i=0; i < tabs.length; i++) {
		$('#tab_'+ tabs[i]).removeClass('activeMostTop');
		$('#content_'+ tabs[i]).hide();
	}
	$('#tab_'+ tab).addClass('activeMostTop');
	$('#content_'+ tab).show();
}

//hide homepage comment
function hhc(c) {
	$.get('/ajax/comments/hide_home/', { commentID: c }, function(data) {
		$("#lastcomments").html(data);
	});
}

