/*******************************************************************************************
 * cssjs
 * Written by Christian Heilmann (http://icant.co.uk)
 * Eases the dynamic application of CSS classes via DOM
 * Parameters: action a, object o and class names c1 and c2 (c2 optional)
 * Actions: swap exchanges c1 and c2 in object o
 *			add adds class c1 to object o
 *			remove removes class c1 from object o
 *			check tests if class c1 is applied to object o
 * Example:	cssjs('swap',document.getElementById('foo'),'bar','baz');
 *******************************************************************************************/

	function cssjs(a,o,c1,c2) {
		switch (a){
			case 'swap':
				o.className=!cssjs('check',o,c1)?o.className.replace(c2,c1):o.className.replace(c1,c2);
			break;
			case 'add':
				if(!o.className) o.className = '';
				if(!cssjs('check',o,c1)){o.className+=o.className?' '+c1:c1;}
			break;
			case 'remove':
				var rep=o.className.match(' '+c1)?' '+c1:c1;
				o.className=o.className.replace(rep,'');
			break;
			case 'check':
				if(!o.className) return false;
				return new RegExp('\\b'+c1+'\\b').test(o.className)
			break;
		}
		return true;
	}
	
/*******************************************************************************************
 * swapTerms
 * Written by Daniel Course
 * If the browser can support javascript it will put the terms into a widget and show/hide
 *******************************************************************************************/

	// swaps the terms and conditions
	function swapTerms() {
		
		var a = document.getElementById("termsContainer");
		var newStyle = 'jsTerms';
		var oldStyle = 'jsTermsSwitch';
		if(cssjs( 'check', a, 'jsTermsSwitch' )){
			newStyle = 'jsTerms';
			oldStyle = 'jsTermsSwitch';
		}
		cssjs('swap', a, newStyle, oldStyle);	
	}		
	
	
	document.write('<style type="text/css" media="screen">');
	document.write('<!-- ');
	
	document.write('.jsTerms {');
	document.write('    display: none;');
	document.write('}');
	
	document.write('.jsTermsSwitch {');
	document.write('    overflow: auto;');
	document.write('}');
	
	document.write('-->');
	document.write('<\/style>');
