// Display email address
function showe(e) {
	document.write('<a href="mailto:' + e + '@' + 'catf.us">' + e + '@' + 'catf.us</a>');
}

// show image
function CATFshowImage(img,w,h) {
    var wobj = window.open(img,'photo','width='+w+',height='+h+',menubar=no,location=no,resizable=no,scrollbars=no,status=no');
    wobj.document.write('<html><head><title>Click to Close - '+img+'</title></head><body style="margin:0; padding:0" onclick="self.close()"><img src="'+img+'" width="'+w+'" height="'+h+'" alt="photo" title="click on image to close this window" /></body></html>');
	wobj.focus();
}


// IE5.5+ PNG Alpha Fix v2.0 Alpha: Background Tiling Support
// (c) 2008 Angus Turnbull http://www.twinhelix.com

// This is licensed under the GNU LGPL, version 2.1 or later.
// For details, see: http://creativecommons.org/licenses/LGPL/2.1/

var IEPNGFix = window.IEPNGFix || {};

IEPNGFix.tileBG = function(elm, pngSrc, ready) {
	// Params: A reference to a DOM element, the PNG src file pathname, and a
	// hidden "ready-to-run" passed when called back after image preloading.

	var data = this.data[elm.uniqueID],
		elmW = Math.max(elm.clientWidth, elm.scrollWidth),
		elmH = Math.max(elm.clientHeight, elm.scrollHeight),
		bgX = elm.currentStyle.backgroundPositionX,
		bgY = elm.currentStyle.backgroundPositionY,
		bgR = elm.currentStyle.backgroundRepeat;

	// Cache of DIVs created per element, and image preloader/data.
	if (!data.tiles) {
		data.tiles = {
			elm: elm,
			src: '',
			cache: [],
			img: new Image(),
			old: {}
		};
	}
	var tiles = data.tiles,
		pngW = tiles.img.width,
		pngH = tiles.img.height;

	if (pngSrc) {
		if (!ready && pngSrc != tiles.src) {
			// New image? Preload it with a callback to detect dimensions.
			tiles.img.onload = function() {
				this.onload = null;
				IEPNGFix.tileBG(elm, pngSrc, 1);
			};
			return tiles.img.src = pngSrc;
		}
	} else {
		// No image?
		if (tiles.src) ready = 1;
		pngW = pngH = 0;
	}
	tiles.src = pngSrc;

	if (!ready && elmW == tiles.old.w && elmH == tiles.old.h &&
		bgX == tiles.old.x && bgY == tiles.old.y && bgR == tiles.old.r) {
		return;
	}

	// Convert English and percentage positions to pixels.
	var pos = {
			top: '0%',
			left: '0%',
			center: '50%',
			bottom: '100%',
			right: '100%'
		},
		x,
		y,
		pc;
	x = pos[bgX] || bgX;
	y = pos[bgY] || bgY;
	if (pc = x.match(/(\d+)%/)) {
		x = Math.round((elmW - pngW) * (parseInt(pc[1]) / 100));
	}
	if (pc = y.match(/(\d+)%/)) {
		y = Math.round((elmH - pngH) * (parseInt(pc[1]) / 100));
	}
	x = parseInt(x);
	y = parseInt(y);

	// Handle backgroundRepeat.
	var repeatX = { 'repeat': 1, 'repeat-x': 1 }[bgR],
		repeatY = { 'repeat': 1, 'repeat-y': 1 }[bgR];
	if (repeatX) {
		x %= pngW;
		if (x > 0) x -= pngW;
	}
	if (repeatY) {
		y %= pngH;
		if (y > 0) y -= pngH;
	}

	// Go!
	this.hook.enabled = 0;
	if (!({ relative: 1, absolute: 1 }[elm.currentStyle.position])) {
		elm.style.position = 'relative';
	}
	var count = 0,
		xPos,
		maxX = repeatX ? elmW : x + 0.1,
		yPos,
		maxY = repeatY ? elmH : y + 0.1,
		d,
		s,
		isNew;
	if (pngW && pngH) {
		for (xPos = x; xPos < maxX; xPos += pngW) {
			for (yPos = y; yPos < maxY; yPos += pngH) {
				isNew = 0;
				if (!tiles.cache[count]) {
					tiles.cache[count] = document.createElement('div');
					isNew = 1;
				}
				var clipR = (xPos + pngW > elmW ? elmW - xPos : pngW),
					clipB = (yPos + pngH > elmH ? elmH - yPos : pngH);
				d = tiles.cache[count];
				s = d.style;
				s.behavior = 'none';
				s.left = xPos + 'px';
				s.top = yPos + 'px';
				s.width = clipR + 'px';
				s.height = clipB + 'px';
				s.clip = 'rect(' +
					(yPos < 0 ? 0 - yPos : 0) + 'px,' +
					clipR + 'px,' +
					clipB + 'px,' +
					(xPos < 0 ? 0 - xPos : 0) + 'px)';
				s.display = 'block';
				if (isNew) {
					s.position = 'absolute';
					s.zIndex = -999;
					if (elm.firstChild) {
						elm.insertBefore(d, elm.firstChild);
					} else {
						elm.appendChild(d);
					}
				}
				this.fix(d, pngSrc, 0);
				count++;
			}
		}
	}
	while (count < tiles.cache.length) {
		this.fix(tiles.cache[count], '', 0);
		tiles.cache[count++].style.display = 'none';
	}

	this.hook.enabled = 1;

	// Cache so updates are infrequent.
	tiles.old = {
		w: elmW,
		h: elmH,
		x: bgX,
		y: bgY,
		r: bgR
	};
};


/*
Managing font
Author: Arun Vishnu
http://arunmvishnu.com/
*/
// Set the font sie during page load. Check cookie for stored font size
function currFontSize(){
	var crntFnt = $.cookie('userFontSize');
	if(crntFnt != null) {
		crntFnt = parseFloat(crntFnt, 10);
		$('body').css('font-size', crntFnt);
	}
	return false;
}
// normal font
function normalFont(){
	var domain = document.domain;
	$('body').css('font-size', 10);
	$.cookie('userFontSize', 10, { expires: 7, path: '/', domain: domain });
	return false;
}
// Increase font
function increaseFont(){
	var currentFontSize = $('body').css('font-size');
	var domain = document.domain;
    var currentFontSizeNum = parseFloat(currentFontSize, 10);
    var newFontSize = currentFontSizeNum*1.2;
    if(newFontSize<15){
    	$.cookie('userFontSize', newFontSize, { expires: 7, path: '/', domain: domain });
    	$('body').css('font-size', newFontSize);
    }
    return false;
}
// Decrease font
function decreaseFont(){
	var currentFontSize = $('body').css('font-size');
	var domain = document.domain;
    var currentFontSizeNum = parseFloat(currentFontSize, 10);
    var newFontSize = currentFontSizeNum*.833;
    if(newFontSize>7.5){
    	$.cookie('userFontSize', newFontSize, { expires: 7, path: '/', domain: domain });
    	$('body').css('font-size', newFontSize);
    }
    return false;
}
// End of Managing font

/**
* Styleswitch stylesheet switcher built on jQuery
* Under an Attribution, Share Alike License
* By Kelvin Luck ( http://www.kelvinluck.com/ )
**/

(function($)
{
	$(document).ready(function() {
		$('.styleswitch').click(function()
		{
			switchStylestyle(this.getAttribute("rel"));
			return false;
		});
		var c = readCookie('style');
		if (c) switchStylestyle(c);
	});

	function switchStylestyle(styleName)
	{
		$('link[@rel*=style][title]').each(function(i) 
		{
			this.disabled = true;
			if (this.getAttribute('title') == styleName) this.disabled = false;
		});
		createCookie('style', styleName, 365);
	}
})(jQuery);


// cookie functions http://www.quirksmode.org/js/cookies.html
function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function eraseCookie(name)
{
	createCookie(name,"",-1);
}
// /cookie functions


IEPNGFix.update = function() {
	// Update all PNG backgrounds.
	for (var i in IEPNGFix.data) {
		var t = IEPNGFix.data[i].tiles;
		if (t && t.elm && t.src) {
			IEPNGFix.tileBG(t.elm, t.src);
		}
	}
};
IEPNGFix.update.timer = 0;

if (window.attachEvent && !window.opera) {
	window.attachEvent('onresize', function() {
		clearTimeout(IEPNGFix.update.timer);
		IEPNGFix.update.timer = setTimeout(IEPNGFix.update, 100);
	});
}

// END IE5.5+ PNG Alpha Fix v2.0 Alpha: Background Tiling Support




// Open link in a new window/tab
$(function(){
	$('a.windowNew').click(function(){
		window.open(this.href);
		return false;
	});
});



// Written by Jonathan Yarbor of Blazed Designs
// http://blazed-designs.com
// View FormClear Homepage: http://blog.blazed-designs.com/2009/06/12/jquery-plugin-clearform/
// Jquery plugin
// Follow me on twitter @blazedd

(function($){$.fn.formclear = function(opts){var defaults = {inactivecolor: '#999',activecolor: '#000000',emptyval: ""  };var opts = $.extend({}, defaults, opts);return this.each(function() {var obj = $(this);  var normalval;var allowedtext = $(this).is(':text') || $(this).is(':password') || $(this).is('textarea');if(allowedtext){var normalval = obj.val();obj.css('color',opts.inactivecolor);}obj.bind('click',function(){if(allowedtext){if(obj.val()==normalval){obj.val(opts.emptyval);obj.css('color',opts.activecolor);}}});obj.bind('blur',function(){if(allowedtext){if(obj.val()==opts.emptyval || !$.trim(obj.val()).length){obj.val(normalval);obj.css('color',opts.inactivecolor);}}});});};})(jQuery);


  jQuery().ready(function() {  
   jQuery('.clear').formclear(); 
  });  

