/**
 * Snapshots
 */
function show_all_companies()
{
	var tbl = document.getElementById("company_snapshot_exclude");
	for(var r = 0; r < tbl.rows.length; r++)
	{
		if(tbl.rows[r].getAttribute("id") != "")
		{
			tbl.rows[r].style.display = '';
		}
	}
	
	document.getElementById("expandIndustries2").innerHTML = '<a href="javascript:hide_companies();">See fewer</a>';
	document.getElementById("expandIndustries").innerHTML = '<a href="javascript:hide_companies();">Fewer competitors</a>';
}

function hide_companies()
{
	var tbl = document.getElementById("company_snapshot_exclude");
	for(var r = tbl.rows.length -1 ; r > 0; r--)
	{
		if(tbl.rows[r].getAttribute("id") != "" && tbl.rows[r].getAttribute("id") != null)
		{
			tbl.rows[r].style.display = 'none';
		}
	}
	
	document.getElementById("expandIndustries2").innerHTML = '<a href="javascript:show_all_companies();">See all</a>';
	document.getElementById("expandIndustries").innerHTML = '<a href="javascript:show_all_companies();">More competitors</a>';
}

/**
 * States and Cities
 */
function showNavTab(tabId,tabNo) {
	var tabCollection = document.getElementById(tabId);
	tabCollection.className='Tab'+tabNo+'Visible';
}


/* FOR VIDEO TOUTS */
function writeWidgetBoxVideo(numFrames,currShow,fade, restart_interval) 
{
	if(typeof(restart_interval) == "undefined")
	{
		var restart_interval = false;
	}
	
	for (var i=1; i<=numFrames; i++) {
		document.getElementById('tnVideo'+i).style.visibility = "hidden";
		document.getElementById('tnVideo'+i).style.display = "none";
		if (i==currShow) {
			document.getElementById('tnVideo'+i).style.visibility = "visible";
			document.getElementById('tnVideo'+i).style.display = "block";
		}
	}
	//if (fade==true) {shiftOpacity('tncontainerVideo', 500);}
	var sequenceInd = document.getElementById('widgetSeqNumsVideo');
	sequenceInd.innerHTML = '';
	sequenceInd.innerHTML = '\(' + currShow + ' of ' + numFrames + '\)';
	var fade = true;
	

	if(restart_interval == true)
	{
		cnnRotateWidgetBoxVideo.restart(currShow);
	}
	
}
function rotateMeVideo(total,curr) {
	var newRotate = curr+1;
	if ( newRotate > total ) { newRotate = 1; }
	writeWidgetBoxVideo(total,newRotate,true);
	setTimeout("rotateMeVideo("+total+","+newRotate+")",7000);
}


/**
 * Image rotate object
 */
var cnnRotateWidgetBoxVideo = {
	window_interval:null,
	total_frames:1,
	current_frame:1,
	
	init:function(total_frames, current_frame)
	{
		this.total_frames = total_frames;
		this.current_frame = current_frame;
	},
	restart:function(current_frame)
	{
		this.current_frame = current_frame;
		this.stop();
		this.start();
	},
	rotate:function()
	{
		this.current_frame++;
		if(this.current_frame > this.total_frames)
		{
			this.current_frame = 1;
		}
		writeWidgetBoxVideo(this.total_frames, this.current_frame, true, false);
	},
	start:function(total_frames, current_frame)
	{
		this.window_interval = window.setInterval('cnnRotateWidgetBoxVideo.rotate()', 7000);
	},
	stop:function()
	{
		if(this.window_interval != null)
		{
			window.clearInterval(this.window_interval);
			this.window_interval = null;
		}
	}
};
/* FOR GALLERY TOUTS ON SNAPSHOTS */
function writeWidgetBox(numFrames,currShow,fade) {
	for (var i=1; i<=numFrames; i++) {
		document.getElementById('tn'+i).style.visibility = "hidden";
		document.getElementById('tn'+i).style.display = "none";
		if (i==currShow) {
			document.getElementById('tn'+i).style.visibility = "visible";
			document.getElementById('tn'+i).style.display = "block";
		}
	}
	//if (fade==true) {shiftOpacity('tncontainer', 500);}
	var sequenceInd = document.getElementById('widgetSeqNums');
	sequenceInd.innerHTML = '';
	sequenceInd.innerHTML = '\(' + currShow + ' of ' + numFrames + '\)';
	var fade = true;
}
function shiftOpacity(id, millisec) {
	document.getElementById(id).style.opacity = 0
	opacity(id, 0, 100, millisec);
}
function opacity(id, opacStart, opacEnd, millisec) {
	var speed = Math.round(millisec / 100);
	var timer = 0;
	for(i = opacStart; i <= opacEnd; i++) {
		setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
		timer++;
	}
}
function changeOpac(opacity, id) {
	var object = document.getElementById(id).style;
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}
function rotateMe(total,curr) {
	var newRotate = curr+1;
	if ( newRotate > total ) { newRotate = 1; }
	writeWidgetBox(total,newRotate,true);
	setTimeout("rotateMe("+total+","+newRotate+")",7000);
}