/*
 * Email Defuscator - jQuery plugin 1.0 alpha
 *
 * Copyright (c) 2007 Joakim Stai
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 *
 * Revision: $Id$
 *
 */

/**
 * Converts obfuscated email addresses into normal, working email addresses.
 *
 * @name defuscate
 * @param Boolean link If true, all defuscated email addresses will be turned into links, defaults to true (optional)
 * @descr Converts obfuscated email addresses into normal email addresses
 */
 
jQuery.fn.defuscate=function(b){b=jQuery.extend({link:true},b);var c=/\b([A-Z0-9._%-]+)\([^)]+\)((?:[A-Z0-9-]+\.)+[A-Z]{2,6})\b/gi;return this.each(function(){if($(this).is('a[@href]')){$(this).attr('href',$(this).attr('href').replace(c,'$1@$2'));var a=true}$(this).html($(this).html().replace(c,(b.link&&!a?'<a href="mailto:$1@$2">$1@$2</a>':'$1@$2')))})}

jQuery.noConflict();
(function($) { 
  $(function() {
	
	$("q").prepend("&ldquo;").append("&rdquo;");
	$("q q").prepend("&lsquo;").append("&rsquo;");
	// Add classes to input pseudotypes
	$("input[type='text'], input[type='password']").addClass("text");
	$("input[type='button'], input[type='submit'], input[type='checkbox'], input[type='image'], input[type='radio'], input[type='reset'], button").addClass("nontext");
	$("input[type='button'], input[type='submit'], input[type='reset'], button").addClass("button");
	// Add classes to link pseudotypes
	$("a[href^='mailto:']").addClass("mailto");
	$("a[href$='.pdf']").addClass("docpdf");
	$("a[href$='.swf']", "a[href$='.fla']", "a[href$='.swd']").addClass("docflash");
	$("a[href$='.xls']", "a[href$='.csv']", "a[href$='.xlt']", "a[href$='.xlw']").addClass("docexcel");
	$("a[href$='.ppt']", "a[href$='.pps']").addClass("docppoint");
	$("a[href$='.doc']", "a[href$='.rtf']", "a[href$='.txt']", "a[href$='.wps']").addClass("docword");
	$("a[href$='.zip']", "a[href$='.gzip']", "a[href$='.rar']").addClass("doczip");
	// External link popper
	$('a[href^=http://]').not('[href*='+window.location.host+']').attr('target','_blank').addClass("external");
		/* 
		checks href against current domain. If not matching and href contains http://, target blank it and add class external
		*/
	
	// Remove classes from a link containing an image
	$("a img").parent().removeClass();
		
	// Wrap <hr> so bg-image doesn't have a border in IE6 and Opera
	$("hr").wrap('<div class="hr"></div>');
	
	/* Add class="obfuscated" and href="mailto:name(at)example.com" to an email address link */
	$('.obfuscated').defuscate();
	
	// Make Containers of Floated Elements Clear Following Content
	$("#access").addClass("clearfix");
			
	// Few setups for IE6
	if(document.all){
		//add class to drop downs and buttons 
	    $('#nav li, button').hover(
			function() { $(this).addClass('over'); },
			function() { $(this).removeClass('over'); }
	    );
	}// if document.all
	
  });
})(jQuery);

// jQuery plugins

// clean console.log
function cl(logit){ if(window.console&&window.console.firebug) { console.log(logit) } };//cl()
// example: cl("If you use cl() instead of console.log(), it won't break IE when you forget to take it out.");


// IE6 fixes
// make sure IE has the abbr and acronym tag
if(document.all){
	document.createElement("abbr");
	document.createElement("acronym");
}
// prevent IE6 flicker
try { document.execCommand('BackgroundImageCache', false, true); } catch(e) {}
