/// <reference path="jquery-1.3.2-vsdoc2.js" />
/// <reference path="swfobject-vsdoc.js" />
/// <reference path="sifr-vsdoc.js" />

function getScrollerWidth() {



    var scr = null;
    var inn = null;
    var wNoScroll = 0;
    var wScroll = 0;

    // Outer scrolling div
    scr = document.createElement('div');
    scr.style.position = 'absolute';
    scr.style.top = '-1000px';
    scr.style.left = '-1000px';
    scr.style.width = '100px';
    scr.style.height = '50px';
    // Start with no scrollbar
    scr.style.overflow = 'hidden';



    // Inner content div
    inn = document.createElement('div');
    inn.style.width = '100%';
    inn.style.height = '200px';

    // Put the inner div in the scrolling div
    scr.appendChild(inn);
    // Append the scrolling div to the doc
    document.body.appendChild(scr);

    // Width of the inner div sans scrollbar
    wNoScroll = inn.offsetWidth;
    // Add the scrollbar
    scr.style.overflow = 'auto';
    // Width of the inner div width scrollbar
    wScroll = inn.offsetWidth;

    // Remove the scrolling div from the doc
    document.body.removeChild(
    document.body.lastChild);

    // Pixel width of the scroller

    return (wNoScroll - wScroll);
}



function isMyStuffScrolling() {

    var docHeight = document.documentElement.scrollHeight;
    var scroll = $(window).height() + $(window).scrollTop();

    if ((docHeight - scroll) == 3 || docHeight == scroll) {
        return true;
    }

    else {
        return false;
    }
}
    

$(document).ready(function() {

    if (isMyStuffScrolling()) {
        $('#div_main_top_inner').css({ padding: '0px ' + getScrollerWidth() + 'px 0px 0px' });
        $('#div_contentwrapper').css({ padding: '0px ' + getScrollerWidth() + 'px 0px 25px' });
        $('#div_footer').css({ padding: '55px ' + (getScrollerWidth() + 25) + 'px 100px 25px' });
    }
    else {
        $('#div_main_top_inner').css({ padding: '0px 0px 0px 0px' });
        $('#div_contentwrapper').css({ padding: '0px 0px 0px 25px' });
        $('#div_footer').css({ padding: '55px 25px 100px 25px' });
    }

	/* 
		FADE OUT AND IN PAGE
		
		This script fades out and in new page when click on all links. It requires a div that lays over all content: 
		<div id="loader" style="position:fixed;top:0px;left:0px;width:100%;height:100%;background:#13191d;z-index:5000;display:none;">&#160;</div>		
	*/
	/*
		$('#loader').css({ display: "block" });
		setTimeout('$("#loader").fadeOut("400")', 500);

		// loop through a tags on page 
		$('a').each(function(idx, item) {
			// if it is not a mailto tag
			if (item.href.indexOf("mailto") == -1) {
				var url = "javascript:delayedRedirect('" + item.href + "');"
				item.href = url;
			}
		});
	*/
	
	/*
		FLASH DETECTION  
		
		Uses jQuery for adding elements. Displays a modal dialog box over a semi-transparent background if 
		flash version too old. 
	
		Todo: Perhaps store in cookies that user has already pressed "ok" to avoid showing message on every load.
	*/
	/*
	if (!swfobject.hasFlashPlayerVersion("9.0.0")) {
		var message = "<b>Flash Player 9 required</b><br />This site requires flash player 9.0.0 or newer. Please <a href='http://www.adobe.com/products/flashplayer/'>download here</a><br/><br/><input type=\"button\" style=\"float:right\" onclick=\"JavaScript:$('#__flashversion').remove();\" value=\"OK\" />";
		var bgcolor = "#FFFFFF";    // color of background
		var msg_width = "200";      // pixels
		var msg_height = "80";      // pixels
		var opacity = 80;           // background per cent visible

		$("body").append("<div id='__flashversion'></div>");
		var flash = $("#__flashversion");
		flash.append("<div id='__flashversion_bg' style=\"position:absolute;background:" + bgcolor + ";-khtml-opacity:." + opacity + "; -moz-opacity:." + opacity + "; -ms-filter:'alpha(opacity=" + opacity + ")'; filter:alpha(opacity=" + opacity + "); opacity:." + opacity + ";left:0;top:0;width:100%;height:100%;\"></div>");
		flash.append("<div style='position:absolute;margin-left:-" + (msg_width / 2) + "px;margin-top:-" + (msg_height / 2) + "px;background:" + bgcolor + ";width:" + msg_width + "px;height:" + msg_height + "px;left:50%;top:50%;padding:20px;text-align:left;border:1px solid #aaaaaa;'>" + message + "</div>");
	}	
	*/
});