function swapImages(id,nav,action,image)
{
	switch (nav)
	{
		case "home":
		case "admin":
		case "other":
			if (action == "over")
				document.getElementById(id).src="/images/menu/"+image+"_ov.png";
			else
				document.getElementById(id).src="/images/menu/"+image+".png";
			break;
			
		/*case "other":
			//alert(image);
			if (action == "over") 
			{
				if (image == "portfolio_inactive")
					image = "portfolio_inert";
				if (image == "insight_inactive")
					image = "insight_inert";
				if (image == "people_inactive")
					image = "people_inert";
				document.getElementById(id).src="/images/menu/"+image+"_ov.png";
			}
			else
			{
				if (image == "portfolio_inert")
					image = "portfolio_inactive";
				if (image == "insight_inert")
					image = "insight_inactive";
				if (image == "people_inert")
					image = "people_inactive";
				document.getElementById(id).src="/images/menu/"+image+".png";
			}
				
			break;*/
			
		case "people":
			if (action == "over")
			{
				if (image == "portfolio_inactive")
					image = "portfolio_inert";
				if (image == "insight_inactive")
					image = "insight_inert";
				document.getElementById(id).src="/images/menu/"+image+"_ov.png";
			}
			else
			{
				if (image == "portfolio_inert")
					image = "portfolio_inactive";
				if (image == "insight_inert")
					image = "insight_inactive";
				if (image == "people_inert")
					image = "people_active";
				document.getElementById(id).src="/images/menu/"+image+".png";
			}
			break;
			
		case "insight":
			if (action == "over")
			{
				if (image == "portfolio_inactive")
					image = "portfolio_inert";
				if (image == "people_inactive")
					image = "people_inert";
				document.getElementById(id).src="/images/menu/"+image+"_ov.png";
			}
			else
			{
				if (image == "portfolio_inert")
					image = "portfolio_inactive";
				if (image == "people_inert")
					image = "people_inactive";
				if (image == "insight_inert")
					image = "insight_active";
				document.getElementById(id).src="/images/menu/"+image+".png";
			}
			break;
		case "portfolio":
			if (action == "over")
			{
				if (image == "insight_inactive")
					image = "insight_inert";
				if (image == "people_inactive")
					image = "people_inert";
				document.getElementById(id).src="/images/menu/"+image+"_ov.png";
			}
			else
			{
				if (image == "insight_inert")
					image = "insight_inactive";
				if (image == "people_inert")
					image = "people_inactive";
				if (image == "portfolio_inert")
					image = "portfolio_active";
				document.getElementById(id).src="/images/menu/"+image+".png";
			}
			break;
	}
}

function showHover(id) {
	document.getElementById(id).style.display = "block";
}

function hideHover(id) {
	document.getElementById(id).style.display = "none";
}

function underlineSpan(id,action)
{
	/*alert("am i here?");
	if (action == 1)
		document.getElementById(id).style.textDecoration = "underline";
	else
		document.getElementById(id).style.textDecoration = "none";*/
}

/* FORM FUNCTIONS */
function showFormImage(id,width,height)
{
	// get the image box element
	var imageEL = document.getElementById(id);
	// set the width and height of the image box
	imageEL.style.width = width + "px";
	imageEL.style.height = height + "px";

	// show the box
	imageEL.style.display = "block";
}

function hideFormImage(id)
{
	document.getElementById(id).style.display = "none";
}

function checkMaxChars(fieldId,num,displayId)
{
	// get the field
	var field = document.getElementById(fieldId);
	// get the current number of characters
	var curChars = field.value.length;
	// If the current characters are greater then the max
	// we need to trim the input and make it the max size
	if (curChars >= num)
	{
		field.value = field.value.substring(0, num);
		curChars = num;
	}
		
	// Lastly update the number of characters left
	var charsLeft = num - curChars;
	document.getElementById(displayId).innerHTML = charsLeft;
}

function validateForm(fields,form)
{
	var aFields = fields.split(',');
	var error = "";
	var fieldEl = "";
	
	if(fields != '')	//Because split on an empty string still produces an array with 1 entry, under IE.
	{
		for (i = 0; i < aFields.length; i++)
		{
			fieldEl = document.getElementById(aFields[i]);
			if (fieldEl.type == "select-one")
			{
				if (fieldEl[fieldEl.selectedIndex].value == "NULL")
				{
					error += "You must select a " + fieldEl.title + ".\n\r";
				}
			}
			else 
			{
				if (fieldEl.value == '')
				{
					if (fieldEl.type == "file")
					{
						error += "You must select a " + fieldEl.title + " to upload.\n\r";
					}
					else
					{
						error += "You must fill in the " + fieldEl.title + " field.\n\r";
					}
				}
			}
		}
	}
	
	if (error != "")
	{
		alert(error);
		return false;
	}
	else
	{
		//alert ('Am i here');
		document.getElementById(form).submit();
		return true;
	}
}

function pop_up_links(path, width, height, location)
{
	var width = (width == null) ? 0 : width;
	var height = (height == null) ? 0 : height;
	var location = (location == null) ? 0 : 1;
	
	var extra = "";
	if (width != 0)
	{
		extra += "width="+width;
	}
	if (height != 0)
	{
		extra += ", height="+height;
	}
	if (location != 0)
	{
		extra += ", location=1";
	}
	
	//alert('Extra Info: '+extra)
	
	new_window = window.open(path,"",extra)
}

// Default states
var currentTab = "clients";
function tabHoverKEEP(tab,hover)
{
	if (hover == '1')
	{
		if (tab == 'portfolio_tab_products' && currentTab == 'clients')
		{
			document.getElementById('portfolio_tabs').style.backgroundImage = "url('../images/shell/tabs/portfolio_products_ov.png')";
		}
		else if (tab == 'portfolio_tab_clients' && currentTab == 'products')
		{
			document.getElementById('portfolio_tabs').style.backgroundImage = "url('../images/shell/tabs/portfolio_client_ov.png')";
		}
	}
	else
	{
		if (currentTab == 'clients')
		{
			document.getElementById('portfolio_tabs').style.backgroundImage = "url('../images/shell/tabs/portfolio_client.png')";
		}
		else
		{
			document.getElementById('portfolio_tabs').style.backgroundImage = "url('../images/shell/tabs/portfolio_products.png')";
		}
	}
}


// Default states
var currentTab = "clients";
function tabHover(tab,hover)
{
	if (hover == '1')
	{
		if (tab == 'portfolio_tab_products' && currentTab == 'clients')
		{
			document.getElementById('portfolio_tab_clients').style.backgroundImage = "url('../images/shell/tabs/portfolio_tabs_selected.png')";
			document.getElementById('portfolio_tab_products').style.backgroundImage = "url('../images/shell/tabs/portfolio_tabs_hi.png')";
			document.getElementById('portfolio_tab_services').style.backgroundImage = "url('../images/shell/tabs/portfolio_tabs_norm.png')";
		}
		else if (tab == 'portfolio_tab_products' && currentTab == 'services')
		{
			document.getElementById('portfolio_tab_clients').style.backgroundImage = "url('../images/shell/tabs/portfolio_tabs_norm.png')";
			document.getElementById('portfolio_tab_products').style.backgroundImage = "url('../images/shell/tabs/portfolio_tabs_hi.png')";
			document.getElementById('portfolio_tab_services').style.backgroundImage = "url('../images/shell/tabs/portfolio_tabs_selected.png')";
		}
		else if (tab == 'portfolio_tab_clients' && currentTab == 'products')
		{
			document.getElementById('portfolio_tab_clients').style.backgroundImage = "url('../images/shell/tabs/portfolio_tabs_hi.png')";
			document.getElementById('portfolio_tab_products').style.backgroundImage = "url('../images/shell/tabs/portfolio_tabs_selected.png')";
			document.getElementById('portfolio_tab_services').style.backgroundImage = "url('../images/shell/tabs/portfolio_tabs_norm.png')";
		}
		else if (tab == 'portfolio_tab_clients' && currentTab == 'services')
		{
			document.getElementById('portfolio_tab_clients').style.backgroundImage = "url('../images/shell/tabs/portfolio_tabs_hi.png')";
			document.getElementById('portfolio_tab_products').style.backgroundImage = "url('../images/shell/tabs/portfolio_tabs_norm.png')";
			document.getElementById('portfolio_tab_services').style.backgroundImage = "url('../images/shell/tabs/portfolio_tabs_selected.png')";
		}
		else if (tab == 'portfolio_tab_services' && currentTab == 'clients')
		{
			document.getElementById('portfolio_tab_clients').style.backgroundImage = "url('../images/shell/tabs/portfolio_tabs_selected.png')";
			document.getElementById('portfolio_tab_products').style.backgroundImage = "url('../images/shell/tabs/portfolio_tabs_norm.png')";
			document.getElementById('portfolio_tab_services').style.backgroundImage = "url('../images/shell/tabs/portfolio_tabs_hi.png')";
		}
		else if (tab == 'portfolio_tab_services' && currentTab == 'products')
		{
			document.getElementById('portfolio_tab_clients').style.backgroundImage = "url('../images/shell/tabs/portfolio_tabs_norm.png')";
			document.getElementById('portfolio_tab_products').style.backgroundImage = "url('../images/shell/tabs/portfolio_tabs_selected.png')";
			document.getElementById('portfolio_tab_services').style.backgroundImage = "url('../images/shell/tabs/portfolio_tabs_hi.png')";
		}
	}
	if (hover == '0')
	{
		if (tab == 'portfolio_tab_products' && currentTab == 'clients')
		{
			document.getElementById('portfolio_tab_clients').style.backgroundImage = "url('../images/shell/tabs/portfolio_tabs_selected.png')";
			document.getElementById('portfolio_tab_products').style.backgroundImage = "url('../images/shell/tabs/portfolio_tabs_norm.png')";
			document.getElementById('portfolio_tab_services').style.backgroundImage = "url('../images/shell/tabs/portfolio_tabs_norm.png')";
		}
		else if (tab == 'portfolio_tab_products' && currentTab == 'services')
		{
			document.getElementById('portfolio_tab_clients').style.backgroundImage = "url('../images/shell/tabs/portfolio_tabs_norm.png')";
			document.getElementById('portfolio_tab_products').style.backgroundImage = "url('../images/shell/tabs/portfolio_tabs_norm.png')";
			document.getElementById('portfolio_tab_services').style.backgroundImage = "url('../images/shell/tabs/portfolio_tabs_selected.png')";
		}
		else if (tab == 'portfolio_tab_clients' && currentTab == 'products')
		{
			document.getElementById('portfolio_tab_clients').style.backgroundImage = "url('../images/shell/tabs/portfolio_tabs_norm.png')";
			document.getElementById('portfolio_tab_products').style.backgroundImage = "url('../images/shell/tabs/portfolio_tabs_selected.png')";
			document.getElementById('portfolio_tab_services').style.backgroundImage = "url('../images/shell/tabs/portfolio_tabs_norm.png')";
		}
		else if (tab == 'portfolio_tab_clients' && currentTab == 'services')
		{
			document.getElementById('portfolio_tab_clients').style.backgroundImage = "url('../images/shell/tabs/portfolio_tabs_norm.png')";
			document.getElementById('portfolio_tab_products').style.backgroundImage = "url('../images/shell/tabs/portfolio_tabs_norm.png')";
			document.getElementById('portfolio_tab_services').style.backgroundImage = "url('../images/shell/tabs/portfolio_tabs_selected.png')";
		}
		else if (tab == 'portfolio_tab_services' && currentTab == 'clients')
		{
			document.getElementById('portfolio_tab_clients').style.backgroundImage = "url('../images/shell/tabs/portfolio_tabs_selected.png')";
			document.getElementById('portfolio_tab_products').style.backgroundImage = "url('../images/shell/tabs/portfolio_tabs_norm.png')";
			document.getElementById('portfolio_tab_services').style.backgroundImage = "url('../images/shell/tabs/portfolio_tabs_norm.png')";
		}
		else if (tab == 'portfolio_tab_services' && currentTab == 'products')
		{
			document.getElementById('portfolio_tab_clients').style.backgroundImage = "url('../images/shell/tabs/portfolio_tabs_norm.png')";
			document.getElementById('portfolio_tab_products').style.backgroundImage = "url('../images/shell/tabs/portfolio_tabs_selected.png')";
			document.getElementById('portfolio_tab_services').style.backgroundImage = "url('../images/shell/tabs/portfolio_tabs_norm.png')";
		}
	}
	
}

function swapTabKEEP(tab)
{
	currentTab = tab;
	
	if (tab == 'clients')
	{
		// Display the client div
		document.getElementById('portfolio_products_wrapper').style.display = "none";
		document.getElementById('portfolio_clients_wrapper').style.display = "block";
	}
	else
	{
		// Display the product div
		document.getElementById('portfolio_clients_wrapper').style.display = "none";
		document.getElementById('portfolio_products_wrapper').style.display = "block";
	}
	
	// swap the background image
	tabHover('','0');
}

function swapTab(tab)
{
	currentTab = tab;
	
	if (tab == 'clients')
	{
		// Display the client div
		document.getElementById('portfolio_products_wrapper').style.display = "none";
		document.getElementById('portfolio_clients_wrapper').style.display = "block";
		document.getElementById('portfolio_services_wrapper').style.display = "none";
			document.getElementById('portfolio_tab_clients').style.backgroundImage = "url('../images/shell/tabs/portfolio_tabs_selected.png')";
			document.getElementById('portfolio_tab_products').style.backgroundImage = "url('../images/shell/tabs/portfolio_tabs_norm.png')";
			document.getElementById('portfolio_tab_services').style.backgroundImage = "url('../images/shell/tabs/portfolio_tabs_norm.png')";
	}
	if (tab == 'products')
	{
		// Display the product div
		document.getElementById('portfolio_clients_wrapper').style.display = "none";
		document.getElementById('portfolio_products_wrapper').style.display = "block";
		document.getElementById('portfolio_services_wrapper').style.display = "none";
			document.getElementById('portfolio_tab_products').style.backgroundImage = "url('../images/shell/tabs/portfolio_tabs_selected.png')";
			document.getElementById('portfolio_tab_clients').style.backgroundImage = "url('../images/shell/tabs/portfolio_tabs_norm.png')";
			document.getElementById('portfolio_tab_services').style.backgroundImage = "url('../images/shell/tabs/portfolio_tabs_norm.png')";
	}
	if (tab == 'services')
	{
		// Display the product div
		document.getElementById('portfolio_clients_wrapper').style.display = "none";
		document.getElementById('portfolio_products_wrapper').style.display = "none";
		document.getElementById('portfolio_services_wrapper').style.display = "block";
			document.getElementById('portfolio_tab_services').style.backgroundImage = "url('../images/shell/tabs/portfolio_tabs_selected.png')";
			document.getElementById('portfolio_tab_products').style.backgroundImage = "url('../images/shell/tabs/portfolio_tabs_norm.png')";
			document.getElementById('portfolio_tab_clients').style.backgroundImage = "url('../images/shell/tabs/portfolio_tabs_norm.png')";
	}
	
	// swap the background image
	tabHover('','0');
}

function showHideDiv(id) {

	if (document.getElementById(id).style.display == "block")
	{
		document.getElementById(id).style.display = "none";
	}
	else
	{
		document.getElementById(id).style.display = "block";
	}
	
}

function toggleAll(){
    tmp = document.getElementsByTagName('div');
    for (i=0;i<tmp.length;i++)
	{
        if (tmp[i].className == 'client_text') tmp[i].style.display = "none";
        if (tmp[i].className == 'client_wrapper') tmp[i].style.color = "#778690";
    }
	
    tmp = document.getElementsByTagName('img');
    for (i=0;i<tmp.length;i++)
	{
        if (tmp[i].className == 'button_image_hover') tmp[i].src = "/images/buttons/plus_red.png";
        if (tmp[i].className == 'button_img') tmp[i].src = "/images/buttons/plus_orange.png";
    }
}


function showHideClientDiv(id)
{
	
	if (document.getElementById(id).style.display == "block")
	{
		toggleAll();
		//document.getElementById(id).style.display = "none";
		// change the minus sing to a plus sign
		//document.getElementById("minus_"+id).src = "/images/buttons/plus_red.png";
		//document.getElementById("plus_"+id).src = "/images/buttons/plus_orange.png";
		//document.getElementById("wrapper_"+id).style.color = "#778690";
	}
	else
	{
		toggleAll();
		document.getElementById(id).style.display = "block";
		document.getElementById("minus_"+id).src = "/images/buttons/minus_red.png";
		document.getElementById("plus_"+id).src = "/images/buttons/minus_orange.png";
		document.getElementById("wrapper_"+id).style.color = "#fd9b29";
	}
}

var portfolioClientSort = new Array();
var portfolioProductSort = new Array();
var portfolioProductSortState = new Array();
function showOnly(touse,id,checkboxId) {
	
	var found = false;
	var index = 0;
	if (touse == "client")
	{
		// alert('am I here?');
		if (document.getElementById(id).checked)
		{
			if (portfolioClientSort.length >= 1)
			{
				for (i = 0; i < portfolioClientSort.length; i++)
				{
					if (portfolioClientSort[i].indexOf(id) >= 0)
					{
						found = true;
					}
				}
			}
			
			if (!found)
				portfolioClientSort.push(id);
			
		}
		else
		{
			if (portfolioClientSort.length >= 1)
			{
				for (i = 0; i < portfolioClientSort.length; i++)
				{
					if (portfolioClientSort[i].indexOf(id) >= 0)
					{
						found = true;
						index = i;
					}
				}
			}
			
			if (found)
				portfolioClientSort.splice(index,1);
		}
		
		// Get the outer div element
		var clientWrapper = document.getElementById('client_content_wrapper');
		for (i = 0; i < clientWrapper.childNodes.length; i++)
		{
			//alert(clientWrapper.childNodes[i].nodeType);
			if (clientWrapper.childNodes[i].nodeType == 1)
			{
				// OK we have found an HTML element node. Should be the wrapping div
				// Now we want to check the ID and see if it contains what we want to show...
				// If the array is empty we will show ALL items...
				if (portfolioClientSort.length == 0)
				{
					clientWrapper.childNodes[i].style.display = "block";
				}
				else
				{
					// loop through the allowed type and if we find it display it. if not make it go away...
					show = false;
					for (p = 0; p < portfolioClientSort.length; p++)
					{
						//alert(clientWrapper.childNodes[i].getAttribute('id'));
						if (clientWrapper.childNodes[i].getAttribute('id').indexOf(portfolioClientSort[p]) >= 0)
						{
							show = true;
						}else{
							show = false;
						}
					}
					if (show)
					{
						clientWrapper.childNodes[i].style.display = "block";
					}
					else
					{
						clientWrapper.childNodes[i].style.display = "none";
					}
				}
			}
			//alert('show '+show);
		}
	}
	else if (touse == "product")
	{
		var statesList = 'state_alabama state_alaska state_american_samoa state_arizona state_arkansas state_california state_colorado state_connecticut state_delaware state_district_of_columbia state_florida state_georgia state_guam state_hawaii state_idaho state_illinois state_indiana state_iowa state_kansas state_kentucky state_louisiana state_maine state_maryland state_massachusetts state_michigan state_minnesota state_mississippi state_missouri state_montana state_nebraska state_nevada state_new_hampshire state_new_jersey state_new_mexico state_new_york state_north_carolina state_north_dakota state_northern_marianas_islands state_ohio state_oklahoma state_oregon state_pennsylvania state_puerto_rico state_rhode_island state_south_carolina state_south_dakota state_tennessee state_texas state_utah state_vermont state_virginia state_virgin_islands state_washington state_west_virginia state_wisconsin state_wyoming';
		if (document.getElementById(id).checked)
		{
			if (statesList.indexOf(id) != -1)
			{
				if (portfolioProductSortState.length >= 1)
				{
					for (i = 0; i < portfolioProductSortState.length; i++)
					{
						if (portfolioProductSortState[i].indexOf(id) >= 0)
						{
							found = true;
						}
					}
				}

				if (!found)
					portfolioProductSortState.push(id);
			}
			else
			{
				if (portfolioProductSort.length >= 1)
				{
					for (i = 0; i < portfolioProductSort.length; i++)
					{
						if (portfolioProductSort[i].indexOf(id) >= 0)
						{
							found = true;
						}
					}
				}

				if (!found)
					portfolioProductSort.push(id);
			}
			

				
			
		}
		else
		{
			if (statesList.indexOf(id) != -1)
			{
				if (portfolioProductSortState.length >= 1)
				{
					for (i = 0; i < portfolioProductSortState.length; i++)
					{
						if (portfolioProductSortState[i].indexOf(id) >= 0)
						{
							found = true;
							index = i;
						}
					}
				}

				if (found)
					portfolioProductSortState.splice(index,1);
			}
			else
			{
				if (portfolioProductSort.length >= 1)
				{
					for (i = 0; i < portfolioProductSort.length; i++)
					{
						if (portfolioProductSort[i].indexOf(id) >= 0)
						{
							found = true;
							index = i;
						}
					}
				}

				if (found)
					portfolioProductSort.splice(index,1);
			}
			
		}
		
		// Get the outer div element
		var clientWrapper = document.getElementById('portfolio_display');
		
		for (i = 0; i < clientWrapper.childNodes.length; i++)
		{
			if (clientWrapper.childNodes[i].nodeType == 1)
			{
				
				// OK we have found an HTML element node. Should be the wrapping div
				// Now we want to check the ID and see if it contains what we want to show...
				// If the array is empty we will show ALL items...
				if (portfolioProductSort.length == 0 && portfolioProductSortState.length == 0)
				{
					clientWrapper.childNodes[i].style.display = "block";
				}
				else
				{
					// loop through the allowed type and if we find it display it. if not make it go away...
					show = true;
					foundAny = false;
					pass = false;
					// we need to do a different loop depending on whats in the arrays
					if (portfolioProductSort.length >= 1 && portfolioProductSortState.length >= 1)
					{
						//alert('BOTH');
						for (p = 0; p < portfolioProductSortState.length; p++)
						{
							if (clientWrapper.childNodes[i].getAttribute('id').indexOf(portfolioProductSortState[p]) == -1)
							{
								if (foundAny == false)
								{
									show = false;
								}
								else
								{
									show = true;
								}
							}
							else
							{
								for (p = 0; p < portfolioProductSort.length; p++)
								{
									if (clientWrapper.childNodes[i].getAttribute('id').indexOf(portfolioProductSort[p]) != -1)
									{
										pass = true;
									}
								}
								
								if (pass)
								{
									foundAny = true;
									show = true;
								}
								else
								{
									show = false;
								}
								
							}
						}
						/*foundAny = false;
						for (p = 0; p < portfolioProductSort.length; p++)
						{
							if (clientWrapper.childNodes[i].getAttribute('id').indexOf(portfolioProductSort[p]) == -1)
							{
								show = false;
							}
						}*/
					}
					else if (portfolioProductSort.length >= 1 || portfolioProductSortState.length >= 1)
					{
						
						if (portfolioProductSortState.length >= 1)
						{
							//alert('STATES');
							for (p = 0; p < portfolioProductSortState.length; p++)
							{
								if (clientWrapper.childNodes[i].getAttribute('id').indexOf(portfolioProductSortState[p]) == -1)
								{
									if (foundAny == false)
									{
										show = false;
									}
									else
									{
										show = true;
									}
								}
								else
								{
									foundAny = true;
									show = true;
								}
							}
						}
						else
						{
							//alert('NO STATES');
							foundAny = false;
							for (p = 0; p < portfolioProductSort.length; p++)
							{
								if (clientWrapper.childNodes[i].getAttribute('id').indexOf(portfolioProductSort[p]) == -1)
								{
									if (foundAny == false)
									{
										show = false;
									}
									else
									{
										show = true;
									}
								}
								else
								{
									foundAny = true;
									show = true;
								}
							}
						}
					}
					
					if (show)
					{
						clientWrapper.childNodes[i].style.display = "block";
					}
					else
					{
						clientWrapper.childNodes[i].style.display = "none";
					}
				}
			}
		}
	}
	
}

function showOverlayImage()
{
	var myWidth = 0, myHeight = 0; 
	// FULL HEIGHT 	
  	if( window.innerHeight && window.scrollMaxY ) // Firefox 
  	{
		myWidth = window.innerWidth + window.scrollMaxX;
		myHeight = window.innerHeight + window.scrollMaxY;
	}
	else if( document.body.scrollHeight > document.body.offsetHeight ) // all but Explorer Mac
	{
		myWidth = document.body.scrollWidth;
		myHeight = document.body.scrollHeight;
	}
	else // works in Explorer 6 Strict, Mozilla (not FF) and Safari
	{ 
		myWidth = document.body.offsetWidth + document.body.offsetLeft; 
		myHeight = document.body.offsetHeight + document.body.offsetTop; 
	}
	// VIEWPORT HEIGHT
	if( typeof( window.innerWidth ) == 'number' ) {
    	//Non-IE
    	screenWidth = window.innerWidth;
    	screenHeight = window.innerHeight;
  	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    	//IE 6+ in 'standards compliant mode'
    	screenWidth = document.documentElement.clientWidth;
    	screenHeight = document.documentElement.clientHeight;
  	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	    //IE 4 compatible
	    screenWidth = document.body.clientWidth;
    	screenHeight = document.body.clientHeight;
  	}
  	
  	
  	//window.alert( 'Width = ' + myWidth );
  	//window.alert( 'Height = ' + myHeight );
  
	document.getElementById('overlay_box').style.height = myHeight + "px";
	document.getElementById('overlay_product_image').style.top = (window.scrollY + ((screenHeight/2)-287)) + "px";
	document.getElementById('overlay_product_image').style.left = ((screenWidth/2)-255) + "px";
	//document.getElementById('overlay_box').style.top = window.scrollY + "px";
	//document.body.scroll = "no";
	
	document.getElementById('overlay_box').style.display = "block";
	document.getElementById('overlay_product_image').style.display = "block";
}

function showAllInsight(ids)
{
	if (ids.indexOf(',') >= 0)
	{
		var id = ids.split(',');
		for (i = 0; i < id.length; i++)
		{
			document.getElementById(id[i]).style.display = "block";
		}
	}
	else
	{
		document.getElementById(ids).style.display = "block";
	}
	
}




function checkFormField(field)
{
	var error = "";
	var passed = false;
	if (document.getElementById(field).type == "text")
	{
		if (document.getElementById(field).value != "")
		{
			passed = true;
			if (field.indexOf('Email') != -1)
			{
				//alert('Am I Here?');
				// make sure it is a valid email
				if (!validateEmail(document.getElementById(field).value))
				{
					error = document.getElementById(field).title + ' is an invalid email.\n\r';
					passed = false;
				}
			}
		}
	}
	
	if (!passed)
	{
		if (error != "")
			alert(error);
	}
	else
	{
		// Swap out the x for a checkbox
		var elemnt=field+'_check';
		var elemntNote=field+'_note';
		
		document.getElementById(elemnt).innerHTML = "<img src='/images/misc/form_check.jpg' alt='Miles Media Group'/>";
		document.getElementById(elemntNote).style.display = "inline";
		document.getElementById(elemnt).style.display = "inline";
		//alert(document.getElementById(field + '_check').src);
		// Check all required fields to activate the submit button if everything is good
		var required = document.getElementById('required_fields').value;
		var goodtogo = true;
		if (required.indexOf(','))
		{
			required = required.split(',');
			for (i = 0; i < required.length; i++)
			{
				var elemnts=required[i]+'_check';
				if (document.getElementById(elemnts).innerHTML.indexOf('misc/form_check.jpg') == -1)				
				{
					goodtogo = false;
				}
			}			
		}
		else
		{
			var elemnts = required + '_check';
			if (indexval=document.getElementById(elemnts).innerHTML.indexOf('misc/form_check.jpg') == -1)
			{
				goodtogo = false;
			}
		}
				
		if (goodtogo)
		{
			document.getElementById('button_disabled').style.display = "none";
			document.getElementById('button_enabled').style.display = "block";
		}
		
	}
}


function validateEmail(email) 
{
	//alert(email);
	// var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
	//var emailReg = "/^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/";
	//var regex = new RegExp(emailReg);
	//return regex.test(email);
	
	var regex = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
  	return regex.test(email);
	
}

function highlightBorder(id,action)
{
	if (action == 1)
		document.getElementById(id).style.border = "3px solid #ff9901";
	else
		document.getElementById(id).style.border = "1px solid #7F9DB9";
}

// GLobal video variable
var currentVideo = "";
function playVideo(video) {
	
	// OK lets build the innerHTML of the wimpy player
	var videoDiv = document.getElementById('video_overlay_box');
	
	var myWidth = 0, myHeight = 0; 
	// FULL HEIGHT 	
  	if( window.innerHeight && window.scrollMaxY ) // Firefox 
  	{
		myWidth = window.innerWidth + window.scrollMaxX;
		myHeight = window.innerHeight + window.scrollMaxY;
	}
	else if( document.body.scrollHeight > document.body.offsetHeight ) // all but Explorer Mac
	{
		myWidth = document.body.scrollWidth;
		myHeight = document.body.scrollHeight;
	}
	else // works in Explorer 6 Strict, Mozilla (not FF) and Safari
	{ 
		myWidth = document.body.offsetWidth + document.body.offsetLeft; 
		myHeight = document.body.offsetHeight + document.body.offsetTop; 
	}
	// VIEWPORT HEIGHT
	if( typeof( window.innerWidth ) == 'number' ) {
    	//Non-IE
    	screenWidth = window.innerWidth;
    	screenHeight = window.innerHeight;
  	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    	//IE 6+ in 'standards compliant mode'
    	screenWidth = document.documentElement.clientWidth;
    	screenHeight = document.documentElement.clientHeight;
  	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	    //IE 4 compatible
	    screenWidth = document.body.clientWidth;
    	screenHeight = document.body.clientHeight;
  	}
	
  	
  	var scrollTop = window.pageYOffset || document.documentElement.scrollTop || 0; var scrollLeft = window.pageXOffset || document.documentElement.scrollLeft || 0;
	var topPadding = scrollTop + ((screenHeight/2)-287);
	var leftPadding = ((screenWidth/2)-255);
			
	document.getElementById('overlay_box').style.height = myHeight + "px";
	//alert(document.getElementById('overlay_product_image').style.top + "TOP PADDING TO ADD: " + topPadding);
	document.getElementById('video_overlay_box').style.top = topPadding + "px";
			
	document.getElementById('video_overlay_box').style.left = leftPadding + "px";
	
	document.getElementById('video_controls_stop').style.display = "block";
	document.getElementById('video_controls_play').style.display = "none";
  	
	/*document.getElementById('overlay_box').style.height = myHeight + "px";
	document.getElementById('video_overlay_box').style.top = (window.scrollY + ((screenHeight/2)-287)) + "px";
	document.getElementById('video_overlay_box').style.left = ((screenWidth/2)-255) + "px";
	alert("here");*/
	
	document.getElementById('overlay_box').style.display = "block";
	videoDiv.style.display = "block";
	buildWimpy(video);
}

function buildWimpy(video)
{
	
	var wimpyConfigs3607 = new Object();
	wimpyConfigs3607.wimpySwf="/wimpy/rave.swf";
	wimpyConfigs3607.wimpyApp="/wimpy/rave.php";
	if (video == "files/team/office_tour.flv")
	{
		wimpyConfigs3607.wimpyWidth="410";
		wimpyConfigs3607.wimpyHeight="230";
		document.getElementById('flashcontent3607').style.left = "60px";
	}
	else
	{
		wimpyConfigs3607.wimpyWidth="320";
		wimpyConfigs3607.wimpyHeight="214";
		document.getElementById('flashcontent3607').style.left = "100px";
	}
	
	
	
	wimpyConfigs3607.wimpyReg="NGJOJTIyJTI0aUVXJTdCJTdFZXZXUiUyN3ElN0JDWXB4TiU0MHFPJTVEJTNCMXpsYzZP";
	wimpyConfigs3607.wimpySkin="/wimpy/skins/skin_video_only.xml";
	wimpyConfigs3607.playlist="/" + video;
	wimpyConfigs3607.autoAdvance="no";
	wimpyConfigs3607.startPlayingOnload="yes";
	wimpyConfigs3607.setAspectRatio="maintain";
	wimpyConfigs3607.tptBkgd="yes";
	makeWimpyPlayer(wimpyConfigs3607, "flashcontent3607");
	// alert(video);
}

function closeVideoOverlay()
{
	document.getElementById('overlay_box').style.display = "none";
	document.getElementById('video_overlay_box').style.display = "none";
}

function showPlayButton()
{
	document.getElementById('video_controls_stop').style.display = "none";
	document.getElementById('video_controls_play').style.display = "block";
}

function showStopButton()
{
	document.getElementById('video_controls_stop').style.display = "block";
	document.getElementById('video_controls_play').style.display = "none";
}