/*	

	------------------------------------------------------------------------
	Future Mind Scripting
	------------------------------------------------------------------------
	Copyright:      Future Mind
	Typ:            JavaScript
	Encoding:       UTF-8
	Version:        1.0
	
*/

/* 
	Methods for resizing the flash stage at runtime.

	setFlashWidth(divid, newW)
	divid: id of the div containing the flash movie.
	newW: new width for flash movie

	setFlashWidth(divid, newH)
	divid: id of the div containing the flash movie.
	newH: new height for flash movie

	setFlashSize(divid, newW, newH)
	divid: id of the div containing the flash movie.
	newW: new width for flash movie
	newH: new height for flash movie

	canResizeFlash()
	returns true if browser supports resizing flash, false if not. 
*/
		
function setFlashWidth(divid, newW){
	/*document.getElementById(divid).style.width = newW+"px";*/
	$("#" + divid).css({ height:newH + "px" });
}
function setFlashHeight(divid, newH){
	/*document.getElementById(divid).style.height = newH+"px";*/
	$("#" + divid).css({ height:newH + "px" });
}
function setFlashSize(divid, newW, newH){
	setFlashWidth(divid, newW);
	setFlashHeight(divid, newH);
}
function canResizeFlash(){
	var ua = navigator.userAgent.toLowerCase();
	var opera = ua.indexOf("opera");
	if( document.getElementById ){
		if(opera == -1) return true;
		else if(parseInt(ua.substr(opera+6, 1)) >= 7) return true;
	}
	return false;
}		

var daxregular = {
	src: 'font/dax-regular.swf'
};
var daxlight = {
	src: 'font/dax-light.swf'
};
sIFR.activate(daxregular);
sIFR.activate(daxlight);
sIFR.replace(daxlight, {
	selector: 'h2.news',
	css: [
	'.sIFR-root { font-size:28px; font-weight:normal; color:#000000; }',
	'a { color:#000000; text-decoration:none; }',
	'a:hover { color:#000000; text-decoration:underline; }'
	],
	wmode: 'transparent'
});
sIFR.replace(daxregular, {
	selector: 'h2.bbheader',
	css: [
	'.sIFR-root { font-size:16px; font-weight:normal; color:#000000; }',
	'a { color:#000000; text-decoration:none; }',
	'a:hover { color:#000000; text-decoration:underline; }'
	],
	wmode: 'transparent'
});	
sIFR.replace(daxregular, {
	selector: 'h3.sifr',
	css: [
	'.sIFR-root { font-size:16px; font-weight:normal; color:#000000; }',
	'a { color:#000000; text-decoration:none; }',
	'a:hover { color:#000000; text-decoration:underline; }'
	],
	wmode: 'transparent'
}); 

/*                  */
var FUTUREMIND = {
	
	_browser: {
		ie: /*@cc_on!@*/false
	},
	start: function() 
	{
		this.sIFR();
		this.inputsStyles();
		this.inputsLabel();
		this.inputsHelp();
		this.htmlManipulation();
		this.formsValid();
		this.addGoogleStats();
	},
	/* =sIFR Configuration
	---------------------------------------------------------------------------- */
	sIFR: function() 
	{
		/*
		var daxregular = {
			src: 'font/dax-regular.swf'
		};
		var daxlight = {
			src: 'font/dax-light.swf'
		};
		sIFR.activate(daxregular);
		sIFR.activate(daxlight);
		sIFR.replace(daxlight, {
			selector: 'h2.news',
			css: [
			'.sIFR-root { font-size:28px; font-weight:normal; color:#000000; }',
			'a { color:#000000; text-decoration:none; }',
			'a:hover { color:#000000; text-decoration:underline; }'
			],
			wmode: 'transparent'
		});
		sIFR.replace(daxregular, {
			selector: 'h2.bbheader',
			css: [
			'.sIFR-root { font-size:16px; font-weight:normal; color:#000000; }',
			'a { color:#000000; text-decoration:none; }',
			'a:hover { color:#000000; text-decoration:underline; }'
			],
			wmode: 'transparent'
		});	
		sIFR.replace(daxregular, {
			selector: 'h3.sifr',
			css: [
			'.sIFR-root { font-size:16px; font-weight:normal; color:#000000; }',
			'a { color:#000000; text-decoration:none; }',
			'a:hover { color:#000000; text-decoration:underline; }'
			],
			wmode: 'transparent'
		});		
		*/					
	},
	/* =Input styles
	---------------------------------------------------------------------------- */
	inputsStyles: function() {
		new Spry.Widget.MenuBar("usernav", {imgDown:"img/SpryMenuBarDownHover.gif", imgRight:"img/SpryMenuBarRightHover.gif"});
		new Spry.Widget.MenuBar("MenuBar1", {imgDown:"SpryAssets/SpryMenuBarDownHover.gif", imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});
	},
	/* =Input labels style
	---------------------------------------------------------------------------- */
	inputsLabel: function() {
	
	},
	/* =Helpers
	---------------------------------------------------------------------------- */
	inputsHelp: function() {
		 
	},
	/* =HTML manipulation
	---------------------------------------------------------------------------- */
	htmlManipulation: function() {
		
		$(".projectItem a").hover(function () 
		{				
			$('> img.default', this).css("display", "none"); 
			$('> img.hover', this).fadeIn("slow");				
		}, function () 
		{
			$('> img.hover', this).css("display", "none");
			$('> img.default', this).fadeIn("slow");	
		});
		
		$("ul.htmlMani li a").click(function() 
		{
			var getClassName = $(this).attr("class");
			
			$("ul#subnav li").removeClass("selected");
			$(this).parent().addClass("selected");
				
			if($(this).hasClass("allProjects"))
				$(".maincontent .category").css("display", "block");
			else
				$(".maincontent .category").fadeOut("slow");
				$(".maincontent ." + getClassName).fadeIn("slow");
				$(".maincontent ." + getClassName + " > *").fadeIn("slow");
				return false;
		});
		
		/*$("ul.htmlMani li a.allProjects").click(function() {
			$(".maincontent .category").css("display", "block");
		});*/
		
		$(".jobSlide a").click(function () 
		{
			var jobHandler = $(this).parent().parent().parent();
			$(jobHandler).find("div.intro").slideToggle("slow");
			return false;
		});

				
		// projects navigation (projects page)
		$('div.projectNav ul.footernav a').bind('click', function(e)
		{
		    var i = $('ul.footernav a').index(this);
		    filterProjects(i);
		});
		
        $('div.projectNav ul#subnav a').bind('click', function(e)
        {
            var i = $('ul#subnav a').index(this);
            filterProjects(i);
        });
        
        var filterProjects = function(i)
        {
            if( i == 0 )
            {
                $('.projects div').fadeIn();
            }
            else
            {
                var type = $('ul#subnav a').eq(i).attr('class');

                $('.projects div').hide();
                $('.projects div.'+type).fadeIn("slow");
            }
            
            $('#subnav li').removeClass('selected');
            $('#subnav li').eq(i).addClass('selected').blur();
        };
        
        // footer navigation (featured page)
        $('div.regularNav ul.footernav a').bind('click', function(e)
        {
            var i = $('ul.footernav a').index(this);
            $('div.tab')
			    .css("display", "none")
				.eq(i)
				.fadeIn("slow");
            
            $('ul.navigationTabs li').removeClass('selected');
            $('ul.navigationTabs li').eq(i).addClass('selected').blur();
        });
        
        // application forms
        $('div.applicationForm').css("display", "none");
        $('div.job a.apply').bind('click', function(e)
        {
            var applyHandler = $(this).parent().parent().parent().parent().find('div.applicationForm');
            var introHandler = $(this).parent().parent().parent().parent().find("div.intro");
            if($(introHandler).css('display') == 'none' && $(applyHandler).css('display') == 'none')
            {
                $(introHandler).slideToggle("slow");
            }
            $(applyHandler).slideToggle("slow");
        });
        
        // 
        $('#argh').bind('click', function(e)
        {
           $('#ugh').trigger('click');
        });
        
	},
	/* =Forms Validation
	---------------------------------------------------------------------------- */
	formsValid: function() {
		
	},
	/* =Google Analitics
	---------------------------------------------------------------------------- */
	addGoogleStats: function() 
	{
		var GAID = 'UA-1521362-2';
		var head = document.getElementsByTagName('head')[0];
		var scr = document.createElement('script');
		scr.type = 'text/javascript';
		scr.src = (location.protocol == 'http:' ? 'http://www.' : 'https://ssl.') + 'google-analytics.com/'+'urchin.js';
		var once = 0;
			function runMe() { 
				if (scr.readyState == 'loading' || urchinTracker == undefined || once) { return; }
				clearInterval(timer);
				once++;
				_uacct = GAID;
				urchinTracker();
			}
		var timer = setInterval(runMe, 2000);
		scr['onload'] = runMe;
		scr['onreadystatechange'] = runMe;
		head.appendChild(scr); 
	}
}
$().ready(function () { FUTUREMIND.start(); });


