/* Copyright (c) 2005 - 2008, James Auldridge; All rights reserved.  Licensed under the BSD, MIT, and GPL (your choice!) Licenses: http://code.google.com/p/cookies/wiki/License Version 2.0 */
var jaaulde=window.jaaulde||{};jaaulde.utils=jaaulde.utils||{};jaaulde.utils.cookies=(function(){var e=[];var f={hoursToLive:0,path:'/',domain:window.location.hostname,secure:false};var g=function(a){var b;if(typeof a!=='object'||a===null){b=f}else{b={hoursToLive:(typeof a.hoursToLive==='number'?a.hoursToLive:f.hoursToLive),path:(typeof a.path==='string'&&a.path!=''?a.path:f.path),domain:(typeof a.domain==='string'&&a.domain!=''?a.domain:f.domain),secure:(typeof a.secure==='boolean'&&a.secure!=''?a.secure:f.secure)}}return b};var h=function(a){a=g(a);return((a.hoursToLive!==0?'; expires='+j(a.hoursToLive):'')+'; path='+a.path+'; domain='+a.domain+(a.secure?'; secure':''))};var j=function(a){var b=new Date();b.setTime(b.getTime()+(a*60*60*1000));return b.toGMTString()};var k=function(){e=[];var a,name,separated=document.cookie.split(';');for(var i=0;i<separated.length;i++){a=separated[i].split('=');name=a[0].replace(/^\s*/,'').replace(/\s*$/,'');value=unescape(a[1]);e[name]=unescape(value)}return e};var constructor=function(){};constructor.prototype.get=function(a){var b;k();if(typeof a==='string'){b=(typeof e[a]!=='undefined')?e[a]:null}else if(typeof a==='object'&&a!==null){b=[];for(var c in a){b[a[c]]=(typeof e[a[c]]!=='undefined')?e[a[c]]:null}}else{b=e}return b};constructor.prototype.set=function(a,b,c){if(typeof b==='undefined'||b===null){if(typeof c!=='object'||c===null){c={}}b='';c.hoursToLive=-8760}var d=h(c);document.cookie=a+'='+escape(b)+d};constructor.prototype.del=function(a,b){if(typeof b!=='object'||b===null){b={}}this.set(a,null,b)};constructor.prototype.test=function(){var a=false,testName='cT',testValue='data';this.set(testName,testValue);if(this.get(testName)==testValue){this.del(testName);a=true}return a};constructor.prototype.setOptions=function(a){if(typeof a!=='object'){a=null}f=g(a)};return new constructor()})();(function(){if(typeof jQuery!=='undefined'){jQuery.cookies=jaaulde.utils.cookies;var c={cookify:function(b){return this.each(function(){var a='',value='',nameAttrs=['name','id'],iteration=0,inputType;while(iteration<nameAttrs.length&&(typeof a!=='string'||a==='')){a=jQuery(this).attr(nameAttrs[iteration]);iteration++}if(typeof a==='string'||a!==''){inputType=jQuery(this).attr('type').toLowerCase();if(inputType!=='radio'&&inputType!=='checkbox'){value=jQuery(this).attr('value');if(typeof value!=='string'||value===''){value=null}jQuery.cookies.set(a,value,b)}}iteration=0})},cookieFill:function(){return this.each(function(){var a='',value,nameAttrs=['name','id'],iteration=0,nodeType;while(iteration<nameAttrs.length&&(typeof a!=='string'||a==='')){a=jQuery(this).attr(nameAttrs[iteration]);iteration++}if(typeof a==='string'&&a!==''){value=jQuery.cookies.get(a);if(value!==null){nodeType=this.nodeName.toLowerCase();if(nodeType==='input'||nodeType==='textarea'){jQuery(this).attr('value',value)}else{jQuery(this).html(value)}}}iteration=0})},cookieBind:function(a){return this.each(function(){$(this).cookieFill().change(function(){$(this).cookify(a)})})}};jQuery.each(c,function(i){jQuery.fn[i]=this})}})();