
	





	
		
			
			








/* /////////////////////////////////////////
	ONREADY ACTIONS
*/
$(function() {

	// User state for tip top toolbar
	var profiledata = $.fn.daccount("getValues"); // Assigns the entire REST object to the profiledata variable.
	if ($.fn.daccount("isGuest")) {
		$("#user-state a").html("Login").attr("href","/content/system/modules/com.dispatch.registration/pages/login.jsp");
		$("#user-state").fadeIn();
	} else {
		$("#user-state a").html("Logout").attr("href","/content/system/modules/com.dispatch.registration/pages/logout.jsp");
		$("#user-state a").before('<a href="/content/system/modules/com.dispatch.registration/pages/edit-profile.jsp" class="logged-in">My account</a>');
		$("#user-state").fadeIn();
	}


	// Footer affiliate dropdown submit
	$("#affiliate-list-go").click(function() {
		document.location = $("#affiliate-list").val();
	});
	
	// Story tools
	$("#printstory").click(function() {
		window.print();
	});
	
	// Header search change on click, remove 'Keywords' default and colorize
	
	// Find forms and attach validation
	var formExists = $("form.validate-form");
	if (formExists.length > 0) { formExists.validate(); }
	
	// Attach overlay play to video thumbnails, sets thumbnail as background and main image as PNG with play button
	$("img.video-thumbnail").each(function(pos) {
		var x_img     = $(this);
		x_img.css("background","url('"+x_img.attr("src")+"') center center no-repeat");
		x_img.attr("src","/content/digital/images/video-thumbnail-play.png");		
	});
	
	
	// Attach lightbox to images, check to see if lightbox has been included before running settings
	if( jQuery.isFunction(jQuery.fn.lightBox) ){
		$('a[rel=lightbox]').lightBox({
			imageLoading : '/content/system/shared/img/lightbox/lightbox-ico-loading.gif',
			imageBtnClose : '/content/system/shared/img/lightbox/lightbox-btn-close.gif',
			imageBtnPrev : '/content/system/shared/img/lightbox/lightbox-btn-prev.gif',
			imageBtnNext : '/content/system/shared/img/lightbox/lightbox-btn-next.gif'
		});
	}	
	
	$("body").addClass("skyline");
});
		
			
			

/*
* Version 1.1 20100708 MP
* Requires jQuery 1.5 and the jQuery template plugin (http://api.jquery.com/category/plugins/templates/)
*
* This plugin has 3 methods.
* - The default method outputs the currently logged in user's account data
* (everything that is exposed by the OpenCMS registration rest API - http://sp10prod/divisions/dispatch_it_web/Redtail%20Wiki/Registration%20Module.aspx)
* in a named jquery template. You can pass this method the name of a named template (there are 6 defined in the plugin - see the documentation).
* 
* - 'getValues' takes no parameters and outputs the profiledata object returned by the rest api.
*
* - 'isGuest' returns true if the user is currently a guest, false if the user is logged in to a registered account. Takes no parameters.
*
* Version 1.1 -- added a callback to the init function and a custom template for the dispatch toobar.
* Version 1.2 -- added caching of account data to avoid repeated calls.
*
*/

(function( $ ){


  // set the cms-link-tagged uri base (all methods below use the same one).
  var globalPostUri = "/content/system/modules/com.dispatch.registration/rest/user";
  
  var userProfile = {};

  var methods = {

    init : function( options ) {

      var tmpmarkup = '<div class="dAccount"><p class="monikers"><span class="realname">{{= firstname}} {{= lastname}}</span> <span class="username">({{= login}})</span></p><p class="email">{{= email}}</p><p class="zipcode">{{= zipcode}}</p><p class="dates">Account Created: <span class="createddate">{{= createddate}}</span> | Last Login: <span class="lastlogin">{{= lastlogin}}</span></p></div>';
      $.template("dAccountDefault", tmpmarkup);
      
      tmpmarkup = '<div class="dAccount"><p class="monikers"><span class="realname">{{= firstname}} {{= lastname}}</span> <span class="username">({{= login}})</span></p><p class="email">{{= email}}</p><p class="zipcode">{{= zipcode}}</p></div>';
      $.template("dAccountNameAndEmail", tmpmarkup);
      
      tmpmarkup = '<div class="dAccount"><p class="monikers"><span class="realname">{{= firstname}} {{= lastname}}</span> <span class="username">({{= login}})</span></p></div>';
      $.template("dAccountName", tmpmarkup);
      
      tmpmarkup = '<div class="dAccount"><p class="username">{{= login}}</p></div>';
      $.template("dAccountUsername", tmpmarkup);
      
      tmpmarkup = '<span class="realname">{{= firstname}} {{= lastname}}</span> <span class="username">({{= login}})</span>';
      $.template("dAccountNameInline", tmpmarkup);
      
      tmpmarkup = '<span class="username">{{= login}}</span>';
      $.template("dAccountUsernameInline", tmpmarkup);
      
      var settings = {
        'template' : 'dAccountDefault',
        'posturi'  : globalPostUri,
        'ifLoggedIn'  : true,
        'loggedOutAlt' : false,
        'loggedOutHTML' : '',
        'clearfirst' : false,
        'callback'  : ''
        
      }
      
      if ( options ) { 
        $.extend( settings, options );
      }

      return this.each(function() {

        var $this = $(this);
        
        if (!userProfile.hasOwnProperty('login')) {
        
          var cachebust = Math.round(new Date().getTime() / 1000);
        
          $.ajax({
            type: "GET",
            jsonp: null,
            jsonpCallback: null,
            url: settings.posturi,
            async: false,
            data: {
            	z : cachebust
            },
            dataType: "json",
            success: function (accountdata) {
              if ((accountdata.login != "Guest" && settings.ifLoggedIn) ||  !settings.ifLoggedIn) {
                if (settings.clearfirst) {
                  $this.html('');
                }
                $.tmpl(settings.template, accountdata).appendTo($this);
                userProfile = accountdata;
              }
              if(typeof settings.callback == 'function'){
                //settings.callback.call(accountdata.login);
                settings.callback(accountdata.login);
              }
            }
          });
        
        } else {
          $.tmpl(settings.template, userProfile).appendTo($this);
        }
        
      });
    },
    getValues : function (options) {
      
      var settings = {
        'posturi'  : globalPostUri
      }
      
      if ( options ) { 
        $.extend( settings, options );
      }
      
      if (!userProfile.hasOwnProperty('login')) {
      
        var cachebust = Math.round(new Date().getTime() / 1000);
        
        var profiledata;
        
        $.ajax({
            type: "GET",
            async: false,
            url: settings.posturi,
            jsonp: null,
            jsonpCallback: null,
            data: {
            	z : cachebust
            },
            dataType: "json",
            success: function (accountdata) {
              profiledata = accountdata;
              userProfile = accountdata;
            }
          });
      
      } else {
        profiledata = userProfile;
      }
        
      return profiledata;
      
    },
    isGuest : function (options) {
      
      var settings = {
        'posturi'  : globalPostUri
      }
      
      if ( options ) { 
        $.extend( settings, options );
      }
      
      var loggedasguest;
      
      if (!userProfile.hasOwnProperty('login')) {
      
        var cachebust = Math.round(new Date().getTime() / 1000);
        
        $.ajax({
            type: "GET",
            async: false,
            url: settings.posturi,
            jsonp: null,
            jsonpCallback: null,
            data: {
            	z : cachebust
            },
            dataType: "json",
            success: function (accountdata) {
              if (accountdata.login == "Guest") {
                loggedasguest = true;
              } else {
                loggedasguest = false;
              }
              userProfile = accountdata;
            }
          });
          
        } else {
        
          if (userProfile.login == "Guest") {
            loggedasguest = true;
          } else {
            loggedasguest = false;
          }
        
        }
      
      return loggedasguest;
    } 
  }

  $.fn.daccount = function ( method ) {

    if ( methods[method] ) {
      return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ));
    } else if ( typeof method === 'object' || ! method ) {
      return methods.init.apply( this, arguments );
    } else {
      $.error( 'Method ' +  method + ' does not exist.' );
    }
  }
})( jQuery );
		
			
			









(function( $ ){
    var methods = {
        init : function(options) {
            // Default settings
			var settings = {
				"videoComponent"    : "Video Player Component", // Name of KA video player component (required)
				"videoUrl"          : false, // URL of video XML (required)
				"playlists"         : false, // Array of playlists (optional)
				"prerollUrl"        : false, // URL of RealMedia ad (optional)
				"omniture"          : false, // Name for Omniture tracking, friendly name (optional)
				"custom"            : false, // Optional objects for other components
				"debug"             : false // Turn on debug
			}
            
            // Override/combine variables with any that have been passed
			if (options) { $.extend(settings, options); }
	               
			// Debug console logging, local to plugin only
			debug = function(str) {
				if (settings.debug) {
					var s = new String(str); s = s+"<br />"; $("#video-plugin-debug").append(s);
				} 
			}
			
			isExternalUrl = function(str) {
				var isExternal    = str.indexOf("http");
				
				if (isExternal < 0) {
	            			isExternal = str.indexOf("rtmp");
	            		}
			
				debug("isExternalUrl: "+isExternal);
			
				return(isExternal);
			}	
		
			
            
            // Handling of targeted element
            return this.each(function() { 
            	var $this = $(this); // $this contains the element you called the plugin on and has all JQ functions

            	

				// Add debug DIV if turned on
				if (settings.debug) {
					$this.append('<pre id="video-plugin-debug" style="position:absolute;top:0;left:0;background-color:#ffc;z-index:99;"></pre>');
					$("#video-plugin-debug").click(function() { $("#video-plugin-debug").html(""); });
					debug("---- DEBUG CONSOLE IS ON");
				}
				
				// Get OBJECT element and get ID for later use
				var widgetId = $this.find("object").attr("id");
				debug("Widget ID: "+widgetId);
				
				// Check browser to handle doc object accordingly.
				var s_browserAgent = navigator.userAgent;
				if ((s_browserAgent.indexOf("Chrome") > 0) || (s_browserAgent.indexOf("Safari") > 0) || (s_browserAgent.indexOf("MSIE") > 0)) {
					o_player  = window[widgetId];
				} else {
					o_player  = document[widgetId];
				}				
						
				// Set video XML on player and playlist, overwrites any baked into object
				
				if (settings.videoUrl) {
					if (isExternalUrl(settings.videoUrl) < 0) {
						settings.videoUrl = "http://www.onntv.com"+settings.videoUrl;
					}
					
					o_player.setComponentProperty(settings.videoComponent, "mediaURL", settings.videoUrl);

					debug("videoComponent: "+settings.videoComponent);
					debug("videoURL: "+settings.videoUrl);					
					
					// Only process playlists if exists, overwrites any baked into object
					if (settings.playlists) {
						debug("Number of playlists: "+settings.playlists.length);
						for (i=0; i < settings.playlists.length; i++) {
							var s_playlistComponent =  settings.playlists[i]["componentName"];
							var s_playlistFeedUrl   =  settings.playlists[i]["feedUrl"];
							
							if (isExternalUrl(s_playlistFeedUrl) < 0) {
					        		s_playlistFeedUrl = "http://www.onntv.com"+s_playlistFeedUrl;
							}
					            	
							debug("playlistComponent "+i+": "+s_playlistComponent);
					        	debug("playlistUrl "+i+": "+s_playlistFeedUrl);					            	
					            	
					        	o_player.setComponentProperty(s_playlistComponent, "mediaURL", s_playlistFeedUrl);
						
						} // END playlist loop
					}
				}
				
				// Omniture settings, overwrites in-widget settings
				if (settings.omniture) {
					debug ("Omniture tracking is ON");
				
					for (var propertyName in settings.omniture) {
						if (settings.omniture.hasOwnProperty(propertyName)) {
							var omnitureProperty      = propertyName;
							var omniturePropertyValue = settings.omniture[propertyName];
							
							o_player.setComponentProperty("AppContainer", omnitureProperty, omniturePropertyValue);
							
							debug ("Setting: "+omnitureProperty+" = "+omniturePropertyValue);
						}
					}					
				} else {
					debug ("Omniture tracking is OFF");
				}			
					
				
				// Set preroll URL if exists, overwrites any baked into object
				if (settings.prerollUrl) {
					debug("prerollUrl: "+settings.prerollUrl);
					
					o_player.setComponentProperty(settings.videoComponent, "twentyFourSevenAdTag", settings.prerollUrl);
				}
				
				// Set custom component values if specified
				if (settings.custom) {
					debug ("Custom components found");
					
					for (i=0; i < settings.custom.length; i++) {
						var o_custom = settings.custom[i];
						
						if (o_custom["componentName"] && o_custom["propertyName"] && o_custom["value"]) {
							o_player.setComponentProperty(o_custom["componentName"], o_custom["propertyName"], o_custom["value"]);
							
							debug (i+": componentName: "+o_custom["componentName"]);
							debug (i+": propertyName: "+o_custom["propertyName"]);
							debug (i+": value: "+o_custom["value"]);							
						}
					}
				}				

            }); // End each()
            
        }   // END init()

    }; // END methods

    // Plugin namespace and attachment
    $.fn.kickappsVideo = function( method ) {
            if ( methods[method] ) {
                    return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 ));
            } else if ( typeof method === 'object' || ! method ) {
                    return methods.init.apply( this, arguments );
            } else {
                    $.error( 'Method ' +  method + ' does not exist on jQuery.kickappsVideo ' );
            }    

    };
})(jQuery);
		
			
			










/* ONREADY */
	$(function() {
		$("#interests-content li:odd").addClass("alt");
	});

/*	///////////////////////////////////////////////////////////////
	FAVORITES/RATINGS/COMMENTS
*/

		function removeFavorite(aObj, id) {
			$(aObj).parent().fadeOut();

			jQuery.ajax({
				type:'POST',
				url:'/content/system/modules/com.dispatch.favorites/rest/deleteFavorite/index.jsp',
				data:'r='+id,
				success: function() {
					//alert("You've removed this favorite.");
				}
			});	
	
		}
		
		function changeRating(aObj, id, rating) {
			var o_stars = $(aObj).parent().parent().find("li");
			var i_stars = 1;
			
			o_stars.each(function(index) {
				if (i_stars <= rating) {
					$(this).removeClass("rating-off").addClass("rating-on");
				} else {
					$(this).removeClass("rating-on").addClass("rating-off");
				}
				
				i_stars++;
			});
			
			jQuery.ajax({
				type:'POST',
				url:'/content/system/modules/com.dispatch.favorites/rest/addRating/index.jsp',
				data:'r='+id+'&rating='+rating,
				success: function() {
					//alert("You've altered this rating.");
				}
			});	
		}


/*	///////////////////////////////////////////////////////////////
	INTERESTS
*/
	function interestOn(aObj, id) {
		$(aObj).parent().removeClass("not-interested").addClass("interested");
		jQuery.ajax({
			type:'POST',
			url:'/content/system/modules/com.dispatch.exacttarget/rest/addInterest/index.jsp',
			data:'iid='+id,
			success: function() {
				//alert("You've been subscribed from this newsletter.");
			}
		});	
	}
	
	function interestOff(aObj, id) {
		$(aObj).parent().removeClass("interested").addClass("not-interested");
		jQuery.ajax({
			type:'POST',
			url:'/content/system/modules/com.dispatch.exacttarget/rest/removeInterest/index.jsp',
			data:'iid='+id,
			success: function() {
				//alert("You've been unsubscribed from this newsletter.");
			}
		});	
	}
	



/*	///////////////////////////////////////////////////////////////
	NEWSLETTERS & ALERTS
*/
		
		
		function newsletterSubscribe(id) {
			$('#newsletters-content input[value="'+id+'"]').attr("checked","checked");
		
			jQuery.ajax({
				type:'POST',
				url:'/content/system/modules/com.dispatch.exacttarget/rest/subscribe/index.jsp',
				data:'nid=' + id,
				success: function() {
					//alert("You've been subscribed from this newsletter.");
					newsletterSubmitToggle();
					
				}
			});	
		}
		
		function newsletterUnsubscribe(id) {
			$('#newsletters-content input[value="'+id+'"]').attr("checked","");
		
			jQuery.ajax({
				type:'POST',
				url:'/content/system/modules/com.dispatch.exacttarget/rest/unsubscribe/index.jsp',
				data:'nid=' + id,
				success: function() {
					newsletterSubmitToggle();
					//alert("You've been unsubscribed from this newsletter.");
				}
			});	
		}
		
		function newsletterSubmitToggle() {
			newsletterToggleMgr = (newsletterToggleMgr - 1);
			
			if (newsletterToggleMgr <= 0) {
				$('#newsletters-content input[type="submit"]').attr("disabled","").attr("value","Save changes");
			}
		}
		
		var newsletterToggleMgr = 0;
		function newsletterChange(inputObj) {
			var o_input = $(inputObj);
			var b_add   = o_input.attr("checked");
			var id      = o_input.attr("value");
			var match   ='input[value="'+id+'"]';
			
			newsletterToggleMgr++;
			$('#newsletters-content input[type="submit"]').attr("disabled","disabled").attr("value","Please wait...");

			if (b_add) {
				newsletterSubscribe(id);
			} else {
				newsletterUnsubscribe(id);
			}
		}		
		
			
			jQuery.url=function(){var segments={};var parsed={};var options={url:window.location,strictMode:false,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}};var parseUri=function(){str=decodeURI(options.url);var m=options.parser[options.strictMode?"strict":"loose"].exec(str);var uri={};var i=14;while(i--){uri[options.key[i]]=m[i]||""}uri[options.q.name]={};uri[options.key[12]].replace(options.q.parser,function($0,$1,$2){if($1){uri[options.q.name][$1]=$2}});return uri};var key=function(key){if(!parsed.length){setUp()}if(key=="base"){if(parsed.port!==null&&parsed.port!==""){return parsed.protocol+"://"+parsed.host+":"+parsed.port+"/"}else{return parsed.protocol+"://"+parsed.host+"/"}}return(parsed[key]==="")?null:parsed[key]};var param=function(item){if(!parsed.length){setUp()}return(parsed.queryKey[item]===null)?null:parsed.queryKey[item]};var setUp=function(){parsed=parseUri();getSegments()};var getSegments=function(){var p=parsed.path;segments=[];segments=parsed.path.length==1?{}:(p.charAt(p.length-1)=="/"?p.substring(1,p.length-1):path=p.substring(1)).split("/")};return{setMode:function(mode){strictMode=mode=="strict"?true:false;return this},setUrl:function(newUri){options.url=newUri===undefined?window.location:newUri;setUp();return this},segment:function(pos){if(!parsed.length){setUp()}if(pos===undefined){return segments.length}return(segments[pos]===""||segments[pos]===undefined)?null:segments[pos]},attr:key,param:param}}();
		
			
			



var dPoll = {
	 // Sends messages to console when true

	// Sends messages to console
	"debug" : function(str) {
		// if (window.console && console.log) { console.log(str); }
	},


	// Setup poll, stores in data() for cases of multiple polls per page
	"ini" : function(pollId, pollUri, multiVote, custom) {
		this.debug("--- dPoll:ini");

		// Create settings object from arguments
		var settings = {
			pollCssId : "#"+pollId,
			pollUri   : pollUri,
			multiVote : multiVote,
			pollId    : pollId
		}
		
		// Add in any custom settings
		$.extend(settings, custom);

		// Store settings unique to poll ID (unique per page load)	
		$("body").data(pollId, settings);


		// Check cookie for poll, unique to poll URI so it follows around the site
		var historyCookie = readCookie(pollUri);
		if (historyCookie && !multiVote) {
			this.debug("cookie for "+pollUri+" exists, just display results");
			this.getResults(settings);
		} else {
			// Display the form if not displaying graphcs on load. This avoid DOM flicker.
			$(settings.pollCssId+" .poll-options").show(); 
		}	
	},
	

	
	// Get results for selected poll
	"getResults": function(settings) {
		this.debug("--- getResults");

		// Call REST to get results for poll
		$.ajax({
			url: "/content/system/modules/com.dispatch.polling/rest/results?poll="+settings.pollUri,
			dataType: "json",
	  		success: function(data){
	  			dPoll.handleResults(data,settings.pollId);
			}
		});	
	},	
	
	
	// Handle poll vote submit
	"submitPoll": function(submit) {
		this.debug("--- submitPoll");
		
		var pollId    = $(submit).parents("form").attr("id");
		var settings  = $("body").data(pollId);
		var voteValue = $(settings.pollCssId+" .poll-options input:checked").val();
	
		this.debug(settings.pollCssId+" .poll-options input:checked");
		this.debug($(settings.pollCssId+" .poll-options input:checked"));
		this.debug("voting for "+voteValue);
	
		if (!settings.multiVote) {
			this.debug("setting cookie as "+settings.pollUri);
			createCookie(settings.pollUri,"voted",1);
		}
		
		
		$.ajax({
			url: "/content/system/modules/com.dispatch.polling/rest/vote?poll="+settings.pollUri+"&choice="+voteValue,
			dataType: "json",
	  		success: function(data){
	  			dPoll.handleResults(data,pollId);
			}
		});
		
	},
	
	
	// Success function for REST calls. Displays results or handles custom settings.
	"handleResults" : function(json, pollId) {
		this.debug("--- handleResults");
		
		var settings = $("body").data(pollId); // Get settings
		
		if (!settings.hideResults) {
    			this.displayResults(json, settings);
    		} else {
    			this.hiddenResults(settings);
    		}	
	},	
	
	
	// If custom hide is set, don't display graphs and show defined message
	"hiddenResults" : function(settings) {
		this.debug("--- hideResults");
		
		$(settings.pollCssId).find(".poll-detail").html('<div class="poll-message">'+settings.hideResults+'</div>');
	},
	
	
	// Display results, uses JSON load from submitPoll() or getResults()
	"displayResults" : function(json, settings) {
		this.debug("--- displayResults");
		
		var pollElement = $(settings.pollCssId);
			
		if (json["result"] == "error") {
			this.debug("ERROR");
			
			pollElement.find(".poll-detail").html('<div class="poll-error">'+json["message"]+'</div>');
		} else {
			this.debug("Displaying results graphs");
			
			
			
			// Go through data and round percentage. Look at custom settings for rounding rules.
			if (!settings.roundToDecimal) {	settings.roundToDecimal = 0; }

			$.each(json["choices"], function(k, pollData) { 
				//alert(index + ': ' + value); 
				pollData.percent = Math.round(pollData.percent*Math.pow(10,settings.roundToDecimal))/Math.pow(10,settings.roundToDecimal);
				  
				json["choices"][k] = pollData;  
			});
			
			this.debug(json);

			
			// Build template, apply template to poll data			
			var resultTmpl = '<li><div class="graph-container"><div class="graph"></div></div><div class="option-name">{{= text}}</div><div class="option-votes">{{= percent}}%</div></li>';
			$.template("pollResultRow", resultTmpl);		
		
			pollElement.find(".poll-detail").html('<ul class="poll-results"></ul>');
		
			$.tmpl("pollResultRow", json["choices"]).appendTo(pollElement.find("ul")); // Loops through JSON and out to template
			
			// If there is a 'withResults' string, append it to the container div here (inside of poll-message) MP 20111031
			if (settings.withResults) {
				$(settings.pollCssId).find(".poll-detail").append('<div class="poll-message">'+settings.withResults+'</div>');
			}
			
			// Animates graphcs from left to right
			var rows = pollElement.find(".graph");
			for (a=0; a < rows.length; a++) {
				var i_percent = json["choices"][a]["percent"];
				if (i_percent >= 100) { i_percent = 99; }
				
				var graph      = $(rows[a]);
				var graphWidth = i_percent+"%";
				
				graph.animate({paddingLeft:graphWidth},"slow"); 
			}
		}			
	}
		
	
} // END class
		
			
			











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);
}
		
			
			/*
* jQuery Templates Plugin 1.0.0pre
* http://github.com/jquery/jquery-tmpl
* Requires jQuery 1.4.2
*
* Copyright Software Freedom Conservancy, Inc.
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*/
(function(a){var r=a.fn.domManip,d="_tmplitem",q=/^[^<]*(<[\w\W]+>)[^>]*$|\{\{\! /,b={},f={},e,p={key:0,data:{}},i=0,c=0,l=[];function g(g,d,h,e){var c={data:e||(e===0||e===false)?e:d?d.data:{},_wrap:d?d._wrap:null,tmpl:null,parent:d||null,nodes:[],calls:u,nest:w,wrap:x,html:v,update:t};g&&a.extend(c,g,{nodes:[],parent:d});if(h){c.tmpl=h;c._ctnt=c._ctnt||c.tmpl(a,c);c.key=++i;(l.length?f:b)[i]=c}return c}a.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(f,d){a.fn[f]=function(n){var g=[],i=a(n),k,h,m,l,j=this.length===1&&this[0].parentNode;e=b||{};if(j&&j.nodeType===11&&j.childNodes.length===1&&i.length===1){i[d](this[0]);g=this}else{for(h=0,m=i.length;h<m;h++){c=h;k=(h>0?this.clone(true):this).get();a(i[h])[d](k);g=g.concat(k)}c=0;g=this.pushStack(g,f,i.selector)}l=e;e=null;a.tmpl.complete(l);return g}});a.fn.extend({tmpl:function(d,c,b){return a.tmpl(this[0],d,c,b)},tmplItem:function(){return a.tmplItem(this[0])},template:function(b){return a.template(b,this[0])},domManip:function(d,m,k){if(d[0]&&a.isArray(d[0])){var g=a.makeArray(arguments),h=d[0],j=h.length,i=0,f;while(i<j&&!(f=a.data(h[i++],"tmplItem")));if(f&&c)g[2]=function(b){a.tmpl.afterManip(this,b,k)};r.apply(this,g)}else r.apply(this,arguments);c=0;!e&&a.tmpl.complete(b);return this}});a.extend({tmpl:function(d,h,e,c){var i,k=!c;if(k){c=p;d=a.template[d]||a.template(null,d);f={}}else if(!d){d=c.tmpl;b[c.key]=c;c.nodes=[];c.wrapped&&n(c,c.wrapped);return a(j(c,null,c.tmpl(a,c)))}if(!d)return[];if(typeof h==="function")h=h.call(c||{});e&&e.wrapped&&n(e,e.wrapped);i=a.isArray(h)?a.map(h,function(a){return a?g(e,c,d,a):null}):[g(e,c,d,h)];return k?a(j(c,null,i)):i},tmplItem:function(b){var c;if(b instanceof a)b=b[0];while(b&&b.nodeType===1&&!(c=a.data(b,"tmplItem"))&&(b=b.parentNode));return c||p},template:function(c,b){if(b){if(typeof b==="string")b=o(b);else if(b instanceof a)b=b[0]||{};if(b.nodeType)b=a.data(b,"tmpl")||a.data(b,"tmpl",o(b.innerHTML));return typeof c==="string"?(a.template[c]=b):b}return c?typeof c!=="string"?a.template(null,c):a.template[c]||a.template(null,q.test(c)?c:a(c)):null},encode:function(a){return(""+a).split("<").join("&lt;").split(">").join("&gt;").split('"').join("&#34;").split("'").join("&#39;")}});a.extend(a.tmpl,{tag:{tmpl:{_default:{$2:"null"},open:"if($notnull_1){__=__.concat($item.nest($1,$2));}"},wrap:{_default:{$2:"null"},open:"$item.calls(__,$1,$2);__=[];",close:"call=$item.calls();__=call._.concat($item.wrap(call,__));"},each:{_default:{$2:"$index, $value"},open:"if($notnull_1){$.each($1a,function($2){with(this){",close:"}});}"},"if":{open:"if(($notnull_1) && $1a){",close:"}"},"else":{_default:{$1:"true"},open:"}else if(($notnull_1) && $1a){"},html:{open:"if($notnull_1){__.push($1a);}"},"=":{_default:{$1:"$data"},open:"if($notnull_1){__.push($.encode($1a));}"},"!":{open:""}},complete:function(){b={}},afterManip:function(f,b,d){var e=b.nodeType===11?a.makeArray(b.childNodes):b.nodeType===1?[b]:[];d.call(f,b);m(e);c++}});function j(e,g,f){var b,c=f?a.map(f,function(a){return typeof a==="string"?e.key?a.replace(/(<\w+)(?=[\s>])(?![^>]*_tmplitem)([^>]*)/g,"$1 "+d+'="'+e.key+'" $2'):a:j(a,e,a._ctnt)}):e;if(g)return c;c=c.join("");c.replace(/^\s*([^<\s][^<]*)?(<[\w\W]+>)([^>]*[^>\s])?\s*$/,function(f,c,e,d){b=a(e).get();m(b);if(c)b=k(c).concat(b);if(d)b=b.concat(k(d))});return b?b:k(c)}function k(c){var b=document.createElement("div");b.innerHTML=c;return a.makeArray(b.childNodes)}function o(b){return new Function("jQuery","$item","var $=jQuery,call,__=[],$data=$item.data;with($data){__.push('"+a.trim(b).replace(/([\\'])/g,"\\$1").replace(/[\r\t\n]/g," ").replace(/\$\{([^\}]*)\}/g,"{{= $1}}").replace(/\{\{(\/?)(\w+|.)(?:\(((?:[^\}]|\}(?!\}))*?)?\))?(?:\s+(.*?)?)?(\(((?:[^\}]|\}(?!\}))*?)\))?\s*\}\}/g,function(m,l,k,g,b,c,d){var j=a.tmpl.tag[k],i,e,f;if(!j)throw"Unknown template tag: "+k;i=j._default||[];if(c&&!/\w$/.test(b)){b+=c;c=""}if(b){b=h(b);d=d?","+h(d)+")":c?")":"";e=c?b.indexOf(".")>-1?b+h(c):"("+b+").call($item"+d:b;f=c?e:"(typeof("+b+")==='function'?("+b+").call($item):("+b+"))"}else f=e=i.$1||"null";g=h(g);return"');"+j[l?"close":"open"].split("$notnull_1").join(b?"typeof("+b+")!=='undefined' && ("+b+")!=null":"true").split("$1a").join(f).split("$1").join(e).split("$2").join(g||i.$2||"")+"__.push('"})+"');}return __;")}function n(c,b){c._wrap=j(c,true,a.isArray(b)?b:[q.test(b)?b:a(b).html()]).join("")}function h(a){return a?a.replace(/\\'/g,"'").replace(/\\\\/g,"\\"):null}function s(b){var a=document.createElement("div");a.appendChild(b.cloneNode(true));return a.innerHTML}function m(o){var n="_"+c,k,j,l={},e,p,h;for(e=0,p=o.length;e<p;e++){if((k=o[e]).nodeType!==1)continue;j=k.getElementsByTagName("*");for(h=j.length-1;h>=0;h--)m(j[h]);m(k)}function m(j){var p,h=j,k,e,m;if(m=j.getAttribute(d)){while(h.parentNode&&(h=h.parentNode).nodeType===1&&!(p=h.getAttribute(d)));if(p!==m){h=h.parentNode?h.nodeType===11?0:h.getAttribute(d)||0:0;if(!(e=b[m])){e=f[m];e=g(e,b[h]||f[h]);e.key=++i;b[i]=e}c&&o(m)}j.removeAttribute(d)}else if(c&&(e=a.data(j,"tmplItem"))){o(e.key);b[e.key]=e;h=a.data(j.parentNode,"tmplItem");h=h?h.key:0}if(e){k=e;while(k&&k.key!=h){k.nodes.push(j);k=k.parent}delete e._ctnt;delete e._wrap;a.data(j,"tmplItem",e)}function o(a){a=a+n;e=l[a]=l[a]||g(e,b[e.parent.key+n]||e.parent)}}}function u(a,d,c,b){if(!a)return l.pop();l.push({_:a,tmpl:d,item:this,data:c,options:b})}function w(d,c,b){return a.tmpl(a.template(d),c,b,this)}function x(b,d){var c=b.options||{};c.wrapped=d;return a.tmpl(a.template(b.tmpl),b.data,c,b.item)}function v(d,c){var b=this._wrap;return a.map(a(a.isArray(b)?b.join(""):b).filter(d||"*"),function(a){return c?a.innerText||a.textContent:a.outerHTML||s(a)})}function t(){var b=this.nodes;a.tmpl(null,null,null,this).insertBefore(b[0]);a(b).remove()}})(jQuery);
		
	

