window.onload = resizeComponents;

function resizeComponents()
{
	resizeColumns();
}

function loadPortfolio(id) {
    var xmlHttp;
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	} 
	var url;
	url = "portfolio.ajax.php";
	var vars = "portfolioId="+id+"&date="+(new Date()).getTime();
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 1)
		{
			$('largePortfolioDiv').innerHTML = "<div style=\"text-align:center\" <img src=\"../i/loading.gif\" /> LOADING...</div>";
			resizeComponents();
		}
		if(xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
		{
			$('largePortfolioDiv').innerHTML = xmlHttp.responseText;
			resizeComponents();	
		}
	}
	xmlHttp.open("POST",url,true);
	xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 
	xmlHttp.send(vars);
}


function resizeColumns()
{
	if($('rightContentDiv').offsetHeight < $('mainContentDiv').offsetHeight)
	{
		if(window.location.pathname == "/portfolio.php")
			$('testimonialsDiv').style.height = $('mainContentDiv').offsetHeight-160 + "px";
		else
			$('testimonialsDiv').style.height = $('mainContentDiv').offsetHeight-414 + "px";
	}
	else if($('mainContentDiv').offsetHeight < $('rightContentDiv').offsetHeight)
	{
		$('pageContentDiv').style.height = $('rightContentDiv').offsetHeight - 312 - $('servicesDiv').offsetHeight + "px";
	}
}

function GetXmlHttpObject()
{ 
	var objXMLHttp=null;
	if (window.XMLHttpRequest)
	{
		objXMLHttp=new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	return objXMLHttp;
}

function highlight(obj)
{
	obj.style.background = "url(i/orangeGradient.png) repeat-x";	
}

function lowlight(obj)
{
	obj.style.background = "url(i/grayGradient.png) repeat-x";
}

function $() {
	var elements = new Array();
	for (var i = 0; i < arguments.length; i++) {
		var element = arguments[i];
		if (typeof element == 'string')
			element = document.getElementById(element);
		if (arguments.length == 1)
			return element;
		elements.push(element);
	}
	return elements;
}

function displaySubContentDiv(obj) {;
	    activeTab = 'tab' + obj;
	    activeDiv = 'subContentDiv_' + obj;

        $('tabWhoWeAre').style.background = "url(i/grayGradient.png) repeat-x";
        $('tabOurProcess').style.background = "url(i/grayGradient.png) repeat-x";
        $('tabWhyIncommand').style.background = "url(i/grayGradient.png) repeat-x";

		$('subContentDiv_Welcome').style.display = "none";
        $('subContentDiv_WhoWeAre').style.display = "none";
        $('subContentDiv_OurProcess').style.display = "none";
        $('subContentDiv_WhyIncommand').style.display = "none";
        
	    $(activeTab).style.background = "url(i/orangeGradient.png) repeat-x";
	    $(activeDiv).style.display = '';
		resizeColumns();
}

function showCallout(e)
{
	var ScrollTop = document.body.scrollTop;
	if (ScrollTop == 0)
	{
		if (window.pageYOffset)
			ScrollTop = window.pageYOffset;
		else
			ScrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
	}
	ex = e.x-(pLeft+2);
	ey = e.y-(pTop-ScrollTop);
	yHeight = pTop-ScrollTop;
	if(ex >=1 && ex <=126)
	{
		//First Column	
		if(ey>=70 && ey <=120)
		{
			
		} 
		else if(ey>=195 && ey <=245)
		{
			
		}
		else if(ey>=320 && ey <=370)
		{
			$('callout').style.left = pLeft-48+"px";
			$('callout').style.top = pTop - $('callout').offsetHeight-45+"px";
			$('calloutContent').innerHTML = "Basic information gathering by client and project manager to discuss problem/solution objectives, timeline, budget to move to next phase.";
			$('callout').style.display = "block";	
		}
	}
	else if(ex >=188 && ex <=313)
	{
		//Second Column	
		if(ey>=70 && ey <=120)
		{
				
		} 
		else if(ey>=320 && ey <=370)
		{
			$('callout').style.left = pLeft+140+"px";
			$('callout').style.top = pTop - $('callout').offsetHeight-45+"px";
			$('calloutContent').innerHTML = "Basic information gathering by client and project manager to discuss problem/solution objectives, timeline, budget to move to next phase.";
			$('callout').style.display = "block";
		}
	}
	else if(ex >=375 && ex <=500)
	{
		//Third Column
		if(ey>=70 && ey <=120)
		{
			
		} 
		else if(ey>=195 && ey <=245)  
		{
			
			
		}
		else if(ey>=320 && ey <=370)
		{
			$('callout').style.left = pLeft-48+"px";
			$('callout').style.top = pTop - $('callout').offsetHeight-45+"px";
			$('calloutContent').innerHTML = "Basic information gathering by client and project manager to discuss problem/solution objectives, timeline, budget to move to next phase.";
			$('callout').style.display = "block";	
		}
	}
}
function getLeft(obj) { 
    x = obj.offsetLeft; 
    tParent = obj.offsetParent; 
    	while (tParent != null) { 
        	x += tParent.offsetLeft; 
			try
			{
				tParent = tParent.offsetParent;
			}
			catch(e){}
		}
    return x; 
} 
function getTop(obj) {// 
    y = obj.offsetTop; 
    tParent = obj.offsetParent; 
    while (tParent != null) 
	{ 
		y += tParent.offsetTop; 
		try
		{
			tParent = tParent.offsetParent;
		}
		catch(e){}
	} 
    return y; 
} 
function showCallouts(num)
{
	pLeft = getLeft($("processImage"));
	pTop = getTop($("processImage"));
	switch(num)
	{
		case 1:
			$('calloutContent').innerHTML = "Basic information gathering by client and project manager to discuss problem/solution objectives, timeline, budget to move to next phase.";

			$('callout').style.left = pLeft-48+"px";
			$('callout').style.top = pTop+40- $('callout').offsetHeight+"px";
			$('callout').style.visibility = "visible";
			break;
		case 2:
			$('calloutContent').innerHTML = "Discussions with clients and dev team to plan how to address the objectives and goals for the project.  Develop functional specs and deliver outline, costs, and timeline.";
			$('callout').style.left = pLeft+140+"px";
			$('callout').style.top = pTop+40- $('callout').offsetHeight+"px";
			$('callout').style.visibility = "visible";
			break;
		case 3:
			$('calloutContent').innerHTML = "Gather information about the design requirements.  Develop site look and post to a preview site for review and modifications.";
			$('callout').style.left = pLeft+427+"px";
			$('callout').style.top = pTop+40- $('callout').offsetHeight+"px";
			$('callout').style.visibility = "visible";
			break;
		case 4:
			$('calloutContent').innerHTML = "Coding and platform testing.  Application Development is broken down into phases depending on project size.";
			$('callout').style.left = pLeft+427+"px";
			$('callout').style.top = pTop +180-($('callout').offsetHeight/2)+"px";
			$('callout').style.visibility = "visible";
			break;
		case 5:
			$('calloutContent').innerHTML = "The site or application is tested or if applicable the server will be prepared and site tested further on hosting environment.";
			$('callout').style.left = pLeft+427+"px";
			$('callout').style.top = pTop+$("processImage").offsetHeight+10+"px";
			$('callout').style.visibility = "visible";
			break;
		case 6:
			$('calloutContent').innerHTML = "The site is launched and submitted to search engines, user training is provided as needed.";
			$('callout').style.left = pLeft+140+"px";
			$('callout').style.top = pTop+$("processImage").offsetHeight+10+"px";
			$('callout').style.visibility = "visible";
			break;
		case 7:
			$('calloutContent').innerHTML = "The marketing plan is carried out for the completed site.";

			$('callout').style.left = pLeft-48+"px";
			$('callout').style.top = pTop+$("processImage").offsetHeight+10+"px";
			$('callout').style.visibility = "visible";
			break;
		case 8:
			$('calloutContent').innerHTML = "New ideas, features and/or change requests keep the site interesting and/or at peak usefulness by visitors.";
			$('callout').style.left = pLeft-50+"px";
			$('callout').style.top = pTop +130-($('callout').offsetHeight/2)+"px";	
			$('callout').style.visibility = "visible";
			break;
		default:
			break;
	}
}

function hideCallouts()
{
	$('callout').style.visibility = "hidden";
}
