/******** Flash embed: ********/

var flashPlaying;

function swfObjectDone(e) {
	flashPlaying = e.success;
	if (!flashPlaying) {
		$('#flashIntro').hide();
		$('#bodySection').css('visibility', 'visible');
		clearInterval (animMenuInterval);
		clearInterval (introInterval);
	} 

}
	
function embedFlash (movieURL, movieID, width, height, testDone) {
	var flashvars = {};
	var params = {};
	var attributes = {};
	params.menu = "false";
	params.quality = "high";
	params.scale = "noscale";
	params.allowFullScreen = "false";
	params.AllowScriptAccess = "always";
	params.wmode = "transparent";
	//attributes.id = "flashIntro";
	if (testDone) {
		swfobject.embedSWF(movieURL, movieID, width, height, "9.0.0", "", flashvars, params, attributes, swfObjectDone);
	} else {
		swfobject.embedSWF(movieURL, movieID, width, height, "9.0.0", "", flashvars, params, attributes);
	}
	//alert(movieURL);
	//var myFlashMovie = document.getElementById("vertNav");
}

embedFlash('swf/intro.swf', 'flashIntro', 1050, 458, true);
embedFlash('swf/vertMenu.swf', 'vertNav', 245, 400, false);



/******** Make sure flash objects exist: ********/

var animMenuExists = false;
function animMenuNowExists () {animMenuExists = true;}
var introExists = false;
function introNowExists () {introExists = true;}
var animMenuInterval;
function animateTheMenu() {
	animMenuInterval = setInterval(function() {
		if (animMenuExists) {
			$('#vertNav').get(0).animMenu();
			clearInterval (animMenuInterval);
		}
	}, 100);
}
var introInterval;
function hideIntro() {
	introInterval = setInterval(function() {
		if (introExists) {
			$('#flashIntro').css('display','none');
			clearInterval (introInterval);
		}
	}, 100);
}

// make sure intervals are cleared after 30 seconds
// in case they somehow don't get cleared:
setTimeout(function () {
		clearInterval (animMenuInterval);
		clearInterval (introInterval);
	} ,30000
);



/******** send email: ********/

function insertMailTag () {
	var e5 = "messinamg";
	var e2 = ":";
	var e7 = "com";
	var e3 = "info";
	var e0 = "mail"
	var e4 = "@";
	var e1 = "to";
	var e6 = ".";
	var e = e0 + e1 + e2 + e3 + e4 + e5 + e6 + e7;
	document.write ( '<a href=\"' + e + '\">Contact</A>' );
}


$(document).ready(function() {	

	/******** Jscrollpane track stick fix: ********/
	
	$('#siteWrapper').mouseup(function() {	
		top.frames[0].explicitCancelDrag();
	});		


	/******** drop down menu ********/

	$('ul.sf-menu').superfish({ 
		delay:		400,                
		autoArrows:  false,
		animation:   {height:'show'},
		dropShadows: false
	});
	
	$('ul.sf-menu ul').click(function(){ 
		$(this).animate({opacity:'hide'},200); 
	}); 

	$('ul.sf-menu, ul.sf-menu li').mouseleave(function(){ 
		$('ul',this).animate({height:'hide'}); 
	}); 

	$('.item').click(
		function () {
			$('#bodySection').css('visibility', 'visible');
			if (flashPlaying) {
				$('#flashIntro').css('display','none');
				animateTheMenu();
				$('#vertNav').get(0).roAll();
			}
		}
	);
		
	
	
	/******** Load iframe if redirected: ********/

	var loc_var=this.location.href; 
	if (loc_var.indexOf('?addr=')!= -1) { 
		var loc_arr=loc_var.split('?addr='); 
		document.getElementById('contentContainer').src=loc_arr[1];

		$('#bodySection').css('visibility', 'visible');
		animateTheMenu();
		hideIntro();

	} else {
	
	}
	
	
	
	/******** CSS for windows: ********/
	
	if (navigator.appVersion.indexOf("Windows")!=-1) {
		$('#footer_1a, .blogHead, .feedburnerFeedBlock ul, .feedburnerFeedBlock a,.feedburnerFeedBlock a:link, .feedburnerFeedBlock a:visited,.feedburnerFeedBlock a:active,.feedburnerFeedBlock a:hover').addClass('windowsFix');
	};
	
	
});
	

