//Define the nudge plugin
$.fn.nudge = function(params) {
	//set default parameters
	params = $.extend({
		amount: 12,				//amount of pixels to pad / marginize
		duration: 180,			//amount of milliseconds to take
		property: 'padding', 	//the property to animate (could also use margin)
		direction: 'left',		//direction to animate (could also use right)
		toCallback: function() {},	//function to execute when MO animation completes
		fromCallback: function() {}	//function to execute when MOut animation completes
	}, params);
	//For every element meant to nudge...
	this.each(function() {
		//variables
		var $t = $(this);
		var $p = params;
		var dir = $p.direction;
		var prop = $p.property + dir.substring(0,1).toUpperCase() + dir.substring(1,dir.length);
		var initialValue = $t.css(prop);
		/* fx */
		var go = {}; go[prop] = parseInt($p.amount) + parseInt(initialValue);
		var bk = {}; bk[prop] = initialValue;
		
		//Proceed to nudge on hover
		$t.hover(function() {
					$t.stop().animate(go, $p.duration, '', $p.toCallback);
				}, function() {
					$t.stop().animate(bk, $p.duration, '', $p.fromCallback);
				});
	});
	return this;
};


// to clear searchfield on click
function clearText(thefield){
	if (thefield.defaultValue==thefield.value)
	thefield.value = ""
}
		
// decorating lists
$(document).ready(function(){

	// beautifying heading lists
	$("#step li").each(function (i) {
		i = i+1;
		$(this).addClass("item"+i);
	});
	
	// beautifying small square lists
	$("#step_small li").each(function (i) {
		i = i+1;
		$(this).addClass("item"+i);
	});
		  
	/* nudge links */
	$('.quicklinks li a').nudge();
	$('.press_releases ul li a').nudge();
	
	// for colorbox
	$("a[rel='popup']").colorbox({height:"90%"});

});
				
//for sliding divs that show hidden content on click
function showSlidingDiv(toggleDiv){
	$(toggleDiv).animate({"height": "toggle"}, { duration: 600 });
}
		
function displaymail(mail,style) {
	document.write('<a hr' + 'ef=mai' + 'lto:' + mail + '@' + 'merlinvicki.com' + ' class='+ style +'>' + mail + '@' + 'merlinvicki.com</a>');
}

function displaytxt(txt,mail) {
	document.write('<a hr' + 'ef=mai' + 'lto:' + mail + '@' + 'merlinvicki.com' + '>' + txt + '</a>');
}

function displayextmail(mail,domain,style) {
	document.write('<a hr' + 'ef=mai' + 'lto:' + mail + '@' + domain + ' class=' + style + '>' + mail + '@' + domain +'</a>');
}


