// begin jQuery handling functions
// -----
function handleMailtoSFA() {
	if ($("a[href^='mailto:'][href$='@sfasu.edu']")) {
		$("<div id='dialog-email' class='hide jquery-ui' title='Sending an e-mail message'><p><span class='ui-icon ui-icon-mail-closed' style='float:left; margin:0 7px 20px 0;'></span><strong>How would you like to send your message?</strong></p><ol><li>Using the SFA e-mail form</li><li>Using your e-mail program (Outlook, Entourage, Thunderbird, etc.).</li></ol></div>").appendTo("body");
	}
	$("a[href^='mailto:'][href$='@sfasu.edu']").click(function(event) {
		event.preventDefault();
		theHref = $("a[href^='mailto:'][href$='@sfasu.edu']").attr("href")
		
		$("#dialog-email").dialog({
			bgiframe: true,
			resizable: false,
			height:200,
			width:450,
			modal: true,
			overlay: {
				backgroundColor: '#000',
				opacity: 0.5
			},
			buttons: {
				'Use the form': function() {
					theHref = theHref.replace(/^mailto:/,"/frmemail.asp?rc=");
					$(this).dialog('close');
					window.location.href = theHref;
				},
				'Use my e-mail program': function() {
					$(this).dialog('close');
					window.location.href = theHref;
				}
			}
		});
	});
}
// -----
function handlePageScan() {
	$("#pagescan").pagescan({
		selector:"#main-content a"
	});
}
// -----
function handleLinkIcons () {
	if ($.browser.msie) {
		if (parseInt($.browser.version) < 7) {
			return false;
		}
	}
	$("a[href$='.pdf']").addClass("filetype-pdf").attr("title","This is a .pdf file").attr("target","_blank");
	$("a[href$='.doc'],a[href$='.docx']").addClass("filetype-doc").attr("title","This is a Word document").attr("target","_blank");
	$("a[href$='.xls'],a[href$='.xlsx']").addClass("filetype-xls").attr("title","This is a Excel spreadsheet").attr("target","_blank");
	$("a[href$='.ppt'],a[href$='.pptx']").addClass("filetype-ppt").attr("title","This is a PowerPoint presentation").attr("target","_blank");
	$("a[href*='://']:not([href*='sfasu.edu'])").addClass("external-link").attr("title","This is a link to an external website").attr("target","_blank");
}
// -----
function handleTextResize() {
	$("<div id='text-size-slider-label'>text size</div><div id='text-size-slider-wrapper'><div id='text-size-slider'></div></div>").insertAfter("#nameplate");
	prefTextSize = 100;
	//get preferred text size from cookie, if it exists
	if ($.cookie("prefTextSize")) {
		prefTextSize = $.cookie("prefTextSize");
	}
	//set the preferred text size
	$("#main-content,#sidebar,#main-navigation").css("font-size", prefTextSize + "%");
	$("#text-size-slider").slider({			
		value: prefTextSize,
		range: "min",
		min: 90,
		max: 150,
		step: 10,
		animate: true,
		slide: function(event,ui){
			$("#main-content,#sidebar,#main-navigation").css("font-size", ui.value + "%");
		}
	});
}
// end jQuery handling functions