var Editor;
 
function Format(action)
{
	Editor.execCommand(action, false, null);
}
 
function Colour(colour)
{		
	Editor.execCommand("forecolor",false, colour);
}
 
window.onload = function()
{
	if (document.getElementById('textbox')) {
		Editor = document.getElementById('textbox').contentWindow.document;
		Editor.designMode = "on";
		document.forms[0].onsubmit = function(){
			var text = document.getElementById('text');
			text.value = Editor.body.innerHTML;
		}
	}
	
}
$(document).ready(function(){

	if($("#hero-scans")){
		$("#hero-scans").scrollable({circular: true, mousewheel: true}).navigator().autoscroll({
			interval: 6000		
		});	
	}

	//$('#switcher').themeswitcher();
	if($("#accordion")){
		$("#accordion").accordion({ autoHeight: false });
	}
	if($("#selectable")){
		$("#selectable").selectable();
	}
	if($("#tabs")){
		$("#tabs").tabs();
	}
	if ($.fn) {
		$.fn.qtip.styles.pbgreen = { // Last part is the name of the style
			width: 200,
			background: '#A2D959',
			color: 'black',
			textAlign: 'left',
			border: {
				width: 7,
				radius: 5,
				color: '#A2D959'
			},
			tip: true,
			name: 'dark' // Inherit the rest of the attributes from the preset dark style
		};
	}
	if ($('.tipDown')) {
		$('.tipDown').each(function(){
			$(this).qtip({
				content: $(this),
				position: {
					corner: {
						target: 'bottomMiddle',
						tooltip: 'topMiddle'
					}
				},
				style: 'pbgreen'
			});
		});
	}
	
	if ($('.tipUp')) {
		$('.tipUp').each(function(){
			$(this).qtip({
				content: $(this),
				position: {
					corner: {
						target: 'topMiddle',
						tooltip: 'bottomMiddle'
					}
				},
				style: 'pbgreen'
			});
		});
	}
	
	if ($('.tipRight')) {
		$('.tipRight').each(function(){
			$(this).qtip({
				content: $(this),
				position: {
					corner: {
						target: 'rightMiddle',
						tooltip: 'leftMiddle'
					}
				},
				style: 'pbgreen'
			});
		});
	}

	if ($('#help-faqs .faqs a[rel]')) {
		$('#help-faqs .faqs a[rel]').each(function(){
			$(this).qtip({
				content: {
					// Set the text to an image HTML string with the correct src URL to the loading image you want to use
					text: '<img class="throbber" src="/projects/qtip/images/throbber.gif" alt="Loading..." />',
					url: $(this).attr('rel'), // Use the rel attribute of each element for the url to load
					title: {
						text: $(this).text(), // Give the tooltip a title using each elements text
						button: 'Close' // Show a close link in the title
					}
				},
				position: {
					corner: {
						target: 'bottomMiddle', // Position the tooltip above the link
						tooltip: 'topMiddle'
					},
					adjust: {
						screen: true // Keep the tooltip on-screen at all times
					}
				},
				show: {
					when: 'click',
					solo: true // Only show one tooltip at a time
				},
				hide: 'unfocus',
				style: {
					tip: true, // Apply a speech bubble tip to the tooltip at the designated tooltip corner
					border: {
						width: 0,
						radius: 4
					},
					name: 'light', // Use the default light style
					width: 570 // Set the tooltip width
				}
			})
		});
	}
   
	if ($('.contest_copy_backup a')) {
		$('.contest_copy_backup a').qtip({
			content: {
				// Set the text to an image HTML string with the correct src URL to the loading image you want to use
				text: '<img class="throbber" src="/projects/qtip/images/throbber.gif" alt="Loading..." />',
				url: $('.contest_copy_backup a').attr('rel'), // Use the rel attribute of each element for the url to load
				title: {
					text: $('.contest_copy_backup a').text(), // Give the tooltip a title using each elements text
					button: 'Close' // Show a close link in the title
				}
			},
			position: {
				target: $(document.body), // Position it via the document body...
				corner: 'center' // ...at the center of the viewport
			},
			show: {
				when: 'click', // Show it on click
				solo: true // And hide all other tooltips
			},
			hide: false,
			style: {
				width: 850,
				padding: '14px',
				border: {
					width: 9,
					radius: 9,
					color: '#666666'
				},
				name: 'light'
			}
		});
	}

	if($('#copy a[href].tip')){
		$('#copy a[href].tip').qtip();
	}
	
	if($('a[title].tip')){
		$('a[title].tip').qtip();
	}
	
});

Cufon.replace('#page-title h1', { fontFamily: 'greyscale-ext' });
Cufon.replace('#page-title h2', { fontFamily: 'greyscale' });
Cufon.replace('#accordion h3', { fontFamily: 'trebuchet' });
Cufon.replace('#store-home h3', { fontFamily: 'greyscale' });

Cufon.replace('#copy h3', { fontFamily: 'calibri' });
Cufon.replace('#copy h4', { fontFamily: 'calibri' });
Cufon.replace('#checkout h1', { fontFamily: 'greyscale-ext' });
Cufon.replace('#checkout h2', { fontFamily: 'greyscale' });
Cufon.replace('#checkout h3', { fontFamily: 'trebuchet' });

Cufon.replace('.trebuchet', { fontFamily: 'trebuchet' });
Cufon.replace('.greyscale', { fontFamily: 'greyscale' });
Cufon.replace('.greyscale-ext', { fontFamily: 'greyscale-ext' });

Cufon.replace('#tabs .ui-tabs-nav li', { fontFamily: 'trebuche' });
Cufon.replace('.features-get_started h4', { fontFamily: 'greyscale' });

Cufon.replace('.calibri', { fontFamily: 'calibri' });

Cufon.replace('#scanning-services h2', { fontFamily: 'calibri' });
Cufon.replace('#scanning-services h3', { fontFamily: 'calibri' });

