// Globals
// Major version of Flash required
var requiredMajorVersion = 6;
// Minor version of Flash required
var requiredMinorVersion = 0;
// Revision of Flash required
var requiredRevision = 0;
// the version of javascript supported
var jsVersion = 1.0;

var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
jsVersion = 1.1;
// JavaScript helper required to detect Flash Player PlugIn version information
function JSGetSwfVer(i){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
      		var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			descArray = flashDescription.split(" ");
			tempArrayMajor = descArray[2].split(".");
			versionMajor = tempArrayMajor[0];
			versionMinor = tempArrayMajor[1];
			if ( descArray[3] != "" ) {
				tempArrayMinor = descArray[3].split("r");
			} else {
				tempArrayMinor = descArray[4].split("r");
			}
      		versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
            flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
      	} else {
			flashVer = -1;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	// Can't detect in all other cases
	else {
		
		flashVer = -1;
	}
	return flashVer;
} 
// If called with no parameters this function returns a floating point value 
// which should be the version of the Flash Player or 0.0 
// ex: Flash Player 7r14 returns 7.14
// If called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) 
{
 	reqVer = parseFloat(reqMajorVer + "." + reqRevision);
   	// loop backwards through the versions until we find the newest version	
	for (i=25;i>0;i--) {	
		if (isIE && isWin && !isOpera) {
			versionStr = VBGetSwfVer(i);
		} else {
			versionStr = JSGetSwfVer(i);		
		}
		if (versionStr == -1 ) { 
			return false;
		} else if (versionStr != 0) {
			if(isIE && isWin && !isOpera) {
				tempArray         = versionStr.split(" ");
				tempString        = tempArray[1];
				versionArray      = tempString .split(",");				
			} else {
				versionArray      = versionStr.split(".");
			}
			versionMajor      = versionArray[0];
			versionMinor      = versionArray[1];
			versionRevision   = versionArray[2];
			
			versionString     = versionMajor + "." + versionRevision;   // 7.0r24 == 7.24
			versionNum        = parseFloat(versionString);
        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
			if ( (versionMajor > reqMajorVer) && (versionNum >= reqVer) ) {
				return true;
			} else {
				return ((versionNum >= reqVer && versionMinor >= reqMinorVer) ? true : false );	
			}
		}
	}	
	return (reqVer ? false : 0.0);
}

var hasRightVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);

function write_homepage_movie()
{
	var output = "";
	
	if(hasRightVersion)
	{
		output += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="735" height="104">';
		output += '<param name="movie" value="swf/homepage.swf">';
		output += '<param name="quality" value="high">';
		output += '<embed src="swf/homepage.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="735" height="104"></embed>';
		output += '</object>';
	}
	else
	{
		output += '<img src="images/scroll_backup.jpg" width="735" height="104">';
	}
	
	document.write(output);
}

function write_nav(primary, secondary)
{
	if(hasRightVersion) {  // if we've detected an acceptable version
	 var arg_str = "";
	 if(primary != "")
	{
		arg_str = "?primary="+primary;
		
		if(secondary != "")
			arg_str += "&secondary="+secondary;
	}
	
    var oeTags = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
    + 'width="735" height="60"'
    + 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">'
    + '<param name="movie" value="/swf/somera_nav_bar.swf'+arg_str+'" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />'
    + '<embed src="/swf/somera_nav_bar.swf'+arg_str+'" quality="high" bgcolor="#ffffff" '
    + 'width="735" height="60" name="somera_nav_bar" align="middle"'
    + 'play="true"'
    + 'loop="false"'
    + 'quality="high"'
    + 'allowScriptAccess="sameDomain"'
    + 'type="application/x-shockwave-flash"'
    + 'pluginspage="http://www.macromedia.com/go/getflashplayer">'
    + '<\/embed>'
    + '<\/object>';
    document.write(oeTags);   // embed the flash movie
  } else {  // flash is too old or we can't detect the plugin
    var alternateContent = get_html_nav(primary, secondary);
    document.write(alternateContent);  // insert non-flash content
  }
}

function get_html_nav(primary, secondary)
{
	var rtn = "";
	
	var about_class = (primary == "aboutUs") ? "class='selected'" : "";
	var ourinvest_class = (primary == "ourInvestments") ? "class='selected'" : "";
	var investcrit_class = (primary == "investmenCriteria") ? "class='selected'" : "";
	var contact_class = (primary == "contact") ? "class='selected'" : "";
	
	rtn += '<div class="html_nav">';
	rtn += '<div class="top"></div>';
	rtn += '<div class="primary"><a href="/">home</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="/about_us/" '+about_class+'>about us</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="/our_invest/" '+ourinvest_class+'>our investments</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="/invest_criteria/" '+investcrit_class+'>investment criteria</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="/contact/" '+contact_class+'>contact</a></div>';
	rtn += get_secondary_nav(primary, secondary);
	rtn += '<div class="bottom"></div>';
	rtn += '</div>';
	
	return rtn;
}

function get_secondary_nav(primary, secondary)
{
	var rtn = "";
	
	if(primary == "aboutUs")
	{
		var mge_team = (secondary == "managementTeam") ? "class='selected'" : "";
		var pro_staff = (secondary == "professionalStaff") ? "class='selected'" : "";
		var stg_partners = (secondary == "strategicPartners") ? "class='selected'" : "";
		var our_phpy = (secondary == "ourPhilosophy") ? "class='selected'" : "";
		var news_press = (secondary == "newsAndPress") ? "class='selected'" : "";
		
		rtn  = '<div class="secondary">';
		rtn += '<a href="/about_us/mge_team.html" '+mge_team+'>management team</a>';
		rtn += '&nbsp;&nbsp;|&nbsp;&nbsp;';
		rtn += '<a href="/about_us/pro_staff.html" '+pro_staff+'>professional staff</a>';
		rtn += '&nbsp;&nbsp;|&nbsp;&nbsp;';
		rtn += '<a href="/about_us/stg_partners.html" '+stg_partners+'>strategic partners</a>';
		rtn += '&nbsp;&nbsp;|&nbsp;&nbsp;';
		rtn += '<a href="/about_us/our_phpy.html" '+our_phpy+'>our philosophy</a>';
		rtn += '&nbsp;&nbsp;|&nbsp;&nbsp;';
		rtn += '<a href="/about_us/news_press/" '+news_press+'>news and press</a>';
		rtn += '</div>';
	}
	else if(primary == "ourInvestments")
	{
		var office = (secondary == "office") ? "class='selected'" : "";
		var retail = (secondary == "retail") ? "class='selected'" : "";
		var multifamily = (secondary == "multifamily") ? "class='selected'" : "";
		var hospitality = (secondary == "hospitality") ? "class='selected'" : "";
		var other = (secondary == "other") ? "class='selected'" : "";
		
		rtn  = '<div class="secondary">';
		rtn += '<a href="/our_invest/view_properties.php?type=Office" '+office+'>management team</a>';
		rtn += '&nbsp;&nbsp;|&nbsp;&nbsp;';
		rtn += '<a href="/our_invest/view_properties.php?type=Retail" '+retail+'>professional staff</a>';
		rtn += '&nbsp;&nbsp;|&nbsp;&nbsp;';
		rtn += '<a href="/our_invest/view_properties.php?type=Multi-family" '+multifamily+'>strategic partners</a>';
		rtn += '&nbsp;&nbsp;|&nbsp;&nbsp;';
		rtn += '<a href="/our_invest/view_properties.php?type=Hospitality" '+hospitality+'>our philosophy</a>';
		rtn += '&nbsp;&nbsp;|&nbsp;&nbsp;';
		rtn += '<a href="/our_invest/view_properties.php?type=Other" '+other+'>news and press</a>';
		rtn += '</div>';
	}
	else if(primary == "investmentCriteria")
	{
		var generalAcquisition = (secondary == "generalAcquisition") ? "class='selected'" : "";
		var regionalMallAcquisition = (secondary == "regionalMallAcquisition") ? "class='selected'" : "";
		var jointVentureInvestment = (secondary == "jointVentureInvestment") ? "class='selected'" : "";
		
		rtn  = '<div class="secondary">';
		rtn += '<a href="/invest_criteria/" '+generalAcquisition+'>management team</a>';
		rtn += '&nbsp;&nbsp;|&nbsp;&nbsp;';
		rtn += '<a href="/invest_criteria/reg_mall_invest.html" '+regionalMallAcquisition+'>professional staff</a>';
		rtn += '&nbsp;&nbsp;|&nbsp;&nbsp;';
		rtn += '<a href="/invest_criteria/joint_invest.html" '+jointVentureInvestment+'>strategic partners</a>';
		rtn += '</div>';
	}
	
	return rtn;
}