function sendContactData(data) {
	var obj = { action:'sendContact', data:data };
	jQuery.get('/ajax-data.php', obj, emailSent);
};

function emailSent(res) {
	document.getElementById('flashGallery').contactSent(res);	
};

function handleImageChanged() {
	try { 
		var path = SWFAddress.getPath();
		pageTracker._trackPageview((path=='/home/' ? '/' : path));
	} catch(err) {};
};

(function($) {	
	var skipFirst = String(window.location).indexOf('#')>0;
		  
	function updateFlash() {
		$('#head li').removeClass('selected').blur(); 
		var path = SWFAddress.getPath();
				
		pn = SWFAddress.getPathNames();
		if(path && path!='/' && (pn[0]!='gallery' || pn[1])) $('#head li a[href*='+path+']').parent().addClass('selected');
		
		if(pn.length<1) return;
		
		if(!skipFirst) {
			pageTracker._trackPageview((path=='/home/' ? '/' : path));
		} else {
			skipFirst = false;	
		};
		switchPage(pn);		
	};
	
	function switchPage(pn) {
		try{
			switch(pn[0]) {
				case 'gallery': document.getElementById('flashGallery').changeCategory({ url:pn[1] }); break;
				default: 		document.getElementById('flashGallery').changePage({ url:pn[0] }); break;
			};
		} catch(err) { setTimeout(function() { switchPage(pn); },50); };
	};
	
	function setContentHeight() {
		var h = $('#body').height()-$('#head').height()-$('#foot').height()-1;
		$('#content').css({ height:h, padding:0, paddingTop:$('#head').height(), margin:0, background:'#ccc' });
	};
		  
	$(document).ready(function() {
		if(parseInt(getFlashVersion()) && $.cookie('flashOff')!='1') {
			$('body').css({ height:'100%' });
				
			SWFAddress.addEventListener(SWFAddressEvent.CHANGE, updateFlash); 
			$('#mainMenu li a,#head #controlsMenu .subpage').click(function() { SWFAddress.setValue(String(this.href).replace(baseHref,'')); return false; });
			$('#head h1 a').click(function() { SWFAddress.setValue('home/'); return false; });
			
			$(window).resize(setContentHeight);
			setContentHeight();
			swfobject.embedSWF("/flash/Gallery.swf", "flashGallery", "100%", "100%", "10.0.0", "/flash/expressInstall.swf", {}, { menu:'false', wmode:'opaque', bgColor:'#231F20', scale:'noscale', allowFullScreen:'true', allowScriptAccess:'sameDomain' });			   
		};
	});
})(jQuery);