//jQuery.noConflict();

var name = "#portNav";
	/*menuYloc = parseInt($(name).css("top").substring(0,$(name).css("top").indexOf("px")))*/
$(window).scroll(function () 
{ 
	if ($(document).scrollTop()>2050){					   
		offset = 2475+"px";
	}
	else if ($(document).scrollTop()>1500){					   
		offset = 1905+"px";
	}
	else if ($(document).scrollTop()>950){					   
		offset = 1330+"px";
	}
	else if ($(document).scrollTop()>350){					   
		offset = 755+"px";
	}
	else {					   
		offset = 175+"px";
	}
	/*else {
	topper=parseInt($("#portStrategy").css("top").substring(0,$("#portStrategy").css("top").indexOf("px")));
	alert (topper);
	offset=topper;
	
	}*/
	$(name).animate({top:offset},{duration:500,queue:false});
});




function improvements()
{
	jQuery('.boxgrid.slideright').hover(
		function(){
		jQuery(".cover", this).stop().animate({top:'120px'},{queue:false,duration:500});
		}, 
		function() {
			jQuery(".cover", this).stop().animate({top:'0px'},{queue:false,duration:500});
		}
	);	

	
	 jQuery('.imgFade').each(function() {
			jQuery(this).find('img').stop().animate({ opacity: 1.0 }, 300);							 
            jQuery(this).hover(function() {
               jQuery(this).find('img').stop().animate({ opacity: 0.5 }, 300);
            },
           function() {
              jQuery(this).find('img').stop().animate({ opacity: 1.0 }, 300);
           });
        });
	 
	
	
	/* iepng fix for images */
	
	if((jQuery.browser.msie && parseInt(jQuery.browser.version) < 7))
	{
		jQuery("#nav, .navwrap, #main, #content, #footer").addClass("ie6fix");
	}
	
	/* footer stick to the bottom of the window.
	Only if the document body height is less than the window height. 
	If it isn't it 'll just follow the normal document flow. */
	

	function positionFooter(){
		if(jQuery(document.body).height() < jQuery(window).height()){
			jQuery("#footercontener").css({position: "absolute",top:(jQuery(window).scrollTop()+jQuery(window).height()-jQuery("#footercontener").height())+"px"})
		}	
	}
	positionFooter(); 
 
	jQuery(window).scroll(positionFooter).resize(positionFooter);

}


/**
 * @author Alexander Farkas
 * v. 1.02
 */
(function($) {
	$.extend($.fx.step,{
	    backgroundPosition: function(fx) {
            if (fx.state === 0 && typeof fx.end == 'string') {
                var start = $.curCSS(fx.elem,'backgroundPosition');
                start = toArray(start);
                fx.start = [start[0],start[2]];
                var end = toArray(fx.end);
                fx.end = [end[0],end[2]];
                fx.unit = [end[1],end[3]];
			}
            var nowPosX = [];
            nowPosX[0] = ((fx.end[0] - fx.start[0]) * fx.pos) + fx.start[0] + fx.unit[0];
            nowPosX[1] = ((fx.end[1] - fx.start[1]) * fx.pos) + fx.start[1] + fx.unit[1];
            fx.elem.style.backgroundPosition = nowPosX[0]+' '+nowPosX[1];

           function toArray(strg){
               strg = strg.replace(/left|top/g,'0px');
               strg = strg.replace(/right|bottom/g,'100%');
               strg = strg.replace(/([0-9\.]+)(\s|\)|$)/g,"$1px$2");
               var res = strg.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);
               return [parseFloat(res[1],10),res[2],parseFloat(res[3],10),res[4]];
           }
        }
	});
})(jQuery);



jQuery(document).ready(function()
{	
	
	jQuery('.imgFadereverse').each(
		function() {
			jQuery(this).find('img').stop().animate({ opacity: 0.5 }, 300);							 
			jQuery(this).hover(
				function() {
					jQuery(this).find('img').stop().animate({ opacity: 1.0 }, 300);
				},
				function() {
					jQuery(this).find('img').stop().animate({ opacity: 0.5 }, 300);
				}
			);
		}
	);
	
	/*jQuery("a.lightbox").lightbox({
     
    });*/

	
	//Horizontal Sliding	
	improvements(); // adds some improvements to the site	
});



