// ORIELLA JavaScript Document
var IMG_ROOT = '/images/';
var holder = new Array();
var tabImg = new Array();




function showHideCaseStudy(obj)
{	
	holder['webex'] = document.getElementById('webex_content');
	holder['kalido'] = document.getElementById('kalido_content');
	holder['mfocus'] = document.getElementById('mfocus_content');	
	holder_default = document.getElementById('default_content');
	
	tabImg['webex'] = document.getElementById('webex');
	tabImg['kalido'] = document.getElementById('kalido');
	tabImg['mfocus'] = document.getElementById('mfocus');
	
	
	var img = getRenderedImgSrc(obj);

	if(img["imageState"] != 'on.jpg')
	{
		holder_default.style.display="none"; 
		// Turns all divs OFF and then turns the one clicked ON
		for(tabName in holder)
		{ 
			holder[tabName].style.display="none"; 
			
			var tabImgObj = getRenderedImgSrc(tabImg[tabName]);
			if(tabImgObj['imageState'] == 'on.jpg') //If the button is ON, it will make it OFF.
			{
				tabImg[tabName].src = IMG_ROOT+"tab_"+tabName+".jpg";
				tabImg[tabName].style.borderTop="1px solid #ffffff";
				tabImg[tabName].style.borderLeft="1px solid #ffffff";
				tabImg[tabName].style.borderRight="1px solid #ffffff";
				tabImg[tabName].style.borderBottom="none";
			}
		}
	
		tabImg[obj.id].style.borderTop="1px solid #e4e4e4";
		tabImg[obj.id].style.borderLeft="1px solid #e4e4e4";
		tabImg[obj.id].style.borderRight="1px solid #e4e4e4";
		tabImg[obj.id].style.borderBottom="1px solid #ffffff";
		obj.src = IMG_ROOT+img["imageName"]+"_on.jpg";//Turns the clicked tab ON
		holder[obj.id].style.display="inline";//Displays the relative content 		
		resizeWebsiteToFitScreen('caseStudy');
	}
	
}
function resizeWebsiteToFitScreen(pageType)
{
	if(document.documentElement.clientWidth < 1400)
	{		 
		var siteRestraint = document.getElementById('site_restraint');	
		var siteHolder = document.getElementById('site_holder');		
		var siteWidth = document.getElementById('site_rhs');		
		
		if(pageType == "caseStudy")
		{
			//Checks if currently on the inside page, and makes sure the site_holder has the right height for firefox
			if(document.getElementById('caseStudies_content'))
			{
				headerHeight = 320;
				tabsHeight = 65;
				footerHeight = 150;
				bodyHeight = document.getElementById('caseStudies_content').offsetHeight;				
				siteHolder.style.height = bodyHeight + footerHeight + tabsHeight + headerHeight+"px";	
			}
		}
		else
		{
			//Checks if currently on the inside page, and makes sure the site_holder has the right height for firefox
			if(document.getElementById('content'))
			{
				headerHeight = 320;
				footerHeight = 240;
				bodyHeight = document.getElementById('content').offsetHeight;
				siteHolder.style.height = bodyHeight + footerHeight + headerHeight+"px";
	
			}		
		}
		var new_rhs_width = 1400-document.documentElement.clientWidth;
		new_rhs_width = 241 - new_rhs_width;
		
		if(new_rhs_width >=0 ){
			siteWidth.style.width = new_rhs_width +"px"; //Cuts the width to the screensize
			siteHolder.style.width = document.documentElement.clientWidth +"px"; //Cuts the width to the screensize
			siteRestraint.style.width = document.documentElement.clientWidth +"px"; //Cuts the width to the screensize
		}
	}
	
}


//Returns image properties
function getRenderedImgSrc(imgObj)
{
	imgsrc = imgObj.src;	
	img_root = imgsrc.split("/"); 
	img_name = img_root[img_root.length-1];	
	img_nameSpaces = img_name.split("_");

	img_state = img_nameSpaces[img_nameSpaces.length-1]; /* gets the word after last _ , looking for _on */	
	
	justImageName = img_name.split(".");
	
	var resultSet = new Array();
	resultSet['imageName'] = justImageName[0]; // send the image name only up until the extention 
	resultSet['imageExtention'] = justImageName[1]; // sends the image extention
	resultSet['imageState'] = img_state; //sends the state of an image like on.gif, on.jpg
	
	
	return resultSet; //Returns just the image name without the extention	
}

