<!--

//Video HTML5 support test

// returns true if string contains any of the strings in strings_to_find
function string_contains_one_of (string, strings_to_find) {
  for (var i=0; i < strings_to_find.length; i++) {
    if (string.indexOf(strings_to_find[i]) != -1) {
      return true;
    }
  }
  return false;
}

// returns true if the browser can play h264 in a <video> tag
function browser_supports_html5_h264() {
  var user_agent = navigator.userAgent.toLowerCase()
  return string_contains_one_of (user_agent, 
                                 ["iphone", "ipod", "ipad"]);   
}

// replaces the contents of player_div_id with the contents 
// of html5_player_div_id if the browser supports playing h264 in 
// an HTML5 <video> tag
function use_html5_player_if_supported (player_div_id, html5_player_div_id) {
  if (browser_supports_html5_h264()) {
    document.getElementById(player_div_id).innerHTML = document.getElementById(html5_player_div_id).innerHTML;
  }
}

// Welcome Ad Trigger

function callWelcomeAd(size) {

  if (size==null || size=="" || size.indexOf('x')==-1)	{
    size = "600x600";
  }
  var awidth = size.slice(0,size.indexOf('x'));
  var aheight = size.slice(size.indexOf('x')+1);
  if (isNaN(Number(awidth))) {
    awidth = 600;
  }
  if (isNaN(Number(aheight))) {
    aheight = 600;
  }

  if ((document.cookie.indexOf('interstitial=welcome')==-1) &&
  /*(navigator.userAgent.indexOf("IE")>-1) &&*/
  (this.location.host.indexOf("inc.com")!=-1) &&
  (this.location.pathname.indexOf("5000")==-1) &&
  (this.location.pathname.indexOf("apply")==-1) &&
  (this.location.pathname.indexOf("inc500_app")==-1) &&
  (this.location.search.indexOf("partner")==-1) &&
  (this.location.search.indexOf('nowelcome')==-1)) {

    var tomorrow = new Date();
  	// 96 = 4 days -- change this value to configure how often users should see the ad
    //  var nowPlus =  tomorrow.getTime() + (96*60*60*1000);
    var nowPlus =  tomorrow.getTime() + (48*60*60*1000);
    tomorrow.setTime(nowPlus);

	var currentloc=this.location.href;
    document.cookie = 'interstitial=welcome; path=/; domain=.inc.com; expires=' + tomorrow.toGMTString();

    if (document.cookie.indexOf('interstitial=welcome')!=-1){
		  this.location.href='http://www.inc.com/welcome.html?aw='+awidth+'&ah='+aheight+'&destination='+ currentloc;
    }
  }
}


// Div toggle

function toggle( targetId ){
  if (document.getElementById){
  target = document.getElementById( targetId );
  if (target.style.display == "none"){
  target.style.display = "";
  } else {
  target.style.display = "none";
  }
  }
}


function showBucketPromo() {
document.write('<div id="BucketPromo">');
document.write('<h2>Special Sections</h2>');
document.write('<div class="content_box2"><img src="http://images.inc.com/special/mobility/mobility.jpg" alt="" width="50" height="50" class="img_left" />');
document.write('<p class="nopad"><span class="orange_link"><a href="http://www.inc.com/mobility-tips/index.html/"> Mobility Tips and Tricks </a></span><br /><span class="smallest">Sponsored by Toshiba</span></p>');
document.write('<ul class="arrow_list3_float">');
document.write('<li><a href="http://www.inc.com/mobility-tips/index.html/">Your guide to the latest mobile computing trends, data protection and technology savings. </a></li>');
document.write('</ul>');
document.write('</div>');
document.write('<div class="content_box2"><img src="http://images.inc.com/special/pr/20070413.gif" alt="" width="50" height="50" class="img_left" />');
document.write('<p class="nopad"><span class="orange_link"><a href="http://www.inc.com/partners/prnewswire/">PR Toolkit</a></span><br /><span class="smallest">Sponsored by <strong>PR Newswire</strong></span></p>');
document.write('<p><a href="http://www.inc.com/partners/prnewswire/" style="font-weight: normal;">Distribute a press release with PR Newswire &amp; promote your business</a></p>');
document.write('</div>');
document.write('<div class="content_box2"><img src="http://images.inc.com/special/careerbuilder/careerbuilder.gif" alt="" width="50" height="50" class="img_left" />');
document.write('<p class="nopad"><span class="orange_link"><a href="http://www.careerbuilder.com/jobposter/?lr=cbinc&siteid=inc00">Hiring Guide</a></span><br /><span class="smallest">Content from CareerBuilder in partnership with Inc.com</span></p>');
document.write('<ul class="arrow_list3_float">');
document.write('<li><a href="http://www.careerbuilder.com/jobposter/?lr=cbinc&siteid=inc01">Stop rolling the dice when you need to hire</a></li>');
document.write('<li><a href="http://www.careerbuilder.com/jobposter/small-business/best-practices.aspx?lr=cbinc&siteid=inc02">Advice and best practices for your business</a></li>');
document.write('<li><a href="http://www.careerbuilder.com/jobposter/small-business/page.aspx?pagever=SMB_Prod&lr=cbinc&siteid=inc03">Hiring products to help you find employees</a></li>');
document.write('<li><a href="http://www.careerbuilder.com/jobposter/events/webinar/?lr=cbinc&siteid=inc04">Free webinars and recruitment training</a></li>');
document.write('</ul>');
document.write('</div>');
document.write('</div>');
}




// random sub offers
function incSubOfferLink(text) {
    var links = new Array("http://trax.inc.com/k/w/sub/jun06pricetest/10",
                          "http://trax.inc.com/k/w/sub/jun06pricetest/997",
                          "http://trax.inc.com/k/w/sub/jun06pricetest/1097",
                          "http://trax.inc.com/k/w/sub/jun06pricetest/11");
	var rand = Math.floor(Math.random() * links.length);
        document.write("<a href='" + links[rand] + "' target='_blank'>" + text + "</a>");
}
function incSubOfferFormLink() {
	var flinks = new Array("https://w1.buysub.com/servlet/ConvertibleGateway?cds_mag_code=QMV&cds_page_id=83935&cds_response_key=I0JEIH01",
						   "https://w1.buysub.com/servlet/ConvertibleGateway?cds_mag_code=QMV&cds_page_id=83935&cds_response_key=I0JEIH01",
                     	   "https://w1.buysub.com/servlet/ConvertibleGateway?cds_mag_code=QMV&cds_page_id=83935&cds_response_key=I0JEIH01",
                     	   "https://w1.buysub.com/servlet/ConvertibleGateway?cds_mag_code=QMV&cds_page_id=83935&cds_response_key=I0JEIH01");
	var rand = Math.floor(Math.random() * flinks.length);
	return flinks[rand];
}
function incWriteFormAction() {
	var formLink = incSubOfferFormLink();
	document.write('<form action="' + formLink + '" method="post">');
}

// Tab Nav Hover

<!--//--><![CDATA[//><!--

sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

//--><!]]>




<!-- Most Popular/Most Emailed box -->
function selecttab(tabName){

	if(tabName=="pop"){
		document.getElementById('pop').style.background="url('http://images.inc.com/redesign/mostpoptab_on.gif')";
		document.getElementById('pop').style.borderBottom="0";
		document.getElementById('emailTab').style.background="url('http://images.inc.com/redesign/mostemailtab_off.gif')";
		document.getElementById('popContent').style.display="";
		document.getElementById('emailContent').style.display="none";
	}else if (tabName=="email"){
		document.getElementById('emailTab').style.background="url('http://images.inc.com/redesign/mostemailtab_on.gif')";
		document.getElementById('emailTab').style.borderBottom="0";
		document.getElementById('pop').style.background="url('http://images.inc.com/redesign/mostpoptab_off.gif')";
		document.getElementById('emailContent').style.display="";
		document.getElementById('popContent').style.display="none";
	}

	}


function getCookie(Name) {
var search = Name + "="
if (document.cookie.length > 0) { // if there are any cookies
offset = document.cookie.indexOf(search) 
if (offset != -1) { // if cookie exists 
offset += search.length 
// set index of beginning of value
end = document.cookie.indexOf(";", offset) 
// set index of end of cookie value
if (end == -1) 
end = document.cookie.length
return unescape(document.cookie.substring(offset, end))
} 
}
}


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;
}



<!-- Quickbooks Rollover -->

function quickbox(){
	document.getElementById("quickbox").style.display="block";
}

function quickHide(){
	document.getElementById("quickbox").style.display="none";
}


<!-- Sets cookie that expires every night at midnight -->
function cookie_24(cookieName,cookieValue) {
var now = new Date();

month=now.getMonth();
day=now.getDate();
year=now.getFullYear();

var expireNow = new Date(year, month, day, 23, 59);

document.cookie = cookieName + "=" + cookieValue + "; expires=" + expireNow.toGMTString() + "; path=/;"
}




/* New Welcome/Interstitial Ad Code*/

$(document).ready(function () {
  	var doc_width = document.body.clientWidth + "px";
	var doc_height = document.body.clientHeight + "px";

	$(".bgCover").css({
		width: doc_width,
		height: doc_height
	});
});

var overlayAdOpen = new Boolean();
var triggerAd = false;
var fadeSpeed = "slow";

function overlay_ad(){
		// Check to see if cookie exists/url is a partner page
		var cookieExists = readCookie('interstitial');
		var current_url =  this.location.href;
		var partner_page = current_url.indexOf("?partner=");

		// If cookie exists/it's a partner page, do nothing; otherwise set cookie and show welcome ad
		if(partner_page>0){
			return;
		}else if(cookieExists){
			return;
		}else{
			var tomorrow = new Date();
			// Modify values below to set date range for cookie expiration
		    var nowPlus =  tomorrow.getTime() + (6*60*60*1000);
		    tomorrow.setTime(nowPlus);

			var currentloc=this.location.href;
		    document.cookie = 'interstitial=welcomead; path=/; domain=.inc.com; expires=' + tomorrow.toGMTString();

			triggerAd = true;
		}

		if(triggerAd){
		overlayAdOpen = false; // Set the overlay box state

		// Write iFrame with Ad Code
		var build_ad = "<div class='bgCover'></div><div class='overlayBox'><p class='countdown' style=\"vertical-align: middle;\"> Your page in <span id='sec_count'>15</span> seconds. <a class='closeLink'><img src=\"http://images.inc.com/welcome/skip-this.gif\" border=\"0\" style=\"vertical-align: middle;\" /></a></p><p align='center' class='adv'> ADVERTISEMENT<br><iframe id='ad_frame' name='ad_frame' src='http://www.inc.com/welcome/ad_code.html' scrolling='no' frameborder='0'><\/iframe></p></div>";
		$("#interstitial_ad").html(build_ad);

		$(".bgCover").css({opacity:0.8}); // Redefine opacity for non CSS3 browsers
		$("a.closeLink").click(hideAdOverlay); // Set close ad overlay event
		$(".bgCover").click(hideAdOverlay); // Set close ad overlay event

		// if window is resized then reposition the overlay and ad box
		$(window).bind("resize", positionAdOverlay);

		//showAdOverlay();
		setTimeout(showAdOverlay,1000);
	}
}



function positionAdOverlay() {
	if( (overlayAdOpen == false) || (triggerAd == false) ) return;

	var adBoxLeft_raw = ( $(window).width() - $(".overlayBox").width() )/2;
	var adBoxTop_raw = ( $(window).height() - $(".overlayBox").height() )/2;

	if(adBoxTop_raw < 0){
		adBoxTop_raw = 15;
	}

	var adBoxLeft = adBoxLeft_raw + 'px';
	var adBoxTop = adBoxTop_raw + 'px';

	if ($.browser.msie && $.browser.version <= 6 ){
		$(".overlayBox").css({
			left: adBoxLeft,
			top: adBoxTop,
			position: "absolute"
		});

		window.setInterval(function() {
			var adBoxTop_adjusted = (document.documentElement.scrollTop + adBoxTop_raw) + 'px';
			$(".overlayBox").css({
				top: adBoxTop_adjusted
			});
		}, 100);
	}else{
		$(".overlayBox").css({
		left: adBoxLeft,
		top: adBoxTop,
		position: "fixed"
		});
	}


	var doc_width = document.body.clientWidth + "px";
	var doc_height = document.body.clientHeight + "px";

	$(".bgCover").css({
		width: doc_width,
		height: doc_height
	});

	$(".overlayBox").css({
		visibility: "visible"
	});

}

function showAdOverlay() {

	overlayAdOpen = true;

	//positionAdOverlay();
	setTimeout(positionAdOverlay,1000);

	$(".bgCover").fadeIn(fadeSpeed, countdown());

	$("#leaderboard_ad").hide();
	$("#add_336_top").hide();

}

function hideAdOverlay() {
	triggerAd = false;

	// Fade out the background
	$(".bgCover").fadeOut(fadeSpeed);

	$(".overlayBox").css({
		visibility:"hidden"
	});

	$("#leaderboard_ad").show();
	$("#add_336_top").show();

}

//var target = new Date();
//var target_time = Date.parse(target)/1000;
var counter = 16;
// Display 15 second countdown, then redirects
function countdown(){
	//var current = new Date();
	//current_time = Date.parse(current)/1000;

	var x = counter - 1;
	counter = x;

	$("#sec_count").html(x);

	if(x > 0){
		setTimeout(countdown, 1000);
	} else {
		hideAdOverlay();
	}
}

