var currentSelectID,printedDocWrite=0;
function loadContent(formName,back,noScroll)
{
	if(formName == '' || typeof(formName) == 'undefined' || formName.length == 0)
		return;
		
	var temp;//is a function, something is returned and cancelled
	if(window.onbeforeunload && (temp=window.onbeforeunload()) && !confirm(temp))
		return;
	window.onbeforeunload=null;
	if(Tips)Tips.hideAll();
	if($('mainContent'))
	{
		var postBody;
		if($(formName))
			postBody=$(formName).serialize()+'&ajaxContent=on';
		else if(document.forms[formName])
			postBody=getFormData(formName)+'&ajaxContent=on';
		else
			postBody=formName+'&ajaxContent=on';
		if($('listContainer') && postBody.indexOf('ajax=on')!=-1)
			targetDiv='listContainer';
		else
			targetDiv='mainContent';
		document.write = function(text){ if(_domainName=="proof.ptly.com" && (!printedDocWrite++)) alert(currentSelectID + ' - ' + text); };
		if($('contentOverlay') && targetDiv=='mainContent')
		{
			$('contentOverlay').up().style.position='relative';
			$('contentOverlay').style.zIndex=300;
			if(back)
				$('contentOverlay').show();
			else
				Effect.Appear('contentOverlay',{from:0,to:0.7});
			$('contentLoading').style.zIndex=301;
			Effect.Appear('contentLoading',{duration: 3});
		}
		if(document.forms[formName])
			new Ajax.Updater(targetDiv, 'ocd.aspx', {asynchronous:true,evalScripts:true,method:'post',postBody:postBody,afterFinish:function(){$('contentOverlay').up().style.position=''; }});
		else if(postBody.indexOf('?')!=-1)
			new Ajax.Updater(targetDiv, postBody, {asynchronous:true,evalScripts:true,afterFinish:function(){$('contentOverlay').up().style.position=''; }});
		else
			new Ajax.Updater(targetDiv, 'ocd.aspx?'+postBody, {asynchronous:true,evalScripts:true,afterFinish:function(){$('contentOverlay').up().style.position=''; }});
		if(!noScroll && document.viewport.getScrollOffsets()[1] > $('mainContent').cumulativeOffset().top)
			Effect.ScrollTo($('mainContent'));
	}
	else if(document.forms[formName])
		document.forms[formName].submit();
	else if(formName.indexOf('?')!=-1)
		document.location.href=formName+'&ajaxContent=on';
	else
		document.location.href='ocd.aspx?'+formName+'&ajaxContent=on';
	if(typeof(pageTracker) == 'undefined' && typeof(_gat) != 'undefined')
		pageTracker = _gat._getTracker("UA-3010922-6");
	if(typeof(pageTracker) != 'undefined')
		pageTracker._trackPageview('/'+_subDir+'/ocd.aspx'+window.location.hash);
	return true;
}
	if(typeof(jQuery) != 'undefined')
	(function( jQuery ) {
		jQuery.widget( "ui.combobox", {
			_create: function() {
				var self = this,
					select = this.element.hide(),
					selected = select.children( ":selected" ),
					value = selected.val() ? selected.text() : "";
				var input = this.input = jQuery( "<input>" )
					.insertAfter( select )
					.val( value )
					.autocomplete({
						delay: 0,
						minLength: 0,
						source: function( request, response ) {
							var matcher = new RegExp( jQuery.ui.autocomplete.escapeRegex(request.term), "i" );
							response( select.children( "option" ).map(function() {
								var text = jQuery( this ).text();
								if ( this.value && ( !request.term || matcher.test(text) ) )
									return {
										label: text.replace(
											new RegExp(
												"(?![^&;]+;)(?!<[^<>]*)(" +
												jQuery.ui.autocomplete.escapeRegex(request.term) +
												")(?![^<>]*>)(?![^&;]+;)", "gi"
											), "<strong>$1</strong>" ),
										value: text,
										option: this
									};
							}) );
						},
						select: function( event, ui ) {
							ui.item.option.selected = true;
							self._trigger( "selected", event, {
								item: ui.item.option
							});
						},
						change: function( event, ui ) {
							if ( !ui.item ) {
								var matcher = new RegExp( "^" + jQuery.ui.autocomplete.escapeRegex( jQuery(this).val() ) + "$", "i" ),
									valid = false;
								select.children( "option" ).each(function() {
									if ( jQuery( this ).text().match( matcher ) ) {
										this.selected = valid = true;
										return false;
									}
								});
								if ( !valid ) {
									// remove invalid value, as it didn't match anything
									jQuery( this ).val( "" );
									select.val( "" );
									input.data( "autocomplete" ).term = "";
									return false;
								}
							}
						}
					})
					.addClass( "ui-widget ui-widget-content ui-corner-left" );

				input.data( "autocomplete" )._renderItem = function( ul, item ) {
					return jQuery( "<li></li>" )
						.data( "item.autocomplete", item )
						.append( "<a>" + item.label + "</a>" )
						.appendTo( ul );
				};

				this.button = jQuery( "<button type='button'>&nbsp;</button>" )
					.attr( "tabIndex", -1 )
					.attr( "title", "Show All Items" )
					.insertAfter( input )
					.button({
						icons: {
							primary: "ui-icon-triangle-1-s"
						},
						text: false
					})
					.removeClass( "ui-corner-all" )
					.addClass( "ui-corner-right ui-button-icon" )
					.click(function() {
						// close if already visible
						if ( input.autocomplete( "widget" ).is( ":visible" ) ) {
							input.autocomplete( "close" );
							return;
						}

						// work around a bug (likely same cause as #5265)
						jQuery( this ).blur();

						// pass empty string as value to search for, displaying all results
						input.autocomplete( "search", "" );
						input.focus();
					});
			},

			destroy: function() {
				this.input.remove();
				this.button.remove();
				this.element.show();
				jQuery.Widget.prototype.destroy.call( this );
			}
		});
	})( jQuery );

function setCookie(c_name,value,exdays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate() + exdays);
	var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
	document.cookie=c_name + "=" + c_value;
}
function getCookie(c_name)
{
	var i,x,y,ARRcookies=document.cookie.split(";");
	for (i=0;i<ARRcookies.length;i++)
	{
		x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
		y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
		x=x.replace(/^\s+|\s+$/g,"");
		if (x==c_name)
		{
			return unescape(y);
		}
	}
}

function compareTables()
{
	var message='';
	if(!$$('#remotePending #dataTable')[0] || !$$('#localPending #dataTable')[0])
	{
		setTimeout('compareTables()',1000);
		return
	}
	var i=0;
	$$('#remotePending tr td:nth-child(4)').each(function(T){
		if(T.innerHTML && $$('#localPending input#'+T.innerHTML)[0])
		{
			if(message) message+=", ";
			message+=T.siblings()[2].innerHTML+" "+T.siblings()[1].innerHTML;
		}
	});
	if(message) alert("Warning: data has been changed at both locations for " + message + ".");
}
function selectOption(DD,val)
{
	$(DD).select('option').each(function(o) {
		o.selected = o.innerHTML.toLowerCase() == val.escapeHTML().toLowerCase();
	});
}
// Horizontal menu script - if menu has 1 child, it is moved up one level in hierarchy
document.observe("dom:loaded", function() 
{
	if(typeof(HistMan)!='undefined' && $$('.history')[0])
		HistMan.start('/reference/php/HistMan.php', 'loadContent');
});

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-3010922-6']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
    
/*
function handleError (err, url, line) {
	new Ajax.Request('/error.aspx?Error='+err+'&  url='+url+'&  line='+line);
}
if(typeof(_domainName)!='undefined' && _domainName.indexOf('proof.ptly.com')>=0)
	window.onerror = handleError; // assign own handler
*/
function clearExamples()
{
	if(typeof(allowSubmit)=='undefined' || allowSubmit)
		$$('.example').each(function(t){
			t.value='';
			t.removeClassName('example');	
		});
}
function setupExampleField(ID,text)
{
	if(typeof(jQuery)!='undefined' && jQuery('#'+ID).example)
	{
		jQuery('#'+ID).example(text, {className: 'example'});
		return;
	}
/*	var field=$(ID);
	if(!field) field=$$('[name='+ID+']')[0];
	if(!text) text='Search for a member';
	if(!field.orig)
		field.orig=text;
	field.observe('focus',function(){
		if(this.hasClassName('example'))
		{
			this.removeClassName('example');
			this.value=''
		}
	});
	field.observe('blur',function(){
		if(this.value=='' && !this.hasClassName('example'))
		{
			this.addClassName('example');
			this.value=this.orig
		}
	});
	if(field.value=='' || field.value==text)
	{
		field.value=text;
		field.addClassName('example');
	}
	var form;
	if(form=field.form) 
		$(form).observe('submit',function(){
			clearExamples();
			return true;
		});
*/	
}

var swfobject=function(){var D="undefined",r="object",S="Shockwave Flash",W="ShockwaveFlash.ShockwaveFlash",q="application/x-shockwave-flash",R="SWFObjectExprInst",x="onreadystatechange",O=window,j=document,t=navigator,T=false,U=[h],o=[],N=[],I=[],l,Q,E,B,J=false,a=false,n,G,m=true,M=function(){var aa=typeof j.getElementById!=D&&typeof j.getElementsByTagName!=D&&typeof j.createElement!=D,ah=t.userAgent.toLowerCase(),Y=t.platform.toLowerCase(),ae=Y?/win/.test(Y):/win/.test(ah),ac=Y?/mac/.test(Y):/mac/.test(ah),af=/webkit/.test(ah)?parseFloat(ah.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,X=!+"\v1",ag=[0,0,0],ab=null;if(typeof t.plugins!=D&&typeof t.plugins[S]==r){ab=t.plugins[S].description;if(ab&&!(typeof t.mimeTypes!=D&&t.mimeTypes[q]&&!t.mimeTypes[q].enabledPlugin)){T=true;X=false;ab=ab.replace(/^.*\s+(\S+\s+\S+$)/,"$1");ag[0]=parseInt(ab.replace(/^(.*)\..*$/,"$1"),10);ag[1]=parseInt(ab.replace(/^.*\.(.*)\s.*$/,"$1"),10);ag[2]=/[a-zA-Z]/.test(ab)?parseInt(ab.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0}}else{if(typeof O.ActiveXObject!=D){try{var ad=new ActiveXObject(W);if(ad){ab=ad.GetVariable("$version");if(ab){X=true;ab=ab.split(" ")[1].split(",");ag=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}}catch(Z){}}}return{w3:aa,pv:ag,wk:af,ie:X,win:ae,mac:ac}}(),k=function(){if(!M.w3){return}if((typeof j.readyState!=D&&j.readyState=="complete")||(typeof j.readyState==D&&(j.getElementsByTagName("body")[0]||j.body))){f()}if(!J){if(typeof j.addEventListener!=D){j.addEventListener("DOMContentLoaded",f,false)}if(M.ie&&M.win){j.attachEvent(x,function(){if(j.readyState=="complete"){j.detachEvent(x,arguments.callee);f()}});if(O==top){(function(){if(J){return}try{j.documentElement.doScroll("left")}catch(X){setTimeout(arguments.callee,0);return}f()})()}}if(M.wk){(function(){if(J){return}if(!/loaded|complete/.test(j.readyState)){setTimeout(arguments.callee,0);return}f()})()}s(f)}}();function f(){if(J){return}try{var Z=j.getElementsByTagName("body")[0].appendChild(C("span"));Z.parentNode.removeChild(Z)}catch(aa){return}J=true;var X=U.length;for(var Y=0;Y<X;Y++){U[Y]()}}function K(X){if(J){X()}else{U[U.length]=X}}function s(Y){if(typeof O.addEventListener!=D){O.addEventListener("load",Y,false)}else{if(typeof j.addEventListener!=D){j.addEventListener("load",Y,false)}else{if(typeof O.attachEvent!=D){i(O,"onload",Y)}else{if(typeof O.onload=="function"){var X=O.onload;O.onload=function(){X();Y()}}else{O.onload=Y}}}}}function h(){if(T){V()}else{H()}}function V(){var X=j.getElementsByTagName("body")[0];var aa=C(r);aa.setAttribute("type",q);var Z=X.appendChild(aa);if(Z){var Y=0;(function(){if(typeof Z.GetVariable!=D){var ab=Z.GetVariable("$version");if(ab){ab=ab.split(" ")[1].split(",");M.pv=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}else{if(Y<10){Y++;setTimeout(arguments.callee,10);return}}X.removeChild(aa);Z=null;H()})()}else{H()}}function H(){var ag=o.length;if(ag>0){for(var af=0;af<ag;af++){var Y=o[af].id;var ab=o[af].callbackFn;var aa={success:false,id:Y};if(M.pv[0]>0){var ae=c(Y);if(ae){if(F(o[af].swfVersion)&&!(M.wk&&M.wk<312)){w(Y,true);if(ab){aa.success=true;aa.ref=z(Y);ab(aa)}}else{if(o[af].expressInstall&&A()){var ai={};ai.data=o[af].expressInstall;ai.width=ae.getAttribute("width")||"0";ai.height=ae.getAttribute("height")||"0";if(ae.getAttribute("class")){ai.styleclass=ae.getAttribute("class")}if(ae.getAttribute("align")){ai.align=ae.getAttribute("align")}var ah={};var X=ae.getElementsByTagName("param");var ac=X.length;for(var ad=0;ad<ac;ad++){if(X[ad].getAttribute("name").toLowerCase()!="movie"){ah[X[ad].getAttribute("name")]=X[ad].getAttribute("value")}}P(ai,ah,Y,ab)}else{p(ae);if(ab){ab(aa)}}}}}else{w(Y,true);if(ab){var Z=z(Y);if(Z&&typeof Z.SetVariable!=D){aa.success=true;aa.ref=Z}ab(aa)}}}}}function z(aa){var X=null;var Y=c(aa);if(Y&&Y.nodeName=="OBJECT"){if(typeof Y.SetVariable!=D){X=Y}else{var Z=Y.getElementsByTagName(r)[0];if(Z){X=Z}}}return X}function A(){return !a&&F("6.0.65")&&(M.win||M.mac)&&!(M.wk&&M.wk<312)}function P(aa,ab,X,Z){a=true;E=Z||null;B={success:false,id:X};var ae=c(X);if(ae){if(ae.nodeName=="OBJECT"){l=g(ae);Q=null}else{l=ae;Q=X}aa.id=R;if(typeof aa.width==D||(!/%$/.test(aa.width)&&parseInt(aa.width,10)<310)){aa.width="310"}if(typeof aa.height==D||(!/%$/.test(aa.height)&&parseInt(aa.height,10)<137)){aa.height="137"}j.title=j.title.slice(0,47)+" - Flash Player Installation";var ad=M.ie&&M.win?"ActiveX":"PlugIn",ac="MMredirectURL="+O.location.toString().replace(/&/g,"%26")+"&MMplayerType="+ad+"&MMdoctitle="+j.title;if(typeof ab.flashvars!=D){ab.flashvars+="&"+ac}else{ab.flashvars=ac}if(M.ie&&M.win&&ae.readyState!=4){var Y=C("div");X+="SWFObjectNew";Y.setAttribute("id",X);ae.parentNode.insertBefore(Y,ae);ae.style.display="none";(function(){if(ae.readyState==4){ae.parentNode.removeChild(ae)}else{setTimeout(arguments.callee,10)}})()}u(aa,ab,X)}}function p(Y){if(M.ie&&M.win&&Y.readyState!=4){var X=C("div");Y.parentNode.insertBefore(X,Y);X.parentNode.replaceChild(g(Y),X);Y.style.display="none";(function(){if(Y.readyState==4){Y.parentNode.removeChild(Y)}else{setTimeout(arguments.callee,10)}})()}else{Y.parentNode.replaceChild(g(Y),Y)}}function g(ab){var aa=C("div");if(M.win&&M.ie){aa.innerHTML=ab.innerHTML}else{var Y=ab.getElementsByTagName(r)[0];if(Y){var ad=Y.childNodes;if(ad){var X=ad.length;for(var Z=0;Z<X;Z++){if(!(ad[Z].nodeType==1&&ad[Z].nodeName=="PARAM")&&!(ad[Z].nodeType==8)){aa.appendChild(ad[Z].cloneNode(true))}}}}}return aa}function u(ai,ag,Y){var X,aa=c(Y);if(M.wk&&M.wk<312){return X}if(aa){if(typeof ai.id==D){ai.id=Y}if(M.ie&&M.win){var ah="";for(var ae in ai){if(ai[ae]!=Object.prototype[ae]){if(ae.toLowerCase()=="data"){ag.movie=ai[ae]}else{if(ae.toLowerCase()=="styleclass"){ah+=' class="'+ai[ae]+'"'}else{if(ae.toLowerCase()!="classid"){ah+=" "+ae+'="'+ai[ae]+'"'}}}}}var af="";for(var ad in ag){if(ag[ad]!=Object.prototype[ad]){af+='<param name="'+ad+'" value="'+ag[ad]+'" />'}}aa.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+ah+">"+af+"</object>";N[N.length]=ai.id;X=c(ai.id)}else{var Z=C(r);Z.setAttribute("type",q);for(var ac in ai){if(ai[ac]!=Object.prototype[ac]){if(ac.toLowerCase()=="styleclass"){Z.setAttribute("class",ai[ac])}else{if(ac.toLowerCase()!="classid"){Z.setAttribute(ac,ai[ac])}}}}for(var ab in ag){if(ag[ab]!=Object.prototype[ab]&&ab.toLowerCase()!="movie"){e(Z,ab,ag[ab])}}aa.parentNode.replaceChild(Z,aa);X=Z}}return X}function e(Z,X,Y){var aa=C("param");aa.setAttribute("name",X);aa.setAttribute("value",Y);Z.appendChild(aa)}function y(Y){var X=c(Y);if(X&&X.nodeName=="OBJECT"){if(M.ie&&M.win){X.style.display="none";(function(){if(X.readyState==4){b(Y)}else{setTimeout(arguments.callee,10)}})()}else{X.parentNode.removeChild(X)}}}function b(Z){var Y=c(Z);if(Y){for(var X in Y){if(typeof Y[X]=="function"){Y[X]=null}}Y.parentNode.removeChild(Y)}}function c(Z){var X=null;try{X=j.getElementById(Z)}catch(Y){}return X}function C(X){return j.createElement(X)}function i(Z,X,Y){Z.attachEvent(X,Y);I[I.length]=[Z,X,Y]}function F(Z){var Y=M.pv,X=Z.split(".");X[0]=parseInt(X[0],10);X[1]=parseInt(X[1],10)||0;X[2]=parseInt(X[2],10)||0;return(Y[0]>X[0]||(Y[0]==X[0]&&Y[1]>X[1])||(Y[0]==X[0]&&Y[1]==X[1]&&Y[2]>=X[2]))?true:false}function v(ac,Y,ad,ab){if(M.ie&&M.mac){return}var aa=j.getElementsByTagName("head")[0];if(!aa){return}var X=(ad&&typeof ad=="string")?ad:"screen";if(ab){n=null;G=null}if(!n||G!=X){var Z=C("style");Z.setAttribute("type","text/css");Z.setAttribute("media",X);n=aa.appendChild(Z);if(M.ie&&M.win&&typeof j.styleSheets!=D&&j.styleSheets.length>0){n=j.styleSheets[j.styleSheets.length-1]}G=X}if(M.ie&&M.win){if(n&&typeof n.addRule==r){n.addRule(ac,Y)}}else{if(n&&typeof j.createTextNode!=D){n.appendChild(j.createTextNode(ac+" {"+Y+"}"))}}}function w(Z,X){if(!m){return}var Y=X?"visible":"hidden";if(J&&c(Z)){c(Z).style.visibility=Y}else{v("#"+Z,"visibility:"+Y)}}function L(Y){var Z=/[\\\"<>\.;]/;var X=Z.exec(Y)!=null;return X&&typeof encodeURIComponent!=D?encodeURIComponent(Y):Y}var d=function(){if(M.ie&&M.win){window.attachEvent("onunload",function(){var ac=I.length;for(var ab=0;ab<ac;ab++){I[ab][0].detachEvent(I[ab][1],I[ab][2])}var Z=N.length;for(var aa=0;aa<Z;aa++){y(N[aa])}for(var Y in M){M[Y]=null}M=null;for(var X in swfobject){swfobject[X]=null}swfobject=null})}}();return{registerObject:function(ab,X,aa,Z){if(M.w3&&ab&&X){var Y={};Y.id=ab;Y.swfVersion=X;Y.expressInstall=aa;Y.callbackFn=Z;o[o.length]=Y;w(ab,false)}else{if(Z){Z({success:false,id:ab})}}},getObjectById:function(X){if(M.w3){return z(X)}},embedSWF:function(ab,ah,ae,ag,Y,aa,Z,ad,af,ac){var X={success:false,id:ah};if(M.w3&&!(M.wk&&M.wk<312)&&ab&&ah&&ae&&ag&&Y){w(ah,false);K(function(){ae+="";ag+="";var aj={};if(af&&typeof af===r){for(var al in af){aj[al]=af[al]}}aj.data=ab;aj.width=ae;aj.height=ag;var am={};if(ad&&typeof ad===r){for(var ak in ad){am[ak]=ad[ak]}}if(Z&&typeof Z===r){for(var ai in Z){if(typeof am.flashvars!=D){am.flashvars+="&"+ai+"="+Z[ai]}else{am.flashvars=ai+"="+Z[ai]}}}if(F(Y)){var an=u(aj,am,ah);if(aj.id==ah){w(ah,true)}X.success=true;X.ref=an}else{if(aa&&A()){aj.data=aa;P(aj,am,ah,ac);return}else{w(ah,true)}}if(ac){ac(X)}})}else{if(ac){ac(X)}}},switchOffAutoHideShow:function(){m=false},ua:M,getFlashPlayerVersion:function(){return{major:M.pv[0],minor:M.pv[1],release:M.pv[2]}},hasFlashPlayerVersion:F,createSWF:function(Z,Y,X){if(M.w3){return u(Z,Y,X)}else{return undefined}},showExpressInstall:function(Z,aa,X,Y){if(M.w3&&A()){P(Z,aa,X,Y)}},removeSWF:function(X){if(M.w3){y(X)}},createCSS:function(aa,Z,Y,X){if(M.w3){v(aa,Z,Y,X)}},addDomLoadEvent:K,addLoadEvent:s,getQueryParamValue:function(aa){var Z=j.location.search||j.location.hash;if(Z){if(/\?/.test(Z)){Z=Z.split("?")[1]}if(aa==null){return L(Z)}var Y=Z.split("&");for(var X=0;X<Y.length;X++){if(Y[X].substring(0,Y[X].indexOf("="))==aa){return L(Y[X].substring((Y[X].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(a){var X=c(R);if(X&&l){X.parentNode.replaceChild(l,X);if(Q){w(Q,true);if(M.ie&&M.win){l.style.display="block"}}if(E){E(B)}}a=false}}}}();
function newsMods(UL)
{
	var TO,row=0,C,items;
	if(!(UL=$(UL)))
		C=(UL=$('bullMod_News')).up('div.bullModContainer');
	else
		C=UL.up('div.bullModContainer');
	var D=C.down('div.displayContainer'),L=C.childElements()[1];
	C.select('li.bullMod').each(function(item){
		if(!item.hasClassName('featured'))
			UL.insert(item);
	})
	var items=C.select('li.bullMod');
//	items=items.concat(C.select('li.bullMod')).uniq();
	this.setup=function()
	{
		if(C.getWidth()>400)
		{
			var self=this,height=0;
			D.style.width=(C.getWidth()-247)+'px';
			L.style.position='absolute';
			L.style.right='0';
			L.style.width='220px';
			D.style.display='';
			C.addClassName('fullWidth');
			C.observe('mouseover',function(){self.stop();});
			C.observe('mouseout',function(){self.start();});
			$A(C.getElementsByClassName('border')).each(function(t){t.removeClassName('border')})
			$A(C.getElementsByTagName('li')).each(function(t){
				t.observe('mouseover',function(){self.display(this);});
			})
			C.style.minHeight=UL.getHeight()+'px';
			this.display(items[0]);
			this.TO=setInterval(function(){self.display();},5000);
		}
		else
		{
			Accordion_News=new accordion(UL.id,{onEvent : 'mouseover'});
			Accordion_News.activate(UL.down('.accordion_toggle'));
		}
	}
	this.display=function(item)
	{
		L=C.childElements()[1];
		if(item)
		{
			var temp;
			for(var i=0,row=-1;row==-1 && (temp=items[i]);i++)
				if(temp==item)
					this.row=i;
		}
		else
			if(!(item=items[++this.row]))
				item=items[this.row=0];
		if(!item.up('ul'))
			this.stop();	
		else
		{
			$A(item.up('ul').getElementsByTagName('li')).each(function(t){t.removeClassName('highlighted')});
			item.addClassName('highlighted');
			var container=item.up('div.bullModContainer').down('div.displayContainer')
			container.innerHTML=item.down('div.fullView').innerHTML;
			if(container.down('.messageContainer').innerHTML.length>150)
				container.down('.messageContainer').innerHTML=container.down('.messageContainer').innerHTML.substring(0,150) + "...";
			D.style.width=(C.getWidth()-247)+'px';
			if((container.getHeight()+10)>parseInt(C.style.minHeight))
				C.style.minHeight=(container.getHeight()+10)+'px'; 
		}
	}
	this.stop=function()
	{
		clearInterval(this.TO);
	}
	this.start=function()
	{
		var self=this;
		clearInterval(this.TO);
		this.TO=setInterval(function(){self.display();},5000);
	}
	if(C && $$('#bullMod_News li')) this.setup();
}

function imagesFade(c,s)
{
	var i=0;
	if(!s) s=5;
	if(!(c=$(c))) return;
	var img=(c.select('img'));
	if(!img[0]) return;
	c.style.position='relative';
	img.each(function(c){c.style.position='absolute';c.style.top='0px';c.style.left='0px';c.hide();});
	img[i].style.position='relative';
	img[i].style.display='';
	c.show();
	c.style.height=c.getHeight() + 'px';
	c.style.width=c.getWidth() + 'px';
	img[i].style.position='absolute';
	this.timeOut=setInterval(function(obj){return(function(){if(obj.n)obj.n();});}(this), s*1000);
	addOnload(function(obj){return(function(){obj.cache();});}(this));
	this.cache=function()
	{
		var i=0;
		imgArray = new Array();
		img.each(function(o)
		{
			imgArray[i]=new Image();
			imgArray[i++].src=o.src;
		});
	}
	this.n=function()
	{
		var n=i+1;
		if(!img[n]) n=0;
		Effect.Fade(img[i]);
		Effect.Appear(img[n]);
		i=n;
	}
}

function fillContainer(container,content)
{

	if(container && content)
	{
		startHeight=container.getHeight();
//		startContent=content.getHeight();
		content.style.minHeight=(content.getHeight()-content.style.paddingTop-content.style.paddingBottom)+'px';
		if(startHeight!=container.getHeight())
			content.style.minHeight=(parseInt(content.style.minHeight)+(startHeight-container.getHeight()))+'px';
		for(var i=0;(startHeight==container.getHeight()) && i<500;i++)
			content.style.minHeight=(parseInt(content.style.minHeight)+1)+'px';
		content.style.minHeight=(parseInt(content.style.minHeight)-1)+'px';
	}
}
function calculatePayment(code,noShipping,This,currency)
{
	var items=[],C;
	var further='',url='',i=0;
	if(!This || !(C=$(This).up('.content')))
		if(!This || !(C=$(This).up('.module')))
			if(!(C=$('mainContent')))
			{
				alert('an error has occured, please contact your administrator');
			}
	C.getElementsBySelector('select').each(function(select){
		if(select.selectedIndex!=-1 && select.options[select.selectedIndex].text!='0')
		{
			var val=[]; //name, value
			var cost,o=select.options[select.selectedIndex];
			if((cost=o.value)=="" || cost==o.text)
				if(((cost=select.options[0].value)=='' || cost==select.options[0].text) && cost!='0')
					cost=select.name.substring(select.name.indexOf("$")+1).replace( /(^.+)(\w\d+\w)(.+$)/i,'$2'); //get cost from end of string
			cost=cost.replace( /(^.+\D)(\d+)(\D.+$)/i,'$2'); //get cost from anywhere in string
			if(isNaN(o.text))
			{
				val[0]=select.name + ' -- ' + o.text;
				val[1]=cost;
				val[2]=1;
			}
			else
			{
				val[0]=select.name;
				val[1]=cost;
				val[2]=o.text;
			}
			items[items.length]=val;
		}
	});
	C.getElementsBySelector('input[type=checkbox]').each(function(select){
		if(select.checked)
		{
			var val=[]; //name, value
			val[0]=select.name;
			val[1]=select.value.replace( /(^.+\D)(\d+)(\D.+$)/i,'$2');
			val[2]=1;
			items[items.length]=val;
		}
	});
	C.getElementsBySelector('input[type=text]').each(function(input){
		if(input.value!='')
		{
			if(further!='') further+='; ';
			further+=input.name+': '+input.value;
		}
	});
	for(i=0;i<items.length;i++)
		url+='&item_name_'+(i+1)+'='+escape(items[i][0])+'&amount_'+(i+1)+'='+items[i][1]+'&quantity_'+(i+1)+'='+items[i][2];
	url='ocd.aspx?action=redirect_URL&code='+code+'&custom='+escape(further)+url+'&no_shipping='+(noShipping?noShipping:0)+'&no_note=1&currency_code='+ ((!(typeof(UKSite)!='undefined' && UKSite))?'AUD':'GBP')+'&lc=AU&notify_url=https%3A//'+ location.hostname + location.pathname +'%3Faction%3Dpaypalconfirm%26code%3D'+code+'%26paypalField%3D*default*%26increment%3Dfalse';
	C.getElementsBySelector('input[type=hidden]').each(function(input){
			url+='&'+input.name+'='+input.value;
	});
/*	var remote=window.open(url,'remote', 'left=50,top=50,toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,status=no,resizable=yes,height=780,width=800');
	if(!remote)*/
	window.location.href=url;
}

function calculatePaypal(paypalUsername,code,noShipping,This,currency)
{
	var items=[],C;
	var further='',url='',i=0;
	if(!This || !(C=$(This).up('.content')))
		if(!This || !(C=$(This).up('.module')))
			if(!(C=$('mainContent')))
			{
				alert('an error has occured, please contact your administrator');
			}
	C.getElementsBySelector('select').each(function(select){
		if(select.selectedIndex!=-1 && select.options[select.selectedIndex].text!='0')
		{
			var val=[]; //name, value
			var cost,o=select.options[select.selectedIndex];
			if((cost=o.value)=="" || cost==o.text)
				if((cost=select.options[0].value)=='' || cost==select.options[0].text)
					cost=select.name.substring(select.name.indexOf("$")+1).replace( /(^.+)(\w\d+\w)(.+$)/i,'$2'); //get cost from end of string
			cost=cost.replace( /(^.+\D)(\d+)(\D.+$)/i,'$2'); //get cost from anywhere in string
			if(isNaN(o.text))
			{
				val[0]=o.text;
				val[1]=cost;
				val[2]=1;
			}
			else
			{
				val[0]=select.name;
				val[1]=cost;
				val[2]=o.text;
			}
			items[items.length]=val;
		}
	});
	C.getElementsBySelector('input[type=checkbox]').each(function(select){
		if(select.checked)
		{
			var val=[]; //name, value
			val[0]=select.name;
			val[1]=select.value.replace( /(^.+\D)(\d+)(\D.+$)/i,'$2');;
			val[2]=1;
			items[items.length]=val;
		}
	});
	C.getElementsBySelector('input[type=text]').each(function(input){
		if(input.value!='')
		{
			if(further!='') further+='; ';
			further+=input.name+': '+input.value;
		}
	});
	for(i=0;i<items.length;i++)
		url+='&item_name_'+(i+1)+'='+escape(items[i][0])+'&amount_'+(i+1)+'='+items[i][1]+'&quantity_'+(i+1)+'='+items[i][2];
	window.open('https://www.paypal.com/cgi-bin/webscr?cmd=_cart&upload=1&business='+paypalUsername+url+'&custom='+escape(further)+'&no_shipping='+(noShipping?noShipping:0)+'&no_note=1&currency_code='+ ((!(typeof(UKSite)!='undefined' && UKSite))?'AUD':'GBP')+'&lc=AU&notify_url=https%3A//'+ location.hostname + location.pathname +'%3Faction%3Dpaypalconfirm%26code%3D'+code+'%26paypalField%3D*default*%26increment%3Dfalse','remote', 'left=50,top=50,toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,status=no,resizable=yes,height=780,width=800');
}
  function findAddress(address,show,target) {
  if(target)target=$(target)
  else target=$('googleMap');
	if($('showGoogle'))
	{
		if(!$('showGoogle').checked)
		{
			$('googleFound').hide();
			target.style.visibility='hidden';
			return;
		}
		$('googleFound').show();
	}
  if(typeof(geocoder)=='undefined' || !geocoder)
  {
    geocoder = new google.maps.Geocoder();
    var latlng = new google.maps.LatLng(-34.397, 150.644);
    var myOptions = {
      zoom: 14,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    mymap = new google.maps.Map(target, myOptions);
  }

	if (geocoder) {
	  //    var address = document.getElementById(address).value;
	    geocoder.geocode( { 'address': address}, function(results, status) {
	      if (status == google.maps.GeocoderStatus.OK) {
			if($('googleFound')) $('googleFound').innerHTML='<div class="success" style="width:164px;margin-left:0;margin-right:0;">Address found in google.<br><a href="javascript:findAddress($(\'location\').value,1)">View Map</a></div>';
			if(show)
			{
		        mymap.setCenter(results[0].geometry.location);
		        var marker = new google.maps.Marker({
		            map: mymap, 
		            position: results[0].geometry.location
		        });
				target.style.visibility='';
			}			

	      } else {
			if($('googleFound')) $('googleFound').innerHTML='<div class="warning" style="width:164px;margin-left:0;margin-right:0;">Address not found in google.</div>';
			//target.hide();
			target.style.visibility='hidden';
	      }
	    });
	}
  }

/*function findAddress(address) {
	if(!$('showGoogle').checked)
	{
		$('googleFound').hide();

		$('googleMap').style.visibility='hidden';
		return;
	}
	$('googleFound').show();
	if (geocoder) {
		geocoder.getLatLng(
        	address,
        	function(point) {
				if (!point) {
					$('googleFound').innerHTML='<div class="warning" style="width:164px;margin-left:0;margin-right:0;">Address not found in google.</div>';
					$('googleMap').hide();
            	} else {
					$('googleFound').innerHTML='<div class="success" style="width:164px;margin-left:0;margin-right:0;">Address found in google.<br><a href="javascript:showGoogleMap($(\'location\').value)">View Map</a></div>';
            	}});
    }
    if(map) showGoogleMap(address);
}*/
function showGoogleMap(address,target,displayText) 
{
	if(!target) target='googleMap';
	if(displayText) displayText='<div class="googleSpeechBubble">'+displayText+'<div style="clear:both"></div></div>';
	if($('showGoogle'))
	{
		if(!$('showGoogle').checked)
		{
			$('googleFound').hide();
			$(target).style.visibility='hidden';
//			$('googleMap').hide();
			return;
		}
		$('googleFound').show();
	}
	if (GBrowserIsCompatible()){
	map=null;
		if(!map)
		{
	      map = new GMap2(document.getElementById(target));
	      map.addControl(new GSmallMapControl());
	      map.addControl(new GScaleControl());
	    }
		if (geocoder) {
			geocoder.getLatLng(
	        	address,
	        	function(point) {
					if (!point) {
						if($('showGoogle'))
						{
							$('googleFound').innerHTML='<div class="warning" style="width:164px;margin-left:0;margin-right:0;">Address not found in google.</div>';
							$('googleMap').hide();
						}
	            	} else {
	            		if($(target))
	            		{
							$(target).show();
							$(target).style.visibility='visible';
	              		}
	              		map.setCenter(point, 14);
	               		var marker = new GMarker(point);
//	               		map.addOverlay(marker);



				map.addOverlay(marker, displayText);
				if(displayText){
					marker.openInfoWindowHtml(displayText);
				}
				GEvent.addListener(marker, "click", function()
				{
					map.openInfoWindowHtml(point, displayText);
				});



	            	}});
		    }
    }
}
function getSelectCount(select){
	var counter=0;
	for (var i = 0; i < select.options.length; i++)
	if (select.options[i].selected)
		counter++;
	return counter;
}
var logoutTimer=null;
function resetLogoutTimer(code,reset)
{
	if(window!=window.parent && window.parent.resetLogoutTimer)
	{
		window.parent.resetLogoutTimer(code,reset);
		return;
	}	
	if(logoutTimer && !reset)
	{
		if(logoutTimer) clearTimeout(logoutTimer)
		if(!confirm('You will be timed out of this site due to inactivity in 5 minutes, click OK to reset the timer.')){
			logoutTimer=null;	
			return;
		}
		new Ajax.Request('ocd.aspx', {method: 'post',postBody: 'action=main&code='+code,onSuccess: function(transport){
			if(transport.responseText.match('please enter your password')){
				newwin=window.open('', 'admin_remote', 'left=50,top=50,toolbar=no,location=no,directories=no,menubar=no,scrollbars=auto,status=no,resizable=no,height=200,width=400');
				newwin.document.write('<HTML><HEAD><TITLE>Login</TITLE><link rel="StyleSheet" href="/defaults/modules.css" type="text/css" media="screen"/><link rel="StyleSheet" href="/defaults/allsites.css" type="text/css" media="screen"/><script type="text/javascript" src="/library/prototype.js"></script><script type="text/javascript" src="/library/core.js"></script></HEAD>'+
					'<body style="padding:20px"><form onsubmit="ajaxSuccess(\'ocd.aspx\',\'action=verify&code='+code+'&password=\'+$(\'password\').value,\'post\',\'resetLogoutTimer\',function(){window.close();},function(){alert(\'An error has occurred, please try again.\');});return false;">'+
					'<div class="info">You have been logged out, please enter your password.</div><div class="blank"><b>Password</b><br><input type="password" name="password" id="password"> <input class="ButtonSmall" type="submit" name="B1" value="&gt;"></div></form></body></HTML>');
			   newwin.document.close();
			}
		}});
	}
	if(logoutTimer) clearTimeout(logoutTimer)
	logoutTimer=setTimeout('resetLogoutTimer("'+ code +'",0);',25*60*1000);//1500
}

function ajaxSuccess(url,postBody,method,successText,onSuccess,onFail)
{
	
	var success=false;
	new Ajax.Request(url, {
		method: method,
		postBody: postBody,
		onSuccess: function(transport) {
			var response=transport.responseText,not=0;
			if(response.charAt(0)=='!'){
				not=1;
				response=response.substring(1);
			}
			if ((response.toLowerCase().match(successText.toLowerCase()) && !not) || (not && !response.toLowerCase().match(successText.toLowerCase())))
			{
				if(onSuccess) onSuccess(transport);
				success=true;
			}
			else
				if(onFail) onFail(transport);
		},
		onFailure: function(transport){
			if(onFail) onFail(transport);
		}
	});
	return success;
}

function enableDDIndex(checked,code)
{
	if(checked)
	{
		$$('#photoIndexContainer div.handle').each(function(obj){
			Effect.Appear(obj);
		});
		Sortable.create($('photoIndexContainer'),{
			tag:'div',overlap:'horizontal',only:'photoBoard',scroll:window,onUpdate: function() {
				new Ajax.Request('ocd.aspx' , {
					method: 'post',postBody:getFormData('indexForm')
				});
			}//,handle:'handle'
		});
	}
	else
	{
		$$('#photoIndexContainer div.handle').each(function(obj){
			Effect.Fade(obj);
		});
		Sortable.destroy($('photoIndexContainer'))
	}
}

function loadDragDrop(sortables,code){

	$('menuDragDrop').value='on'
	sections = $$('.photoBContainer,.photoMenuItem');
	$$('.photoBContainer div.handle').each(function(obj){Effect.Appear(obj);})
	sortables.each(function(sort){Sortable.create(sort,{tag:'div',handle:'handle',containment: sections,only:'tableWrapper',overlap:'horizontal',scroll:window,onUpdate: function() {new Ajax.Request('ocd.aspx' , {method: 'post',postBody:getPhotoBoardCats()+'&code='+code});}});})
	$$('.photoBContainer div.catHandle').each(function(obj){Effect.Appear(obj);})
	Sortable.create('categoriesContainer',{tag:'div',handle:'catHandle',only:'photoBContainer',scroll:window,onUpdate: function() {new Ajax.Request('ocd.aspx' , {method: 'post',postBody:getPhotoBoardCats()+'&code='+code});}});
}
function disableDragDrop(sortables){
	$('menuDragDrop').value=''
//	$('categoriesContainer').removeClassName('dragDrop');
	$$('.photoBContainer div.catHandle').each(function(obj){Effect.Fade(obj);})
	$$('.photoBContainer div.handle').each(function(obj){Effect.Fade(obj);})
	for(var i=0;i<sortables.length;i++)
		Sortable.destroy(sortables[i]);
	Sortable.destroy('categoriesContainer');
}

function movePhotos(from,to,code)
{
	var j,forms=$(from).getElementsByTagName('form'),postString='action=photo_categories&ajaxcontent=on&code='+code+'&dragdrop=on&';
	for(j=0;j<forms.length;j++)
	{
		var form=forms[j];
//		$(form).down('#pBoard2').value=unescape(to.id.substring(11));
//		$(form).down('#pBoard').selectedIndex=0;
		$(form).elements[7].value=unescape(to.id.substring(11));//7
		$(form).elements[6].selectedIndex=0;//6
		postString+=getFormData(form.name) + '&';
		if(from.id.indexOf('catCon')==-1) from.remove();		
	}
	if(from.id.indexOf('catCon')!=-1) from.remove();		
	new Ajax.Request('ocd.aspx' , {method: 'post',postBody:postString});
	document.forms.photoIndex.sub_dir.value=$('photoboardName').innerHTML;
	if($(to).down('noOfPhotos'))
	{
		$(to).down('#noOfPhotos').innerHTML=$(to).down('#noOfPhotos').innerHTML*1+j;
		setTimeout('Effect.Shake($$("#carousel_photoB #'+to.id+'")[0].down(".noOfPhotosContainer"));',500);
	}
//	Effect.Shake(to.down('.noOfPhotosContainer'));
}

function getPhotoBoardCats()
{
	var cats = $$('#categoriesContainer .photoBContainer'),postString='action=photo_categories&ajaxcontent=on&resetIndex=on&dragdrop=on&';
	for(var i=0;i<cats.length;i++)
	{
		var cat=$(cats[i]);
		var forms=cat.getElementsByTagName('form');
		for(var j=0;j<forms.length;j++)
		{
			var form=$(forms[j]),id;
			id=unescape(cat.down('div.photoboardTitle').innerHTML);
			form.elements[1].value=id;
			if($F(select=form.elements[11])!=id)
				select.selectedIndex=0;
			postString+=getFormData(form.name) + '&';
		}
	}
//	alert(postString);
	return postString;
}

function getMenuItems() {
	var items = $$('#menuEditContainer li.menu')
	var returnString = '';
	var i=1;
	items.each(function(item) {
		returnString+='menuItemText_' + i + '=' + escape(item.down().value) + '&menuItem_' + i++ + '=' + escape(item.id) + '&';
	});
	return 'action=editMenuItems&'+returnString;
}

function toolTip(o,m,c,type)//newHook,newStem,newOffset)
{
	if(typeof(Tip)=='undefined')
	{
		if(type==3) //was a click 
			window.parent.document.location.href='ocd.aspx'
		else if(m.indexOf("<a")==-1)
			$(o).observe('click',function(){alert(c+'\n\n'+m.replace(/<br>/gi,"\n"))});
		return;
	}
	var newStem,newHook,newOffset,newCloseButton=false,newHideAfter=1,newShowOn='mousemove';
	if(type==3)
	{
		newCloseButton=true;
		newHideAfter=0;
		newShowOn='click'
		newStem='topRight';
		newHook={tip:'topRight',target:'bottomRight'};
		newOffset={x: 0, y: 0};
	}
	else if(!type || type==1)//0=to mouse 1=to object corner
	{
		newStem='topLeft';
		newHook=(type)?{tip:'topLeft',target:'bottomRight'}:{tip:'topLeft',mouse: true};
		newOffset={ x: 0, y: type?10:10 };
	}
	else if(type==2) //2=no stem beneith middle
	{
		newStem='';
		newHook={ tip: 'topMiddle', mouse: true }
		newOffset={ x: 0, y: 5 };
	}
	var ob=new Tip(o, m, {
	    title : c,
		style: 'protoblue',
		hideOthers: true,
		stem: newStem?newStem:'',
		fixed: true,
		hook: newHook,
		offset: newOffset,
		hideOn: false, // disable the normal hide event, because we only want to use the hideAfter option
		hideAfter: newHideAfter,
		closeButton: newCloseButton,
		showOn: newShowOn
	});
	return ob;
}

function printFriendlyName(field)
{
	var fields= new Array();fields["fname"]="first name";fields["lname"]="last name";fields["emailaddr"]="email address";
	fields["dob"]="date of birth";fields["dob_day"]="day of birth";fields["dob_month"]="month of birth";fields["dob_year"]="year of birth";fields["res_mobile"]="mobile number";fields["res_street"]="address";fields["password_check"]="password confirmation";
	fields["fyear"]="peer year";fields["bus_name"]="business name";fields["bus_title"]="business title";fields["bus_dept"]="business department";
	fields["bus_sector"]="business sector";fields["bus_industry"]="business industry";
	if(fields[field]) return fields[field];
	else return null;
}

function echeck(str) {
	var at="@",dot=".",lat=str.indexOf(at),lstr=str.length,ldot=str.indexOf(dot);
	if (str.indexOf(at)==-1) return false;
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr) return false;
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr) return false;
	if (str.indexOf(at,(lat+1))!=-1) return false;
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot) return false;
	if (str.indexOf(dot,(lat+2))==-1) return false;
	if (str.indexOf(" ")!=-1) return false;
	return true;
}

function checkRequiredFields(fields)
{
	var message='',first;
	$$('input.example').each(function(item) {
	  if(item.disabled!=true && item.value!='')
		item.value='';
	});
	fields=fields.split(/[\t,;]+/);
//	fields=fields.concat('fname,lname,fyear,password,password_check,secretQuestion1,secretAnswer1,secretQuestion2,secretAnswer2,dob_day,dob_month,dob_year'.split(','));
	fields=$A(fields).uniq();
	for(var i=0;i<fields.length;i++)
	{ 
		var item=fields[i],str;
		if($(item) && (($F(item)=='') || ($F(item)==' ') || (fields[i]=='emailaddr' && !echeck($F(item)))))
		{
			if(!first) first=item;
			$(item).addClassName('notMatch');
			$(item).observe('keydown',function(){$(this).removeClassName('notMatch')});
			$(item).observe('change',function(){$(this).removeClassName('notMatch')});
			if(fields[i]=='emailaddr') message+='You have not entered a valid email address, please confirm\n';
			else if(str=printFriendlyName(item)) message+='You have not entered a value for your ' + str +'\n';
			else if(!message) message+='You have not entered a value for a required field\n';
		}
	}
	if(message!='')
	{
		alert(message);
		Effect.ScrollTo($(first).up());
		return false;
	}
	else 
		return true;
}

function citySelect(me,target,prepend)
{
	if(!target) target='countriesContainer';
	if(!me)
		submitAjax(target,0,0,0,0,0,0,0,"/reference/php/citiesdropdownlist/index.php?prepend="+prepend)
	else if (me.name == (prepend+"country")) {
		submitAjax(target,0,0,0,0,0,0,0,"/reference/php/citiesdropdownlist/index.php?countries=" + encodeURIComponent(me.value)+"&prepend="+prepend)
	}
	else if (me.name == (prepend+"state")) {
		submitAjax(target,0,0,0,0,0,0,0,"/reference/php/citiesdropdownlist/index.php?countries=" + encodeURIComponent(document.getElementById(prepend+"country").value) + "&states=" + encodeURIComponent(me.value)+"&prepend="+prepend)
	}
}

function setupPBoard(name){
var hCarousel_pBoard=new UI.Carousel(name);
}

function displayNetworking(name)
{
	$$('#networkingContainer .networkingItem').each(function(item) {
	  if(!($(item).down('input').value=='' || $(item).down('input').className.indexOf(' example')!=-1) || item.down('input').name==name)
	  {
	  	item.style.display='';
		$(item).down('input').disabled=false;
//		if(item.down('input').name==name) $(item).down('input').focus();
	  }
	  else
	  {
	  	item.style.display='none';
		$(item).down('input').disabled=true;
	  }
	});
}

function resizeLW(width,height)
{
	var contents,container;
	if($('lightwindow_contents'))
	{
		contents=$('lightwindow_contents');
		container=$('lightwindow_container');
	}
	else
	{
		contents=window.parent.$('lightwindow_contents');
		container=window.parent.$('lightwindow_container');
	}
	
	contents.style.width=width+'px';
	contents.style.height=height+'px';
	container.style.width=(width*1+20)+'px';
	container.style.height=(height*1+87)+'px';
	container.style.left= -((width+20)/2)+'px';
	container.style.top= -((height+87)/2)+'px';
}


function placeAll(text)
{
	if(!$('PBall').checked)
	{
		alert('You can only change all values if you have the appropriate selection in Step 1');
		return;
	}
	Ins = document.getElementsByTagName('input');
	Sels = document.getElementsByTagName('select');
	for (i=0;i<Sels.length;i++)
	if(Sels[i].name.indexOf('moveTo')==0)
	{
		var found=0;
		opts=Sels[i].options;
		for(j=0;j<opts.length;j++)
		{
			if(opts[j].text==text)
			{
				found=1;
				Sels[i].selectedIndex=j;
			}
		}
		if(!found) Sels[i].selectedIndex=0;
	}
	for ( i = 0; i < Ins.length; i++ )
	if ( Ins[i].type == 'text' && Ins[i].name.indexOf('moveTo')==0)
	Ins[i].value=text;
}
function slideUpDown(name,dir)
{
	if(typeof(name)!='object') name=$(name);
	if(name.visible())
	{
		if(dir!='down') Effect.SlideUp(name, { duration: 0.5 });
	}
	else
	{
		if(dir!='up') Effect.SlideDown(name, { duration: 0.5 });
	}
}

function setTeamSelect(r,g,t)
{
	var im0=$('cbi_r'+r+'g'+g+'t0');
	var cb0=$('cb_r'+r+'g'+g+'t0');
	var im1=$('cbi_r'+r+'g'+g+'t1');
	var cb1=$('cb_r'+r+'g'+g+'t1');
	var im2=$('cbi_r'+r+'g'+g+'d');
	var cb2=$('cb_r'+r+'g'+g+'d');
	if(!t)
	{
		im0.className='CBticked';
		cb0.checked=true;
	}else{
		im0.className='CBunticked';
		cb0.checked=false;
	}
	if(t==1)
	{
		im1.className='CBticked';
		cb1.checked=true;
	}else{
		im1.className='CBunticked';
		cb1.checked=false;
	}
	if(t==2 && im2 && cb2)
	{
		im2.className='CBticked';
		cb2.checked=true;
	}else if(im2 && cb2){
		im2.className='CBunticked';
		cb2.checked=false;
	}
	tippingChange=1;	
}
 function AddSelectOption(tempselectObj, text, value, isSelected) 
{
	var selectObj=tempselectObj;
	if(typeof(selectObj)=='string') 
		if(!(selectObj=$$('select#' + tempselectObj)[0]))
			selectObj=$$('select[name=' + tempselectObj + ']')[0]
			
    if (selectObj != null && selectObj.options != null)
    {
        selectObj.options[selectObj.options.length] = 
            new Option(text, value, false, isSelected);
    }
}

function printYears(selectObj,start,negoffset,posoffset)
{
	selectObj=$(selectObj);
	if(start || negoffset)
	{
		end=(new Date()).getYear();
		if(end<1000)
			end+=1900;
		if(negoffset)
			start=end-negoffset;
		if(posoffset)
			end+=posoffset;
		for (;end>=start;end--)
		{
//			document.write('<option>'+end);
			AddSelectOption(selectObj, end,end, false);
		}
	}
	else
	{
		start=(new Date()).getYear();
		if(start<1000)
			start+=1900;
		end=start+posoffset;
		for (;end>=start;start++)
		{
//			document.write('<option>'+start);
			AddSelectOption(selectObj, start,start, false);
		}
	}

}
function printCountries()
{
	var c = new Array('Afghanistan','Albania','Algeria','Andorra','Angola','Antarctica','Antigua and Barbuda','Argentina','Armenia','Australia','Austria','Azerbaijan','Bahrain','Bangladesh','Barbados','Belarus','Belgium','Belize','Benin','Bhutan','Bolivia','Bosnia and Herzegovina','Botswana','Brazil','Brunei','Bulgaria','Burkina Faso','Burma (Myanmar)','Burundi','Cambodia','Cameroon','Canada','Cape Verde','Cayman Islands','Central African Republic','Chad','Chile','China','Colombia','Comoros','Congo, Republic of','Costa Rica','Cote d\'Ivoire','Croatia','Cuba','Cyprus','Czech Republic','Denmark','Djibouti','Dominica','Dominican Republic','Ecuador','Egypt','El Salvador','Equatorial Guinea','Eritrea','Estonia','Ethiopia','Fiji','Finland','France','French Guiana','Gabon','Georgia','Germany','Ghana','Greece','Greenland (Kalaallit Nunaat)','Grenada','Guatemala','Guinea','Guinea-Bissau','Guyana','Haiti','Honduras','Hong Kong','Hungary','Iceland','India','Indonesia','Iran','Iraq','Ireland','Israel','Italy','Ivory Coast (Cote d\'Ivoire)','Jamaica','Japan','Jordan','Kazakstan','Kenya','Kiribati','Korea, North','Korea, South','Kuwait','Kyrgyzstan','Laos','Latvia','Lebanon','Lesotho','Liberia','Libya','Liechtenstein','Lithuania','Luxembourg','Macedonia','Madagascar','Malawi','Malaysia','Maldives','Mali','Malta','Marshall Islands','Mauritania','Mauritius','Mexico','Micronesia','Moldova','Monaco','Mongolia','Morocco','Mozambique','Myanmar','Namibia','Nauru','Nepal','Netherlands','New Zealand','Nicaragua','Niger','Nigeria','Norway','Oman','Pakistan','Palau','Panama','Papua New Guinea','Paraguay','Peru','Philippines','Poland','Portugal','Qatar','Romania','Russia','Rwanda','Sain','Saint Kitts and Nevis','Saint Lucia','Saint Vincent and the Grenadines','Samoa','San Marino','Sao Tome and Principe','Saudi Arabia','Senegal','Serbia and Montenegro','Seychelles','Sierra Leone','Singapore','Slovakia (Slovak Republic)','Slovenia','Solomon Islands','Somalia','South Africa','Spain','Sri Lanka','Sudan','Suriname','Swaziland','Sweden','Switzerland','Syria','Taiwan','Tajikistan','Tanzania','Thailand','The Bahamas','The Gambia','Timor-Leste','Togo','Tonga','Trinidad and Tobago','Tunisia','Turkey','Turkmenistan','Tuvalu','Uganda','Ukraine','United Arab Emirates','United Kingdom','United States of America','Uruguay','Uzbekistan','Vanuatu','Vatican City','Venezuela','Vietnam','Yemen','Zambia','Zimbabwe')
	var t = (typeof(defaultCountries)!='undefined')?defaultCountries:(new Array(9,31,60,75,127,189,190));
	var home=(typeof(homeCountry)!='undefined')?homeCountry:(((typeof(UKSite)!='undefined' && UKSite))?189:9);
	var i,ar=$A(arguments),showH=0;
	var selectObj=ar.shift();
	if((showH=(ar[0]=='Y' || ar[0]=='y')) || ar[0]=='N' || ar[0]=='n') i=1;
	else if((showH=(ar[1]=='Y' || ar[1]=='y')) || ar[1]=='N' || ar[1]=='n'){
		if((home=ar[0]).length>2) home=c.indexOf(ar[0]);
		i=2;}
	else i=(showH=0);
//If no arguements, print default pre-list//
	if(i==ar.length){ for(i=0;t[i];i++) if (t[i]!=home || showH) AddSelectOption(selectObj, c[t[i]], c[t[i]], false);}
	else for (i; i < ar.length; i++) AddSelectOption(selectObj, c[ar[i]], c[ar[i]], false);
	AddSelectOption(selectObj, '-----------------------------------', ' ', false);
	for(i=0;c[i];i++) if (i!=home || showH) AddSelectOption(selectObj, c[i], c[i], false);
}

function slideList(panel,mod,li,inc,dontTO) {
    var This;
	if(!inc) inc=1;
	for(This=$('list_'+panel+'_'+mod+'_'+li);This && This.style.display=='none';This=$('list_'+panel+'_'+mod+'_'+(++li)));
	if(!This)
		var This=$('list_'+panel+'_'+mod+'_'+(li=0));
	var Next;
	if(!(Next=$('list_'+panel+'_'+mod+'_'+(li+=inc))))
	{
		if(inc==1) Next=$('list_'+panel+'_'+mod+'_'+(li=0));
		else for(Next=$('list_'+panel+'_'+mod+'_'+(li=0));$('list_'+panel+'_'+mod+'_'+(li*1+1));Next=$('list_'+panel+'_'+mod+'_'+(li++)));
	}
	if(!Next)
		return;
	if(inc>0)
	{
		var i;
		if((i=(Next.style.left.replace("px","")))>2 && i<300)
		{
			slideList(panel,mod,li,inc,dontTO);
			return;
		}
		Next.style.left='300px';
		Next.style.zIndex='2';
		Next.show();
		This.style.zIndex='1';
		Next.morph('left:2px');
//		Next.morph('left:8px',{duration: 3,transition:Effect.Transitions.spring});
		setTimeout('$("'+This.id+'").hide();',1000);
	}
	else
	{
		Next.style.zIndex='1';
		This.style.zIndex='2';
		Next.show();
		Next.style.left='2px';
		This.morph('left:300px');
//		This.morph('left:300px',{duration: 3,transition:Effect.Transitions.spring});
		setTimeout('$("'+This.id+'").hide();',3000);
	}
	if(!dontTO)
		window['l_'+mod]=setTimeout('slideList(0,\''+mod+'\','+li+');',5000);
	return;
}
function getSelectionId(text, li)
{
	form=$('autoCompleteForm');
//alert(li.id);
	if(li.id)
	{
		form.ref_no.value=li.id;
		form.down('#autocomplete').value='';
	}
	form.submit();
}

function setupActiveSearch(code,fieldName,results,onComplete,admin)
{
	new Ajax.Autocompleter
	(
		fieldName||"autocomplete", results||"autocomplete_choices", "ocd.aspx",
		 {
		 	minChars: 3
		 	,parameters:'code='+code+'&action=autocomplete&search_exact=not' + (admin?'&searchAll=on':'')
		 	,afterUpdateElement : onComplete?((typeof(onComplete)=='function')?onComplete:function(text,li){$(onComplete).value=li.id;return false;}):getSelectionId
		 	,indicator: $('autoSearchLoading')?'autoSearchLoading':null
	 });
}

function transMod(T,mod,s)
{
	var last=eval('l_'+mod),This='mod_'+last+'_'+mod,Next,type=T;
	if(!$(Next='mod_'+(++last)+'_'+mod))
		Next='mod_'+(last=1)+'_'+mod;
	$(This).absolutize();
	$(This).style.top='0px'
	if(!type) type=Math.floor(Math.random()*6)+1;
	switch(type)
	{
		case 1:
			Effect.Fade(This,{duration: 2});
			Effect.Appear(Next,{duration: 2,afterFinish: function() { resetMods(mod); }});
			break;
		case 2:
			Effect.Puff(This,{duration: 2});
			Effect.Appear(Next,{duration: 2,afterFinish: function() { resetMods(mod); }});
			break;
		case 3:
			Effect.DropOut(This,{duration: 2});
			Effect.BlindDown(Next,{duration: 2,afterFinish: function() { resetMods(mod); }});
			break;
		case 4:
			Effect.Shrink(This,{duration: 1.5});
			Effect.Grow(Next,{delay: 1,duration: 1.5,afterFinish: function() { resetMods(mod); }});
			break;
		case 5:
			Effect.SwitchOff(This,{duration: 2});
			Effect.BlindDown(Next,{duration: 2,delay: 1,afterFinish: function() { resetMods(mod); }});
			break;
		case 6:
			Effect.DropOut(This,{duration: 1.5});
			Effect.SlideDown(Next,{delay:1,duration: 3,transition:Effect.Transitions.Elastic,afterFinish: function() { $(Next).relativize();resetMods(mod); }});
			break;
	}
	window['l_'+mod]=last;
	setTimeout('transMod('+T+',"'+mod+'",'+s+')',(s||10)*1000);
}
// Elastic (adapted from "EaseOutElastic") divided by 2 to reduce overshoot
Effect.Transitions.Elastic = function(pos) {
    return -1*Math.pow(4,-8*pos) * Math.sin((pos*6-1)*(2*Math.PI)/2) + 1;
};
function resetMods(mod)
{
return;
	var p;
	for(var j=1;m=$('mod_'+j+'_'+mod);j++)
		with(m)
		{
			if(style.position=='absolute')
			{
				if(!p)p=$(m.parentNode);
//				style.left=(p.cumulativeOffset()[0]+2*1)+'px';
//				style.top=p.cumulativeOffset()[1]+'px';
			}
			else
			{
				style.left='0px';
				style.top='0px';
			}
		}
}

var Editor =function()
{
	this.getHTML = function() {
		var oEditor = FCKeditorAPI.GetInstance('htmlmessage') ;
		return oEditor.GetXHTML();
	}
	this.focusEditor = function(text) {
	}
	this.setMode = function() {
	}
	this.config = function() {
		this.baseURL=null;
	}
	this.insertHTML = function(text) {
		var oEditor = FCKeditorAPI.GetInstance('htmlmessage') ;
		oEditor.InsertHtml(text);
	}
	this.setHTML = function(text) {
		var oEditor = FCKeditorAPI.GetInstance('htmlmessage') ;
		oEditor.SetHTML(text);
	}	
}
//editorconfig = function () {
//	this.baseURL=null;
//}
editor = new Editor;

function showImageAbove(imghref,height,modName)
{
	var img,txt;
	if(imghref)
	{
		(img=$('carousel_'+modName)).innerHTML='<div style="text-align:center"><img style="margin:auto;max-width:none;" src="' + imghref + '" height='+height+'/></div>';
		img.style.visibility='';
		$('carouselText_'+modName).hide();
	}
	else
	{
		$('carousel_'+modName).style.visibility='hidden';
		$('carouselText_'+modName).show();
	
	}
}
function slideUL(name,start)
{
	if(!$(name))
	{
		alert('no list by name -' +name);
		return;
	}
	this.listNo=0;
	this.timeOut=null;
	this.c=$(name);
	this.rows=this.c.getElementsByTagName('li');
	if(this.c.style.position!='absolute')
		this.c.style.position='relative';
	for(var i=1;i<this.rows.length;i++)
		$(this.rows[i]).hide();
	this.setDim=function()
	{	
		this.c.style.width=this.c.getWidth()+'px';
		this.c.style.height=this.c.getHeight()+'px';
		this.c.style.overflow='hidden';
		this.y=$(this.rows[0]).positionedOffset()[0]+'px';
		this.x=this.rows[0].positionedOffset()[1]+'px';
		for(var i=0;i<this.rows.length;i++)
		{
			with($(this.rows[i]))
			{
				style.width=getWidth()+'px';
				style.height=getHeight()+'px';
				style.position='absolute';
				if(i!=0) hide();
			}
		}
	}
	this.i=function()
	{	
		var t=this.rows[this.listNo];
		this.listNo=(++this.listNo)%this.rows.length;
		var n=this.rows[this.listNo];
		n.style.left='300px';
		if(!this.y) this.setDim();
		n.style.top=this.y;
		n.style.zIndex='2';
		n.show();
		t.style.zIndex='1';
		n.morph('left:'+ this.x);
		t.fade({delay:.4});
	}
	this.d=function()
	{	
		var t=this.rows[this.listNo];
		if(--this.listNo<0) this.listNo=this.rows.length-1;
		var n=this.rows[this.listNo];
		n.style.zIndex='1';
		t.style.zIndex='2';
		if(!this.y) this.setDim();
		n.style.top=this.y;
		n.hide();
		n.style.left=this.x;
		t.morph('left:300px');
		n.appear();
	}
	this.p=function()
	{
		clearTimeout(this.timeOut)
	}
	this.s=function()
	{
		if(this.listNo<0 || this.listNo>this.rows.length)
			alert('error - no ' + this.listNo)
		if(this.rows.length==1)
			return;
		this.TO;
	} 
	this.TO=function()
	{
		this.timeOut=setInterval(function(obj){return(function(){obj.i();});}(this), 5000); //this uses closure apparently...
	}
	if(start)
		this.TO();
}

function imageOver(image,over)
{
	src=image.src;
	var last=src.substring(src.lastIndexOf('.'));
	if(over)
	{
		var first=src.substring(0,src.lastIndexOf('.'));
		image.src=first+'_over'+last;
	}
	else
	{
		var first=src.substring(0,src.lastIndexOf('_over'));
		image.src=first+last;
	}
}

if (typeof Effect == 'undefined')
	throw("accordion.js requires including script.aculo.us' effects.js library!");
 
var accordion = Class.create();
accordion.prototype = {
 
	//
	// Setup the Variables
	//
	showAccordion : null,
	currentAccordion : null,
	duration : null,
	effects : [],
	animating : false,
	 
	//
	// Initialize the accordions
	//
	initialize: function(container, options) {
		if (!$(container)) {
			throw(container+" doesn't exist!");
			return false;
		}
	
		this.options = Object.extend({
		resizeSpeed : 8,
		classNames : {
			toggle : 'accordion_toggle',
			toggleActive : 'accordion_toggle_active',
			content : 'accordion_content'
		},
		defaultSize : {
			height : null,
			width : null
		},
		direction : 'vertical',
		onEvent : 'click'
		}, options || {});
		 
	this.duration = ((11-this.options.resizeSpeed)*0.15);
 
	var accordions = $$('#'+container+' .'+this.options.classNames.toggle);
	if(accordions)
	accordions.each(function(accordion) {
		Event.observe(accordion, this.options.onEvent, this.activate.bind(this, accordion), false);
		if (this.options.onEvent == 'click') {
			accordion.onclick = function() {return false;};
		}
		if (this.options.onEvent == 'mouseover') { //if activates on mouseover, enable onclick override as well
			Event.observe(accordion, 'click', this.activate.bind(this, accordion), false);
		}
 
		if (this.options.direction == 'horizontal') {
			var options = {width: '0px', display:'none'};
		} else {
			var options = {height: '0px', display:'none'};
		}
		// options.merge({display: 'none'});
 
		this.currentAccordion = $(accordion.next(0)).setStyle(options);
	}.bind(this));
},
 
//
// Activate an accordion
//
	activate : function(accordion) {
		if (this.animating || !accordion) {
			return false;
		}
 
		this.effects = [];
		this.currentAccordion = $(accordion.next(0));
		this.currentAccordion.setStyle({
			display: 'block'
		});
 
		this.currentAccordion.previous(0).addClassName(this.options.classNames.toggleActive);
 
		if (this.options.direction == 'horizontal') {
			this.scaling = $H({
				scaleX: true,
				scaleY: false
			});
		} else {
			this.scaling = $H({
				scaleX: false,
				scaleY: true
			});
		}
		if (this.currentAccordion == this.showAccordion) {
			if (this.options.onEvent == 'mouseover')
				return;
			this.deactivate();
		} else {
			this._handleAccordion();
		}
	},
//
// Deactivate an active accordion
//
	deactivate : function() {
		var options = $H({
			duration: this.duration,
			scaleContent: false,
			transition: Effect.Transitions.sinoidal,
			queue: {
				position: 'end',
				scope: 'accordionAnimation'
			},
			scaleMode: {
				originalHeight: this.options.defaultSize.height ? this.options.defaultSize.height : this.currentAccordion.scrollHeight,
				originalWidth: this.options.defaultSize.width ? this.options.defaultSize.width : this.currentAccordion.scrollWidth
			},
			afterFinish: function() {
				this.showAccordion.setStyle({
				height: 'auto',
				display: 'none'
			});
			this.showAccordion = null;
			this.animating = false;
		}.bind(this)
	});
// options.merge(this.scaling);
 
	this.showAccordion.previous(0).removeClassName(this.options.classNames.toggleActive);
 
	new Effect.Scale(this.showAccordion, 0, options.update(this.scaling).toObject());
},
 
//
// Handle the open/close actions of the accordion
//
_handleAccordion : function() {
	var options = $H({
		sync: true,
		scaleFrom: 0,
		scaleContent: false,
		transition: Effect.Transitions.sinoidal,
		scaleMode: {
			originalHeight: this.options.defaultSize.height ? this.options.defaultSize.height : this.currentAccordion.scrollHeight,
			originalWidth: this.options.defaultSize.width ? this.options.defaultSize.width : this.currentAccordion.scrollWidth
		}
	});
	options.merge(this.scaling);
 
	this.effects.push(
		new Effect.Scale(this.currentAccordion, 100, options.update(this.scaling).toObject())
	);
 
	if (this.showAccordion) {
		this.showAccordion.previous(0).removeClassName(this.options.classNames.toggleActive);
 
		options = $H({
			sync: true,
			scaleContent: false,
			transition: Effect.Transitions.sinoidal
		});
		options.merge(this.scaling);
	 
		this.effects.push(
			new Effect.Scale(this.showAccordion, 0, options.update(this.scaling).toObject())
		);
	}
 
	new Effect.Parallel(this.effects, {
		duration: this.duration,
		queue: {
			position: 'end',
			scope: 'accordionAnimation'
		},
		beforeStart: function() {
			this.animating = true;
		}.bind(this),
		afterFinish: function() {
			if (this.showAccordion) {
				this.showAccordion.setStyle({
					display: 'none'
				});
			}
			$(this.currentAccordion).setStyle({
				height: 'auto'
			});
			this.showAccordion = this.currentAccordion;
			this.animating = false;
		}.bind(this)
	});
}
}
Event.observe(window, 'load', function(){window.isLoaded=true}, false);
