// Load jQuery

	
	
	$(document).ready( function() {
		
		
		// lightbox
		
		$("a.fancyBox").colorbox({
			
			photo: true,
			opacity: 0.65,
			scalePhotos: true,
			maxWidth: '75%', 
			maxHeight:'75%'
		});
		
		
		// add default text to input boxes
		$('.swapValue').each( function(n) {
			if ( $(this).val().length == 0 ) {
				$(this).val($(this).attr('title'));
				$(this).addClass('ghostInput');
			}
			$(this).bind('focus',function() {
				 if ( $(this).val() == $(this).attr('title') ) {
					$(this).val('');
					$(this).removeClass('ghostInput');
				 } else {
					$(this).select();
					$(this).removeClass('ghostInput');
				 }
			});
			$(this).bind('blur',function() {
				if ( $(this).val().length == 0 ) {
					$(this).val($(this).attr('title'));
					$(this).addClass('ghostInput');
				} else {
					$(this).removeClass('ghostInput');
				}
			});
		});
		
		$('form').bind('submit',function() {
			$('.swapValue').each(function() {
				if( $(this).val() == $(this).attr('title') ) {
						$(this).val('');
				}
			});
		});
		
		
		// make sure links are using target="_blank" as well as rel="external"
		$('a[rel=external]').each( function(n) {
			$(this).attr('target','_blank');
			$(this).attr('title','Open '+$(this).attr('href')+' in a new window');
		});
				
		$("input.datePicker").datepicker({
			dateFormat: 'dd/mm/yy',
			firstDay: 0
		});
		
	});
		


// tinyMCE configuration
tinyMCE.init({
	mode : "specific_textareas",
	editor_selector : "tiny_mce",
	theme : "advanced",
	body_class : "cms",
	content_css : "/styles/main.css",
	plugins: "safari,inlinepopups,paste,table",
	width: "640",
	height: "500",
	theme_advanced_buttons1 : "bold, italic, underline,|,bullist,numlist,|,link,unlink,|,formatselect,|,pasteword,code,charmap",
	theme_advanced_buttons2 : "",
	theme_advanced_buttons3 : "",
	theme_advanced_resizing : true,
	theme_advanced_toolbar_location : "top",
	theme_advanced_toolbar_align : "center",
	theme_advanced_statusbar_location : "bottom",
	theme_advanced_blockformats : "p,h4",
	convert_urls : false,
	verify_html : false,
	valid_elements : "-p[class|style],strong/b[class|style],a[name|href|target|title],img[class|src|border=0|alt|title|width|height|align|style],hr[class|width|size|noshade],span[class|align],h4,ul,ol,li"
});
