// JavaScript Document
// Vortual Host application V1.0
// Copyright 2008 - 2009 by Bruen Media Group,LLC
// 970-593-6300
// www.bruen.com
// Code assembled by Justin Bruen
// Last modified
// 07/01/10 

window.onbeforeunload=toggleDivOff
var filePathPrefix=""
var vhApplicationSubPath="/_data/docs/virtualHost/"
var vhLoadingAnimationHoldoff=true
var autoPlay=true
var newMoviePath="vhWelcome.flv"
var delayTime=4000
var enableCookies=true
var defaultCookieValue="skip"
var defaultCookieExpire=30
var vhActivateButton=false
var hideAllActivateButtonsOnFirstPlay=false
var activateButtonDelay=true
var activateButtonImage="vhPlay.gif"
var vhCloseButton=false
var closeButtonImage="vhClose.gif"
var activateButtonTrumpsCookies=true
var alternateVideo
var skipActionParam=false
var vhHeight=400
var vhWidth=400
var vhAlerts=false
var vhDiagnose=false
var vhAlwaysVisible
var vhVideo
var vhTL,vhTR,vhBL,vhBR
var vhActive
var cookieValue
var expires
var filePathPrefix_param=gup('path')
var action_param=gup('action')
var vhActive_param=gup("vhActive")
var activateButton_param=gup("btn")
var closeButton_param=gup("xbtn")
var autoPlay_param=gup("auto")
var cookie_param=gup("c")
var vhFlag_param=gup("vhFlag")
var flashTimeout
var linkMovieName
var flashCapable=false
var enableLinks=false
var stopLoading=false
var playerCount=0
var playerReported=0
var activateDivPosition=-1000
var preloadVideoName=newMoviePath
var vhActivateButtonDisable=false
var vhApplicationPath="http://"+document.location.hostname+"/"+vhApplicationSubPath
var swfPath="http://"+document.location.hostname+"/"+vhApplicationSubPath+"virtualHost.swf"
var y=readCookie(preloadVideoName)
if(cookie_param=="f"){enableCookies=false}
if(vhActive_param=="vhTL"){vhTL=true;}
if(vhActive_param=="vhTR"){vhTR=true;}
if(vhActive_param=="vhBL"){vhBL=true;}
if(vhActive_param=="vhBR"){vhBR=true;}
if(activateButton_param=="t"){vhActivateButton=true;}
if(activateButton_param=="f"){vhActivateButton=false;}
if(activateButtonTrumpsCookies==true&&vhActivateButton==true){enableCookies=false}
if(y=="skip"&&enableCookies==true){vhActivateButtonDisable=true;hideActivateButton();}
if(closeButton_param=="t"){vhCloseButton=true;}
if(closeButton_param=="f"){vhCloseButton=false;}
if(vhActivateButton==true&&action_param){preloadVideoName=action_param+".flv";}
if(activateButtonDelay==true){activateDivPosition=-1000;}
if(filePathPrefix_param !=""){filePathPrefix=filePathPrefix_param;}
if(action_param){newMoviePath=action_param+".flv";}
if(filePathPrefix!=""){preloadVideoName=filePathPrefix+newMoviePath;}
if(autoPlay_param=="t"){autoPlay=true;}
function flashActive(){
playerReported++
if(playerReported==playerCount){
flashCapable=true
enableLinks=true
clearTimeout(flashTimeout)
if(vhActivateButton !=true&&autoPlay==true){playVH();}
createCookie('virtualHost','lastVisit',20)}}
function flvPreloaded(){
flashCapable=true
enableLinks=true
if(vhActivateButtonDisable==false){
if(vhActive_param){vhActive=vhActive_param;}
document.poppedActivate=eval('document.getElementById(vhActive +"divActivate")')
if(vhActive=="vhTL"){document.poppedActivate.style.left="0px";return;}
if(vhActive=="vhTR"){document.poppedActivate.style.right="0px";return;}
if(vhActive=="vhBL"){document.poppedActivate.style.left="0px";return;}
if(vhActive=="vhBR"){document.poppedActivate.style.right="0px";return;}}}
function flvPlaying(){
flashCapable=true
enableLinks=true
vhLoadingAnimationHoldoff=false
toggleDivOn()}
function hideActivateButton(){
if(vhTR==true&&hideAllActivateButtonsOnFirstPlay==true){document.poppedActivate=eval('document.getElementById("vhTRdivActivate")');document.poppedActivate.style.right="-1000px";}
if(vhTL==true&&hideAllActivateButtonsOnFirstPlay==true){document.poppedActivate=eval('document.getElementById("vhTLdivActivate")');document.poppedActivate.style.left="-1000px";}
if(vhBR==true&&hideAllActivateButtonsOnFirstPlay==true){document.poppedActivate=eval('document.getElementById("vhBRdivActivate")');document.poppedActivate.style.right="-1000px";}
if(vhBL==true&&hideAllActivateButtonsOnFirstPlay==true){document.poppedActivate=eval('document.getElementById("vhBLdivActivate")');document.poppedActivate.style.left="-1000px";}
document.poppedActivate=eval('document.getElementById(vhActive +"divActivate")')
if(vhActive=="vhTL"){document.poppedActivate.style.left="-1000px";return;}
if(vhActive=="vhTR"){document.poppedActivate.style.right="-1000px";return;}
if(vhActive=="vhBL"){document.poppedActivate.style.left="-1000px";return;}
if(vhActive=="vhBR"){document.poppedActivate.style.right="-1000px";return;}}
function disableVH(){
createCookie('virtualHost','disable',20)}
function gup(name){
name=name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]")
var regexS="[\\?&]"+name+"=([^&#]*)"
var regex=new RegExp(regexS)
var results=regex.exec(window.location.href)
if(results==null)
return ""
else
return results[1]}
function getFlashMovieObject(movieName){
if(window.document[movieName]){
return window.document[movieName]}
if(navigator.appName.indexOf("Microsoft Internet")==-1){
if(document.embeds&&document.embeds[movieName])
return document.embeds[movieName]}
else{
return document.getElementById(movieName)}}
function toggleDivOn(){
if(flashCapable==true){
SendStartDataToFlashMovie()
if(vhLoadingAnimationHoldoff==false){
document.poppedLayer=eval('document.getElementById(vhActive +"div")')
document.poppedActivate=eval('document.getElementById(vhActive +"divActivate")')
if(vhActive=="vhTL"){document.poppedLayer.style.left="0px";document.poppedActivate.style.left="-1000px";return;}
if(vhActive=="vhTR"){document.poppedLayer.style.right="0px";document.poppedActivate.style.right="-1000px";return;}
if(vhActive=="vhBL"){document.poppedLayer.style.left="0px";document.poppedActivate.style.left="-1000px";return;}
if(vhActive=="vhBR"){document.poppedLayer.style.right="0px";document.poppedActivate.style.right="-1000px";return;}}}}
function toggleDivOff(){
SendStopDataToFlashMovie()
document.poppedLayer=eval('document.getElementById(vhActive +"div")')
vhWidthString=1-vhWidth+'px'
if(vhActive=="vhTL"){document.poppedLayer.style.left=vhWidthString;return;}
if(vhActive=="vhTR"){document.poppedLayer.style.right=vhWidthString;return;}
if(vhActive=="vhBL"){document.poppedLayer.style.left=vhWidthString;return;}
if(vhActive=="vhBR"){document.poppedLayer.style.right=vhWidthString;return;}}
function SendStartDataToFlashMovie(){
var flashMovie=getFlashMovieObject(vhActive+"swf")
flashMovie.SetVariable("moviePath",filePathPrefix+newMoviePath)
flashMovie.SetVariable("playMovie",1)}
function SendStopDataToFlashMovie(){
var flashMovie=getFlashMovieObject(vhActive+"swf")
if(stopLoading==true){flashMovie.SetVariable("stopLoading","true")}
flashMovie.SetVariable("playMovie",0)}
function checkFlash(){
if(flashCapable==false){
if(confirm('Content on this page requires a newer version of Macromedia Flash Player. Do you want to download it now?'))
{window.location="http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash";}}}
function linkPlay(linkMovieName){
if(enableLinks==true){
newMoviePath=linkMovieName
toggleDivOn()}}
function createCookie(name,value,days){
if(days){
var date=new Date()
date.setTime(date.getTime()+(days*24*60*60*1000))
var expires="; expires="+date.toGMTString()}
else var expires=""
document.cookie=name+"="+value+expires+"; path=/"}
function readCookie(name){
var nameEQ=name+"="
var ca=document.cookie.split(';')
for(var i=0;i<ca.length;i++){
var c=ca[i]
while(c.charAt(0)==' ')c=c.substring(1,c.length)
if(c.indexOf(nameEQ)==0)return c.substring(nameEQ.length,c.length)}
return null}
function eraseCookie(name){
createCookie(name,"",-1)}
function playVH(activePlayer,name,value,days,alternateName){
vhActivateButtonDisable=true
var x=readCookie('virtualHost')
if(x=="disable"){return;}
if(action_param&&skipActionParam !=true&&activePlayer==undefined){
if(vhActive_param){vhActive=vhActive_param;}
newMoviePath=action_param+".flv"
vhVideo=action_param+".flv"
toggleDivOn()
skipActionParam=true
action_param=-1
hideActivateButton()
return}
if(name){
vhLoadingAnimationHoldoff=false
if(vhActive !=activePlayer){
stopLoading=true
toggleDivOff()
stopLoading=false
vhActive=activePlayer
vhVideo=name}
else{
if(name!=vhVideo){
toggleDivOff()
vhVideo=name}
else{
vhVideo=name}
if(value&&enableCookies==true){
var y=readCookie(name);if(y=="skip"){return;}
createCookie(vhVideo,value,days)}
linkPlay(vhVideo)
hideActivateButton()
return}}
if(x==vhVideo){;}
if(cookieValue&&enableCookies==true){
var y=readCookie(vhVideo)
if(y=="skip"){
return}
createCookie(vhVideo,cookieValue,expires)}
if(vhVideo){
linkPlay(vhVideo)
hideActivateButton()}}
function bruen_writeswf(){
if(vhActive_param){vhActive=vhActive_param;}
offPosition=1-vhWidth
if(vhTL==true){
playerCount++
document.write('<div id="vhTLdiv">')
document.write('<OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" CODEBASE="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab" WIDTH="'+vhWidth+'" HEIGHT="'+vhHeight+'" ID="vhTLswf">')
document.write('<PARAM NAME="MOVIE" VALUE="'+swfPath+'" />')
document.write('<PARAM NAME="PLAY" VALUE="true" />')
document.write('<PARAM NAME="LOOP" VALUE="false" />')
document.write('<PARAM NAME="QUALITY" VALUE="high" />')
document.write('<PARAM NAME="SCALE" VALUE="SHOWALL" />')
document.write('<PARAM NAME="ALLOWSCRIPTACCES" VALUE="ALWAYS" />')
document.write('<PARAM NAME="WMODE" VALUE="transparent" />')
if(vhActivateButton==true&&vhActive=="vhTL"){
document.write('<PARAM NAME="FLASHVARS" VALUE="vhActive=vhTL&preloadFilename='+preloadVideoName+'" />')
document.write('<EMBED SRC="'+swfPath+'" WIDTH="'+vhWidth+'" HEIGHT="'+vhHeight+'" LOOP="false" PLAY="true" QUALITY="high" SCALE="SHOWALL" swLiveConnect="true" allowScriptAccess="always" wmode="transparent" FlashVars="vhActive=vhTL&preloadFilename='+preloadVideoName+'" NAME="vhTLswf" PLUGINSPAGE="http://www.macromedia.com/go/flashplayer/">')}
else{
document.write('<PARAM NAME="FLASHVARS" VALUE="vhActive=vhTL" />')
document.write('<EMBED SRC="'+swfPath+'" WIDTH="'+vhWidth+'" HEIGHT="'+vhHeight+'" LOOP="false" PLAY="true" QUALITY="high" SCALE="SHOWALL" swLiveConnect="true" allowScriptAccess="always" wmode="transparent" FlashVars="vhActive=vhTL" NAME="vhTLswf" PLUGINSPAGE="http://www.macromedia.com/go/flashplayer/">')}
document.write('</EMBED>')
document.write('</OBJECT>')
document.write('</div>')
document.write('<style type="text/css"> #vhTLdiv {display:block;position:fixed;left:'+offPosition+'px;top:0px;z-index:200000;} *html #vhTLdiv {position:absolute;}</style>')
document.write('<div id="vhTLdivActivate">')
document.write("<a href=\"javascript:playVH('vhTL','"+newMoviePath+"','"+defaultCookieValue+"','"+defaultCookieExpire+"')\">")
document.write('<img src="'+vhApplicationPath+activateButtonImage+'"</a>')
if(vhCloseButton==true){
document.write("<br /><a href=\"javascript:hideActivateButton()\">")
document.write('<img src="'+vhApplicationPath+closeButtonImage+'"</a>')}
document.write('</div>')
document.write('<style type="text/css"> #vhTLdivActivate {display:block; position:fixed;left:'+activateDivPosition+'px; top:0px; z-index:200001;} *html #vhTLdivActivate {position:absolute;}</style>')}
if(vhTR==true){
playerCount++
document.write('<div id="vhTRdiv">')
document.write('<OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" CODEBASE="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab" WIDTH="'+vhWidth+'" HEIGHT="'+vhHeight+'"  ID="vhTRswf">')
document.write('<PARAM NAME="MOVIE" VALUE="'+swfPath+'" />')
document.write('<PARAM NAME="PLAY" VALUE="true" />')
document.write('<PARAM NAME="LOOP" VALUE="false" />')
document.write('<PARAM NAME="QUALITY" VALUE="high" />')
document.write('<PARAM NAME="SCALE" VALUE="SHOWALL" />')
document.write('<PARAM NAME="ALLOWSCRIPTACCES" VALUE="ALWAYS" />')
document.write('<PARAM NAME="WMODE" VALUE="transparent" />')
if(vhActivateButton==true&&vhActive=="vhTR"){
document.write('<PARAM NAME="FLASHVARS" VALUE="vhActive=vhTR&preloadFilename='+preloadVideoName+'" />')
document.write('<EMBED SRC="'+swfPath+'" WIDTH="'+vhWidth+'" HEIGHT="'+vhHeight+'" LOOP="false" PLAY="true" QUALITY="high" SCALE="SHOWALL" swLiveConnect="true" allowScriptAccess="always" wmode="transparent" FlashVars="vhActive=vhTR&preloadFilename='+preloadVideoName+'" NAME="vhTRswf" PLUGINSPAGE="http://www.macromedia.com/go/flashplayer/">')}
else{
document.write('<PARAM NAME="FLASHVARS" VALUE="vhActive=vhTR" />')
document.write('<EMBED SRC="'+swfPath+'" WIDTH="'+vhWidth+'" HEIGHT="'+vhHeight+'" LOOP="false" PLAY="true" QUALITY="high" SCALE="SHOWALL" swLiveConnect="true" allowScriptAccess="always" wmode="transparent" FlashVars="vhActive=vhTR" NAME="vhTRswf" PLUGINSPAGE="http://www.macromedia.com/go/flashplayer/">')}
document.write('</EMBED>')
document.write('</OBJECT>')
document.write('</div>')
document.write('<style type="text/css"> #vhTRdiv {display:block;position:fixed;right:'+offPosition+'px;top:0px;z-index:200000;} *html #vhTRdiv {position:absolute;}</style>')
document.write('<div id="vhTRdivActivate">')
document.write("<a href=\"javascript:playVH('vhTR','"+newMoviePath+"','"+defaultCookieValue+"','"+defaultCookieExpire+"')\">")
document.write('<img src="'+vhApplicationPath+activateButtonImage+'"</a>')
if(vhCloseButton==true){
document.write("<br /><a href=\"javascript:hideActivateButton()\">")
document.write('<img src="'+vhApplicationPath+closeButtonImage+'"</a>')}
document.write('</div>')
document.write('<style type="text/css"> #vhTRdivActivate {display:block; position:fixed;right:'+activateDivPosition+'px; top:0px; z-index:200001;} *html #vhTRdivActivate {position:absolute;}</style>')}
if(vhBL==true){
playerCount++
document.write('<div id="vhBLdiv">')
document.write('<OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" CODEBASE="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab" WIDTH="'+vhWidth+'" HEIGHT="'+vhHeight+'"  ID="vhBLswf">')
document.write('<PARAM NAME="MOVIE" VALUE="'+swfPath+'" />')
document.write('<PARAM NAME="PLAY" VALUE="true" />')
document.write('<PARAM NAME="LOOP" VALUE="false" />')
document.write('<PARAM NAME="QUALITY" VALUE="high" />')
document.write('<PARAM NAME="SCALE" VALUE="SHOWALL" />')
document.write('<PARAM NAME="ALLOWSCRIPTACCES" VALUE="ALWAYS" />')
document.write('<PARAM NAME="WMODE" VALUE="transparent" />')
if(vhActivateButton==true&&vhActive=="vhBL"){
document.write('<PARAM NAME="FLASHVARS" VALUE="vhActive=vhBL&preloadFilename='+preloadVideoName+'" />')
document.write('<EMBED SRC="'+swfPath+'" WIDTH="'+vhWidth+'" HEIGHT="'+vhHeight+'" LOOP="false" PLAY="true" QUALITY="high" SCALE="SHOWALL" swLiveConnect="true" allowScriptAccess="always" wmode="transparent" FlashVars="vhActive=vhBL&preloadFilename='+preloadVideoName+'" NAME="vhBLswf" PLUGINSPAGE="http://www.macromedia.com/go/flashplayer/">')}
else{
document.write('<PARAM NAME="FLASHVARS" VALUE="vhActive=vhBL" />')
document.write('<EMBED SRC="'+swfPath+'" WIDTH="'+vhWidth+'" HEIGHT="'+vhHeight+'" LOOP="false" PLAY="true" QUALITY="high" SCALE="SHOWALL" swLiveConnect="true" allowScriptAccess="always" wmode="transparent" FlashVars="vhActive=vhBL" NAME="vhBLswf" PLUGINSPAGE="http://www.macromedia.com/go/flashplayer/">')}
document.write('</EMBED>')
document.write('</OBJECT>')
document.write('</div>')
document.write('<style type="text/css"> #vhBLdiv {display:block;position:fixed;left:'+offPosition+'px;bottom:0px;z-index:200000;} *html #vhBLdiv {position:absolute;}</style>')
document.write('<div id="vhBLdivActivate">')
document.write("<a href=\"javascript:playVH('vhBL','"+newMoviePath+"','"+defaultCookieValue+"','"+defaultCookieExpire+"')\">")
document.write('<img src="'+vhApplicationPath+activateButtonImage+'"</a>')
if(vhCloseButton==true){
document.write("<br /><a href=\"javascript:hideActivateButton()\">")
document.write('<img src="'+vhApplicationPath+closeButtonImage+'"</a>')}
document.write('</div>')
document.write('<style type="text/css"> #vhBLdivActivate {display:block; position:fixed;left:'+activateDivPosition+'px; bottom:0px; z-index:200001;} *html #vhBLdivActivate {position:absolute;}</style>')}
if(vhBR==true){
playerCount++
document.write('<div id="vhBRdiv">')
document.write('<OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" CODEBASE="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab" WIDTH="'+vhWidth+'" HEIGHT="'+vhHeight+'" ID="vhBRswf">')
document.write('<PARAM NAME="MOVIE" VALUE="'+swfPath+'" />')
document.write('<PARAM NAME="PLAY" VALUE="true" />')
document.write('<PARAM NAME="LOOP" VALUE="false" />')
document.write('<PARAM NAME="QUALITY" VALUE="high" />')
document.write('<PARAM NAME="SCALE" VALUE="SHOWALL" />')
document.write('<PARAM NAME="ALLOWSCRIPTACCES" VALUE="ALWAYS" />')
document.write('<PARAM NAME="WMODE" VALUE="transparent" />')
if(vhActivateButton==true&&vhActive=="vhBR"){
document.write('<PARAM NAME="FLASHVARS" VALUE="vhActive=vhBR&preloadFilename='+preloadVideoName+'" />')
document.write('<EMBED SRC="'+swfPath+'" WIDTH="'+vhWidth+'" HEIGHT="'+vhHeight+'" LOOP="false" PLAY="true" QUALITY="high" SCALE="SHOWALL" swLiveConnect="true" allowScriptAccess="always" wmode="transparent" FlashVars="vhActive=vhBR&preloadFilename='+preloadVideoName+'" NAME="vhBRswf" PLUGINSPAGE="http://www.macromedia.com/go/flashplayer/">')}
else{
document.write('<PARAM NAME="FLASHVARS" VALUE="vhActive=vhBR" />')
document.write('<EMBED SRC="'+swfPath+'" WIDTH="'+vhWidth+'" HEIGHT="'+vhHeight+'" LOOP="false" PLAY="true" QUALITY="high" SCALE="SHOWALL" swLiveConnect="true" allowScriptAccess="always" wmode="transparent" FlashVars="vhActive=vhBR" NAME="vhBRswf" PLUGINSPAGE="http://www.macromedia.com/go/flashplayer/">')}
document.write('</EMBED>')
document.write('</OBJECT>')
document.write('</div>')
document.write('<style type="text/css"> #vhBRdiv {display:block; position:fixed; right:'+offPosition+'px; bottom:0px; z-index:200000;} *html #vhBRdiv {position:absolute;}</style>')
document.write('<div id="vhBRdivActivate">')
document.write("<a href=\"javascript:playVH('vhBR','"+newMoviePath+"','"+defaultCookieValue+"','"+defaultCookieExpire+"')\">")
document.write('<img src="'+vhApplicationPath+activateButtonImage+'"</a>')
if(vhCloseButton==true){
document.write("<br /><a href=\"javascript:hideActivateButton()\">")
document.write('<img src="'+vhApplicationPath+closeButtonImage+'"</a>')}
document.write('</div>')
document.write('<style type="text/css"> #vhBRdivActivate {display:block; position:fixed;right:'+activateDivPosition+'px; bottom:0px; z-index:200001;} *html #vhBRdivActivate {position:absolute;}</style>')}}


