/*
JavaScript Random Images v1.1
Originally developed by Matt Ditter (April 2009)
jQueryized by Derrick Gall (May 22, 2009)
Last Updated by Derrick Gall (November 4th, 2009)
Minified with YUI Compressor & Ant

See WingDing for instructions: 
http://wingding.int.thomson.com/#random-images
*/
$.fn.randomize=function(c){var e=false,g=0,f=$(this);c=$.extend({numberOf:1,altTags:[],background:false,classPrefix:"random",syncImages:false,linkTo:""},c);if(c.type=="image"){if(!c.id||!c.src){return false}}function a(l){var k;do{k=Math.ceil(Math.random()*c.numberOf)}while(k==l);return k}function h(m,n,o){var l,k;if(o){l=new Date();l.setTime(l.getTime()+(o*24*60*60*1000));k="; expires="+l.toGMTString()}else{k=""}document.cookie=m+"="+n+k+"; path=/"}function i(l){var n=l+"=",k=document.cookie.split(";"),o,m;for(m=0;m<k.length;m++){o=k[m];while(o.charAt(0)===" "){o=o.substring(1,o.length)}if(o.indexOf(n)===0){return o.substring(n.length,o.length)}}return null}function j(){e="randomizeBackground";if(f.attr("id")){e+=f.attr("id")}g=a(i(e));f.addClass(c.classPrefix+g)}function d(){var n="",o="",p="",m="",l=$(document.body),k;e="randomizeImage"+c.src.replace(/.*\/([^\d]+)\d+(\.\w+)$/g,"$1");if(c.syncImages){k=l.data("randomImageIndex")}if(k){g=k}else{g=a(i(e));if(c.syncImages){l.data("randomImageIndex",g)}}o=c.src.replace(/\d+(\.\w+)$/g,g+"$1");p=c.id;if(c.altTags[g-1]){m=c.altTags[g-1]}n='<img id="'+p+'" src="'+o+'" alt="'+m+'" />';if(c.linkTo){if(c.linkTo.constructor.toString().indexOf("Array")>-1){if(c.linkTo[g-1]){n='<a id="'+p+'Link" href="'+c.linkTo[g-1]+'">'+n+"</a>"}}else{n='<a id="'+p+'Link" href="'+c.linkTo+'">'+n+"</a>"}}f.replaceWith(n)}function b(){e="randomizeParent";if(f.attr("id")){e+=f.attr("id")}c.numberOf=f.children().length;g=a(i(e));f.children(":eq("+(g-1)+")").show().siblings().hide()}if(c.background){j()}if(c.src){d()}if(!c.background&&!c.src){b()}if(e){h(e,g,365)}};
