var ie		= (document.all) ? true : false;
var fD;
window.load = setTimeout("createLightboxes()",250);
function openDemoForm(e) {
	var keynum;
	var keychar;
	if(window.event){
		keynum = e.keyCode;
	}else if(e.which){
		keynum = e.which;
	}
	if(keynum==13){
		if(document.getElementById('popout').style.display=='block'){
			submitForm();
		}else{
			if(document.getElementById('myEmail').value=='email address'){
				document.getElementById('myEmail').value='';
			}
			document.getElementById('dfEmail').value=document.getElementById('myEmail').value;
			openbox(1);
		}
	}
}

/* simple lightboxing */
function gradient(id, level) {
	var box = document.getElementById(id);
	box.style.opacity = level;
	box.style.MozOpacity = level;
	box.style.KhtmlOpacity = level;
	box.style.filter = "alpha(opacity=" + level+ ")";
	box.style.display="block";
	return;
}

function fadein(id) {
	var level = 0;
	while(level <= 1) {
		setTimeout( "gradient('" + id + "'," + level + ")", (level* 1000) + 10);
		level += 0.01;
	}
}
function openwbox(fade) {
	var box = document.getElementById('wpbox'); 
	document.getElementById('wpRequest').style.display='block';
	document.getElementById('filter').style.display='block';
	if(ie){
		document.getElementById('wpbox').style.display='block';
	}else{
		if(fade){
			gradient("wpbox", 0);
			fadein("wpbox");
		}else{ 	
			box.style.display='block';
		}  	
	}
}
function openboxtovideo(fade) {
	document.getElementById('filter').style.height = '1200px';
	var box = document.getElementById('vbox'); 
	document.getElementById('vout').style.display='block';
	document.getElementById('filter').style.display='block';
	document.getElementById('vboxtitle').innerHTML = 'Tech Close Up from Outside Lands';
	if(ie){
		document.getElementById('vbox').style.display='block';
	}else{
		if(fade){
			gradient("vbox", 0);
			fadein("vbox");
		}else{ 	
			box.style.display='block';
		}  	
	}
	//setTimeout("logEntryFlow()",1000);
	setTimeout("fillVideo()",1000);
}
function fillVideo(){
	var vp = '<div>\n';
	vp += '<div id="hqPlayer" style="margin: 0px auto; overflow: hidden; width: 656px; height: 511px; position: relative;">\n';
	vp += '<div id="slContainer" style="width: 656px; position: absolute; left: 0px; top: 0px;">\n';
	vp += '<object id="sl" height="511" width="656" data="data:application/x-silverlight," type="application/x-silverlight">\n';
	vp += '<param value="true" name="windowless"/>\n';
	vp += '<param value="true" name="enableHtmlAccess"/>\n';
	vp += '<param value="true" name="allowHtmlPopupWindow"/>\n';
	vp += '<param value="white" name="background"/>\n';
	vp += '<param value="color=faa141,colordark=ea8d28,vWidth=656,mediaFeed=outsideLands.xml" name="initParams"/>\n';
	vp += '<param value="ClientBin/ispSSPlayer.xap" name="source"/>\n';
	vp += '<div style="margin:0px auto;width:511px;height:656px;padding:20px;">\n';
	vp += '	This video presentation requires Silverlight 3.0 to view.  \n';
	vp += '</div>\n';
	vp += '</object>\n';
	vp += '</div>\n';
	vp += '</div>\n';
	vp += '<div style="margin: -15px auto 15px; background: transparent none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; height: auto ! important; min-height: 20px;"/>\n';
	vp += '</div>\n';
	document.getElementById('playerBlock').innerHTML = vp;
}
function openbox(fade) {
	var box = document.getElementById('popbox'); 
	document.getElementById('popout').style.display='block';
	document.getElementById('filter').style.display='block';
	if(ie){
		document.getElementById('popbox').style.display='block';
	}else{
		if(fade){
			gradient("popbox", 0);
			fadein("popbox");
		}else{ 	
			box.style.display='block';
		}  	
	}
}
function closebox(d) {
	if(document.getElementById('playerBlock')){
		document.getElementById('playerBlock').innerHTML = '';
		document.getElementById('vbox').style.display='none';
	}
	if(d=='df'){
		if(document.demoForm){
			document.getElementById('dfName').value = '';
			document.getElementById('dfEmail').value = '';
			document.getElementById('dfPhone').value = '';
		}
		document.getElementById('popout').style.display='none';
		document.getElementById('popbox').style.display='none';
	}else if(d=='wp'){
		if(document.wpForm){
			document.wpForm.wpName.value = '';
			document.wpForm.wpEmail.value = '';
			document.wpForm.wpPhone.value = '';
			document.wpForm.wpCompany.value = '';
			document.wpForm.wpIndustry.selectedIndex = 0;
		}
		document.getElementById('wpRequest').style.display='none';
		document.getElementById('wpbox').style.display='none';
	}
	document.getElementById('filter').style.display='none';
}
function submitForm(fn) {
	if(fn=='df'){
		var di = document.getElementById('dfInstructions');
		if(document.getElementById('dfName').value != ''){
			if(emailCheck(document.getElementById('dfEmail').value)){
				if(document.getElementById('dfPhone').value != ''){
					document.getElementById('demoForm').submit();
					document.getElementById('dfForm').innerHTML = '';
					document.getElementById('dfButtons').innerHTML = '';
					di.innerHTML = 'Thank you for your request, you should hear from our team shortly.';
					fD = 'df';
					clearRequest();
				}else{
					di.innerHTML = 'Please provide a phone number to reach you at.<br/><br/>&nbsp;';
					di.style.color = '#fcc244';
					di.style.fontWeight = 'bold';
				}
			}else{
				di.innerHTML = 'Please provide a valid email address to write to you.<br/><br/>&nbsp;';
				di.style.color = '#fcc244';
				di.style.fontWeight = 'bold';
			}
		}else{
			di.innerHTML = 'Please provide your name.<br/><br/>&nbsp;';
			di.style.color = '#fcc244';
			di.style.fontWeight = 'bold';
		}
	}else if(fn=='wp'){
		var di = document.getElementById('wpInstructions');
		if(document.getElementById('wpName').value != ''){
			if(document.getElementById('wpCompany').value != ''){
				if(emailCheck(document.getElementById('wpEmail').value)){
					if(document.getElementById('wpPhone').value != ''){
						document.wpForm.submit();
						di.innerHTML = 'Thank you for your request, your download will begin shortly.';
						fD = 'wp';
						//clearRequest();
						document.getElementById("allData").style.display='none';
						document.getElementById("allData2").style.display='block';
					}else{
						di.innerHTML = 'Please provide a phone number to reach you at.<br/><br/>&nbsp;';
						di.style.color = '#fcc244';
						di.style.fontWeight = 'bold';
					}
				}else{
					di.innerHTML = 'Please provide a valid email address to write to you.<br/><br/>&nbsp;';
					di.style.color = '#fcc244';
					di.style.fontWeight = 'bold';
				}
			}else{
				di.innerHTML = 'Please provide your company/affiliation.<br/><br/>&nbsp;';
				di.style.color = '#fcc244';
				di.style.fontWeight = 'bold';
			}
		}else{
			di.innerHTML = 'Please provide your name.<br/><br/>&nbsp;';
			di.style.color = '#fcc244';
			di.style.fontWeight = 'bold';
		}
	}
}
function clearRequest() {
	setTimeout("closeboxtimer()",1000);
}
function closeboxtimer() {
	closebox(fD);
}
function launchChat(){
	var url = 'http://support.istreamplanet.com/phplive/request_email.php?l=admin&x=1&deptid=2';
	var newwindow=window.open(url,'name','height=360,width=450,resizable=no');
	if (window.focus) {
		newwindow.focus()
	}
}

//** SLIDEBOX global variables *******************************************
var fps = 1; 		//speed of movement - the lower number makes it faster (milsecs)
var motionTimer; 	//a variable for a timer
var img = 1; 		//the image that is currently in the viewport
var destX = 0;		//sets the destination in terms of pixels
var direction = 1;	//assume 1 = right, 0 = left
var speed = 6; 	//easing rate - lower is faster
var autoSlide = true;
var autoSlideTimer;

function showBig(imgKey) {
	var imgMax = document.getElementById("ribbonImages").getElementsByTagName("div").length; //total number of images in gallery
	if(imgKey > img){
		direction = 1;
	}else{
		direction = 0;
	}
	if(imgKey == 0){
		imgKey = imgMax;
	}else if(imgKey == imgMax + 1){
		imgKey = 1;
	}
	if(imgKey > 0 && imgKey <= imgMax) {
		destX = -(imgKey - 1) * 300;
		img = imgKey;
		clearInterval(motionTimer);
		motionTimer = setInterval("slideRibbonWithEasing()", fps);
	}
}
function autoSlideStop() {
	clearInterval(autoSlideTimer);
}
function autoSlider(){
	autoSlideTimer = setInterval("runSlider()",4000);
}
function runSlider(){
	showBig(img+1);
}

function slideRibbonWithEasing(){
	var ribbon = document.getElementById("galleryRibbon");
	var ribbonX = parseInt(ribbon.offsetLeft);
	if(Math.abs(destX - ribbonX) <= speed) {
		ribbon.style.left = destX + 'px';
		clearInterval(motionTimer);
	} else {
		var px = (ribbonX + ((destX - ribbonX) / speed));
		ribbon.style.left = px + 'px';
	}
}

function createLightboxes(){
	var dfReqHtml = '';
	dfReqHtml += '		<div id="popbox" style="display:none;">\n';
	dfReqHtml += '			<div id="popclose">\n';
	dfReqHtml += '				<a href="javascript:closebox(\'df\');"><img src="images/circlex-close.png" border="0" alt="close"/></a>\n';
	dfReqHtml += '			</div>\n';
	dfReqHtml += '			<div id="popboxtitle">Live Demo Request</div>\n';
	dfReqHtml += '			<form name="demoForm" action="cdomail.asp?action=df" target="datahole">\n';
	dfReqHtml += '			<p>\n';
	dfReqHtml += '				<span id="dfInstructions">Thank you for your interest in a live demonstration with one of\n';
	dfReqHtml += '				our technicians.  Please give us a bit more information so that we\n';
	dfReqHtml += '				can schedule the right expert for your needs.</span>\n';
	dfReqHtml += '				<table id="dfTable" style="margin-left:12px;margin-top:5px;">\n';
	dfReqHtml += '				<tr>\n';
	dfReqHtml += '					<td>Your Name:</td>\n';
	dfReqHtml += '					<td colspan="3"><input type="text" name="dfName" id="dfName" value="" maxlength="50" style="width:180px;"/></td>\n';
	dfReqHtml += '				</tr>\n';
	dfReqHtml += '				<tr>\n';
	dfReqHtml += '					<td>Email Address:</td>\n';
	dfReqHtml += '					<td colspan="3"><input type="text" name="dfEmail" id="dfEmail" value="" maxlength="50" style="width:180px;"/></td>\n';
	dfReqHtml += '				</tr>\n';
	dfReqHtml += '				<tr>\n';
	dfReqHtml += '					<td>Phone Number:</td>\n';
	dfReqHtml += '					<td colspan="3"><input type="text" name="dfPhone" id="dfPhone" value="" maxlength="24" style="width:120px;"/></td>\n';
	dfReqHtml += '				</tr>\n';
	dfReqHtml += '				<tr>\n';
	dfReqHtml += '					<td>Products of Interest:</td>\n';
	dfReqHtml += '					<td nowrap><input type="checkbox" name="dfProducts1" value="Director"/> Director</td>\n';
	dfReqHtml += '					<td nowrap><input type="checkbox" name="dfProducts2" value="DRM"/> DRM</td>\n';
	dfReqHtml += '					<td nowrap><input type="checkbox" name="dfProducts3" value="Presenter"/> Presenter</td>\n';
	dfReqHtml += '				</tr>\n';
	dfReqHtml += '				<tr>\n';
	dfReqHtml += '					<td></td>\n';
	dfReqHtml += '					<td nowrap><input type="checkbox" name="dfProducts4" value="Player"/> Player</td>\n';
	dfReqHtml += '					<td nowrap><input type="checkbox" name="dfProducts5" value="PayCast"/> PayCast</td>\n';
	dfReqHtml += '					<td nowrap><input type="checkbox" name="dfProducts6" value="Creative"/> Creative Services</td>\n';
	dfReqHtml += '				</tr>\n';
	dfReqHtml += '				<tr>\n';
	dfReqHtml += '					<td></td>\n';
	dfReqHtml += '					<td nowrap colspan="2"><input type="checkbox" name="dfProducts7" value="Webcasting"/> Managed Webcasting</td>\n';
	dfReqHtml += '					<td nowrap><input type="checkbox" name="dfProducts8" value="Other"/> Other</td>\n';
	dfReqHtml += '				</tr>\n';
	dfReqHtml += '				</table>\n';
	dfReqHtml += '			</p>\n';
	dfReqHtml += '			</form>\n';
	dfReqHtml += '			<p style="text-align:center;" id="dfSubmit"> \n';
	dfReqHtml += '				<input type="button" name="submit" value="SUBMIT" onclick="submitForm(\'df\');" class="button btnbold"/>\n';
	dfReqHtml += '				<input type="button" name="cancel" value="CANCEL" onclick="closebox(\'df\');" class="button"/>\n';
	dfReqHtml += '			</p>\n';
	var wpReqHtml = '';	//http://www.hoovers.com/free/industries/
	wpReqHtml += '		<div id="wpbox" style="display:none;">\n';
	wpReqHtml += '			<div id="wpclose">\n';
	wpReqHtml += '				<a href="javascript:closebox(\'wp\');"><img src="images/circlex-close.png" border="0" alt="close"/></a>\n';
	wpReqHtml += '			</div>\n';
	wpReqHtml += '			<div id="wpboxtitle">Download the White Paper</div>\n';
	wpReqHtml += '			<div id="allData2" style="display:none;">\n';
	wpReqHtml += '			<p>\n';
	wpReqHtml += '				Download the white paper: <a href="http://www.istreamplanet.com/webdemo/whitepaper/iSP_MS_Smooth_White_Paper.pdf" style="color:#ffbb00;font-weight:bold;">right click here</a> and select "Save As"\n';
	wpReqHtml += '			</p>\n';
	wpReqHtml += '			<p>\n';
	wpReqHtml += '				Thanks for your interest in reading our guide to deployment.  Should you have any questions or need assistance with your online live event webcast, contact us at 702.492.5900 or <a href="mailto:sales@istreamplanet.com" style="color:#ffbb00;">sales@istreamplanet.com</a>\n';
	wpReqHtml += '			</p>\n';
	wpReqHtml += '			<p>\n';
	wpReqHtml += '				<a href="javascript:closebox(\'wp\');" style="color:#ffbb00;">CLOSE WINDOW</a>\n';
	wpReqHtml += '			</p>\n';
	wpReqHtml += '			</div>\n';
	wpReqHtml += '			<div id="allData" style="display:block;">\n';
	wpReqHtml += '			<form name="wpForm" method="post" action="cdomail.asp?action=wp" target="datahole">\n';
	wpReqHtml += '			<p>\n';
	wpReqHtml += '				<span id="wpInstructions">Thank you for your interest in downloading our "Delivering Live and On-demand Smooth Streaming Video" white paper.  Please complete the following in order to receive the PDF.</span>\n';
	wpReqHtml += '				<table id="wpTable" style="margin-left:20px;margin-top:5px;">\n';
	wpReqHtml += '				<tr>\n';
	wpReqHtml += '					<td>Your Name:</td>\n';
	wpReqHtml += '					<td colspan="3"><input type="text" name="wpName" id="wpName" value="" maxlength="50" style="width:180px;"/></td>\n';
	wpReqHtml += '				</tr>\n';
	wpReqHtml += '				<tr>\n';
	wpReqHtml += '					<td>Company:</td>\n';
	wpReqHtml += '					<td colspan="3"><input type="text" name="wpCompany" id="wpCompany" value="" maxlength="32" style="width:180px;"/></td>\n';
	wpReqHtml += '				</tr>\n';
	wpReqHtml += '				<tr>\n';
	wpReqHtml += '					<td>Industry:</td>\n';
	wpReqHtml += '					<td colspan="3"><select name="wpIndustry" id="wpIndustry" style="width:184px;"/>\n';
	wpReqHtml += '						<option>--select one--</option>\n';
	wpReqHtml += '						<option>Aerospace & Defense</option>\n';
	wpReqHtml += '						<option>Agriculture</option>\n';
	wpReqHtml += '						<option>Automotive & Transport</option>\n';
	wpReqHtml += '						<option>Banking</option>\n';
	wpReqHtml += '						<option>Beverages</option>\n';
	wpReqHtml += '						<option>Business Services</option>\n';
	wpReqHtml += '						<option>Charitable Organizations</option>\n';
	wpReqHtml += '						<option>Chemicals</option>\n';
	wpReqHtml += '						<option>Computer Hardware</option>\n';
	wpReqHtml += '						<option>Computer Services</option>\n';
	wpReqHtml += '						<option>Computer Software</option>\n';
	wpReqHtml += '						<option>Construction</option>\n';
	wpReqHtml += '						<option>Consumer Products Manufacturers</option>\n';
	wpReqHtml += '						<option>Consumer Services</option>\n';
	wpReqHtml += '						<option>Cultural Institutions</option>\n';
	wpReqHtml += '						<option>Education</option>\n';
	wpReqHtml += '						<option>Electronics</option>\n';
	wpReqHtml += '						<option>Energy & Utilities</option>\n';
	wpReqHtml += '						<option>Environmental Svcs & Equipment</option>\n';
	wpReqHtml += '						<option>Financial Services</option>\n';
	wpReqHtml += '						<option>Food</option>\n';
	wpReqHtml += '						<option>Government</option>\n';
	wpReqHtml += '						<option>Health Care</option>\n';
	wpReqHtml += '						<option>Industrial Manufacturing</option>\n';
	wpReqHtml += '						<option>Insurance</option>\n';
	wpReqHtml += '						<option>Leisure</option>\n';
	wpReqHtml += '						<option>Media</option>\n';
	wpReqHtml += '						<option>Metals & Mining</option>\n';
	wpReqHtml += '						<option>Pharmaceuticals</option>\n';
	wpReqHtml += '						<option>Real Estate</option>\n';
	wpReqHtml += '						<option>Retail</option>\n';
	wpReqHtml += '						<option>Security Products & Services</option>\n';
	wpReqHtml += '						<option>Telecommunications Equipment</option>\n';
	wpReqHtml += '						<option>Telecommunications Services</option>\n';
	wpReqHtml += '						<option>Transportation Services</option>\n';
	wpReqHtml += '						<option>Other</option>\n';
	wpReqHtml += '					</select></td>\n';
	wpReqHtml += '				</tr>\n';
	wpReqHtml += '				<tr>\n';
	wpReqHtml += '					<td>Email Address:</td>\n';
	wpReqHtml += '					<td colspan="3"><input type="text" name="wpEmail" id="wpEmail" value="" maxlength="50" style="width:180px;"/></td>\n';
	wpReqHtml += '				</tr>\n';
	wpReqHtml += '				<tr>\n';
	wpReqHtml += '					<td>Phone Number:</td>\n';
	wpReqHtml += '					<td colspan="3"><input type="text" name="wpPhone" id="wpPhone" value="" maxlength="24" style="width:120px;"/></td>\n';
	wpReqHtml += '				</tr>\n';
	wpReqHtml += '				</table>\n';
	wpReqHtml += '			</p>\n';
	wpReqHtml += '			</form>\n';
	wpReqHtml += '			<p style="text-align:center;" id="wpSubmit"> \n';
	wpReqHtml += '				<input type="button" name="submit" value="SUBMIT" onclick="submitForm(\'wp\');" class="button btnbold"/>\n';
	wpReqHtml += '				<input type="button" name="cancel" value="CANCEL" onclick="closebox(\'wp\');" class="button"/>\n';
	wpReqHtml += '			</p>\n';
	wpReqHtml += '			</div>\n';
	var vpReqHtml = '';
	vpReqHtml += '		<div id="vbox" style="display:none;">\n';
	vpReqHtml += '			<div id="vclose">\n';
	vpReqHtml += '				<a href="javascript:closebox(\'vp\');"><img src="images/circlex-close.png" border="0" alt="close"/></a>\n';
	vpReqHtml += '			</div>\n';
	vpReqHtml += '			<div id="vboxtitle"></div>\n';
	vpReqHtml += '			<div style="position:relative; width:736px;height:511px;margin-top:10px;" id="playerBlock"></div>\n';

	var docbody;
	docbody = document.getElementsByTagName("body")[0];
	if(!docbody){
		docbody = document.getElementsByTagName("body").item(0);
	}
	if(!document.getElementById("datahole")){
		var datahole = document.createElement("IFRAME");
		datahole.setAttribute("id", "datahole");
		datahole.setAttribute("name", "datahole");
		datahole.setAttribute("src", "about:blank");
		datahole.setAttribute("border", "0");
		datahole.setAttribute("frameborder", "0");
		datahole.setAttribute("scrolling", "no");
		datahole.setAttribute("width", "0");
		datahole.setAttribute("height", "0");
		if(datahole && docbody){
			docbody.appendChild(datahole);		
		}
	}
	var filter = document.createElement("DIV");
	filter.setAttribute("id", "filter");
	if(filter && docbody){
		docbody.appendChild(filter);
	}
	var dfReq = document.createElement("DIV");
	dfReq.setAttribute("id", "popout");
	if(dfReq && docbody){
		docbody.appendChild(dfReq);
		dfReq.innerHTML = dfReqHtml;
	}
	var wpReq = document.createElement("DIV");
	wpReq.setAttribute("id", "wpRequest");
	if(wpReq && docbody){
		docbody.appendChild(wpReq);
		wpReq.innerHTML = wpReqHtml;
	}
	var vpReq = document.createElement("DIV");
	vpReq.setAttribute("id", "vout");
	if(vpReq && docbody){
		docbody.appendChild(vpReq);
		vpReq.innerHTML = vpReqHtml;
	}
}