jQuery.noConflict();

var exitStageLeft, enterStageRight, arrowHomeTop = 0, shimmer = 0, arrowHomeLeft = 0;

var hideTime, activePrimary = -1, activeSecondary =-1, activeTertiary =-1;
var ddTriggerArray = ["whyION", "areasOfExpertise", "productsServices", "dataLibrary", "resourceCenter"];
var ddLayerArray = ["whyIONDD", "areasOfExpertiseDD", "productsServicesDD", "dataLibraryDD", "resourceCenterDD"];
var timeOuts= new Array();
//var mytabs;


// parseUri 1.2.2
// (c) Steven Levithan <stevenlevithan.com>
// MIT License
function parseUri(d){for(var a=parseUri.options,d=a.parser[a.strictMode?"strict":"strict"].exec(d),c={},b=14;b--;)c[a.key[b]]=d[b]||"";c[a.q.name]={};c[a.key[12]].replace(a.q.parser,function(d,b,e){b&&(c[a.q.name][b]=e)});return c}
parseUri.options={strictMode:!1,key:"source,protocol,authority,userInfo,user,password,host,port,relative,path,directory,file,query,anchor".split(","),q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}};

jQuery.fn.copyCSS = function( style, toNode ){
  var self = jQuery(this);
  if( !jQuery.isArray( style ) ) style=style.split(' ');
  jQuery.each( style, function( i, name ){ toNode.css( name, self.css(name) ) } );
  return self;
}

jQuery(function() {
	
  jQuery('a[href$=".pdf"]').click(function(){
        _gat._getTrackerByName()._trackEvent('Download', 'Pdf', this.href);
        setTimeout('document.location = "' + this.href + '"', 100);
	return false
    });

    jQuery('a[href$=".pdf"]').click(function(){
        _gat._getTrackerByName()._trackEvent('Download', 'Exe', this.href);
        setTimeout('document.location = "' + this.href + '"', 100);
	return false
    });

    jQuery('a[href^="mailto:"]').click(function(){
        _gat._getTrackerByName()._trackEvent('Contact', 'Email', this.href);
        setTimeout('document.location = "' + this.href + '"', 100);
	return false
    });
	
	jQuery('a[href^="http://www.youtube.com/watch"]').each(function(idx,elem){$elem = jQuery(elem);
		var ytid = parseUri($elem.addClass('ytlbox').attr('href')).queryKey.v;
		$elem.attr('href',"http://www.youtube.com/embed/"+ytid+"?controls=0&rel=0");
		//console.log(ytid);
	});
	
	jQuery('a[href^="http://youtube.com/watch"]').each(function(idx,elem){$elem = jQuery(elem);
		var ytid = parseUri($elem.addClass('ytlbox').attr('href')).queryKey.v;
		$elem.attr('href',"http://www.youtube.com/embed/"+ytid+"?controls=0&rel=0");
		//console.log(ytid);
	});
	
	jQuery('a[href^="http://youtu.be/"]').each(function(idx,elem){$elem = jQuery(elem);
		var ytid = parseUri($elem.addClass('ytlbox').attr('href')).file;
		$elem.attr('href',"http://www.youtube.com/embed/"+ytid+"?controls=0&rel=0");
		//console.log(ytid);
	});
	
	if (jQuery().fancybox) {
		jQuery("a.ytlbox").fancybox({
			'width'				: '35%',
			'height'			: '40%',
			'autoScale'     	: false,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'type'				: 'iframe',
			onComplete	:	function(arr,idx) {
           
			_gat._getTrackerByName()._trackEvent('Video', 'Lightbox', parseUri(jQuery(arr[idx]).attr('href')).file);
		}
		});
	}
	
	// use youtube api to make them nicer
	jQuery("iframe[src^='http://www.youtube.com/embed/']").each(function(idx,elem){elem = jQuery(elem);
							var id = parseUri(elem.attr('src')).file,
							$wrap = elem.wrap("<a class='wrap' href='"+elem.attr('src')+"&rel=0'/>").parent("a.wrap");
							elem.copyCSS(['margin-left','margin-right','margin-top','margin-bottom','padding-left','padding-right','padding-top','padding-bottom'],$wrap);
							if(elem.attr('align') == 'right' || elem.attr('align') == 'left'){
							$wrap.attr(elem.attr('align'));	
							}
							jQuery.getJSON("http://gdata.youtube.com/feeds/api/videos/"+id+"?v=2&alt=jsonc&callback=?",function(res){
							$wrap.append("<img src="+res.data.thumbnail.hqDefault+" height='100%' width='100%'>");
							$wrap.append("<img src='/images/ion2011/ytplay.png' class='playbtn' style='top:"+(($wrap.height()-49)/2)+"px;left:"+(($wrap.width()-71)/2)+"px;'>");
							$wrap.find('img.playbtn').css('opacity','0.7');
							$wrap.hover(function(){ jQuery(this).find('img.playbtn').css('opacity','1'); },function(){ jQuery(this).find('img.playbtn').css('opacity','0.7'); });
							});
				
							$wrap.width(elem.width()).height(elem.height()).empty();
							elem.remove();
							});
		
							jQuery("a.wrap").fancybox({
							'width'				: '35%',
							'height'			: '40%',
        					'autoScale'     	: false,
    					    'transitionIn'		: 'none',
							'transitionOut'		: 'none',
							'type'				: 'iframe',
								onComplete	:	function(arr,idx) {
            						_gat._getTrackerByName()._trackEvent('Video', 'Lightbox', parseUri(jQuery(arr[idx]).attr('href')).file);
								}
							});
	
	//lol fixes black gackground flash
	jQuery('body').css('background-color','black');
	
	if(!jQuery('section p:eq(0)').hasClass('normal')){
		jQuery('section p:eq(0)').addClass('intro');
	}
	
	jQuery.extend( jQuery.easing, {
		easeInQuart: function ( x, t, b, c, d ) {
			return c * ( t /= d ) * t * t * t + b;
		},
		easeOutQuart: function ( x, t, b, c, d ) {
			return -c * ( ( t = t / d - 1 ) * t * t * t - 1) + b;
		},
		easeInSine: function ( x, t, b, c, d ) {
			return -c * Math.cos( t / d * ( Math.PI / 2 ) ) + c + b;
		},
		easeOutSine: function ( x, t, b, c, d ) {
			return c * Math.sin( t / d * ( Math.PI /2 ) ) + b;
		}
	});
	
	/* Shade Button Code */
	/* Shade Button Configurator */
	jQuery(".wsImage").each(function () {
		var $this = jQuery(this), myTarget = $this.parent().attr('href'), myLabel = $this.parent().attr('title'), myDescription = $this.attr('alt'), myWidth = $this.width(), myHeight = $this.height();
		$this.parent().wrap('<div class="shadebuttonwrapper" />').before('<div class="shadebuttonlabel hand" onclick="document.location=\'' + myTarget + '\'">' + myLabel + '</div>', '<div class="shadeclipper"><div class="shadebuttontab"><div class="shadebuttondesc">' + myDescription + '</div></div></div>', '<div onclick="document.location=\'' + myTarget + '\'" class="shadebuttontrigger" title=""><img src="http://www.marathon.com/images/spacer.gif" alt="" /></div>');
		$this.parent().siblings('.shadeclipper, .shadebuttontrigger').css('width', String(myWidth + 'px')).css('height', String(myHeight + 'px')).find('.shadebuttontab').css('width', String(myWidth + 'px'));
		$this.parent().siblings('.shadebuttontrigger').find('img').css('width', String(myWidth + 'px')).css('height', String(myHeight + 'px'));
		//console.log($this.parent().siblings('.shadebuttontrigger').find('img').attr('src'));
	});
	
	/* Shadebutton Watcher */
	jQuery('.shadebuttontrigger').hover(function () {
		var $this = jQuery(this);
		$this.siblings('.shadeclipper').find('.shadebuttontab').animate({ marginTop: 0 }, 125, "swing");
	}, function () {
		var $this = jQuery(this);
		$this.siblings('.shadeclipper').find('.shadebuttontab').animate({ marginTop: -99 }, 500, "swing");
	});
	
	/* Large image formatter */
	jQuery(".largeImage").each(function () {
		var $this = jQuery(this), myDescription = $this.attr('alt'), myWidth = $this.width(), myHeight = $this.height();
		$this.wrap('<div class="largeImageWrapper" style="width:'+myWidth+'px;"></div>').before('<div class="largeImageClipper"></div>');
		$this.siblings('.largeImageClipper').css('width', String(myWidth + 'px')).css('height', String(myHeight + 'px'));
		if (myDescription) $this.parent().append('<p>'+myDescription+'</p><div class="clear"></div>');
	});
	
	/* Rounded image formatter */
	jQuery(".roundedImage").each(function () {
		var $this = jQuery(this), myDescription = $this.attr('alt'), myWidth = $this.width(), myHeight = $this.height();
		$this.wrap('<div class="roundedImageWrapper" style="width:'+myWidth+'px;"></div>').before('<div class="roundedImageClipper"></div>');
		$this.siblings('.roundedImageClipper').css('width', String(myWidth + 'px')).css('height', String(myHeight + 'px'));
		if (myDescription) $this.parent().append('<p>'+myDescription+'</p><div class="clear"></div>');
	});
	
	/* Small image formatter */
	jQuery(".smallImage").each(function () {
		var $this = jQuery(this), myDescription = $this.attr('alt'), myWidth = $this.width(), myHeight = $this.height();
		$this.wrap('<div class="smallImageWrapper" style="width:'+myWidth+'px;"></div>').before('<div class="smallImageClipper"></div>');
		$this.siblings('.smallImageClipper').css('width', String(myWidth + 'px')).css('height', String(myHeight + 'px'));
		if (myDescription) $this.parent().append('<p>'+myDescription+'</p><div class="clear"></div>');
	});
	
	/* Tabbed content */
	jQuery(".tabbedContent>ul>li").click(function() {
		var $tab = jQuery(this).addClass("active");
		$tab.siblings().removeClass("active");
		$tab.parents(".tabbedContent").children("div").removeClass("active").filter(":eq("+String($tab.prevAll().length)+")").addClass("active");
	});
	
	/* Break Secondary Nav tabs to two lines */
	jQuery(".secondaryNav ul li a, #homeBanner ul li").each( function() {
		var thisText = jQuery(this).html();
		if (thisText.indexOf(' ') != -1) {
			var midPoint = Math.floor(thisText.length/2 - 1);
			var spacePos = thisText.indexOf(' ', midPoint);
			if (spacePos == -1) {
				spacePos = thisText.substring(0, midPoint).lastIndexOf(' ');
			}
			thisText = thisText.substring(0,spacePos)+'<br/>'+thisText.substring(spacePos+1);
			jQuery(this).html(thisText);
		}
	});
	
	/* Secondary Nav helper */
	jQuery(".secondaryNav ul li, nav.primaryNav ul li").click( function(event) {
		event.preventDefault();
		window.location = jQuery(this).find("a").attr("href");
	});
	
	/* Home page banner animation */
	var $banners = jQuery(".banners");
	var windowWidth = jQuery(window).width();
	var liveArea = jQuery(".content>div.pageWidth").width();
	var bannerHome = jQuery(".mainLogo").offset().left;
	var tabLoopTimer;
	
	var exitStageLeft = function() {
		jQuery("#homeBanner>div>.active>.bannerText").animate({"left":"-"+String(1.5*(980+bannerHome))+"px"}, 500, "easeInQuart", function() {jQuery(this).delay(500).css({"left":String(windowWidth+256)+"px"});});
		jQuery("#homeBanner>div>.active>.bannerImage").delay(200).animate({"left":"-"+String(1.5*(980+bannerHome))+"px"}, 500, "easeInQuart", function() {jQuery(this).delay(1000).css({"left":String(windowWidth+256)+"px"}).parent().removeClass("active");});
	}
	
	var enterStageRight = function(position) {
		$this = jQuery(".banner:eq("+position+")");
		$this.find(".bannerText").css({"left":String(windowWidth+256)+"px"}).parent().addClass("active").find(".bannerText").delay(500).animate({"left":"0px"}, 1000, "easeOutQuart");
		$this.find(".bannerImage").css({"left":String(windowWidth+256)+"px"}).parent().addClass("active").find(".bannerImage").delay(550).animate({"left":"0px"}, 1000, "easeOutQuart");
	}

	closeTab = function(indexOfTab,speed) {
		if(speed == undefined){speed = 100}
		var tab = jQuery("#homeBanner ul li:eq("+indexOfTab+")").removeClass('active');
		tab.animate({"margin-top": "0", "height": "37px"}, speed, "easeInSine", function() {
			tab.css({"background-image":"url(http://www.iongeo.com/images/ion2011/secondaryOrange.jpg)", "background-color": "#0060b8"});
		});
	}
	
	openTab = function(indexOfTab,speed) {
		if(speed == undefined){speed = 100}
		var tab = jQuery("#homeBanner ul li:eq("+indexOfTab+")").addClass('active');
		tab.css({"background-image":"url(http://www.iongeo.com/images/ion2011/secondaryBlue.jpg)", "background-color": "#0060b8"}).animate({"margin-top": "-12px", "height": "47px"}, speed,"easeOutSine");
	}
	
	shimmerTabs = function(){
		for (i=0, t=0, l=jQuery("#homeBanner ul li").length; i<l; i++, t=t+100) { setTimeout("bumptab("+String(i)+")",t);}
		setTimeout("openTab(0, 100)",750);
		tabLoopTimer = setTimeout(loopTabs,5000);
	}
	
	bumptab = function(idx){
		openTab(idx,150);
		setTimeout("closeTab("+idx+",150)",150)	
	}
	
	loopTabs = function(){
		if(shimmer++>jQuery("#homeBanner ul li").length-1){ shimmer = 0; }
		activateTab(jQuery("#homeBanner ul li:eq("+shimmer+")"));
		openTab(shimmer,300);
		tabLoopTimer = setTimeout(loopTabs,5000);				
	}
	
	var activateTab = function(tab) {
		var index = jQuery(tab).prevAll().length;
		var active = jQuery(".banner").filter(".active").prevAll().length;
		jQuery(tab).siblings().removeClass("active");
		jQuery(tab).addClass("active");
		if (index != active) {
			closeTab(active);
			exitStageLeft();
			enterStageRight(index);
		}
	}
		
	if(jQuery('body').hasClass('home')){
		setTimeout(shimmerTabs,1500);
	}
	
	jQuery("#homeBanner ul li").click( function() {
		clearTimeout(tabLoopTimer);
		activateTab(this);
	});
	
	jQuery("#homeBanner ul li").hover(
		function() {
			$this = jQuery(this).css({"background-image":"url(http://www.iongeo.com/images/ion2011/secondaryBlue.jpg)", "background-color": "#0060b8"}).animate({"margin-top": "-12px", "height": "47px"}, 100);
		},
		function() {
			if (!(jQuery(this).hasClass("active"))) {
				$this = jQuery(this).animate({"margin-top": "0", "height": "37px"}, 100, function() {
					jQuery(this).css({"background-image":"url(http://www.iongeo.com/images/ion2011/secondaryOrange.jpg)", "background-color": "#0060b8"});
				});
			}
		}
	);
	
	jQuery.fn.ionNav = function(params) { 
		this.each(function() {		
			var pageID, showPrimaryTimeout;
			
		 	switch(params.type) {
		 		case 'secondary':
		 			pageID = jQuery(this).attr("id").substring(5);
		 			break;
		 		case 'tertiary':
		 			pageID = jQuery(this).attr("id").substring(5);
		 	}	
			
			jQuery(this).bind("mouseover", function() { 
				stopTimeOut();
				switch(params.type) {
					case 'primary':
						var index = jQuery(this).prevAll().length;
						timeOuts["showPrimary"] = setTimeout(function() {
							primaryMouseOver(index);
						},500);
						break;
					case 'secondary':
						secondaryMouseOver(pageID);
						break;
					case 'tertiary':
						tertiaryMouseOver(pageID);
					case 'tertiaryContainer':
						break;
					default:			
				}
			 });
			 
			jQuery(this).bind("mouseout", function() { 
				clearTimeout(timeOuts["showPrimary"]);
				switch(params.type) {
					case 'container':
						timeOuts["mouseOut"] = setTimeout("allOff()",50);
						break;
					default:
						break;	
				}
			});
		});
	};
	
	stopTimeOut = function() {
		clearTimeout(timeOuts["mouseOut"]);
	}
	
	primaryMouseOver = function(index) {
		if (index!= activePrimary) {
			jQuery("#navArrow").hide();
			jQuery("#primaryUL>li").removeClass('hovered'); // Handle existing Primary
			jQuery("#secondaryNav>div").removeClass('hovered'); //remove any hovers on secondary nav
			jQuery("#secondaryNav>div").hide(); // Handle existing secondary
			jQuery("#tertiaryNav").hide(); // Handle existing tertiary
			jQuery("#primaryUL li:eq("+index+")").addClass('hovered'); // Handle new primary
			jQuery("#secondaryNav>div:eq("+index+")").show(); // Handle new secondary
			jQuery("#secondaryNav>div:eq("+index+")").addClass('hovered'); // Give new secondary a class
			// There is no new tertiary
			activePrimary = index;
		}
	}
	
	secondaryMouseOver = function(index) {
		if (index!= activeSecondary) {
			//console.log(index);
			jQuery("#tertiaryNav").removeClass('nonav');
			var $selted = jQuery("#ulNav"+index), width = $selted.outerWidth(), left = $selted.position().left, loff = Math.round((width-46)/2)+left;
			//console.log($selted,width,left,);
			jQuery("#navArrow").css('left',loff).show();
			
			// Existing primary is unaffected
			// Existing secondary is unaffected
			jQuery("#tertiaryNavCol>div, #tertiaryDescCol>div").hide(); // Handle existing tertiary elements
			// There is no new primary
			// There is no new secondary
			if(jQuery(".tert"+String(index)+">ul").length == 1) {
				jQuery(".tert"+String(index)).show(); // Show new tertiary navigaton
			} else {
				jQuery("#tertiaryNav").addClass('nonav');
			}
			jQuery(".d"+String(index)).show(); // Show new secondary description
			jQuery("#tertiaryImgCol img").attr('src', 'http://www.iongeo.com/images/ion2011/ddimages/'+index+'.jpg'); // Show new secondary image
			jQuery("#tertiaryNav").show(); // Show the tertiary nav container
			activeSecondary = index;
		}
	}
	
	tertiaryMouseOver = function(index) {
		if (index!= activeTertiary) {
			// Existing primary is unaffected
			// Existing secondary is unaffected
			jQuery("#tertiaryDescCol>div").hide(); // Handle existing description
			// There is no new primary
			// There is no new secondary
			jQuery(".d"+String(index)).show(); // Show new tertiary description
			activeTertiary = index;
		}
	}
	
	allOff = function() {	
		secondaryOff(activePrimary);
		allTertiaryOff();
	}
	
	var secondaryOff = function(index) {
		jQuery("#navArrow").fadeOut(350);
		jQuery("#tertiaryNav").removeClass('nonav');
		jQuery("#secondaryNav>div").removeClass('hovered'); //remove any hovers on secondary nav
		jQuery("#primaryUL>li").removeClass('hovered');
		jQuery("#secondaryNav>div").fadeOut(350);
		activePrimary = -1;
		activeSecondary = -1;
		
	}
	
	var tertiaryOff = function(index) {
		jQuery(".tert"+String(index)).fadeOut(350);
		jQuery(".d"+String(index)).fadeOut(350);
		//jQuery("#ulNav"+String(index)).removeClass('hovered');
		activePrimary = -1;
	}
	
	var allTertiaryOff = function() { 
		jQuery("#tertiaryNav").fadeOut(350);
	
	}
	
	
	activateRollovers = function() {
		// This conditional is here because sometimes browsers try and run this bit before elements have their offset top and left defined
		if (jQuery("#primaryUL>li:eq(0)").offset().left != jQuery("#primaryUL>li:eq(1)").offset().left) {
			jQuery(".primaryNav").ionNav({type: 'container'});
			jQuery("#primaryUL>li").ionNav({type: 'primary'});
			jQuery("#secondaryNav>div>ul>li").ionNav({type: 'secondary'});
			jQuery("#secondaryNav>div").ionNav({type: 'secondaryContainer'});
			jQuery("#tertiaryNav>div").ionNav({type: 'tertiaryContainer'});
			jQuery("#tertiaryNavCol>div>ul>li").ionNav({type: 'tertiary'});
			jQuery("#hidetertiary").click(allOff); // hide the nav if bottom arrow clicked
		} else {
			setTimeout("activateRollovers()", 100);
		}
	};
	
	jQuery(".timeOutKiller, .timeOutKiller ul").bind("mouseover", function() {
		stopTimeOut();
	});
	
	activateRollovers();
	
	updateResourceList = function() {
		jQuery(".resourceList>li").show();
		jQuery(".filterGroup:visible").each( function() {
			// If there is something selected in this list
			var filters = [];
			if (jQuery(this).find(".trigger.active").length > 0) {
				jQuery(this).find(".clearFilter").show();
				jQuery(this).find(".trigger.active").each( function() {
					filters.push(jQuery(this).text());
				});
				jQuery(".resourceList>li").each( function() {
					var match = false;
					for (i=0, count = filters.length;i<count;i++) {
						if (jQuery(this).hasClass(filters[i])) match = true;	
					}
					if (match == false) jQuery(this).hide();
				});
			} else {
				jQuery(this).find(".clearFilter").hide();		
			}
		});
		jQuery(".resourceList>li:visible").length == 0 ? jQuery("#noMatch").show() : jQuery("#noMatch").hide();	
	}
	
	drawFilter = function() {
		jQuery(".filterGroup").each( function() {
			jQuery(this).find(".trigger").each( function() {
				$this = jQuery(this);
				if (jQuery(".resourceList>li."+$this.text()).length == 0) {
					$this.hide();
				} else {
					$this.bind("click", function() { 
						$this = jQuery(this);
						$this.toggleClass('active');
						updateResourceList();
					});
				}
			});
			jQuery(this).find(".clearFilter").bind("click", function() {
				$this = jQuery(this);
				$this.siblings(".trigger").removeClass("active");
				updateResourceList();
			});
			if ((jQuery(this).find("div:visible").length) <=1 ) {
				jQuery(this).hide();
			}
		});
	}
	
	jQuery("#filter").each( function() {
		drawFilter();
	});
	
});

var resizeText = function (size) {   
  	var myCookie = jQuery.cookie('fontSize', size); 
  	redrawFonts(size);
} 

var redrawFonts = function(size) {
	$body = jQuery("body").removeClass('resize0');
	$body.removeClass('resize1');
	$body.removeClass('resize2');
	$body.addClass('resize' + String(size));
	
	jQuery("#resizeSmallTool").removeClass('active');
	jQuery("#resizeMediumTool").removeClass('active');
	jQuery("#resizeLargeTool").removeClass('active');
	//turn on the right one
	switch (size)
	{
		case 0:
		jQuery("#resizeSmallTool").addClass('active');
		break;
		case 1:
		jQuery("#resizeMediumTool").addClass('active');
		break;
		case 2:
		jQuery("#resizeLargeTool").addClass('active');
		break;
		default:
		//jQuery("#resizeMediumTool").addClass('active');
	}
	
	
	
}


var emailPage = function() {
	temploc='/About_Us/Email_Page/?myURL=';
	if(jQuery('body').hasClass('samstaging')){
		temploc='/ion2011staged/'+temploc;
	}
	temploc = temploc + window.location.href.replace(/\&/, '%26').replace(/\?/, '%3F');
	window.location.href = temploc;
}

var printPage = function() {
	window.print();
}

/*jslint browser: true */ /*global jQuery: true */

/**
 * jQuery Cookie plugin
 *
 * Copyright (c) 2010 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */

// TODO JsDoc

/**
 * Create a cookie with the given key and value and other optional parameters.
 *
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Set the value of a cookie.
 * @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
 * @desc Create a cookie with all available options.
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Create a session cookie.
 * @example $.cookie('the_cookie', null);
 * @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
 *       used when the cookie was set.
 *
 * @param String key The key of the cookie.
 * @param String value The value of the cookie.
 * @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
 * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
 *                             If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
 *                             If set to null or omitted, the cookie will be a session cookie and will not be retained
 *                             when the the browser exits.
 * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
 * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
 * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
 *                        require a secure protocol (like HTTPS).
 * @type undefined
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */

/**
 * Get the value of a cookie with the given key.
 *
 * @example $.cookie('the_cookie');
 * @desc Get the value of a cookie.
 *
 * @param String key The key of the cookie.
 * @return The value of the cookie.
 * @type String
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */
jQuery.cookie = function (key, value, options) {
    // key and at least value given, set cookie...
    if (arguments.length > 1 && String(value) !== "[object Object]") {
        options = jQuery.extend({}, options);

        if (value === null || value === undefined) {
            options.expires = -1;
        }

        if (typeof options.expires === 'number') {
            var days = options.expires, t = options.expires = new Date();
            t.setDate(t.getDate() + days);
        }
        
        value = String(value);
        
        return (document.cookie = [
            encodeURIComponent(key), '=',
            options.raw ? value : encodeURIComponent(value),
            options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
            options.path ? '; path=' + options.path : '',
            options.domain ? '; domain=' + options.domain : '',
            options.secure ? '; secure' : ''
        ].join(''));
    }

    // key and possibly options given, get cookie...
    options = value || {};
    var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
    return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
};

	
jQuery(document).ready(function(){
	jQuery(".thickboxcust").bind("click", function(e){
		e.preventDefault();
		var url = jQuery(this).attr("href");
		tb_show('',url+'?KeepThis=true&amp;TB_iframe=true&amp;height=580&amp;width=570');
	});
							
	jQuery(".thickboxAR").bind("click", function(e){
		e.preventDefault();
		var url = jQuery(this).attr("href");
		tb_show('',url+'?KeepThis=true&amp;TB_iframe=true&amp;height=470&amp;width=670');
	});
	
	 if (jQuery.cookie('fontSize') === null) {
        resizeText(1);
		//alert('dint find a cookie');
    } else {
        redrawFonts(Number(jQuery.cookie('fontSize')));
		
    }
	
});
