//currently only being used in the new cr section for 2008 report

$(document).ready(function () { //HTML DOM document is ready

	//image rollover
	$("a.roll").livequery('mouseover focus', function(event) {
		$(this).find('img').attr("src", $(this).find('img').attr("src").split('_f1').join('_f2'))
	}).livequery('mouseout blur', function(event) {/*mouseout*/
		$(this).find('img').attr("src", $(this).find('img').attr("src").split('_f2').join('_f1'))
	});


	//open links in a new window - rel=external
	$("a[rel=external]").attr("target","_blank").each(function(n) {
		$(this).attr("title") !='' ? this.title=$(this).attr("title")+'. Opens in a new browser window.' : this.title='Opens in a new browser window.';
	});


	//form button rollovers
	
	$("form input.form_button").livequery('mouseover focus', function(event) {
		$(this).addClass('form_button_f2');
	}).livequery('mouseout blur', function(event) {
		$(this).removeClass('form_button_f2');
	});
	
	// CR section tools - shortcut to add page
	$("form.savepageform input.button_save").bind('mouseover focus', function(event) {
		$(this).addClass('button_save_f2');
	}).bind('mouseout blur', function(event) {
		$(this).removeClass('button_save_f2');
	});

	// main pages for tools: folder / notes page 
	$("form input.tools_button").bind('mouseover focus', function(event) {
		$(this).addClass('tools_button_f2');
	}).bind('mouseout blur', function(event) {
		$(this).removeClass('tools_button_f2');
	});

});
(function(){var head=document.getElementsByTagName("head")[0];if(head){var scriptStyles=document.createElement("link");scriptStyles.rel="stylesheet";scriptStyles.type="text/css";scriptStyles.href="style/pagestyle/js_hide.css";head.appendChild(scriptStyles);}}());/* Copyright (c) 2007 Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 *
 * Version: 1.0.2
 * Requires jQuery 1.1.3+
 * Docs: http://docs.jquery.com/Plugins/livequery
 */
(function($){$.extend($.fn,{livequery:function(type,fn,fn2){var self=this,q;if($.isFunction(type))fn2=fn,fn=type,type=undefined;$.each($.livequery.queries,function(i,query){if(self.selector==query.selector&&self.context==query.context&&type==query.type&&(!fn||fn.$lqguid==query.fn.$lqguid)&&(!fn2||fn2.$lqguid==query.fn2.$lqguid))return(q=query)&&false;});q=q||new $.livequery(this.selector,this.context,type,fn,fn2);q.stopped=false;$.livequery.run(q.id);return this;},expire:function(type,fn,fn2){var self=this;if($.isFunction(type))fn2=fn,fn=type,type=undefined;$.each($.livequery.queries,function(i,query){if(self.selector==query.selector&&self.context==query.context&&(!type||type==query.type)&&(!fn||fn.$lqguid==query.fn.$lqguid)&&(!fn2||fn2.$lqguid==query.fn2.$lqguid)&&!this.stopped)$.livequery.stop(query.id);});return this;}});$.livequery=function(selector,context,type,fn,fn2){this.selector=selector;this.context=context||document;this.type=type;this.fn=fn;this.fn2=fn2;this.elements=[];this.stopped=false;this.id=$.livequery.queries.push(this)-1;fn.$lqguid=fn.$lqguid||$.livequery.guid++;if(fn2)fn2.$lqguid=fn2.$lqguid||$.livequery.guid++;return this;};$.livequery.prototype={stop:function(){var query=this;if(this.type)this.elements.unbind(this.type,this.fn);else if(this.fn2)this.elements.each(function(i,el){query.fn2.apply(el);});this.elements=[];this.stopped=true;},run:function(){if(this.stopped)return;var query=this;var oEls=this.elements,els=$(this.selector,this.context),nEls=els.not(oEls);this.elements=els;if(this.type){nEls.bind(this.type,this.fn);if(oEls.length>0)$.each(oEls,function(i,el){if($.inArray(el,els)<0)$.event.remove(el,query.type,query.fn);});}else{nEls.each(function(){query.fn.apply(this);});if(this.fn2&&oEls.length>0)$.each(oEls,function(i,el){if($.inArray(el,els)<0)query.fn2.apply(el);});}}};$.extend($.livequery,{guid:0,queries:[],queue:[],running:false,timeout:null,checkQueue:function(){if($.livequery.running&&$.livequery.queue.length){var length=$.livequery.queue.length;while(length--)$.livequery.queries[$.livequery.queue.shift()].run();}},pause:function(){$.livequery.running=false;},play:function(){$.livequery.running=true;$.livequery.run();},registerPlugin:function(){$.each(arguments,function(i,n){if(!$.fn[n])return;var old=$.fn[n];$.fn[n]=function(){var r=old.apply(this,arguments);$.livequery.run();return r;}});},run:function(id){if(id!=undefined){if($.inArray(id,$.livequery.queue)<0)$.livequery.queue.push(id);}else
$.each($.livequery.queries,function(id){if($.inArray(id,$.livequery.queue)<0)$.livequery.queue.push(id);});if($.livequery.timeout)clearTimeout($.livequery.timeout);$.livequery.timeout=setTimeout($.livequery.checkQueue,20);},stop:function(id){if(id!=undefined)$.livequery.queries[id].stop();else
$.each($.livequery.queries,function(id){$.livequery.queries[id].stop();});}});$.livequery.registerPlugin('append','prepend','after','before','wrap','attr','removeAttr','addClass','removeClass','toggleClass','empty','remove');$(function(){$.livequery.play();});var init=$.prototype.init;$.prototype.init=function(a,c){var r=init.apply(this,arguments);if(a&&a.selector)r.context=a.context,r.selector=a.selector;if(typeof a=='string')r.context=c||document,r.selector=a;return r;};$.prototype.init.prototype=$.prototype;})(jQuery);$(document).ready(function () { 
	$("#cr_container div.cr_navigation a").livequery('click', function(event) {
		//var ParentId=$(this).parents("div").parents("div").parents("div").attr("class");
		var strImage=this.href.split('slide=')
		var strPageid=this.href.split('pageid=')
		strPageid=strPageid[1].split('&')
		strPageid=strPageid[0]
		
		//update nav
		$('#cr_container div.cr_navigation').load("managed_content/homepages/cr_report.asp?pageid="+strPageid +"&slide="+strImage[1]+"  div.cr_navigation ul")
		
		//update slide: fade out old, fade in new
		$('#cr_container div.maincontent div.slide').fadeOut('fast',loadContent);
		function loadContent() {$('#cr_container div.maincontent div.slide').load("managed_content/homepages/cr_report.asp?slide="+strImage[1]+" .slide > div",'',showNewContent)}
		function showNewContent() {$('#cr_container .slide').fadeIn('fast');}
		
		//metrics starts
		//s.tl(this,'o','cr_report_hompepage: '+strPage[1]+': Slide '+strNav[1]);
		//metrics ends
		
		return false;
	});

});



$(document).ready(function(){
	
	
	$(".sectionholder div.show").hide();
	$(".sectionholder div.show_open").slideToggle("fast");
	
	$('.togglecontent').click(function(){
		var currentitem = $(this).parent()
		$(currentitem).next("div.show").slideToggle("slow")
		
		$(currentitem).parent().toggleClass('section_open')
		
		if($(' .togglecontent',currentitem).html() == 'Close'){
			$(' .togglecontent',currentitem).html('Open');
		} else {
			if($(' .togglecontent',currentitem).html() == 'Open') {
				$('.togglecontent',currentitem).html('Close');
			}
		}
		return false;
	});
	
	
	
	/*page 642*/
	
	$(".showthis").hide();
	
	
	 $("img#pic1").toggle(function(e){
         $(this).attr("src","images/text/cr_section/txt_energy_f2.gif")
		 $("#show_consumption").slideDown("fast")
		 return false;
     }, function(e) {
         $(this).attr("src","images/text/cr_section/txt_energy_f1.gif")
		 $("#show_consumption").slideUp("fast");
     }); 
	 
	 
	$("img#pic2").toggle(function(e){
         $(this).attr("src","images/text/cr_section/txt_energy_f2.gif")
		 $("#show_emissions").slideDown("fast")
		 return false;
     }, function(e) {
         $(this).attr("src","images/text/cr_section/txt_energy_f1.gif")
		 $("#show_emissions").slideUp("fast");
     }); 
	
	
	
	
});/*
 * Autocomplete - jQuery plugin 1.0.2
 *
 * Copyright (c) 2007 Dylan Verheul, Dan G. Switzer, Anjesh Tuladhar, Jörn Zaefferer
 *
 * 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: jquery.autocomplete.js 5747 2008-06-25 18:30:55Z joern.zaefferer $
 *
 */
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}(';(3($){$.31.1o({12:3(b,d){5 c=Y b=="1w";d=$.1o({},$.D.1L,{11:c?b:14,w:c?14:b,1D:c?$.D.1L.1D:10,Z:d&&!d.1x?10:3U},d);d.1t=d.1t||3(a){6 a};d.1q=d.1q||d.1K;6 I.K(3(){1E $.D(I,d)})},M:3(a){6 I.X("M",a)},1y:3(a){6 I.15("1y",[a])},20:3(){6 I.15("20")},1Y:3(a){6 I.15("1Y",[a])},1X:3(){6 I.15("1X")}});$.D=3(o,r){5 t={2N:38,2I:40,2D:46,2x:9,2v:13,2q:27,2d:3x,2j:33,2o:34,2e:8};5 u=$(o).3f("12","3c").P(r.24);5 p;5 m="";5 n=$.D.2W(r);5 s=0;5 k;5 h={1z:B};5 l=$.D.2Q(r,o,1U,h);5 j;$.1T.2L&&$(o.2K).X("3S.12",3(){4(j){j=B;6 B}});u.X(($.1T.2L?"3Q":"3N")+".12",3(a){k=a.2F;3L(a.2F){Q t.2N:a.1d();4(l.L()){l.2y()}A{W(0,C)}N;Q t.2I:a.1d();4(l.L()){l.2u()}A{W(0,C)}N;Q t.2j:a.1d();4(l.L()){l.2t()}A{W(0,C)}N;Q t.2o:a.1d();4(l.L()){l.2s()}A{W(0,C)}N;Q r.19&&$.1p(r.R)==","&&t.2d:Q t.2x:Q t.2v:4(1U()){a.1d();j=C;6 B}N;Q t.2q:l.U();N;3A:1I(p);p=1H(W,r.1D);N}}).1G(3(){s++}).3v(3(){s=0;4(!h.1z){2k()}}).2i(3(){4(s++>1&&!l.L()){W(0,C)}}).X("1y",3(){5 c=(1n.7>1)?1n[1]:14;3 23(q,a){5 b;4(a&&a.7){16(5 i=0;i<a.7;i++){4(a[i].M.O()==q.O()){b=a[i];N}}}4(Y c=="3")c(b);A u.15("M",b&&[b.w,b.H])}$.K(1g(u.J()),3(i,a){1R(a,23,23)})}).X("20",3(){n.18()}).X("1Y",3(){$.1o(r,1n[1]);4("w"2G 1n[1])n.1f()}).X("1X",3(){l.1u();u.1u();$(o.2K).1u(".12")});3 1U(){5 b=l.26();4(!b)6 B;5 v=b.M;m=v;4(r.19){5 a=1g(u.J());4(a.7>1){v=a.17(0,a.7-1).2Z(r.R)+r.R+v}v+=r.R}u.J(v);1l();u.15("M",[b.w,b.H]);6 C}3 W(b,c){4(k==t.2D){l.U();6}5 a=u.J();4(!c&&a==m)6;m=a;a=1k(a);4(a.7>=r.22){u.P(r.21);4(!r.1C)a=a.O();1R(a,2V,1l)}A{1B();l.U()}};3 1g(b){4(!b){6[""]}5 d=b.1Z(r.R);5 c=[];$.K(d,3(i,a){4($.1p(a))c[i]=$.1p(a)});6 c}3 1k(a){4(!r.19)6 a;5 b=1g(a);6 b[b.7-1]}3 1A(q,a){4(r.1A&&(1k(u.J()).O()==q.O())&&k!=t.2e){u.J(u.J()+a.48(1k(m).7));$.D.1N(o,m.7,m.7+a.7)}};3 2k(){1I(p);p=1H(1l,47)};3 1l(){5 c=l.L();l.U();1I(p);1B();4(r.2U){u.1y(3(a){4(!a){4(r.19){5 b=1g(u.J()).17(0,-1);u.J(b.2Z(r.R)+(b.7?r.R:""))}A u.J("")}})}4(c)$.D.1N(o,o.H.7,o.H.7)};3 2V(q,a){4(a&&a.7&&s){1B();l.2T(a,q);1A(q,a[0].H);l.1W()}A{1l()}};3 1R(f,d,g){4(!r.1C)f=f.O();5 e=n.2S(f);4(e&&e.7){d(f,e)}A 4((Y r.11=="1w")&&(r.11.7>0)){5 c={45:+1E 44()};$.K(r.2R,3(a,b){c[a]=Y b=="3"?b():b});$.43({42:"41",3Z:"12"+o.3Y,2M:r.2M,11:r.11,w:$.1o({q:1k(f),3X:r.Z},c),3W:3(a){5 b=r.1r&&r.1r(a)||1r(a);n.1h(f,b);d(f,b)}})}A{l.2J();g(f)}};3 1r(c){5 d=[];5 b=c.1Z("\\n");16(5 i=0;i<b.7;i++){5 a=$.1p(b[i]);4(a){a=a.1Z("|");d[d.7]={w:a,H:a[0],M:r.1v&&r.1v(a,a[0])||a[0]}}}6 d};3 1B(){u.1e(r.21)}};$.D.1L={24:"3R",2H:"3P",21:"3O",22:1,1D:3M,1C:B,1a:C,1V:B,1j:10,Z:3K,2U:B,2R:{},1S:C,1K:3(a){6 a[0]},1q:14,1A:B,E:0,19:B,R:", ",1t:3(b,a){6 b.2C(1E 3J("(?![^&;]+;)(?!<[^<>]*)("+a.2C(/([\\^\\$\\(\\)\\[\\]\\{\\}\\*\\.\\+\\?\\|\\\\])/2A,"\\\\$1")+")(?![^<>]*>)(?![^&;]+;)","2A"),"<2z>$1</2z>")},1x:C,1s:3I};$.D.2W=3(g){5 h={};5 j=0;3 1a(s,a){4(!g.1C)s=s.O();5 i=s.3H(a);4(i==-1)6 B;6 i==0||g.1V};3 1h(q,a){4(j>g.1j){18()}4(!h[q]){j++}h[q]=a}3 1f(){4(!g.w)6 B;5 f={},2w=0;4(!g.11)g.1j=1;f[""]=[];16(5 i=0,30=g.w.7;i<30;i++){5 c=g.w[i];c=(Y c=="1w")?[c]:c;5 d=g.1q(c,i+1,g.w.7);4(d===B)1P;5 e=d.3G(0).O();4(!f[e])f[e]=[];5 b={H:d,w:c,M:g.1v&&g.1v(c)||d};f[e].1O(b);4(2w++<g.Z){f[""].1O(b)}};$.K(f,3(i,a){g.1j++;1h(i,a)})}1H(1f,25);3 18(){h={};j=0}6{18:18,1h:1h,1f:1f,2S:3(q){4(!g.1j||!j)6 14;4(!g.11&&g.1V){5 a=[];16(5 k 2G h){4(k.7>0){5 c=h[k];$.K(c,3(i,x){4(1a(x.H,q)){a.1O(x)}})}}6 a}A 4(h[q]){6 h[q]}A 4(g.1a){16(5 i=q.7-1;i>=g.22;i--){5 c=h[q.3F(0,i)];4(c){5 a=[];$.K(c,3(i,x){4(1a(x.H,q)){a[a.7]=x}});6 a}}}6 14}}};$.D.2Q=3(e,g,f,k){5 h={G:"3E"};5 j,y=-1,w,1m="",1M=C,F,z;3 2r(){4(!1M)6;F=$("<3D/>").U().P(e.2H).T("3C","3B").1J(2p.2n);z=$("<3z/>").1J(F).3y(3(a){4(V(a).2m&&V(a).2m.3w()==\'2l\'){y=$("1F",z).1e(h.G).3u(V(a));$(V(a)).P(h.G)}}).2i(3(a){$(V(a)).P(h.G);f();g.1G();6 B}).3t(3(){k.1z=C}).3s(3(){k.1z=B});4(e.E>0)F.T("E",e.E);1M=B}3 V(a){5 b=a.V;3r(b&&b.3q!="2l")b=b.3p;4(!b)6[];6 b}3 S(b){j.17(y,y+1).1e(h.G);2h(b);5 a=j.17(y,y+1).P(h.G);4(e.1x){5 c=0;j.17(0,y).K(3(){c+=I.1i});4((c+a[0].1i-z.1c())>z[0].3o){z.1c(c+a[0].1i-z.3n())}A 4(c<z.1c()){z.1c(c)}}};3 2h(a){y+=a;4(y<0){y=j.1b()-1}A 4(y>=j.1b()){y=0}}3 2g(a){6 e.Z&&e.Z<a?e.Z:a}3 2f(){z.2B();5 b=2g(w.7);16(5 i=0;i<b;i++){4(!w[i])1P;5 a=e.1K(w[i].w,i+1,b,w[i].H,1m);4(a===B)1P;5 c=$("<1F/>").3m(e.1t(a,1m)).P(i%2==0?"3l":"3k").1J(z)[0];$.w(c,"2c",w[i])}j=z.3j("1F");4(e.1S){j.17(0,1).P(h.G);y=0}4($.31.2b)z.2b()}6{2T:3(d,q){2r();w=d;1m=q;2f()},2u:3(){S(1)},2y:3(){S(-1)},2t:3(){4(y!=0&&y-8<0){S(-y)}A{S(-8)}},2s:3(){4(y!=j.1b()-1&&y+8>j.1b()){S(j.1b()-1-y)}A{S(8)}},U:3(){F&&F.U();j&&j.1e(h.G);y=-1},L:3(){6 F&&F.3i(":L")},3h:3(){6 I.L()&&(j.2a("."+h.G)[0]||e.1S&&j[0])},1W:3(){5 a=$(g).3g();F.T({E:Y e.E=="1w"||e.E>0?e.E:$(g).E(),2E:a.2E+g.1i,1Q:a.1Q}).1W();4(e.1x){z.1c(0);z.T({29:e.1s,3e:\'3d\'});4($.1T.3b&&Y 2p.2n.3T.29==="3a"){5 c=0;j.K(3(){c+=I.1i});5 b=c>e.1s;z.T(\'3V\',b?e.1s:c);4(!b){j.E(z.E()-28(j.T("32-1Q"))-28(j.T("32-39")))}}}},26:3(){5 a=j&&j.2a("."+h.G).1e(h.G);6 a&&a.7&&$.w(a[0],"2c")},2J:3(){z&&z.2B()},1u:3(){F&&F.37()}}};$.D.1N=3(b,a,c){4(b.2O){5 d=b.2O();d.36(C);d.35("2P",a);d.4c("2P",c);d.4b()}A 4(b.2Y){b.2Y(a,c)}A{4(b.2X){b.2X=a;b.4a=c}}b.1G()}})(49);',62,261,'|||function|if|var|return|length|||||||||||||||||||||||||data||active|list|else|false|true|Autocompleter|width|element|ACTIVE|value|this|val|each|visible|result|break|toLowerCase|addClass|case|multipleSeparator|moveSelect|css|hide|target|onChange|bind|typeof|max||url|autocomplete||null|trigger|for|slice|flush|multiple|matchSubset|size|scrollTop|preventDefault|removeClass|populate|trimWords|add|offsetHeight|cacheLength|lastWord|hideResultsNow|term|arguments|extend|trim|formatMatch|parse|scrollHeight|highlight|unbind|formatResult|string|scroll|search|mouseDownOnSelect|autoFill|stopLoading|matchCase|delay|new|li|focus|setTimeout|clearTimeout|appendTo|formatItem|defaults|needsInit|Selection|push|continue|left|request|selectFirst|browser|selectCurrent|matchContains|show|unautocomplete|setOptions|split|flushCache|loadingClass|minChars|findValueCallback|inputClass||selected||parseInt|maxHeight|filter|bgiframe|ac_data|COMMA|BACKSPACE|fillList|limitNumberOfItems|movePosition|click|PAGEUP|hideResults|LI|nodeName|body|PAGEDOWN|document|ESC|init|pageDown|pageUp|next|RETURN|nullData|TAB|prev|strong|gi|empty|replace|DEL|top|keyCode|in|resultsClass|DOWN|emptyList|form|opera|dataType|UP|createTextRange|character|Select|extraParams|load|display|mustMatch|receiveData|Cache|selectionStart|setSelectionRange|join|ol|fn|padding|||moveStart|collapse|remove||right|undefined|msie|off|auto|overflow|attr|offset|current|is|find|ac_odd|ac_even|html|innerHeight|clientHeight|parentNode|tagName|while|mouseup|mousedown|index|blur|toUpperCase|188|mouseover|ul|default|absolute|position|div|ac_over|substr|charAt|indexOf|180|RegExp|100|switch|400|keydown|ac_loading|ac_results|keypress|ac_input|submit|style|150|height|success|limit|name|port||abort|mode|ajax|Date|timestamp||200|substring|jQuery|selectionEnd|select|moveEnd'.split('|'),0,{}));/**
 * TableDnD plug-in for JQuery, allows you to drag and drop table rows
 * You can set up various options to control how the system will work
 * Copyright (c) Denis Howlett <denish@isocra.com>
 * Licensed like jQuery, see http://docs.jquery.com/License.
 *
 * Configuration options:
 * 
 * onDragStyle
 *     This is the style that is assigned to the row during drag. There are limitations to the styles that can be
 *     associated with a row (such as you can't assign a border--well you can, but it won't be
 *     displayed). (So instead consider using onDragClass.) The CSS style to apply is specified as
 *     a map (as used in the jQuery css(...) function).
 * onDropStyle
 *     This is the style that is assigned to the row when it is dropped. As for onDragStyle, there are limitations
 *     to what you can do. Also this replaces the original style, so again consider using onDragClass which
 *     is simply added and then removed on drop.
 * onDragClass
 *     This class is added for the duration of the drag and then removed when the row is dropped. It is more
 *     flexible than using onDragStyle since it can be inherited by the row cells and other content. The default
 *     is class is tDnD_whileDrag. So to use the default, simply customise this CSS class in your
 *     stylesheet.
 * onDrop
 *     Pass a function that will be called when the row is dropped. The function takes 2 parameters: the table
 *     and the row that was dropped. You can work out the new order of the rows by using
 *     table.rows.
 * onDragStart
 *     Pass a function that will be called when the user starts dragging. The function takes 2 parameters: the
 *     table and the row which the user has started to drag.
 * onAllowDrop
 *     Pass a function that will be called as a row is over another row. If the function returns true, allow 
 *     dropping on that row, otherwise not. The function takes 2 parameters: the dragged row and the row under
 *     the cursor. It returns a boolean: true allows the drop, false doesn't allow it.
 * scrollAmount
 *     This is the number of pixels to scroll if the user moves the mouse cursor to the top or bottom of the
 *     window. The page should automatically scroll up or down as appropriate (tested in IE6, IE7, Safari, FF2,
 *     FF3 beta
 * dragHandle
 *     This is the name of a class that you assign to one or more cells in each row that is draggable. If you
 *     specify this class, then you are responsible for setting cursor: move in the CSS and only these cells
 *     will have the drag behaviour. If you do not specify a dragHandle, then you get the old behaviour where
 *     the whole row is draggable.
 * 
 * Other ways to control behaviour:
 *
 * Add class="nodrop" to any rows for which you don't want to allow dropping, and class="nodrag" to any rows
 * that you don't want to be draggable.
 *
 * Inside the onDrop method you can also call $.tableDnD.serialize() this returns a string of the form
 * <tableID>[]=<rowID1>&<tableID>[]=<rowID2> so that you can send this back to the server. The table must have
 * an ID as must all the rows.
 *
 * Other methods:
 *
 * $("...").tableDnDUpdate() 
 * Will update all the matching tables, that is it will reapply the mousedown method to the rows (or handle cells).
 * This is useful if you have updated the table rows using Ajax and you want to make the table draggable again.
 * The table maintains the original configuration (so you don't have to specify it again).
 *
 * $("...").tableDnDSerialize()
 * Will serialize and return the serialized string as above, but for each of the matching tables--so it can be
 * called from anywhere and isn't dependent on the currentTable being set up correctly before calling
 *
 * Known problems:
 * - Auto-scoll has some problems with IE7  (it scrolls even when it shouldn't), work-around: set scrollAmount to 0
 * 
 * Version 0.2: 2008-02-20 First public version
 * Version 0.3: 2008-02-07 Added onDragStart option
 *                         Made the scroll amount configurable (default is 5 as before)
 * Version 0.4: 2008-03-15 Changed the noDrag/noDrop attributes to nodrag/nodrop classes
 *                         Added onAllowDrop to control dropping
 *                         Fixed a bug which meant that you couldn't set the scroll amount in both directions
 *                         Added serialize method
 * Version 0.5: 2008-05-16 Changed so that if you specify a dragHandle class it doesn't make the whole row
 *                         draggable
 *                         Improved the serialize method to use a default (and settable) regular expression.
 *                         Added tableDnDupate() and tableDnDSerialize() to be called when you are outside the table
 */
jQuery.tableDnD = {
    /** Keep hold of the current table being dragged */
    currentTable : null,
    /** Keep hold of the current drag object if any */
    dragObject: null,
    /** The current mouse offset */
    mouseOffset: null,
    /** Remember the old value of Y so that we don't do too much processing */
    oldY: 0,

    /** Actually build the structure */
    build: function(options) {
        // Set up the defaults if any

        this.each(function() {
            // This is bound to each matching table, set up the defaults and override with user options
            this.tableDnDConfig = jQuery.extend({
                onDragStyle: null,
                onDropStyle: null,
				// Add in the default class for whileDragging
				onDragClass: "tDnD_whileDrag",
                onDrop: null,
                onDragStart: null,
                scrollAmount: 5,
				serializeRegexp: /[^\-]*$/, // The regular expression to use to trim row IDs
				serializeParamName: null, // If you want to specify another parameter name instead of the table ID
                dragHandle: null // If you give the name of a class here, then only Cells with this class will be draggable
            }, options || {});
            // Now make the rows draggable
            jQuery.tableDnD.makeDraggable(this);
        });

        // Now we need to capture the mouse up and mouse move event
        // We can use bind so that we don't interfere with other event handlers
        jQuery(document)
            .bind('mousemove', jQuery.tableDnD.mousemove)
            .bind('mouseup', jQuery.tableDnD.mouseup);

        // Don't break the chain
        return this;
    },

    /** This function makes all the rows on the table draggable apart from those marked as "NoDrag" */
    makeDraggable: function(table) {
        var config = table.tableDnDConfig;
		if (table.tableDnDConfig.dragHandle) {
			// We only need to add the event to the specified cells
			var cells = jQuery("td."+table.tableDnDConfig.dragHandle, table);
			cells.each(function() {
				// The cell is bound to "this"
                jQuery(this).mousedown(function(ev) {
                    jQuery.tableDnD.dragObject = this.parentNode;
                    jQuery.tableDnD.currentTable = table;
                    jQuery.tableDnD.mouseOffset = jQuery.tableDnD.getMouseOffset(this, ev);
                    if (config.onDragStart) {
                        // Call the onDrop method if there is one
                        config.onDragStart(table, this);
                    }
                    return false;
                });
			})
		} else {
			// For backwards compatibility, we add the event to the whole row
	        var rows = jQuery("tr", table); // get all the rows as a wrapped set
	        rows.each(function() {
				// Iterate through each row, the row is bound to "this"
				var row = jQuery(this);
				if (! row.hasClass("nodrag")) {
	                row.mousedown(function(ev) {
	                    if (ev.target.tagName == "TD") {
	                        jQuery.tableDnD.dragObject = this;
	                        jQuery.tableDnD.currentTable = table;
	                        jQuery.tableDnD.mouseOffset = jQuery.tableDnD.getMouseOffset(this, ev);
	                        if (config.onDragStart) {
	                            // Call the onDrop method if there is one
	                            config.onDragStart(table, this);
	                        }
	                        return false;
	                    }
	                }).css("cursor", "move"); // Store the tableDnD object
				}
			});
		}
	},

	updateTables: function() {
		this.each(function() {
			// this is now bound to each matching table
			if (this.tableDnDConfig) {
				jQuery.tableDnD.makeDraggable(this);
			}
		})
	},

    /** Get the mouse coordinates from the event (allowing for browser differences) */
    mouseCoords: function(ev){
        if(ev.pageX || ev.pageY){
            return {x:ev.pageX, y:ev.pageY};
        }
        return {
            x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
            y:ev.clientY + document.body.scrollTop  - document.body.clientTop
        };
    },

    /** Given a target element and a mouse event, get the mouse offset from that element.
        To do this we need the element's position and the mouse position */
    getMouseOffset: function(target, ev) {
        ev = ev || window.event;

        var docPos    = this.getPosition(target);
        var mousePos  = this.mouseCoords(ev);
        return {x:mousePos.x - docPos.x, y:mousePos.y - docPos.y};
    },

    /** Get the position of an element by going up the DOM tree and adding up all the offsets */
    getPosition: function(e){
        var left = 0;
        var top  = 0;
        /** Safari fix -- thanks to Luis Chato for this! */
        if (e.offsetHeight == 0) {
            /** Safari 2 doesn't correctly grab the offsetTop of a table row
            this is detailed here:
            http://jacob.peargrove.com/blog/2006/technical/table-row-offsettop-bug-in-safari/
            the solution is likewise noted there, grab the offset of a table cell in the row - the firstChild.
            note that firefox will return a text node as a first child, so designing a more thorough
            solution may need to take that into account, for now this seems to work in firefox, safari, ie */
            e = e.firstChild; // a table cell
        }

        while (e.offsetParent){
            left += e.offsetLeft;
            top  += e.offsetTop;
            e     = e.offsetParent;
        }

        left += e.offsetLeft;
        top  += e.offsetTop;

        return {x:left, y:top};
    },

    mousemove: function(ev) {
        if (jQuery.tableDnD.dragObject == null) {
            return;
        }

        var dragObj = jQuery(jQuery.tableDnD.dragObject);
        var config = jQuery.tableDnD.currentTable.tableDnDConfig;
        var mousePos = jQuery.tableDnD.mouseCoords(ev);
        var y = mousePos.y - jQuery.tableDnD.mouseOffset.y;
        //auto scroll the window
	    var yOffset = window.pageYOffset;
	 	if (document.all) {
	        // Windows version
	        //yOffset=document.body.scrollTop;
	        if (typeof document.compatMode != 'undefined' &&
	             document.compatMode != 'BackCompat') {
	           yOffset = document.documentElement.scrollTop;
	        }
	        else if (typeof document.body != 'undefined') {
	           yOffset=document.body.scrollTop;
	        }

	    }
		    
		if (mousePos.y-yOffset < config.scrollAmount) {
	    	window.scrollBy(0, -config.scrollAmount);
	    } else {
            var windowHeight = window.innerHeight ? window.innerHeight
                    : document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight;
            if (windowHeight-(mousePos.y-yOffset) < config.scrollAmount) {
                window.scrollBy(0, config.scrollAmount);
            }
        }


        if (y != jQuery.tableDnD.oldY) {
            // work out if we're going up or down...
            var movingDown = y > jQuery.tableDnD.oldY;
            // update the old value
            jQuery.tableDnD.oldY = y;
            // update the style to show we're dragging
			if (config.onDragClass) {
				dragObj.addClass(config.onDragClass);
			} else {
	            dragObj.css(config.onDragStyle);
			}
            // If we're over a row then move the dragged row to there so that the user sees the
            // effect dynamically
            var currentRow = jQuery.tableDnD.findDropTargetRow(dragObj, y);
            if (currentRow) {
                // TODO worry about what happens when there are multiple TBODIES
                if (movingDown && jQuery.tableDnD.dragObject != currentRow) {
                    jQuery.tableDnD.dragObject.parentNode.insertBefore(jQuery.tableDnD.dragObject, currentRow.nextSibling);
                } else if (! movingDown && jQuery.tableDnD.dragObject != currentRow) {
                    jQuery.tableDnD.dragObject.parentNode.insertBefore(jQuery.tableDnD.dragObject, currentRow);
                }
            }
        }

        return false;
    },

    /** We're only worried about the y position really, because we can only move rows up and down */
    findDropTargetRow: function(draggedRow, y) {
        var rows = jQuery.tableDnD.currentTable.rows;
        for (var i=0; i<rows.length; i++) {
            var row = rows[i];
            var rowY    = this.getPosition(row).y;
            var rowHeight = parseInt(row.offsetHeight)/2;
            if (row.offsetHeight == 0) {
                rowY = this.getPosition(row.firstChild).y;
                rowHeight = parseInt(row.firstChild.offsetHeight)/2;
            }
            // Because we always have to insert before, we need to offset the height a bit
            if ((y > rowY - rowHeight) && (y < (rowY + rowHeight))) {
                // that's the row we're over
				// If it's the same as the current row, ignore it
				if (row == draggedRow) {return null;}
                var config = jQuery.tableDnD.currentTable.tableDnDConfig;
                if (config.onAllowDrop) {
                    if (config.onAllowDrop(draggedRow, row)) {
                        return row;
                    } else {
                        return null;
                    }
                } else {
					// If a row has nodrop class, then don't allow dropping (inspired by John Tarr and Famic)
                    var nodrop = jQuery(row).hasClass("nodrop");
                    if (! nodrop) {
                        return row;
                    } else {
                        return null;
                    }
                }
                return row;
            }
        }
        return null;
    },

    mouseup: function(e) {
        if (jQuery.tableDnD.currentTable && jQuery.tableDnD.dragObject) {
            var droppedRow = jQuery.tableDnD.dragObject;
            var config = jQuery.tableDnD.currentTable.tableDnDConfig;
            // If we have a dragObject, then we need to release it,
            // The row will already have been moved to the right place so we just reset stuff
			if (config.onDragClass) {
	            jQuery(droppedRow).removeClass(config.onDragClass);
			} else {
	            jQuery(droppedRow).css(config.onDropStyle);
			}
            jQuery.tableDnD.dragObject   = null;
            if (config.onDrop) {
                // Call the onDrop method if there is one
                config.onDrop(jQuery.tableDnD.currentTable, droppedRow);
            }
            jQuery.tableDnD.currentTable = null; // let go of the table too
        }
    },

    serialize: function() {
        if (jQuery.tableDnD.currentTable) {
            return jQuery.tableDnD.serializeTable(jQuery.tableDnD.currentTable);
        } else {
            return "Error: No Table id set, you need to set an id on your table and every row";
        }
    },

	serializeTable: function(table) {
        var result = "";
        var tableId = table.id;
        var rows = table.rows;
        for (var i=0; i<rows.length; i++) {
            if (result.length > 0) result += ",";
            var rowId = rows[i].id;
            if (rowId && rowId && table.tableDnDConfig && table.tableDnDConfig.serializeRegexp) {
                rowId = rowId.match(table.tableDnDConfig.serializeRegexp)[0];
            }

        //    result += tableId + '[]=' + rowId;
			result += rowId;
        }
        return ","+result+",";
	},

	serializeTables: function() {
        var result = "";
        this.each(function() {
			// this is now bound to each matching table
			result += jQuery.tableDnD.serializeTable(this);
		});
        return result;
    }

}

jQuery.fn.extend(
	{
		tableDnD : jQuery.tableDnD.build,
		tableDnDUpdate : jQuery.tableDnD.updateTables,
		tableDnDSerialize: jQuery.tableDnD.serializeTables
	}
);// ---- FUNCTIONS ---//
var changeTabs = function(layerId) {
	var showToggle=true;
	$("#toolstab_content > div").each(function(n) {
		if ($(this).hasClass("showtool")) {
			$(this).hide().removeClass("showtool");
			showToggle=false;
		}
	});
	if (showToggle==true) {
		$("#"+layerId).slideDown().addClass("showtool")
	} else {
		$("#"+layerId).show().addClass("showtool")
	};
}

var highlitghtTab = function(classname) {
	$("#toolstab > li > a").each(function(n) {
		if ($(this).hasClass(""+classname+"")) {
			$(this).addClass("lit");
		} else {
			$(this).removeClass("lit");	
		}
	});
}


$(".savedpagesbuttons .total").addClass("tick");
$(".notesbuttons .total").addClass("tick");

var updateCount = function() {
	var total = 0;
	var strPages = "page";
	var strNotes = "note";
	$("#toolsdata td :checkbox:checked").each(function() {total=total+1;});
	if (total!=1) {strPages=strPages+"s";strNotes=strNotes+"s";}
	$(".savedpagesbuttons .total").text(total+" "+strPages+" selected");
	$(".notesbuttons .total").text(total+" "+strNotes+" selected");
};

var checkAll = function(boolean) {
	$("input[name=item]").each(function() {$("input[name=item]").attr('checked', boolean)});
	var selector_checked = $("#toolsdata tr td :checkbox:checked").length;
	if (selector_checked >0){
		$("#toolsdata tr td :checkbox:checked").each(function() {$("#toolsdata tr").addClass("selected")});
	} else {
		$("#toolsdata tr td :not:checkbox").each(function() {$("#toolsdata tr").removeClass("selected")});
	}
};

var updateNumbering = function() {
	$("#toolsdata td span.number").each(function(i){$(this).text(i+1);});
	$("#toolsdata button.delete").each(function(i){i=i+1;$(this).attr("id", "del_"+(i));});
};

var updateOrder = function(data) {
	var strList = $(":input[name=list]").val();
	var strOrder = $(":input[name=order]").val();
	$.post("managed_content/library/tools/fragment/reorder.asp", { update: data, order: strOrder, list: strList});
	$("#toolsdata tbody tr").each(function(i){i=i+1;$(this).attr("id", "id_"+(i));});
};

var outputList = function(url,div,message) {
	var strGetFields = $(":input:checkbox").serializeArray();
	var strItems =",";
	var strErrorText=div.html();
	jQuery.each(strGetFields, function(i, field){strItems=strItems+(field.value+",");});
	if (strItems===",") {
		if (strErrorText==="") {div.html(message);}
	} else {
		div.html("");
		window.open(url+strItems);
	}
}

var getCookie = function(name) {
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1) {
		begin = dc.indexOf(prefix);
		if (begin != 0) return null;
	} else
		begin += 2;
	var end = document.cookie.indexOf(";", begin);
	if (end == -1)
		end = dc.length;
	return unescape(dc.substring(begin + prefix.length, end));
}
//--- FUNCTIONS END ---/



$(document).ready(function(){
	
	//--- TABS ---//
	$("#toolstab a.opensavepage").livequery('click', function(event) {
		changeTabs("savepagetab");
		highlitghtTab("opensavepage");
		return false;
	});
	$("a.opennotes").livequery('click', function(event) {
		changeTabs("notestab");
		highlitghtTab("opennotes");
		return false;
	});
	$("#toolstab a.openglossary").livequery('click', function(event) {
		$("div.glossarysearchresults").html("");
		$("input#glossarysearchterm").val("");
		changeTabs("glossarytab");
		highlitghtTab("openglossary");
		return false;
	});
	$("#toolstab_content a.closetab").livequery('click', function(event) {
		$(this).parent().parent().slideUp("slow").removeClass("showtool");
		$("#toolstab > li > a").each(function(n) {$(this).removeClass("lit");});
		return false;
	});
	//--- TABS END---//
	
	
	//--- SAVE PAGE ---//
	$("form.savepageform").submit(function() {
		var strSavepageurl=$(this.savepageurl).val()
		var strSavepageTitle=$(this.pagetitle).val()
		$("div.savepage,li.savepageform").load("managed_content/library/tools/fragment/savepage.asp", {
			savepageurl: strSavepageurl, 
			pagetitle: strSavepageTitle, 
			addpage: '1'
		}, function() {
			$("div.latestpages").load("managed_content/library/tools/fragment/latestpages.asp", {ajax: 'true'});
			$("span.pagecount").load("managed_content/library/tools/fragment/countpages.asp", {ajax: 'true'});
		});
		return false;
	})
	//--- SAVE PAGE END ---//


	//--- NOTES ---//
	$("form.notestool").livequery('submit', function(event) {
		var strPageTitle=$(this.pagetitle).val()
		var frmPageUrl=$(this.savepageurl).val()
		var NoteText=$(this.note).val()
		var strUpdate=$(this.updatenote).val()
		$("div.noteform").load("managed_content/library/tools/fragment/notes.asp", {
			note: NoteText,
			savepageurl: frmPageUrl,
			pagetitle: strPageTitle,
			addnote: '1',
			updatenote: strUpdate,
			requiredfields: 'note',
			ajax: 'true'
		}, function() {
			$("li.editnote").load("managed_content/library/tools/tools_shortcuts.asp .editnote", {ajax: 'true'});
			$("span.notecount").load("managed_content/library/tools/fragment/countnotes.asp", {ajax: 'true'});
		});
		return false;
	})
	$("#notestab a.vieweditnotes").livequery('click', function(event){
		var strHref=$(this).attr("href");
		$("div.noteform").load("managed_content/library/tools/fragment/notes.asp", { backtoform: 'true', href: strHref });
		return false;
	})
	
	
	
	/*function updateCharacterCount() {
	var limit=1000
	var text = $("#note").val(); 
	var textlength = text.length;
	//$("#characterlimit").html((limit-textlength)+' characters left.')
	if(textlength > limit) {
		$("#note").val(text.substr(0,limit));return false;
	} else {
		$("#characterlimit").html((limit - textlength) +' characters left.');return true;
	}
}*/
//	updateCharacterCount();
//	$("#note").keyup(function(){updateCharacterCount();});
	//--- NOTES END ---//


	//--- GLOSSARY ---//
	if ( $("#glossarytab").length > 0 ) {
		$("#glossarysearchterm").autocomplete(glossaryterms, {
			minChars: 1,			/*minumun no. of characters before the results are displayed*/
			matchContains: false,	/*look inside (i.e. does "ba" match "foo bar") the search results*/
			scroll: true,			/*set to false to display first 10 results only*/
			selectFirst: false		/*first autocomplete value selected?*/
		});
	}
	$("form.glossarysearch").livequery('submit', function(event) {
		var strTerm=$(this.glossarysearchterm).val()
		$("div.glossarysearchresults").load("managed_content/library/tools/fragment/glossarysearch.asp", {
			glossarysearchterm: strTerm,
			glossarysearch: '1',
			ajax: 'true',
			requiredfields: 'glossarysearchterm'
		});
		//Omniture addition
		s.tl(this,'o','CR08 Report Tools: Glossary: '+strTerm);
		//Omniture addition ends
		return false;
	})
	//--- GLOSSARY END ---//

	
	//--- TOOLS DATA TABLES ---//
	
	//--- select all/deselect all
	$("#toolsdata #select").html("<a href=\"#\" id=\"checkboxall\">Select all</a> | <a href=\"#\" id=\"checkboxnone\">Deselect all</a>");	
	$("#checkboxall").click(function() {checkAll(true);updateCount();return false;});
	$("#checkboxnone").click(function() {checkAll(false);updateCount();return false;});
	$("#toolsdata #reorder").text("Re-order");
	
	//--- count selected items
	$("#toolsdata td .count").click(function() {
		$(this).parents("tr").toggleClass("selected");
		updateCount();
		$("div.errormessage").html("")
	});
	
	//--- row hover state
	$("#toolsdata tbody tr").mouseover(function() {
			$(this).addClass("hover").find("td img").attr("src", $(this).find("td img").attr("src").split('_f1').join('_f2'))
		}).mouseout(function() {
			$(this).removeClass("hover").find("td img").attr("src", $(this).find("td img").attr("src").split('_f2').join('_f1'))
		;}
	);
	
	//--- Reorder (drag and drop)
	$("#toolsdata tbody td.dragme").addClass("dragmeimage")
	$("#toolsdata").tableDnD({
		onDragClass: "dragclass",
		dragHandle: "dragme",
		onDrop: function(table, row) {
			updateNumbering();
			updateOrder($.tableDnD.serialize())			
		}
	});
	
	//--- delete
	$("button.delete").livequery('click', function(event) {
		var strList = $(":input[name=list]").val();
		var strOrder = $(":input[name=order]").val();
		var strId = $(this).attr("id")
		$(this).parents("tr").find("td .close").not(':last').slideUp("slow").end()
		.filter(':last').slideUp("slow", function() { 
			var checkbox=$(this).parents("tr").find("td div div :checkbox:checked").length
			$(this).parents("tr").remove();
			if (checkbox > 0) {updateCount();}
			updateNumbering();	
			$.post("managed_content/library/tools/fragment/removeitem.asp", { deleterow: 'true', update: strId, order: strOrder, list: strList});
			
		}); return false;
	});
		
	//--- set number of items selected
	$('.savedpagesbuttons .total').text('0 pages selected')
	$('.notesbuttons .total').text('0 notes selected')
	
	
	
	//show/hide note
	$("div.opennote").hide().before("<p class=\"clearboth\"><a href=\"#\" class=\"opennote\">+ Open note</a></p>");
	$("a.opennote").click(function() {
		if ($(this).parent().next("div.opennote").is(':hidden')) {
			$(this).parent().next().slideDown("normal");
			$(this).text("- Close note")
		} else {
			$(this).parent().next().slideUp("normal");
			$(this).text("+ Open note")
		} return false;
	});
	
	
	//--- NOTES buttons
	$("input.downloadnotertf").click(function() {
		if(/MSIE [1-6]/.test(navigator.userAgent)){
			//go to non-js version of the page
		} else {
			var errorDiv=$(this).parent().find("div.errormessage");
			var strOrder = $(":input[name=order]").val();
			outputList("managed_content/library/tools/fragment/downloadnotes.asp?order="+strOrder+"&items=",errorDiv,"<p>Please select a note to download.</p>");
			return false;
		}		
	})
	$("input.downloadnotehtml").click(function() {
		var errorDiv=$(this).parent().find("div.errormessage");
		var strOrder = $(":input[name=order]").val();
		outputList("managed_content/library/tools/fragment/printnotes.asp?order="+strOrder+"&items=",errorDiv,"<p>Please select a note to print.</p>");
		return false;
	})
	$("input.deletenote").click(function() {
		var strErrorDiv = $(this).parents("div.buttonwrapper").find("div.errormessage")							 
		var strGetFields = $(":input:checkbox").serializeArray();
		var strItems ="";
		var strErrorText=strErrorDiv.html();
		jQuery.each(strGetFields, function(i, field){strItems=strItems+(field.value+",");});
		if (strItems==="") {
			if (strErrorText==="") {strErrorDiv.html("<p>Please select a note to delete.</p>");}
		} else {
			strErrorDiv.html("");
			var strOrder=$(this.order).val()
			$("div#confirmdelete").load("managed_content/library/tools/fragment/confirmdeletenotes.asp", {
				ajax: 'true',
				item: strItems,
				order: strOrder
			});
			//Omniture addition
			s.tl(this,'o','CR08 Report Tools: Delete note');
			//Omniture addition ends
		}; return false;
	})
	
	
	//--- SAVED PAGES buttons
	$("input.downloadpagepdf").click(function() {
		//Omniture addition
		s.tl(this,'o','CR08 Report Tools: Download page as PDF');
		//Omniture addition ends
		//--- UPDATE COOKIE NAME & SITE URL
		var strID=getCookie('CR08')
		var strSiteUrl=	"http://www.ihgplc.com";
		//--- UPDATE COOKIE NAME & SITE URL
		var errorDiv=$(this).parent().find("div.errormessage");
		var strOrder = $(":input[name=order]").val();
		outputList("http://files.the-group.net/library/_webcore/report_tools/createpdf/v1/index.cfm?site="+strSiteUrl+"/savedpages.asp?id="+strID+"__order="+strOrder+"__items=",errorDiv,"<p>Please select a page to download.</p>");
		return false;
	})
	$("input.downloadpagehtml").click(function() {
		//Omniture addition
		s.tl(this,'o','CR08 Report Tools: Download page as HTML');
		//Omniture addition ends
		var errorDiv=$(this).parent().find("div.errormessage");
		var strOrder = $(":input[name=order]").val();
		outputList("savedpages.asp?print=true&order="+strOrder+"&items=",errorDiv,"Please select a page to download.");
		return false;
	})
	$("input.deletepage").click(function() {
		//Omniture addition
		s.tl(this,'o','CR08 Report Tools: Delete page');
		//Omniture addition ends																	 
		var strErrorDiv = $(this).parents("div.buttonwrapper").find("div.errormessage")							 
		var strGetFields = $(":input:checkbox").serializeArray();
		var strItems ="";
		var strErrorText=strErrorDiv.html();
		jQuery.each(strGetFields, function(i, field){strItems=strItems+(field.value+",");});
		if (strItems==="") {
			if (strErrorText==="") {strErrorDiv.html("<p>Please select a page to delete.</p>");}
		} else {
			strErrorDiv.html("");
			var strOrder=$(this.order).val()
			$("div#confirmdelete").load("managed_content/library/tools/fragment/confirmdeletepages.asp", {
				ajax: 'true',
				item: strItems,
				order: strOrder
			});
		}; return false;
	})
	
	//--- TOOLS DATA TABLES END ---//
});