$(document).ready(function(){
	//instantiate contact page for lightbox launch
	$(".fancy-popup").fancybox({
		'scrolling': 'yes',
		'autoScale': false,
		'autoDimensions': true
	});

	//Disable right click
	/*
	$(function() {
    	$(this).bind("contextmenu", function(e) {
        	e.preventDefault();
    	});
	});
	*/
	
	//Populate middleImage with xml image data and cycle through picutres
	if ($('#middleImage').length > 0) {
		(function midImagePop(){
			$.ajax({
				type: "GET",
				url: $.BASE_URL + "static/random-pictures.xml",
				dataType: "xml",
				success: function(xml){
					$('#middleImage').html('');
					$(xml).find("picture").each(function(){
						$('#middleImage').append("<img id='image' src='"+$(this).find('location').text() +"' alt='"+$(this).find('alt').text() +"' height='350px' width='750px' />");
					});
					$('#middleImage').cycle({
						fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
					}); 
				}
			});
		})();
	}

	// map hilight
	$('.map img[usemap]').each(function () {
		var $map = $(this);
		$map.maphilight();
		$('.map area').each(function () {
			$(this).data('maphilight', $.extend($(this).data('maphilight') || {}, {alwaysOn:true}));
			$(this).qtip({
				content: $(this).attr('alt'), // Use the ALT attribute of the area map
				position: {
					corner: {
						tooltip: 'bottomRight', // Use the corner...
						target: 'topLeft' // ...and opposite corner
					}
				},
				style: {
					name: 'light', // Give it the preset dark style
					border: {
						width: 0, 
						radius: 2 
					}, 
					tip: true // Apply a tip at the default tooltip corner
				},
				show: {
					delay: 10
				}
			});
			$(this).attr('alt', ''); // *fix* prevent default tooltip in IE7
			$(this).hover(function () {
				var data = $(this).data('maphilight');
				if (data.alwaysOn) {
					$(this).data('maphilight', $.extend($(this).data('maphilight') || {}, {
						fill: true,
						strokeColor: 'ffffff',
						strokeWidth: 3,
						alwaysOn: false
					}));
					$(this).mouseover();
				}
			}, function () {
				$(this).data('maphilight', $.extend($(this).data('maphilight') || {}, {
					fill: false,
					strokeColor: 'FF8040',
					strokeWidth: 2,
					alwaysOn:true
				}));
			});
		});
	});
	
});

