// FLASH
// version of Flash required
var requiredMajorVersion = 9;

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;

function GetSwfVer() {
    var flashVer = -1;
    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;
            var descArray = flashDescription.split(" ");
            var tempArrayMajor = descArray[2].split(".");
            var versionMajor = tempArrayMajor[0];
            flashVer = versionMajor;
        }
    } else if (isIE && isWin && !isOpera) {
        var version, axo, e;
        try { axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7"); version = axo.GetVariable("$version"); } catch (e) { }
        if (!version) {
            try { axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6"); version = "WIN 6,0,21,0"; axo.AllowScriptAccess = "always"; version = axo.GetVariable("$version"); } catch (e) { }
        }
        flashVer = version;
    }
    return flashVer;
}

function DetectFlashVer(reqMajorVer) {
	versionStr = GetSwfVer();
	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("."); }
		var versionMajor = versionArray[0];
		if (versionMajor >= parseFloat(reqMajorVer)) { return true;	}
		return false;
	}
}

var hasProductInstall = DetectFlashVer(6, 0, 65);
var hasReqestedVersion = DetectFlashVer(requiredMajorVersion);
var hasFlash = hasReqestedVersion;

function writeFlash(ourSwf,ourWidth,ourHeight,ourBg,msgOrPage,noFlashMsg,flashvar) {
	if (hasFlash) {
	 	document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
        document.write('  codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ');
        document.write(' ID=FLASH_AD WIDTH='+ourWidth+' HEIGHT='+ourHeight+'>');
        if (ourBg == 'transparent') { document.write(' <PARAM NAME=movie VALUE="' + ourSwf + '"> <param name="AllowScriptAccess" value="always"> <PARAM NAME="allowFullScreen" VALUE="true"> <PARAM NAME=FlashVars VALUE="' + flashvar + '"> <PARAM NAME=quality VALUE=high> <PARAM NAME="wmode" VALUE="transparent"> '); }
        else if (ourBg != '') { document.write(' <PARAM NAME=movie VALUE="' + ourSwf + '"> <param name="AllowScriptAccess" value="always"> <PARAM NAME="allowFullScreen" VALUE="true"> <PARAM NAME=FlashVars VALUE="' + flashvar + '"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=' + ourBg + '> '); }
        else if (ourBg == '') { document.write(' <PARAM NAME=movie VALUE="' + ourSwf + '"> <param name="AllowScriptAccess" value="always"> <PARAM NAME="allowFullScreen" VALUE="true"> <PARAM NAME=FlashVars VALUE="' + flashvar + '"> <PARAM NAME=quality VALUE=high>'); }
        document.write(' <EMBED src="' + ourSwf + '" FlashVars="' + flashvar + '" allowscriptaccess="always" allowFullscreen="true" quality=high swLiveConnect=TRUE WIDTH=' + ourWidth + ' HEIGHT=' + ourHeight);
		if(ourBg=='transparent') { document.write(' WMODE="transparent"'); } 
		else if(ourBg!='') { document.write(' bgcolor='+ourBg);	}
		document.write(' TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">');
        document.write(' </EMBED>'); document.write(' </OBJECT>');
	} else { // if the right flash player version has not been found:
		if (msgOrPage==1) { document.write('<meta http-equiv="Refresh" content="1; URL='+noFlashMsg+'">'); }
		else if (msgOrPage==2) { popup(noFlashMsg,'noflash',350,350); }
		else if (msgOrPage==3) { document.write('<a href="http://www.adobe.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" target="_blank">'+noFlashMsg+'</a>');  }
	}	
}

// lightview style pop up
var pid;
function hidePop() { document.getElementById('bopop').style.visibility = 'hidden';document.getElementById('pop1').style.display = 'none';ie6Form('visible');document.getElementById('viewframe').style.display = 'none';window.tour.location='/virtualblank.html'; }
function showVideo() { 
	getPageSize();
    
    try
    {
        pageTracker._trackEvent("video", "play", "virtualtour");
    }
    catch (err) {}
        
	document.getElementById('fade').style.height = pageHeight;
	document.getElementById('pop1').style.display = 'block';
	document.getElementById('bopop').style.visibility = 'visible';
	ie6Form('hidden');
	document.getElementById('viewframe').style.display = 'block';	
	window.tour.location='/virtualtour.html';
	//swfobject.embedSWF("/delamar.swf", "flcontent", "720", "480", "9.0.45", "/expressInstall.swf", flashvars, params, attributes);
} 
var pageWidth,pageHeight;
function getPageSize() {	        
    var xScroll, yScroll;	
	if (window.innerHeight && window.scrollMaxY) {	xScroll = window.innerWidth + window.scrollMaxX;yScroll = window.innerHeight + window.scrollMaxY; } 
	else if (document.body.scrollHeight > document.body.offsetHeight){ xScroll = document.body.scrollWidth;yScroll = document.body.scrollHeight; } 
	else { xScroll = document.body.offsetWidth;yScroll = document.body.offsetHeight; }	
	var windowWidth, windowHeight;	
	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){ windowWidth = document.documentElement.clientWidth; } 
		else { windowWidth = self.innerWidth;	}
		windowHeight = self.innerHeight;
	} 
	else if (document.documentElement && document.documentElement.clientHeight) { windowWidth = document.documentElement.clientWidth;windowHeight = document.documentElement.clientHeight; } 
	else if (document.body) { windowWidth = document.body.clientWidth;windowHeight = document.body.clientHeight; }		
	if(yScroll < windowHeight){	pageHeight = windowHeight; } else { pageHeight = yScroll; }
	if(xScroll < windowWidth){ 	pageWidth = xScroll; } else { pageWidth = windowWidth; }
	return [pageWidth,pageHeight];	
}

function ie6Form(state) {	
	if (document.all) {
		var version=/MSIE \d+.\d+/;var brwsr=navigator.appVersion.match(version);
		if ((""+brwsr).indexOf("6")>0) {
			var frmInput=new Array();frmInput=document.getElementsByTagName("input");var stop1=frmInput.length;
			for (var i=0;i<stop1;i++) { frmInput[i].style.visibility=state;	}
			var frmSelect=new Array();frmSelect=document.getElementsByTagName("select");var stop2=frmSelect.length;
			for (var i=0;i<stop2;i++) { frmSelect[i].style.visibility=state; }
			var frmTextarea=new Array();frmTextarea=document.getElementsByTagName("textarea");var stop3=frmTextarea.length;
			for (var i=0;i<stop3;i++) { frmTextarea[i].style.visibility=state; }
		}
	}
}




// Image rollover code
function over(id) {
	var str=id.src;
	if (str.match(".png")) { id.src=str.replace(/.png/,"_on.png"); }
	if (str.match(".jpg")) { id.src=str.replace(/.jpg/,"_on.jpg"); }
	if (str.match(".gif")) { id.src=str.replace(/.gif/,"_on.gif"); }
}
function out(id) {
	var str=id.src;
	if (str.match(".png")) { id.src=str.replace(/_on.png/,".png"); }
	if (str.match(".jpg")) { id.src=str.replace(/_on.jpg/,".jpg"); }
	if (str.match(".gif")) { id.src=str.replace(/_on.gif/,".gif"); }
}

function siteBg() {
	var bgamount=7;
	randomNum=Math.floor((Math.random()*bgamount)+1);
	//document.getElementById('bdy').style.backgroundImage='url(/Contentfiles/background/bg'+randomNum+'.jpg)';
}

function checkImgs() {	
	if (document.getElementById('wysiswyg')){
		var myLinks = new Array();
	    myLinks = document.getElementById('wysiswyg').getElementsByTagName("a");
		for (var i=0; i < myLinks.length; i++) {
	        if (myLinks[i].getElementsByTagName("img").length > 0) {
	            myLinks[i].style.border='0px';
	        }
	    }
		myLinks = null;
	}
}

function toggleDates() {
	var state=document.getElementById('datelinks').style.display;
	if (state=='none') { document.getElementById('datelinks').style.display='block'; }
	else { document.getElementById('datelinks').style.display='none'; }
}

function initAll() {
	siteBg();
	checkImgs();
	try { getContent(); }
	catch(e) {}
}

$(document).ready(function() {
    $('input').focus(function() {
        $(this).select();
    });
});

//onload=initAll;





