

$(document).ready(function(){
	$("a[href^='http']").attr('target','_blank');//all outbound links target a new window
	$("a[rel='gal']").colorbox({transition:"none", width:"60%", height:"60%", preloading:'true'});
	$('a.email').colorbox({transition:'elastic', width:'675px', height:'690px', iframe:true});
	$('a.dialog').colorbox({transition:'elastic', width:'400px', height:'275px', iframe:true});
	//$('a.del').colorbox({transition:'elastic', width:'400px', height:'275px'});
	if ($('#login').exists()) $('#login #email').focus();
	//if ($("#map_canvas").exists()) init_map();//google maps
	//if ($("#map_canvas_all").exists()) init_map_all();//google maps
});

// for google maps api stuff
//$(document).unload(function() { GUnload(); });

$.fn.exists = function() { return this.length>0; };//add a way for testing if a div exists to jquery


//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())) {
		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);
	});
}

function rld() {
	setTimeout("location.reload()", 100);
}



