/*********************************************/
/**/
/**/ // Google map global variables
/**/ var googlemap;
/**/ var geoCoder;
/**/ var geoCoderBusinessName = '';
/**/	
/**/ var nextPosition = 210;
/**/ 
/**/ var topmost = 0;
/**/ var newsHeight = 75;
/**/ 
/**/ var displayArray = new Array();
/**/ 
/**/ var newsQueue = new Array();
/**/ 
/**/ var news1_height = 0;
/**/ var isStop = false;
/**/ var holdDelay = 3000; //3000ms (3 seconds)
/**/ var scrollDelay = 20; //20ms
/**/ 
/**/ var gInitFunctions = new Array();
/**/ var agt = navigator.userAgent.toLowerCase();
/**/ var ie  = (agt.indexOf("msie") != -1);
/**/ var ns  = (navigator.appName.indexOf("Netscape") != -1);
/**/ var win = ((agt.indexOf("win")!=-1) || (agt.indexOf("32bit")!=-1));
/**/ var mac = (agt.indexOf("mac")!=-1);
/**/ // List of possible plug-ins
/**/ //var iePlugins = new Array("Adobe.SVGCtl::SVG Viewer", "SWCtl.SWCtl.1::Shockwave Director", "ShockwaveFlash.ShockwaveFlash.1::Shockwave Flash", "rmocx.RealPlayer G2 Control.1::RealPlayer", "QuickTimeCheckObject.QuickTimeCheck.1::QuickTime", "MediaPlayer.MediaPlayer.1::Windows Media Player", "PDF.PdfCtrl.5::Acrobat Reader", "ShockwaveFlash.ShockwaveFlash.1::Shockwave Flash");
/**/ //var nsPlugins = new Array("image/svg-xml::SVG Viewer", "application/x-director::Shockwave Director", "application/x-shockwave-flash::Shockwave Flash", "audio/x-pn-realaudio-plugin::RealPlayer", "video/quicktime::QuickTime", "application/x-mplayer2::Windows Media Player", "application/pdf::Acrobat Reader");
/**/ var iePlugins = new Array("ShockwaveFlash.ShockwaveFlash.1::Shockwave Flash");
/**/ var nsPlugins = new Array("application/x-shockwave-flash::Shockwave Flash");
/**/ var pluginList = '';
/**/ 
/*********************************************/

function detectIE(ClassID, name) 
{
	result = false; 
	document.write('<SCRIPT LANGUAGE=VBScript>result = IsObject(CreateObject("' + ClassID + '"))<\/SCRIPT>\n'); 

	if (result) return name + ','; 
	else return ''; 
}
function detectNS(ClassID,name) 
{ 
	n = ""; 
	if (nse.indexOf(ClassID) != -1) 
	if (navigator.mimeTypes[ClassID].enabledPlugin != null) 
		n = name+","; 
	return n; 
}
function detectPlugins(plugin)
{
	var tempArr;

	// If browser type not recognized, assume plug-in is available.
	if(!ie && !ns)
		return true;
		
	if (ie && win) {	
		for(var i = 0; i < iePlugins.length; i++)
		{
			tempArr = iePlugins[i].split('::');
			pluginList += detectIE(tempArr[0], tempArr[1]);
		}
	}
	else if (ns || !win) {
		nse = ""; 
			
		for (var i=0; i < navigator.mimeTypes.length; i++) 
			nse += navigator.mimeTypes[i].type.toLowerCase();
			
		for(var i = 0; i < nsPlugins.length; i++)
		{
			tempArr = nsPlugins[i].split('::');
			pluginList += detectNS(tempArr[0], tempArr[1]);
		}
	}

	// Test for Java plug-in
	//pluginList += navigator.javaEnabled() ? "Java," : "";
	
	// Remove ending comma
	if (pluginList.length > 0) 
		pluginList = pluginList.substring(0 , pluginList.length - 1);

	if (pluginList.indexOf(plugin) != -1) return true;
	else return false;
}

function detectFlash()
{
	KEYWORD = "Flash";
	return detectPlugins(KEYWORD);
}

function cont()
{
	isStop = false;
	move();
}


function move()
{
	var news1 = document.getElementById("news1");
	var news2 = document.getElementById("news2");
	var news3 = document.getElementById("news3");

	if (news1_loc_top == topmost || news2_loc_top == topmost || news3_loc_top == topmost)
	{
		isStop = true;
		setTimeout('cont()', holdDelay);
	}
	else if (news1_loc_top + newsHeight < topmost)
	{
		news1_loc_top = nextPosition;
		newsQueue.push(news1.innerHTML);
		news1.innerHTML = newsQueue.shift();
	}
	else if (news2_loc_top + newsHeight < topmost)
	{
		news2_loc_top = nextPosition;
		newsQueue.push(news2.innerHTML);
		news2.innerHTML = newsQueue.shift();
	}
	else if (news3_loc_top + newsHeight < topmost)
	{
		news3_loc_top = nextPosition;
		newsQueue.push(news3.innerHTML);
		news3.innerHTML = newsQueue.shift();
	}


	news1.style.top = news1_loc_top - 1;
	news1_loc_top -= 1;


	news2.style.top = news2_loc_top - 1;
	news2_loc_top -= 1;

	news3.style.top = news3_loc_top - 1;
	news3_loc_top -= 1;

	if (!isStop)
	{
		timeout = setTimeout('move()',scrollDelay);
	}
}

function pause()
{
	isStop = true;
}

function init(objectPath)
{
	var flashVersion = 8;
	var movFilename = "vm_intro.swf";
	var movWidth = "538";
	var movHeight = "350";
	var movBorder = 0;
	var scrollFilename = "vm_partner_scroller.swf";
	var scrollWidth = "534";
	var scrollHeight = "59";
	var browserName = navigator.appName;
	var bannerDiv;
	var tmpFilename;
	var tmpWidth;
	var tmpHeight;
	var divId = null;
	var flashImgEquivalent = new Array("vm_intro_static.png","vm_partner_scroller_static.png");
	var flashMarginLeft = new Array(0, 0);
	
	divId = new Array("flashcontent", "flashscrollercontent");	
	tmpFilename = new Array(movFilename, scrollFilename);
	tmpWidth = new Array(movWidth,scrollWidth);
	tmpHeight = new Array(movHeight,scrollHeight);

	// If flash not detected, exit
	if(!detectFlash()) 
	{
		for(i = 0; i < divId.length; i++)
		{		
			bannerDiv = document.getElementById(divId[i]);
			if(bannerDiv == null) continue;

			bannerDiv.innerHTML = "<img src=\"" + objectPath + flashImgEquivalent[i] + "\" style=\"border: none;\"/>";
		}
		
		// Exit function
		return;
	}
	
	if (browserName == "Microsoft Internet Explorer")
	{
		for(i = 0; i < divId.length; i++)
		{
			var fo = new FlashObject(objectPath + tmpFilename[i], "vmmovie" + i, tmpWidth[i], tmpHeight[i], flashVersion, "#ffffff");
			fo.addParam("wmode", "opaque");
			fo.write(divId[i]);
		}
	}
	else
	{
		for(i = 0; i < divId.length; i++)
		{
		
			bannerDiv = document.getElementById(divId[i]);
			if(bannerDiv == null) continue;

			bannerDiv.innerHTML = "<div style=\"margin-left:" + flashMarginLeft[i] + "px;\"><object type=\"application/x-shockwave-flash\" data=\"" + objectPath + tmpFilename[i] + "\" width=\"" + tmpWidth[i] + "\" height=\"" + tmpHeight[i] + "\" style=\"z-index: 255; height: " + tmpHeight[i] + "px; border: 0px; text-align:bottom; cursor:pointer;\">"+
													"<param name=\"wmode\" value=\"transparent\"/>"+
													  "<param name=\"movie\" value=\"" + objectPath + tmpFilename[i] + "\" width=\"" + tmpWidth[i] + "\" height=\"" + tmpHeight[i] + "\" style=\"border: 0px; text-align:bottom;\"/>"+
												  "</object></div>";
		}
	}
	
  for (var i = 0; i < gInitFunctions.length; i++)
  {
    gInitFunctions[i]();
  }
}

function initNewsScroller(objectPath)
{
	var news1 = document.getElementById("news1");
	var news2 = document.getElementById("news2");
	var news3 = document.getElementById("news3");

	if(news1 == null || news2 == null || news3 == null)
		return;
		
	news1.style.top, news1_loc_top = topmost;
	news2.style.top, news2_loc_top = news1.offsetHeight + 20;
	news3.style.top, news3_loc_top = 190;

	if (newsArray.length > 2)
	{
		news1.innerHTML = newsArray[0];
		news2.innerHTML = newsArray[1];
		
		for (var i = 2; i < newsArray.length; i++)
		{
			newsQueue.push(newsArray[i]);
		}
		if (newsQueue.length > 0)
		{
			news3.innerHTML = newsQueue.shift();
		}
		move();
	}
}

function registerInitFunction(f)
{
    gInitFunctions.push(f);
}

function selectLink(cellId,level)
{
	cell = document.getElementById(cellId);
	cell.className = 'left_panel_l'+level+'_hover';
}

function deselectLink(cellId,level)
{
	cell = document.getElementById(cellId);
	cell.className = 'left_panel_l'+level;
}

function startList()
{
	if (document.getElementById)
	{
		navRoot = document.getElementById("nav1");
		
		if(navRoot != null)
		{
			for (i=0; i<navRoot.childNodes.length; i++)
			{
				node = navRoot.childNodes[i];
				if (node.nodeName=="LI")
				{
					node.onmouseover=function()
					{
						this.className+=" over";
						this.style.background="#ABABAB";
				  	}
				  	node.onmouseout=function()
					{
		  				this.className=this.className.replace(" over", "");
						this.style.background="#003366";
		   			}
		   		}
			}
		}	

		j=1;
	  
		navRoot2 = document.getElementById("nav2-"+j);
		if(navRoot2 != null)
		{
		  while (document.getElementById("nav2-"+j))
		  {
			  navRoot2 = document.getElementById("nav2-"+j);
				for (i=0; i<navRoot2.childNodes.length; i++)
				{
					node = navRoot2.childNodes[i];
					if ((node.nodeName=="LI") && (node.className=="level2"))
					{
						node.onmouseover=function()
						{
							this.className+=" over2";
							this.style.background="#CDCDCD";
						}
						node.onmouseout=function()
						{
							this.style.background="#F6F6F6";
							this.className=this.className.replace(" over2", "");
						}
					}

					if ((node.nodeName=="LI") && (node.className=="level3"))
					{
						node.onmouseover=function()
						{
							this.style.background="#CDCDCD";
						}
						node.onmouseout=function()
						{
							this.style.background="#F6F6F6";
						}
					}


			   	}	//for

			  j++;
		  }//while
	  }
	}
}
		
function showElementById( id )
{
  var divElem = document.getElementById(id);
  
  if (divElem.style.display == 'block')
  {
    divElem.style.display = 'none';
  }
  else
  {
    divElem.style.display = 'block';
  }
}

function showCategories( category, imgPath )
{
  var divId = category + '_categories';
  showElementById(divId);
  
  var imgId = category + '_image';
  switchImage(imgId, imgPath);
}

function switchImage( id, imgPath )
{
  var imgElem = document.getElementById(id);
 
  if (imgElem.src.search(imgPath + 'expand.png') != -1)
  {
    imgElem.src = imgPath + 'collapse.png';
  }
  else
  {
    imgElem.src = imgPath + 'expand.png';
  }
}

function geoCoderLoad(address, business)
   {  
	  /******************************************
	   *
	   *
		Source: http://www.developer.com/lang/jscript/print.php/3615681
		Modified to fit needs by André N'guettia - 1/08/2008
	   *
	   *
	   ******************************************/
	  
	  // Store in global variable
	  geoCoderBusinessName = business;
	  
      // Create new map object
      googlemap = new GMap2(document.getElementById("map"));
	  googlemap.addControl(new GLargeMapControl());
	  
      // Create new geocoding object
      geocoder = new GClientGeocoder();

      // Retrieve location information, pass it to addToMap()
      geocoder.getLocations(address, getGeoCoderMap);
   }

   function getGeoCoderMap(response)
   {
    /******************************************
	   *
	   *
		Source: http://www.developer.com/lang/jscript/print.php/3615681
		Modified to fit needs by André N'guettia - 1/08/2008
	   *
	   *
	   ******************************************/
      // Retrieve the object
      place = response.Placemark[0];

      // Retrieve the latitude and longitude
      point = new GLatLng(place.Point.coordinates[1],
                          place.Point.coordinates[0]);

      // Center the map on this point
      googlemap.setCenter(point, 13);

      // Create a marker
      marker = new GMarker(point);

      // Add the marker to map
	  googlemap.addOverlay(marker);

	  var streetAddress = place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.Thoroughfare.ThoroughfareName;
	  var city = place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.LocalityName;
	  var state = place.AddressDetails.Country.AdministrativeArea.AdministrativeAreaName;
	  var zip = place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.PostalCode.PostalCodeNumber;

	  // Add address information to marker
	  marker.openInfoWindowHtml(geoCoderBusinessName + '<br />' + streetAddress + '<br />' + city + ', ' + state + ' ' + zip);
   }