/*
 * SolidFlux 2008
 */
 
var flashGalleryObject = ""
 
if (typeof jQuery != 'undefined') {

$(function() {
	/*
	$('#submenu a').each(function(){
		
	  	console.log('len:'+$(this).html())
		console.log('len:'+$(this).html().length);
		console.log('wid:'+$(this).width());
		console.log('div:'+($(this).width()/$(this).html().length));
		console.log('try:'+(($(this).html().length*5.5)+5));
		console.log('-------------------------------------');
		
	});
	*/
	
	$('#topmenu li:not(.topmenuselected)').mouseover(function(){
		$(this).addClass("topmenuselected");													  	
		//$(this).find(':first-child').addClass("topmenuselected");
		//if mouseover primary nav, then show corresponding subnav ul
		/*
		var currentLI = $(this).parent().get(0);
		currentNum = $("#primary-nav li").index(currentLI);
		$('.subnav').each(function(){
			$(this).removeClass("active");
			$(this).addClass("inactive");
		});
		currentNum--;
		$('.subnav:eq('+currentNum+')').removeClass("inactive");
		$('.subnav:eq('+currentNum+')').addClass("active");		
		return false;
		*/
	});
	
	$('#topmenu li:not(.topmenuselected)').bind("mouseleave",function(){
	    $(this).removeClass("topmenuselected");
		//$(this).find(':first-child').removeClass("topmenuselected");
		/*
		//if mouseleave primary nav, then show original selected ul
		$('.subnav').each(function(){
			$(this).removeClass("active");
			$(this).addClass("inactive");
		});								 	
		$(orgSelectedSub).removeClass("inactive");
		$(orgSelectedSub).addClass("active");			
		*/
	});
	
	$('#topmenu li').bind("click",function(){
		window.location = $(this).find(':first-child').attr("href");
	});
	
	//uses http://www.malsup.com/jquery/cycle/download.html
	if (typeof $('#viewer') != 'undefined') {
		$('#viewer').cycle({ 
			fx:     'fade', 
			speed:   2500, 
			timeout: 5000, 
			next:   '#viewer', 
			pause:   1 
		});
		
		$('#viewer').css({ "position":"absolute"});
		if (typeof $('#mediaviewer') != 'undefined') {
			$('#mediaviewer').css({ "position":"absolute"});
		}
	}
	
	//uses swfobject
	if (typeof $('#flashGallery') != 'undefined') {
		$().embedGallery();
	}
	
	if (typeof $('#applications') != 'undefined') {
		$('#applications').mouseover(function(){
			$('#app_list').show();
		});
		
		$('#applications').bind("mouseleave",function(){
			$('#app_list').hide();
		});
	}
	
	/*faq*/
	if ($("h3.FAQq").get()!=""){
		$("h3.FAQq").click(function () {
			$("div.FAQa:visible").slideToggle("fast")
			$(this).next().slideToggle("fast");		
		});		
	}

});

jQuery.fn.showCurPic = function(curPic) {
	$('#viewer').fadeOut('slow');
	$('#mediaviewer').html('<img src=\'/gallery/'+curPic+'\' />');
	setTimeout("$('#mediaviewer').fadeIn('slow');", 1000);
	setTimeout("$('#mediaviewer').fadeOut('slow');", 8000);
	setTimeout("$('#viewer').fadeIn('slow');", 9000);
};

jQuery.fn.embedGallery = function(curDir) {
	if (typeof curDir == 'undefined') {
		curDir = "";
	}
	
	//console.log(curDir);
	var flashvars = {};
	var params = {
			menu: "false",
			wmode: "transparent"
		};
	var attributes = {};
	
	curDir = encodeURIComponent("?app="+curDir);

	flashGalleryObject = flashobject.embedSWF("/gallery/flash/regal_gallery.swf?xmlUrl=/gallery/xml_content.php"+curDir, "flashGallery", "482", "200", "8.0.0", "/gallery/flash/expressInstall.swf", flashvars, params, attributes);
};
}
