//SET GLOBAL IE FIX VAR
if (navigator.userAgent.search('MSIE') != -1) IE_FIX = true;
else IE_FIX = false;

//nospam for email
function noSpam(user,domain) {
	locationstring = "mailto:" + user + "@" + domain;
	window.location = locationstring;
} function noSpamPrint(user,domain) {
	document.write(user + "@" + domain);
}

/* PANE SCROLL NAVIGATION */
function scroll_to(destination,options) {
	var dest_hash = "";
	if (destination.charAt(0) == '#') {
		//specific anchor name
		dest_hash = destination.substring(1);
	} else {
		//bookmarked destinations
		switch (destination) {
			case "next":
				next_pane_num = options.from+1;
				if ( $('pane'+(next_pane_num)) ) dest_hash = 'pane'+next_pane_num;
				else { dest_hash = 'pane0'; show_next_link(); }
			break;
			case "prev":
				prev_pane_num = options.from-1;
				if ( $('pane'+(prev_pane_num)) ) dest_hash = 'pane'+prev_pane_num;
				else dest_hash = 'pane0';
			break;
		}
	}
	update_url = "window.location.hash = '"+dest_hash+"';";
	if (!IE_FIX) {
		new Effect.ScrollTo(dest_hash);
		setTimeout(update_url,1000);
	} else {
		$(dest_hash).scrollTo();
		eval(update_url);
	}
	return false;
}

//depricated - please use scroll_to (above) instead
function prev_pane(current) { scroll_to('prev',{from: current}); }
function next_pane(current) { scroll_to('next',{from: current}); }

function show_next_link() {
	if ($('next_link')) {
		setTimeout(function() {
			$('next_link').show();
			new Effect.Highlight('next_link', {startcolor: '#DDDDDD'} );
		}, 1200);
	}
}

function show_blurb(blurb_id) {
	if ($('blurb-'+blurb_id)) { $('blurb-'+blurb_id).show(); }
}
function hide_blurb(blurb_id) {
	if ($('blurb-'+blurb_id)) { $('blurb-'+blurb_id).hide(); }
}
function show_feed_details(link_element,hidden_element) {
	if (!$(hidden_element).visible()) new Effect.BlindDown(hidden_element,{duration:0.25, queue: {position: 'end', scope: hidden_element, limit: 1}});
}
function hide_feed_details(link_element,hidden_element) {
	if (!$(link_element).contains(event.toElement) && $(hidden_element).visible()) new Effect.BlindUp(hidden_element,{duration:0.25, queue: {position: 'end', scope: hidden_element, limit: 1}});
}

/* WORK VIEW TOGGLE */
function show_work_by_medium() {
	if ( ! $('mediums').visible() && $('projects').visible() ) {
		new Effect.Fade('projects', {duration: 0.25, queue: 'end'});
		new Effect.Appear('mediums', {duration: 0.25, queue: 'end'});
		$('mediums_toggle').addClassName('chosen'); $('projects_toggle').removeClassName('chosen');
	}
}
function show_work_by_project() {
	if ( ! $('projects').visible() && $('mediums').visible() ) {
		new Effect.Fade('mediums', {duration: 0.25, queue: 'end'});
		new Effect.Appear('projects', {duration: 0.25, queue: 'end'});
		$('projects_toggle').addClassName('chosen'); $('mediums_toggle').removeClassName('chosen');
	}
}


/* COMMENTS SYSTEM */
// function init_comments(post_id) {
// 	new Insertion.After($('comment_link'+post_id),'<div id="comments">test</div>');
// 	$('comments');
// }