if(window.location.hash == '#wosClose')
{
    parent.wosFadeOutTS('0.5');
}


function wosGetInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
  var rv = -1; // Return value assumes failure.
  if (navigator.appName == 'Microsoft Internet Explorer')
  {
    var ua = navigator.userAgent;
    var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null)
      rv = parseFloat( RegExp.$1 );
  }
  return rv;
}

var headerHTML="";
//headerHTML += "<div id='LogoBG' style='position: absolute; left: 50%; top: 0px; margin-left: -180px; height:116px; width: 500px; z-index:1; background-image:url(\"http:\/\/www.webouts.com\/images\/Demo\/LogoBG.png\")'><\/div>";
headerHTML += "<div id='LogoBG' style='position: absolute; left: 50%; top: 0px; margin-left: -300px; height:116px; width: 500px; z-index:2; background-image:url(\"http:\/\/www.webouts.com\/images\/Demo\/LogoBG.png\")'><\/div>";
headerHTML += "<div id='BlueBar' style='position: absolute; left: 0px; top: 35px; height:58px; width: 100%; z-index:3; background-image:url(\"http:\/\/www.webouts.com\/images\/Demo\/BlueBar.png\")'><\/div>";
headerHTML += "<div id='LogoBG' style='position: absolute; left: 50%; top: 0px; margin-left: -240px; height:116px; width: 500px; z-index:4; background-image:url(\"http:\/\/www.webouts.com\/images\/Demo\/LogoBG.png\")'><\/div>";
headerHTML += "<div id='Logo' style='position: absolute; left: 50%; top: 8px; margin-left: -132px; height:89px; width: 283px; z-index:5; background-image:url(\"http:\/\/www.webouts.com\/images\/Demo\/WebOutsLogo.png\")'><\/div>";
headerHTML += "<div id='Tagline' style='position: absolute; left: 50%; margin-left: -485px; top: 53px; height:24px; width: 293px; z-index:5; background-image:url(\"http:\/\/www.webouts.com\/images\/Demo\/Tagline.png\")'><\/div>";
headerHTML += "<div id='CloseBT' onclick='javascript:wosFadeOutTS(\"0.5\");' style='position: absolute; cursor: pointer; left: 50%; margin-left: 260px; top: 35px; height:58px; width: 224px; z-index:5; background-image:url(\"http:\/\/www.webouts.com\/images\/Demo\/CloseDemo.png\")'><\/div>";



var wosOverlay = document.createElement("div");
wosOverlay.id = 'wosOverlay';
document.body.appendChild(wosOverlay);

var wosHeader = document.createElement("div");
wosHeader.id = 'wosHeader';
wosHeader.style.width = '100%';
wosHeader.style.height = 116 + 'px';
wosHeader.style.left = 0 + 'px';
wosHeader.style.top = 0 + 'px';
wosHeader.style.position = 'absolute';
wosHeader.style.display = 'none';
wosHeader.style.zIndex = 99999999;
wosHeader.innerHTML = headerHTML;
document.body.appendChild(wosHeader);

var wosIFrameHolder = document.createElement("div");
wosIFrameHolder.id = 'wosIFrameHolder';
wosIFrameHolder.style.width = 1 + 'px';
wosIFrameHolder.style.height = 1 + 'px';
wosIFrameHolder.style.left = 50 + '%';
wosIFrameHolder.style.position = 'absolute';
wosIFrameHolder.style.display = 'none';
wosIFrameHolder.style.zIndex = 99999999;
document.body.appendChild(wosIFrameHolder);

var wosIFrame = document.createElement("iframe");
wosIFrame.setAttribute('id', 'wosIFrame');
wosIFrame.setAttribute('src', '');

if(wosGetInternetExplorerVersion() < 7 && wosGetInternetExplorerVersion() > 1 )
{
    wosIFrame.setAttribute('height', '800px');
}
else
{
    wosIFrame.setAttribute('height', '100%');
}

wosIFrame.setAttribute('width', '100%');
wosIFrame.setAttribute('marginheight', '0');
wosIFrame.setAttribute('marginwidth', '0');
wosIFrame.setAttribute('frameborder', '0');
wosIFrame.setAttribute('scrolling', 'no');
wosIFrameHolder.appendChild(wosIFrame);


//Floating JavaScript
var wosPageWidth = 0; var wosPageHeight = 0; var wosScrOfX = 0; wosScrOfY = 0;
function wosPositionOverlay()
{
    if( typeof( window.innerWidth ) == 'number' ) { //Non-IE
	  wosPageWidth = window.innerWidth; wosPageHeight = window.innerHeight;
    } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { //IE 6+ in 'standards compliant mode'
	  wosPageWidth = document.documentElement.clientWidth; wosPageHeight = document.documentElement.clientHeight;
    } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { //IE 6+ in 'standards compliant mode'
	  wosPageWidth = document.body.clientWidth; wosPageHeight = document.body.clientHeight;
    }
	  
    if( typeof( window.pageYOffset ) == 'number' ) { //Netscape compliant
	  wosScrOfY = window.pageYOffset; wosScrOfX = window.pageXOffset;
    } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) { //DOM compliant
	  wosScrOfY = document.body.scrollTop; wosScrOfX = document.body.scrollLeft;
    } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {//IE6 standards compliant mode
	  wosScrOfY = document.documentElement.scrollTop; wosScrOfX = document.documentElement.scrollLeft;
    }

    wosOverlay.style.width = (wosPageWidth + wosScrOfX) + 'px';
    wosOverlay.style.height = (wosPageHeight + wosScrOfY ) + 'px';
    wosOverlay.style.top = 0 + 'px';
    wosOverlay.style.left = 0 + 'px';
}




function wosFloatOverlay()
{
    wosPositionOverlay();
    wosOverlay.style.opacity = '0';
    wosOverlay.style.filter = 'alpha(opacity:0)';
    wosOverlay.style.zIndex = 999999;
    wosOverlay.style.width = 100 + '%';
    wosOverlay.style.height = 100 + '%';
    wosOverlay.style.position = 'fixed';
    wosOverlay.style.bottom = 0 + 'px';
    wosOverlay.style.top = 'auto';    

    var isSupported = null;
    if (document.createElement)
    {
        var el = document.createElement("div");
        if (el && el.style)
        {
            el.style.width = "1px";
            el.style.height = "1px";
            el.style.position = "fixed";
            el.style.top = "10px";
            var root = document.body;
            if (root && root.appendChild && root.removeChild)
            {
                root.appendChild(el);
                isSupported = el.offsetTop === 10;
                root.removeChild(el);
            }
            el = null;
        }
    }  
    
    if(!isSupported)
    {
        wosPositionOverlay();
        wosOverlay.style.position = 'absolute';
    }
    
    window.onscroll = wosPositionOverlay;
    window.onresize = wosPositionOverlay;
}


var wosOverlayOpacity = 0;//Will be used to track current opacity of div for fadeout and fadein function


//function wosLoad(opacity, fadeLength, color, height, width, url)
//{
//    scroll(0,0)
//    wosOverlay.style.visibility = 'visible';
//    wosOverlay.style.opacity = '0';
//    wosOverlay.style.filter = 'alpha(opacity:0)';
//    wosOverlay.style.zIndex = 99999;
//    wosOverlay.style.backgroundColor = color;
//    wosOverlay.style.display = 'block';
//    
//    wosHeader.style.width = '100%';
//    wosHeader.style.height = 116 + 'px';
//    wosHeader.style.left = 0 + 'px';
//    wosHeader.style.top = 0 + 'px';
//    wosHeader.style.position = 'absolute';
//    wosHeader.style.display = 'block';
//    wosHeader.style.zIndex = 99999999;
//    wosHeader.style.opacity = '1';
//    wosHeader.style.filter = 'alpha(opacity:100)';
//	    
//    wosFloatOverlay();
//    overlayFinalOpacity = opacity;
//    fadeIncrement = (opacity/(fadeLength * 30));
//    fadeInterval = setInterval(wosFadeOverlay, 33);
//    
//    function wosFadeOverlay()
//    {
//	if(wosOverlayOpacity < overlayFinalOpacity)
//	{
//	    wosOverlayOpacity = wosOverlayOpacity + fadeIncrement;
//	    wosOverlay.style.opacity = wosOverlayOpacity;
//	    wosOverlay.style.filter = 'alpha(opacity:' + (wosOverlayOpacity * 100) +')';
//	}
//	else
//	{
//	    var ml = -1 * (width/2);
//	    
//	    clearInterval(fadeInterval);
//	    
//	    wosIFrameHolder.style.position = 'absolute';
//	    wosIFrameHolder.style.zIndex = 99999999;
//	    wosIFrameHolder.style.display = 'block';
//	    wosIFrameHolder.style.top = '116px';
//	    wosIFrameHolder.style.left = '50%';
//	    wosIFrameHolder.style.marginLeft = ml + 'px';
//	    wosIFrameHolder.style.width = width + 'px';
//	    wosIFrameHolder.style.height = height + 'px';
//	    wosIFrameHolder.style.opacity = '0.5';
//	    wosIFrameHolder.style.filter = 'alpha(opacity:50)';
//	    
//	    parentlocation = String(window.location);
//	    hashlocation = parentlocation.indexOf('#autoload');
//	    locationNoHash = parentlocation.substring(0, hashlocation);
//	    
//	    if(hashlocation > -1)
//	    {
//		document.getElementById('wosIFrame').src = url + '#' + locationNoHash;
//	    }
//	    else
//	    {
//		document.getElementById('wosIFrame').src = url + '#' + window.location;
//	    } 
//	}
//    }
//}


function wosLoad(opacity, fadeLength, color, height, width, url)
{
    scroll(0,0)
    wosOverlay.style.visibility = 'visible';
    wosOverlay.style.zIndex = 9999999;
    wosOverlay.style.backgroundColor = color;
    wosOverlay.style.display = 'block';
    wosOverlay.style.opacity = 0;
    wosOverlay.style.filter = 'alpha(opacity:0)';
    wosFloatOverlay();
   
    wosHeader.style.width = '100%';
    wosHeader.style.height = 116 + 'px';
    wosHeader.style.left = 0 + 'px';
    wosHeader.style.top = 20 + 'px';
    wosHeader.style.position = 'absolute';
    wosHeader.style.display = 'block';
    wosHeader.style.zIndex = 99999999;
    wosHeader.style.opacity = '0';
    wosHeader.style.filter = 'alpha(opacity:0)';
    
    var ml = -1 * (width/2);
    wosIFrameHolder.style.position = 'absolute';
    wosIFrameHolder.style.width = width + 'px';
    wosIFrameHolder.style.height = height + 'px';
    wosIFrameHolder.style.zIndex = 99999999;
    wosIFrameHolder.style.top = '116px';
    wosIFrameHolder.style.left = '50%';
    wosIFrameHolder.style.marginLeft = ml + 'px';
    wosIFrameHolder.style.display = 'block';
    wosIFrameHolder.style.opacity = 0;
    wosIFrameHolder.style.filter = 'alpha(opacity:0)';
  
    document.getElementById('wosIFrame').src = url;
    
    $('#wosOverlay').animate({opacity: 0.7}, 500);
    $('#wosHeader').delay(500).animate({top: '0px', opacity: 1, filter: ''}, 500);
    $('#wosIFrameHolder').delay(1000).animate({opacity: 1, filter: ''}, 500);
}



function wosCheckClose()
{
    if(window.location.hash == '#wosClose')
    {
	clearInterval(wosCloseCheckInterval);
	parent.wosFadeOutTS('0.5');
    }
}

 

function wosFadeOutTS(fadeLength)
{
    $('#wosOverlay').animate({opacity: 0}, 500);
    $('#wosHeader').animate({opacity: 0, filter: ''}, 500);
    $('#wosIFrameHolder').animate({opacity: 0, filter: ''}, 500, function(){
    
    document.getElementById('wosIFrame').src = 'about:blank';
    wosOverlayOpacity = 0;
    wosOverlay.style.display = 'none';
    wosIFrameHolder.style.display = 'none';
    wosHeader.style.display = 'none';
    
    
    });
    
}


if(window.location.hash == '#autoload')
{
    wosLoad('0.5', '0.5', '#ffffff', '800', '995', 'http://webouts.com/Hosting/Samples/WebOuts/Pierce/DashCFWO/');
}
else if(window.location.hash == '#page')
{
    wosLoad('0.8', '0.5', '#ffffff', 'http://webouts.com/Hosting/Samples/WebOuts/Pierce/DashCFWO/');
}
else
{
    //wosLoad('0.8', '0.5', '#ffffff', '1000px', '800px', 'http://webouts.com/Hosting/Samples/WebOuts/Pierce/DashCFWO/');
}

