$(document).ready(function() {
	/* Navigation */
	if (isiPhone()){
		/*
		
		$('.home li a').hover(
			function(){
				showSubNav($(this).attr('rel'));
			},
			function(){
				hideSubNav();
			}
		);*/
	}else{
		$("body").addClass("standard");
		
		$('.home #nav-architecture').hover(
			function(){
				$('#nav-office').addClass('active-architecture');
				$('#nav-news').addClass('active-architecture');
				$('#navigation').removeClass('border-bottom');
				showSubNav($(this).attr('rel'));

			},
			function(){
				$('#nav-office').removeClass('active-architecture');
				$('#nav-news').removeClass('active-architecture');
				$('#navigation').addClass('border-bottom');
				hideSubNav();
			}
		);

		$('.home #subnav-architecture').hover(
			function(){
				$('#nav-architecture').addClass('hover');
				$('#nav-office').addClass('active-architecture');
				$('#nav-news').addClass('active-architecture');
				$('#navigation').removeClass('border-bottom');
				showSubNav($(this).attr('id'));

			},
			function(){
				$('#nav-architecture').removeClass('hover');
				$('#nav-office').removeClass('active-architecture');
				$('#nav-news').removeClass('active-architecture');
				$('#navigation').addClass('border-bottom');
				hideSubNav($(this).attr('id'));
			}
		);

		$('.home #nav-office').hover(
			function(){
				$('#nav-news').addClass('active-office');
				$('#navigation').removeClass('border-bottom');
				showSubNav($(this).attr('rel'));
			},
			function(){
				$('#nav-news').removeClass('active-office');
				$('#navigation').addClass('border-bottom');
				hideSubNav();
			}
		);
		$('.home #subnav-office').hover(
			function(){
				$('#nav-office').addClass('hover');
				$('#nav-office').addClass('active-office');
				$('#nav-news').addClass('active-office');
				$('#navigation').removeClass('border-bottom');
				showSubNav($(this).attr('id'));

			},
			function(){
				$('#nav-office').removeClass('hover');
				$('#nav-office').removeClass('active-office');
				$('#nav-news').removeClass('active-office');
				$('#navigation').addClass('border-bottom');
				hideSubNav($(this).attr('id'));
			}
		);
		$('.home #nav-news').hover(
			function(){
				$('#navigation').removeClass('border-bottom');
				showSubNav($(this).attr('rel'));
			},
			function(){
				$(this).removeClass('hover');
				$('#navigation').addClass('border-bottom');
				hideSubNav();
			}
		);
		$('.home #subnav-news').hover(
			function(){
				$('#nav-news').addClass('hover');
				$('#navigation').removeClass('border-bottom');
				showSubNav($(this).attr('id'));

			},
			function(){
				$('#nav-news').removeClass('hover');
				$('#navigation').addClass('border-bottom');
				hideSubNav($(this).attr('id'));
			}
		);
		
	}

	
	if(!($.browser.msie && $.browser.version=="6.0")){
		if (!(isiPhone())){
			$('#cloud-inner').bgscroll({scrollSpeed:130 , direction:'h' });
		}
	}
	
	$.fn.supersized.options = {
		startwidth: 1024,
		startheight: 768,
		minsize: .5,
		slideshow: 0
	};
	$('#supersize').supersized();
	
	if($('.layout_full').length > 0){
		$('.layout_full').hover(
			function(){
					$(this).addClass('hover');
			},
			function(){
				if(!($(this).hasClass(".selected"))){
					$('.layout_full').removeClass('hover');
				}
			}
		);
		
	}
	if ( $("div.mod_newslist").length > 0 ) {
		$('.mod_newslist').accordion({
			header: '.accordion-header',
			active: false,
			autoheight: false,
			fillSpace: false
		});
	}
	
	function showSubNav(rel){
		$('#'+rel).show();
	}
	function hideSubNav(){
		$('.sub-nav').hide();
	}
	
	if($('#content.intro p').length > 0){
		$('#content.intro p').dropShadow({left: 1, top: 3, opacity: 0.8, blur: 8, color: '#4c617e'});
	}
});


(function() {
	$.fn.bgscroll = $.fn.bgScroll = function( options ) {
		
		if( !this.length ) return this;
		if( !options ) options = {};
		if( !window.scrollElements ) window.scrollElements = {};
		
		for( var i = 0; i < this.length; i++ ) {
			
			var allowedChars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
			var randomId = '';
			for( var l = 0; l < 5; l++ ) randomId += allowedChars.charAt( Math.floor( Math.random() * allowedChars.length ) );
			
				this[ i ].current = 0;
				this[ i ].scrollSpeed = options.scrollSpeed ? options.scrollSpeed : 70;
				this[ i ].direction = options.direction ? options.direction : 'h';
				window.scrollElements[ randomId ] = this[ i ];
				
				eval( 'window[randomId]=function(){var axis=0;var e=window.scrollElements.' + randomId + ';e.current -= 1;if (e.direction == "h") axis = e.current + "px 0";else if (e.direction == "v") axis = "0 " + e.current + "px";else if (e.direction == "d") axis = e.current + "px " + e.current + "px";$( e ).css("background-position", axis);}' );
														 
				setInterval( 'window.' + randomId + '()', options.scrollSpeed ? options.scrollSpeed : 70 );
			}
			
			return this;
		}
})(jQuery);


// Return boolean TRUE/FALSE
function isiPhone(){
	var deviceAgent = navigator.userAgent.toLowerCase();
	    var agentID = deviceAgent.match(/(iphone|ipod|ipad)/);
	    if (agentID) {
	        return true;
	    }
    
}

