// highlight current page on navbar
function init_navbar(section,page) {
	document.getElementById(page).style.fontWeight = "bold";
	document.getElementById(page).removeAttribute("href");
	document.getElementById(page).style.color = "#000";
	if(section=='Industries') {
		document.getElementById('industry').style.fontWeight = "bold";
	}
}

function clearText(thefield) {
	if (thefield.defaultValue==thefield.value)
		thefield.value = "";
}

function launch_popup(file,width,height,scrollbars) {
	window.open(file,'name','width='+width+',height='+height+',top=50,left=50,scrollbars='+scrollbars+',resizable=1,status=0,location=0,toolbar=0,menubar=0');
}

function validate_email(email) {
	var regExpObj = /^([a-zA-Z0-9_\+\-\.\']+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/  //'
	return email.value.search(regExpObj) == 0;
	//if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email.value))) {
	//	email.focus();
	//	return false;
	//}
}

function validate_newsletter(form) {
	if (validate_email(form.email) == false) {
		alert("Please enter a valid email address.");
		return false;
	} else {
		return true;
	}
}

function validate_newsletter_2(form) 
{ // version with newsletter type checkboxes
	if (validate_email(form.email) == false) 
	{
		alert("Please enter a valid email address.");
		return false;
	} 
	else if (!document.getElementById("newsletter_type_sales").checked && !document.getElementById("newsletter_type_recruiting").checked)
	{
		alert("Please select at least one version of our newsletter.\n");
		return false;
	} 
	else 
	{
		return true;
	}
}

// fns for sliding vignettes
var right_speed = 5;	// higher = slower tween
var left_speed = 8;		// higher = slower tween
var img_path = "/About/i/vignettes/";
var vignette_num = 1;	// for flip_vignette()
var the_timeout,goal_top,halfway;
var rnd_vig = Math.round(Math.random() * 5) + 1;  // for random vignette corners at top
vig_captions = new Array("",
						"Sadly, it was almost lunchtime before the keynote speaker realized it was a <i>software</i> anti-piracy conference.",
						"Frank's Database Software Stand (an idea that his wife was totally against from the start) wasn't reaching the right market segments or customers.",
						"&ldquo;Maybe I was rash in deciding how to exercise my stock...&rdquo;",
						"&ldquo;Um... I think Jim may not have been totally forthcoming in his resume.&rdquo;",
						"Upon meeting the headhunter, Jane was suddenly doubtful that he could help her find a job.",
						"Have an idea for an &quot;I wish I knew my stuff&quot; moment?");
vig_explan = new Array("",
						"Use ZoomInfo to research the audience and <a href=\"/search/CompanyQuery.aspx?companyDesc=anti%20piracy\">industry</a> <i>before</i> speaking at any conference or business meeting.",
						"Unless you're selling hot dogs or pretzels, use ZoomInfo to target the right <a href=\"/search/CompanyQuery.aspx?companyDesc=software\">markets</a>, companies and people.",
						"Use ZoomInfo for in-depth <a href=\"/search/CompanyDetail.aspx?CompanyID=24904409&cs=QEBfALZyA\">company</a> research before making any business decisions.",
						"Use ZoomInfo for comprehensive, accurate and objective information on <a href=\"http:/"+"/www.zoominfo.com/jameswolfenstein\">job candidates</a>.",
						"Use ZoomInfo to <a href=\"/search/PersonQuery.aspx?companyDesc=&personTitle=recruiter\">research people</a> before using their services.",
						"Submit it to <a href=\"mailto:knowyourstuff@zoominfo.com\">knowyourstuff@zoominfo.com</a> - and we'll consider adding it here!");
function get_height() {
	var div_height = document.getElementById('div2').offsetHeight;
	goal_top = div_height * -1;	// position (px) where to stop
	halfway = goal_top / 2;		// where to change tween fading
}
function init_vignettes() {	// make vigs visible only on compatible browsers
	if (document.getElementById && document.getElementById("div1")) {
		document.getElementById('div3').style.visibility = "visible";
		document.getElementById('vig_cap_id').innerHTML = vig_captions[1];
		document.getElementById('vig_exp_id').innerHTML = vig_explan[1];
		document.getElementById('vig_corners').src = "/About/i/vignettes/vig_corners" + rnd_vig + ".gif";
	}
}
function slide_div(direction) {
	if(document.getElementById('dropBox')) {
		document.getElementById('dropBox').style.visibility = "hidden";
	}
	document.getElementById('div1').style.visibility = "visible";
	document.getElementById('vig_img_id').src=img_path+"vignette_ab_sm_" + vignette_num + ".jpg";
	document.getElementById('vig_corners').src = "/About/i/spacer.gif";
	var the_style = document.getElementById("div1").style;
	if (the_style) {
		var current_top = parseInt(the_style.top);  // get current coordinates
		if(direction=="in") {
			if(current_top < goal_top)
				current_top = goal_top;
			if(current_top == goal_top) // hasn't yet started moving
				var new_top = current_top + 1;
			else if(current_top <= halfway)
				var new_top = current_top + Math.ceil((current_top - goal_top) / right_speed);
			else
				var new_top = current_top - Math.ceil(current_top / right_speed);
		} else {
			var new_top = current_top + Math.floor((goal_top - current_top) / left_speed);
		}
		the_style.top = new_top + "px";
		if (new_top <= goal_top || new_top >= 0) {
			clearTimeout(the_timeout);  // we've moved too far so stop
			if(document.getElementById('dropBox')) {
				document.getElementById('dropBox').style.visibility = "visible";
			}
			if(direction=="out") {
				document.getElementById('vig_corners').src = "/About/i/vignettes/vig_corners" + rnd_vig + ".gif";
			}
		} else {
			the_timeout = setTimeout('slide_div(\'' + direction + '\');',10);
		}
	}
}
function flip_vignette(direction,size) {
	var style_back = document.getElementById("flip_back").style;
	var style_next = document.getElementById("flip_next").style;
	style_back.color="#0000cc"; style_back.pointer="cursor";
	style_next.color="#0000cc"; style_next.pointer="cursor";

	if(direction=="next" && vignette_num<6)
		vignette_num = vignette_num + 1;
	else if(direction=="next" && vignette_num==6)
		vignette_num = 1;
	else if(direction=="back" && vignette_num>1)
		vignette_num = vignette_num - 1;
	if(vignette_num==6)
		document.getElementById("flip_next").innerHTML="<b>Start over</b>";
	else
		document.getElementById("flip_next").innerHTML="<b>Next reason &raquo;</b>";
	if(vignette_num==1) {
		style_back.color="#999999";
		style_back.pointer="cursor";
	}
	if(size=="reg") {  // from page headers
		document.getElementById('vig_img_id').src = img_path + "vignette_ab_sm_" + vignette_num + ".jpg";
		document.getElementById('vig_href1_id').href = "/About/vignettes/zoom_vignette.aspx?t=f&n=" + vignette_num;	//photo
		document.getElementById('vig_href2_id').href = "/About/vignettes/zoom_vignette.aspx?t=f&n=" + vignette_num;	//a href - forward
		document.getElementById('vig_href3_id').href = "/About/vignettes/zoom_vignette.aspx?t=z&n=" + vignette_num;	//a href - zoom
	}
	document.getElementById('vig_cap_id').innerHTML = vig_captions[vignette_num];
	document.getElementById('vig_exp_id').innerHTML = vig_explan[vignette_num];
}
