var lastServiceElementOpened = 'customerQuote';

// '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
// Preload Object

image1 = new Image();
image1.src = "img/home_over.gif";
image2 = new Image();
image2.src = "img/services_over.gif";
image3 = new Image();
image3.src = "img/press_over.gif";
image4 = new Image();
image4.src = "img/pro_over.gif";
image5 = new Image();
image5.src = "img/properties_over.gif";
image6 = new Image();
image6.src = "img/contact_over.gif";
image7 = new Image();
image7.src = "img/login_over.gif";
image8 = new Image();
image8.src = "img/sub_imagelrg1.jpg";
image9 = new Image();
image9.src = "img/sub_imagelrg2.jpg";
image10 = new Image();
image10.src = "img/sub_imagelrg3.jpg";

/* IE Fix for accordion expand / contract */
function accordionHeaderHover()
{
	$(".ui-accordion-header").hover();
}



//on dom load
jQuery(function($)
{
	// quotes flash
	if( $("#customerQuote").length )
	{
		var so = new SWFObject("flash/quotes/jonesQuotes.swf", "customerQuote", "400", "140", "8");
		so.addParam("wmode", "transparent");
		so.addParam("base", "flash/quotes/");
		so.write("customerQuote");
	}
	
	// if there are any accorions that need to expand/contract, init them.
	if( $(".expandable").length )
	{
		$(".expandable").accordion({collapsible: true, active: false});
	}
	
	//auto expand accordion if this is the active page
	if( $(".accordion .expandable > .activePage").length )
	{
		$(".expandable .activePage").click();
	}
	//call IE fix function
	if( $(".ui-accordion-header").length )
		$(".ui-accordion-header").click(function(){setTimeout("accordionHeaderHover()", 300);})
		
	if( $('.ui-state-active').length )
		$('.ui-state-active').ready(function(){setTimeout("accordionHeaderHover()", 300);})
	
	//actions for clicking on a state in the map
	if( $("#usmap").length )
	{
		$("#usmap area").click(function(){
			stateDisplay($(this).attr("id"));
			return false;
		})
	}
	
	//Make the employee experience box the same height as the content
	if( $("#empText").length )
	{
		var empText = $("#empText");
		var empExperience = $("#empExperience");
		var empTotals = $("#empTotals");
		
		var empTextHeight = $(empText).height() - $(empTotals).height() - 20;
		
		if($(empExperience).height() > empTextHeight)
		{
			$(empExperience).height(empTextHeight);
			$(empExperience).css("overflow", "auto");
		}
	}
	
	//Make the news items box the same height as the content
	if( $("#pressBox").length )
	{
		var articleText = $("#article");
		var pressBox = $("#pressBox");		
		var articleTextHeight = $(articleText).height();
		
		// check if it makes sence to resize before doing so
		if( ($(pressBox).height() > articleTextHeight && articleTextHeight > 200) || ($(pressBox).height() > 400) )
		{
			$(pressBox).height(articleTextHeight);
			$(pressBox).css("overflow", "auto");
		}
	}
		
})

/*
	populatePopup will fill details about a clicked "dot" on the map
	@params: id = the id of the property
*/
function populatePopup(id)
{
	$.ajax({
		type: "POST",
		url: "grabPropDetails.php",
		data: "prop="+id,
		success: function(result) {
			
			//Break msg into an array and msg is a string in the form of:
			//image|address1|address2|city|state|zip|acreage|size|built|value
			//  0  |    1   |    2   | 3  |  4  | 5 |   6   | 7  |  8  |  9  
			var propInfo = result.split('|');
			
			var noImgMsg = "Sorry, no image available";
			
			if( propInfo[2] != "" )
				propInfo[2] = "<br/>"+propInfo[2];
				
			//set image
			$(".map_prop_detail #propImg").attr( "src", "upload/propfiles/"+propInfo[0] );
			$(".map_prop_detail #propImg").attr( "title", "Image of "+propInfo[1] );
			$(".map_prop_detail #propImg").attr( "alt", "Image of "+propInfo[1] );
			
			//set details
			$(".map_prop_detail #propInfo #address").text(propInfo[1] + "" + propInfo[2]);
			$(".map_prop_detail #propInfo #city").text(propInfo[3]);
			$(".map_prop_detail #propInfo #state").text(propInfo[4]);
			$(".map_prop_detail #propInfo #zipcode").text(propInfo[5]);
			$(".map_prop_detail #propInfo .propAcreage .dynamic").text(propInfo[6]);
			$(".map_prop_detail #propInfo .propSize .dynamic").text(propInfo[7]);
			$(".map_prop_detail #propInfo .propBuilt .dynamic").text(propInfo[8]);
			$(".map_prop_detail #propInfo .propPrice .dynamic").text(propInfo[9]);
		},
		error: function(msg){ 
			$(".map_prop_detail #propInfo").html( "Error Getting Details!!<br/><br/><p>Click the 'View More About This Property' button below for details.</p>" );
			$(".map_prop_detail #propImg").attr( "src", "" );
			$(".map_prop_detail #propImg").attr( "title", noImgMsg);
			$(".map_prop_detail #propImg").attr( "alt", noImgMsg );
		},
		timeout: function(msg)	{ 
			$(".map_prop_detail #propInfo").html( "Timeout!!<br/>"+msg );
			$(".map_prop_detail #propImg").attr( "src", "" );
			$(".map_prop_detail #propImg").attr( "title", noImgMsg);
			$(".map_prop_detail #propImg").attr( "alt", noImgMsg );
		},
		complete: function()
		{
			//even if the pull fails, try to link to the property with this ID
			$(".map_prop_detail .getDetailLink").attr( "href", "detail.php?id="+id );
			
			//Show the popup
			$(".map_prop_detail").fadeIn('medium');
		}			
	});	
	return false;
}



function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_closeBrWindow(theURL,winName) 
		{window.close(theURL,winName);
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,x,j=0,x,a=MM_swapImage.arguments;
  document.MM_sr = new Array;
  for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null&&x.indexOf('photo')<0){
    document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// Switcher

function switcher5(token){
	var y = makeRequest("hidden_forsale.php?id="+token)
}
function switcher4(token){
	var y = makeRequest("hidden_nda.php?id="+token)
}
function switcher3(token){
	var y = makeRequest("hidden_current.php?id="+token)
}
function switcher2(token){
	var y = makeRequest("hidden_pro.php?id="+token)
}
function switcher(token){
	var y = makeRequest("hidden.php?id="+token)
}
//alternate method 
function makeRequest(url) {
	var httpRequest;
        if (window.XMLHttpRequest) { // Mozilla, Safari, ...
			httpRequest = new XMLHttpRequest();
			if (httpRequest.overrideMimeType) {
				httpRequest.overrideMimeType('text/html');
				// See note below about this line
            }
        } 
        else if (window.ActiveXObject) { // IE
            try
			{
                httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
            }
			catch (e) 
			{
				try
				{
					httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
				} 
				catch (e) {}
			}
		}

        if (!httpRequest) {
            return false;
        }
        httpRequest.onreadystatechange = function() { return alertContents(httpRequest); };
        httpRequest.open('GET', url, true);
        httpRequest.send('');

    }

    function alertContents(httpRequest) {

        if (httpRequest.readyState == 4) {
            if (httpRequest.status == 200) {
                window.document.getElementById("box").innerHTML = httpRequest.responseText;
            } else {
			   return false;
            }
        }

    }

//quote rotator
function getQuote()
{
/*
Script obtained from Wsabstract.com
For this script and more visit Java-Scripts.net or Wsabstract.com
*/

	quote0= "Your firm is refreshingly different. . . The project manager was there as a support throughout to make certain we got what we wanted, when we needed it and in whatever manner best suited for our requirements. Your team offered well thought out ideas during our construction meetings, was meticulous in details to keep progress on target and was readily available as needed. Thanks again for an enjoyable project from start to finish.";
	author0="Operations Engineer<br/>Reynolds Aluminum/Integris Metals";
	
	quote1= "Jones Development Company offers tenants the ‘best of all worlds’ – the control and flexibility of expanding operations with the strategic benefits of outsourcing. They allow us to focus on our core competencies while they delivered a quality facility tailored to our specific needs.";
	author1="BUNZL Distribution Midcentral";
	
	quote2= "I want to thank you for your efforts on this project. It definitely had its challenges. I appreciate the cooperation that existed between you and our team. Your daily interactions with our field staff and effort to minimize impacts on our operations were greatly appreciated.";
	author2="Project Engineer<br/>FedEx Ground, Inc.";
	
	quote3= "I wanted to let you know that you did a tremendous job. Each issue was handled in a calm and professional manner and what could have been a major embarrassment resulted in being a minor inconvenience at best. This clearly demonstrates the value in having the site superintendent and project manager working hand in hand.";
	author3="Facilities Project Engineer<br/>FedEx Ground, Inc.";
	
	quote4= "Because Jones Development’s buildings are always of the highest quality, the tenants have all been very pleased with their new locations. We believe the true test of a business relationship comes when unforeseen events inevitably arise. Jones Development Company has always operated at the highest level of professionalism to resolve any issues that arise. We are appreciative of the extraordinary degree to which Jones stands behind its work.";
	author4="Executive Vice President<br/>Monmouth Real Estate Investment Corporation";
	
	quote6= "Serving as a management liaison, Jones Development Company immediately shouldered many of the responsibilities necessary to ensure completion of our new office building. Your company continuously provided sound input as well as cost-effective alternatives, which allowed us to determine the best use of our construction dollar and which allowed the project to run smoothly and on time.";
	author6="Chief Financial Officer<br/>Livestock Marketing Association";
	
	quote7= "Jones Development Company is extremely unusual. Your employees have an exceptional attention to detail and their follow-up skills are relentless. Not only do I attribute the success of the retro-fit in Fort Myers to these qualities, but also I appreciate your consistency in applying these standards to each FedEx Ground project with which you are involved.";
	author7="Real Estate Acquisition Specialist<br/>FedEx Ground, Inc.";
	
	quote8= "In my twenty-four year history in construction with FedEx, I’ve never experienced such professionalism and seamlessness in project delivery. I believe it was because of the team you developed from the beginning. Your project manager remained on top of every issue and kept me well informed. He knew what was going on with the project each day";
	author8="Senior Project Management Specialist<br/>FedEx Express";
	
	quote9= "After financing over fifty projects with JDC, I would like to take the opportunity to compliment your team for its integrity and professionalism exhibited on each and every project. It is indeed a pleasure to work with an organization that practices such high standards on a daily basis.";
	author9="First Vice President<br/>Commerce Bank";
	
	quote10= "For the past several years, we have worked with JDC and have thoroughly enjoyed cultivating our professional relationship. Developers, like yourselves, make us look good because you consistently deliver high quality buildings to our clients while accepting complete responsibility for each project despite any unusual or adverse circumstances. Project after project your focus is unwavering and your performance admirable.";
	author10="Vice Chairman<br/>Fischer & Company";
	
	quote11= "We appreciate the level of excellence in which JDC conducts its business. Each project, regardless of its size or scope, receives the same commitment to quality, which is greatly appreciated.";
	author11="Vice Chairman<br/>Fischer & Company";
	
	quote12= "Working with a company of your caliber is always a pleasure because we recognize your accountability to each and every project, your proficiency in the industrial real estate market and your reliability to do what you say you will do. But most importantly, we appreciate the integrity with which your firm conducts its business affairs. Your professionalism and honesty have never faltered.";
	author12="Real Estate Advisor<br/>FedEx Express";
	
	quote13= "We have found JDC to be professional, responsive and capable in performance of their obligations and undertakings. They are good people, who are concerned about the quality of their work as well as meeting their partners’ expectations";
	author13="Regional Vice President<br/>Harrington Bank";

	
	var ran_unrounded=Math.random()*2;
	var ran_number=Math.round(ran_unrounded);
	
	var myquote = eval("quote"+ran_number).toString();
	var myauthor = eval("author"+ran_number).toString();		
	var html = "<div class=\"proQuote\">\""+myquote+"\"<br/><div class=\"proByline\"> - "+ myauthor +"</div></div>";
	document.write(html);
	//return html;
}

// Image Swapping Function
function imageSwapIn(e, p)
{
	// Grab the src object we are going to be replacing.
	var imgsrc = document.getElementById(e).getAttribute('src');
	// Replace the parent src object
	document.getElementById(p).src = imgsrc;
}
function imageSwapOut(p, imgsrc){
	// Revert back!
	document.getElementById(p).src = imgsrc;
}

// Element Swapping Function
function elementShowHide()
{
	// The id of the link tag.
	var elementID = this.id.split('_'); 
	var showMe = 'srv_content_' + elementID[2];
	
	// The element that we want to show.
	var showElement = gO(showMe);
	
	// The element that has the contact information
	var showContact = gS('contactLink');
	
	// The last element that was opened.
	var hideElement = gO(lastServiceElementOpened);
	
	if( hideElement && showElement )
	{
		hideElement.style.display = 'none';
		showElement.style.display = 'block';
		
		if( showContact.display == 'none' || showContact.display == '' )
			showContact.display = 'block';
		
		lastServiceElementOpened = showMe;
	}
	return false;
}

function addServiceHandlers( parent, childTag, childTag2, actionFunction )
{
	var parentElement = gO(parent);
	
	if( parentElement )
	{
		// Grab the first child tag.
		var childTags = parentElement.getElementsByTagName(childTag);

		var tagCount = childTags.length;
		for( var i = 0; i < tagCount; i++ )
		{
			var neededTag = childTags[i].getElementsByTagName(childTag2)[0];
			
			neededTag.onclick = elementShowHide;
		}
	}
}
