﻿$(document).ready(function() {
    //fix document height relative to browser height
	$(window).resize(function() {_resizing(1)});
	var ie = jQuery.browser.msie;
	var version = parseInt(jQuery.browser.version);
	
	function _resizing(time) {
		

	    var winH = $(window).height();
		var winW = $(window).width();
	    if (winH < 700) {
			winH = 700;	
		}
		var height = winH - 45;
		
		var ie = jQuery.browser.msie;
		var version = parseInt(jQuery.browser.version);
		//fix ie6 footer position
		if (ie && version == 6) {
			var footer = $('#footer');
			var winH = $(window).height();
			var winW = $(window).width();
			footer.css('bottom', '0');
			footer = $('#footer');
			var addOffset = winH - footer.offset().top - 45;
			footer.css('bottom', '-'+addOffset+'px');
		}
		
		
		// just a hack fix
		
		if($('body#work').size() > 0)
		{		
	        $("#top-content").css("height", height + "px");
        }
        
        // moving as well the showreel and 
        if($('.strapline').size() && parseFloat($('#showreel_box').css('opacity')) >= 0.7)
        {
            var strap_left = $('.strapline').offset().left;        
            var small_pos = strap_left + $('#showreel_box').width() - 40;
            
            $('#showreel_box').css({'left':strap_left, 'top':'70px'});
            $('#clients_box').css({'left':small_pos, 'top':'100px'})
        }
	    //fix footer left/right positions
	    var centre = $("#centre-content");
	    var offset = centre.offset();
	    

				//fix the positioning of the footer in ie6
				//var sideContent = $("#content");
				//var otherOffset = sideContent.offset();
				//$("#footer").css('left', '-' + otherOffset.left + 'px');
				//$("#footer").css('width', winW);
		
		/*
	    var left = $("#footer #left");
	    var padding = left.css("padding-left");
	    padding = padding.replace("px", "");
		if (!ie || (ie && version == 7)) {
	    	$("#footer #left").css("width", offset.left - padding);
	    	$("#footer #right").css("width", winW - offset.left);
		}
		*/
		
	    //set the width of the full width fix
	    $("#full-width-fix").css("width", winW);
	    $("#full-width-fix").css("height", winH);
		if (time == 1) {
			//call a second time to combat the sometimes off effect
			setTimeout(function() { _resizing(2) }, 500);
		
		}
	}
	_resizing(1);
});


$(window).load(function(){
    //console.log($('body#work').size());
    if($('body#work').size() == 0)
    {
        var content_height = parseInt( $('#content').height() );
        //console.log(content_height);
        
        //$("#top-content").css("height", (content_height + 10) + "px");
        //console.log($("#top-content").height());
    }
});
