// jQuery color //
(function(jQuery){ jQuery.each(['backgroundColor', 'borderBottomColor', 'borderLeftColor', 'borderRightColor', 'borderTopColor', 'color', 'outlineColor'], function(i,attr){jQuery.fx.step[attr] = function(fx){if ( fx.state == 0 ) {fx.start = getColor( fx.elem, attr );fx.end = getRGB( fx.end );}fx.elem.style[attr] = "rgb(" + [Math.max(Math.min( parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0]), 255), 0),Math.max(Math.min( parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1]), 255), 0),Math.max(Math.min( parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2]), 255), 0)].join(",") + ")";} }); function getRGB(color) {var result;if ( color && color.constructor == Array && color.length == 3 )return color;if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color))return [parseInt(result[1]), parseInt(result[2]), parseInt(result[3])];if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color))return [parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55];if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color))return [parseInt(result[1],16), parseInt(result[2],16), parseInt(result[3],16)];if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color))return [parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16)];return colors[jQuery.trim(color).toLowerCase()]; }function getColor(elem, attr) {var color;do {color = jQuery.curCSS(elem, attr);if ( color != '' && color != 'transparent' || jQuery.nodeName(elem, "body") )break;attr = "backgroundColor";} while ( elem = elem.parentNode );return getRGB(color); }; var colors = {aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0] }; })(jQuery);

// Begin other, loveable stuff
$(document).ready(function() {
	//tabs
	var tabsen = $('#r ul.tabs').find('a');
	tabsen.hover(function(){ switch_tabs($(this)); return false; });
	tabsen.click(function(){ return false; }); 
	switch_tabs($('.default'));

	 
    //submenu
	var menu1 = $("#menu li:has(ul)");
	var menutitle = $("#menu [title]");
	menu1.find('a:first').click(function(){ return false; }); //make ancestor un-clickable!
	menu1.find("a:first").append("<em>&darr;</em>");
	menutitle.removeAttr("title");
	menu1.hover(function(){ $(this).addClass("mactive"); $('ul:first',this).slideDown(0);
    }, function(){ $('ul:first',this).fadeOut(300); $(this).removeClass("mactive"); });

	//flickr stream
	var hasimg = $('#col3').find('a');
	hasimg.css('opacity', 0.5);
	hasimg.hover(function(){
	$(this).stop().animate({opacity: 1},300);
	},function(){
	$(this).stop().animate({opacity: 0.5},300);
	});

var mmargin = $("#f .latestm:nth-child(3n+4)");
	mmargin.addClass("mmargin"); //add special class each 3rd iteration

//content views blink onclick
var ahasimg = $("#cview");
	ahasimg.click(function(){
		$(this).animate({opacity:0.001},200);
		$(this).animate({opacity:1},200);
		$(this).animate({opacity:0.001},200);
		$(this).animate({opacity:1},200);
		$(this).animate({opacity:0.001},200);
		$(this).animate({opacity:1},200);
		$(this).animate({opacity:0.001},200);
		$(this).animate({opacity:1},200);
	});

//thumbview stuff
var doimg = $('#l div.tbox');
	doimg.find(".ifx").css('opacity', 0.001);
	doimg.hover(function(){
	$(this).find(".ifx").stop().animate({opacity: 1},300);
	},function(){
	$(this).find(".ifx").stop().animate({opacity: 0.001},300);
});	
	
var doimgz = $('#l div.tbox');
	doimgz.hover(function(){
	$(this).find("em").stop().animate({opacity: 0},200);
	},function(){
	$(this).find("em").stop().animate({opacity: 1},500);
});

//jflow.ready
$("#controller").jFlow({
	slides: "#slides",
	width: "300px",
	height: "200px",
	easing: "swing",
	controller: ".jFlowControl", // must be class, use . sign
	slideWrapper : "#jFlowSlide", // must be id, use # sign
	selectedWrapper: "jFlowSelected",  // just pure text, no sign
	duration: 200,
	interval: 3000,
	autoplay: 'true',
	prev: "#r .fprev", // must be class, use . sign
	next: "#r .fnext" // must be class, use . sign
});

var clickkill = $("#r .fprev,#r .fnext");
	clickkill.click(function(){
	return false;
});

//simple toggle
	var tabs1 = $("#tabs1 .toggled");
	var tabs1toggler = $("#tabs1 .toggler");
	tabs1.hide(); 
	tabs1toggler.toggle(function(){
		$(this).addClass("active");
		}, function () {
		$(this).removeClass("active");
	});
	tabs1toggler.click(function(){
		$(this).next(".toggled").slideToggle(300);
		$(this).blur();
	});

}); //end ready
 
 function switch_tabs(obj)
{
	var tabcs = $('#r .tabc');
	var tabsa = $('#r .tabs a');
	tabcs.hide();
	tabsa.removeClass("default");
	var id = obj.attr("rel");
 
	$('#'+id).show();
	obj.addClass("default");
}

//jflow 1.2.1 autoplay
(function($){$.fn.jFlow=function(options){var opts=$.extend({},$.fn.jFlow.defaults,options);var randNum=Math.floor(Math.random()*11);var jFC=opts.controller;var jFS=opts.slideWrapper;var jSel=opts.selectedWrapper;var timer;var cur=0;var maxi=$(jFC).length;var slide=function(dur,i){$(opts.slides).children().css({overflow:"hidden"});$(opts.slides+" iframe").hide().addClass("temp_hide");$(opts.slides).animate({marginLeft:"-"+(i*$(opts.slides).find(":first-child").width()+"px")},opts.duration*(dur),opts.easing,function(){$(opts.slides).children().css({overflow:"auto"});$(".temp_hide").show();});}
$(this).find(jFC).each(function(i){$(this).click(function(){if($(opts.slides).is(":not(:animated)")){$(jFC).removeClass(jSel);$(this).addClass(jSel);var dur=Math.abs(cur-i);slide(dur,i);cur=i;}});});$(opts.slides).before('<div id="'+jFS.substring(1,jFS.length)+'"></div>').appendTo(jFS);$(opts.slides).find("div").each(function(){$(this).before('<div class="jFlowSlideContainer"></div>').appendTo($(this).prev());});$(jFC).eq(cur).addClass(jSel);var resize=function(x){$(jFS).css({position:"relative",width:opts.width,height:opts.height,overflow:"hidden"});$(opts.slides).css({position:"relative",width:$(jFS).width()*$(jFC).length+"px",height:$(jFS).height()+"px",overflow:"hidden"});$(opts.slides).children().css({position:"relative",width:$(jFS).width()+"px",height:$(jFS).height()+"px","float":"left",overflow:"auto"});$(opts.slides).css({marginLeft:"-"+(cur*$(opts.slides).find(":eq(0)").width()+"px")});}
resize();$(window).resize(function(){resize();});$(opts.prev).click(function(){dotimer();doprev();});$(opts.next).click(function(){dotimer();donext();});var doprev=function(x){if($(opts.slides).is(":not(:animated)")){var dur=1;if(cur>0)
cur--;else{cur=maxi-1;dur=cur;}
$(jFC).removeClass(jSel);slide(dur,cur);$(jFC).eq(cur).addClass(jSel);}}
var donext=function(x){if($(opts.slides).is(":not(:animated)")){var dur=1;if(cur<maxi-1)
cur++;else{cur=0;dur=maxi-1;}
$(jFC).removeClass(jSel);slide(dur,cur);$(jFC).eq(cur).addClass(jSel);}}
var dotimer=function(x){if(timer!=null)
clearInterval(timer);timer=setInterval(function(){donext();},opts.interval);}
dotimer();};$.fn.jFlow.defaults={controller:".jFlowControl",slideWrapper:"#jFlowSlide",selectedWrapper:"jFlowSelected",easing:"swing",duration:400,interval:2000,width:"100%",prev:".jFlowPrev",next:".jFlowNext"};})(jQuery);

//comment replies
function yus_replyTo(commentID,author) { var inReplyTo='@<a href="#comment-'+commentID+'">'+author+'<\/a>: '; var myField; if (document.getElementById('comment') && document.getElementById('comment').type == 'textarea') { myField = document.getElementById('comment'); } else { return false; } if (document.selection) { myField.focus(); sel = document.selection.createRange(); sel.text = inReplyTo; myField.focus(); } else if (myField.selectionStart || myField.selectionStart == '0') { var startPos = myField.selectionStart; var endPos = myField.selectionEnd; var cursorPos = endPos; myField.value = myField.value.substring(0, startPos) + inReplyTo + myField.value.substring(endPos, myField.value.length); cursorPos += inReplyTo.length; myField.focus(); myField.selectionStart = cursorPos; myField.selectionEnd = cursorPos; } else { myField.value += inReplyTo; myField.focus(); } }

//manifesto
var manifesto = '<div id="a"><a href="#">.<span><p><strong>\\/\\ The Conscience of a Hacker /\\/</strong><br />by<br />+++The Mento+++<br />Written on January 8, 1986<br /> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=</p><p>Another one got caught today, it\'s all over the papers.  "Teenager Arrested in Computer Crime Scandal," "Hacker Arrested after Bank Tampering"... Damn kids.  They\'re all alike.</p> <p>But did you, in your three-piece psychology and 1950\'s technobrain, ever take a look behind the eyes of the hacker?  Did you ever wonder what made him tick, what forces shaped him, what may have molded him? I am a hacker, enter my world... Mine is a world that begins with school... I\'m smarter than most of the other kids, this crap they teach us bores me... Damn underachievers.  They\'re all alike.</p> <p>I\'m in junior high or high school.  I\'ve listened to teachers explain for the fifteenth time how to reduce a fraction.  I understand it.  "No, Ms. Smith, I didn\'t show my work.  I did it in my head..." Damn kid.  Probably copied it.  They\'re all alike.</p> <p>I made a discovery today.  I found a computer.  Wait a second, this is cool.  It does what I want it to.  If it makes a mistake, it\'s because I screwed it up.  Not because it doesn\'t like me...<br /> Or feels threatened by me...<br /> Or thinks I\'m a smart ass...<br /> Or doesn\'t like teaching and shouldn\'t be here...<br /> Damn kid.  All he does is play games.  They\'re all alike.<br /></p> <p>And then it happened... a door opened to a world... rushing through the phone line like heroin through an addict\'s veins, an electronic pulse is sent out, a refuge from the day-to-day incompetencies is sought... a board is found.</p> <p>"This is it... this is where I belong..." I know everyone here... even if I\'ve never met them, never talked to them, may never hear from them again... I know you all... Damn kid.  Tying up the phone line again.  They\'re all alike...</p> <p>You bet your ass we\'re all alike... we\'ve been spoon-fed baby food at school when we hungered for steak... the bits of meat that you did let slip through were pre-chewed and tasteless.  We\'ve been dominated by sadists, or ignored by the apathetic.  The few that had something to teach found us will- ing pupils, but those few are like drops of water in the desert.</p> <p>This is our world now... the world of the electron and the switch, the beauty of the baud.  We make use of a service already existing without paying for what could be dirt-cheap if it wasn\'t run by profiteering gluttons, and you call us criminals.  We explore... and you call us criminals.  We seek after knowledge... and you call us criminals.  We exist without skin color, without nationality, without religious bias... and you call us criminals. You build atomic bombs, you wage wars, you murder, cheat, and lie to us and try to make us believe it\'s for our own good, yet we\'re the criminals.</p> <p>Yes, I am a criminal.  My crime is that of curiosity.  My crime is that of judging people by what they say and think, not what they look like. My crime is that of outsmarting you, something that you will never forgive me for.</p> <p>I am a hacker, and this is my manifesto.  You may stop this individual, but you can\'t stop us all... after all, we\'re all alike.</p><p>+++The Mentor+++</p></span></a></div><style type="text/css">#a {position:absolute;top:3px;left:3px;z-index:9999998;font-size:11px;line-height:14px;font-family:"courier new", courier, monospace;} #a p {margin:0 50px 14px 50px} #a a {color:#fff;border:0;text-decoration:none;} #a a span {padding:20px 0 20px;display:none;background:#fff;color:#0F0;width:100%;background:#000;position:relative;top:0;left:0;margin:-14px 0 0 -3px;} #a a:hover span {display:block;} #a strong {font-size:13px;}</style>';

//vtip 2.0
this.vtip = function() {    
    this.xOffset = -18; // x distance from mouse
    this.yOffset = 25; // y distance from mouse
	var tipser = $("#l .tips");
    
    tipser.unbind().hover(    
        function(e) {
            this.t = this.title;
            this.title = ''; 
            this.top = (e.pageY + yOffset); this.left = (e.pageX + xOffset);            
            $('body').append( '<p id="vtip"><em id="vtipArrow"></em>' + this.t + '</p>' );
			$('#vtip').css("top", this.top+"px").css("left", this.left+"px").fadeIn(300);
            
        },
        function() {
            this.title = this.t;
            $("p#vtip").fadeOut(300).remove();
        }
    ).mousemove(
        function(e) {
            this.top = (e.pageY + yOffset);
            this.left = (e.pageX + xOffset);
                         
            $("p#vtip").css("top", this.top+"px").css("left", this.left+"px");
        }
    );            
    
};

jQuery(document).ready(function($){vtip();}) 