


//window.onload = pageAgeCheck;

var alreadyrunflag=0 //flag to indicate whether target function has already been run

if (document.addEventListener)
  document.addEventListener("DOMContentLoaded", function(){alreadyrunflag=1; pageAgeCheck()}, false)
else if (document.all && !window.opera){
  document.write('<script type="text/javascript" id="contentloadtag2" defer="defer" src="javascript:void(0)"><\/script>')
  var contentloadtag=document.getElementById("contentloadtag2")
  contentloadtag.onreadystatechange=function(){
    if (this.readyState=="complete"){
      alreadyrunflag=1
      pageAgeCheck()
    }
  }
}

window.onload=function(){
  setTimeout("if (!alreadyrunflag) pageAgeCheck()", 0)
}

var redVideos = '<a href="javascript:showHD(42046761);" name="&lid=redbandVideo" id="redbandVideo"  title="Sex Drive Trailer (red-band)"><img src="http://creative.myspacecdn.com/Client/SummitEntertainment/SexDrive/Images/thm_redbandtrailer.jpg"></a><a href="javascript:showHD(44696241);" name="&lid=moviepreview_redband" id="moviepreview_redband"  title="Exclusive First 10 Minutes of Sex Drive"><img src="http://creative.myspacecdn.com/Client/SummitEntertainment/SexDrive/Images/thm_moviepreview.jpg"></a><a href="javascript:showHD(44295777);" name="&lid=shoefits_redband" id="shoefits_redband"  title="See How That Shoe Fits (red-band)"><img src="http://creative.myspacecdn.com/Client/SummitEntertainment/SexDrive/Images/thm_shoefits.jpg"></a><a href="javascript:showHD(44168555);" name="&lid=punchingbag_redband" id="punchingbag_redband"  title="Punching Bag (red-band)"><img src="http://creative.myspacecdn.com/Client/SummitEntertainment/SexDrive/Images/thm_punchingbag.jpg"></a><a href="javascript:showHD(43385622);" name="&lid=knockedout_redband" id="knockedout_redband" title="Knocked Out (red-band)"><img src="http://creative.myspacecdn.com/Client/SummitEntertainment/SexDrive/Images/thm_knockedout.jpg" alt="Knocked Out (red-band)"></a><a href="javascript:showHD(43025366);" name="&lid=rexdrives_redband" id="rexdrives_redband" title="Rex Drives Ian to Work (red-band)"><img src="http://creative.myspacecdn.com/Client/SummitEntertainment/SexDrive/Images/thm_rexdrives.jpg" alt="Rex Drives Ian to Work (red-band)"></a><a href="javascript:showHD(43025590);" name="&lid=ezekial_redband" id="ezekial_redband" title="Ezekial Saves the Day (red-band)"><img src="http://creative.myspacecdn.com/Client/SummitEntertainment/SexDrive/Images/thm_ezekial.jpg" alt="Ezekial Saves the Day (red-band)"></a>';

var greenVideos = '<a href="javascript:showHD(42047231);" name="&lid=greenbandVideo" id="greenbandVideo" title="Sex Drive Trailer (green-band)"><img src="http://creative.myspacecdn.com/Client/SummitEntertainment/SexDrive/Images/thm_greenbandtrailer.jpg" alt="Sex Drive Green Band Trailer"></a><a href="javascript:showHD(43025475);" name="&lid=rexdrives_greenband" id="rexdrives_greenband" title="Rex Drives Ian to Work (green-band)"><img src="http://creative.myspacecdn.com/Client/SummitEntertainment/SexDrive/Images/thm_rexdrives.jpg" alt="Rex Drives Ian to Work (green-band)"></a><a href="javascript:showHD(43025674);"  name="&lid=ezekial_greenband" id="ezekial_greenband" title="Ezekial Saves the Day (green-band)"><img src="http://creative.myspacecdn.com/Client/SummitEntertainment/SexDrive/Images/thm_ezekial.jpg" alt="Ezekial Saves the Day (green-band)"></a>';



//show redband - also set the default video to play
//show redband - also set the default video to play
function showRedband() {  
    document.getElementById('videoPanel').innerHTML = '<h2>Video</h2><div class="videoNav"><div id="videoNavContent"><div id="thumbnailSectionContainer"><a href="javascript:void(0)" id="leftnav" name="&lid=leftnav" onmouseover="scrollDivLeft(\'holder\')" onmouseout="stopMe()" title="scroll"><img src="http://creative.myspacecdn.com/Client/SummitEntertainment/SexDrive/Images/left.jpg" /></a><div id="holder"><div id="insideHolder"><div id="lyr1" class="content"><img src="http://creative.myspacecdn.com/Client/SummitEntertainment/SexDrive/Images/title_redband.gif">' + redVideos + '<img src="http://creative.myspacecdn.com/Client/SummitEntertainment/SexDrive/Images/title_greenband.gif" alt="Sex Drive Green Band">' + greenVideos + '</div></div></div><a href="javascript:void(0)" onmouseover="scrollDivRight(\'holder\')" onmouseout="stopMe()" title="scroll"  id="rightnav" name="&lid=rightnav"><img src="http://creative.myspacecdn.com/Client/SummitEntertainment/SexDrive/Images/right.jpg" /></a></div></div></div><div id="videoContent"><iframe src="http://creative.myspacecdn.com/Client/SummitEntertainment/SexDrive/hd-44696241.html" width="852" height="650" frameborder="0"  id="videoRedBand" class="trailerContent"></iframe></div>';
    document.getElementById('soundboardSection').innerHTML = '<object type="application/x-shockwave-flash" allowNetworking="all" allowScriptAccess="always" allowFullScreen="true" height="648" width="450" id="springwidgets_57222" align="middle" data="http://downloads.thespringbox.com/web/wrapper.php?file=57222.sbw"><param name="allowNetworking" value="all" /><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="true" /><param name="movie" value="http://downloads.thespringbox.com/web/wrapper.php?file=57222.sbw" /><param name="flashvars" value="" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="bgColor" value="0x000000" /></object><div style="font:11px/12px arial;width:450px;"><a href="http://www.springwidgets.com/widgets/view/57222/?&width=450&height=630" target="_blank" name="&lid=redbandWidget" id="redbandWidget">Get this widget!</a></div>';
}

//show greenband - also set the default video to play
function showGreenband() {
   document.getElementById('videoPanel').innerHTML = '<h2>Video</h2><div class="videoNav"><div id="videoNavContent"><img src="http://creative.myspacecdn.com/Client/SummitEntertainment/SexDrive/Images/title_greenband.gif" alt="Sex Drive Green Band">' +  greenVideos + '</div></div><div id="videoContent"><iframe src="http://creative.myspacecdn.com/Client/SummitEntertainment/SexDrive/hd-42047231.html"  width="852" height="650" frameborder="0"  id="videoGreenBand" class="trailerContent"></iframe></div>';   
   document.getElementById('soundboardSection').innerHTML = '<object type="application/x-shockwave-flash" allowNetworking="all" allowScriptAccess="always" allowFullScreen="true" height="648" width="450" id="springwidgets_57221" align="middle" data="http://downloads.thespringbox.com/web/wrapper.php?file=57221.sbw"><param name="allowNetworking" value="all" /><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="true" /><param name="movie" value="http://downloads.thespringbox.com/web/wrapper.php?file=57221.sbw" /><param name="flashvars" value="" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="bgColor" value="0x000000" /></object><div style="font:11px/12px arial;width:450px;"><a href="http://www.springwidgets.com/widgets/view/57221/?&width=450&height=630" target="_blank" name="&lid=greenbandWidget" id="greenbandWidget">Get this widget!</a></div>';
}

//show default age gate DIV
function showAgeGate() {
	document.getElementById('age_check').style.display = 'inline';
	document.getElementById('soundboardSection').innerHTML = '<div id="soundboardDisabled"><span>Please select your age above.</span></div>';
}



function pageAgeCheck() {
	
	//if the user is logged in, do the age check and display the appropriate content
	if (isLoggedIn > 0) {
	 
			if (age < 18) {
			    showGreenband();  
			}
					
			if (age >= 18){
			     showRedband();
			}
    }
	
	//if the user is NOT logged in, show Age Gate on the selected DIVs
	if (isLoggedIn < 0) {
		showAgeGate(); 	
	}	

}

function toggleBand(bandType) {

    if (bandType=="red") {
        document.getElementById('redband').style.display = "block";
        document.getElementById('greenband').style.display = "none";
    } else {
        document.getElementById('greenband').style.display = "block";
        document.getElementById('redband').style.display = "none";

    }
}
