var cookies = document.cookie.split("; ");
function GetCookie(name) {
	for (var i=0; i < cookies.length; i++) {
		var cookie = cookies[i].split("=");
		if (cookie[0] == name) {
			return unescape(cookie[1]);
		}
	}
	return null;
}


function SetCookie(name, value, expiration) {
	if (name && value && name != "" && value != "") {
		cookies = name + "=" + escape(value) + ";";
		if (expiration) {
			cookies += " expires=" + expiration.toGMTString();
		}
		document.cookie = cookies;
		cookies = document.cookie.split("; ");
	}
}


function SetLeftColumnMedia () {
	var imageCount = 7;
	var i = Math.round(imageCount*Math.random()) + 1;
	if (i>imageCount) { i = imageCount; }
	
	//var flashCount = 1;
	//var j = Math.round(flashCount*Math.random()) + 1;
	//if (j>flashCount) { j = flashCount; }

	var today = new Date();
	var expiry = new Date(today.getTime() + 1 * 24 * 60 * 60 * 1000); // plus 1 days
	var thisCookie = GetCookie ("FirstVisit");
	var secondCookie = GetCookie ("SecondVisit");
	 
	// var thisCookie = null;
	/*
	 if (thisCookie == null) {
		SetCookie ("FirstVisit", today, null);
		thisCookie = GetCookie ("FirstVisit");
		if (document.all && document.all.LeftFlashObject) {
			document.all.LeftFlashObject.Movie = "/swfs/index/" + j + ".swf";
		}
		else if (!document.all && document.getElementById ("LeftFlashEmbed")) {
			var objLeftFlashEmbed = document.getElementById ("LeftFlashEmbed");
			if (objLeftFlashEmbed.loadMovie) {
				document.getElementById ("LeftFlashEmbed").src = "/swfs/index/" + j + ".swf";
			}
			else {
				var objLeftColumnMedia = document.getElementById ("LeftColumnMedia");
				if (objLeftColumnMedia && objLeftColumnMedia.innerHTML) {
						objLeftColumnMedia.innerHTML = "";
						objLeftColumnMedia.innerHTML = '<embed height="166" width="501" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" quality="high" scale="exactfit" src="/swfs/index/' + j + '.swf" id="LeftFlashEmbed" wmode="transparent"></embed>';
				}
			}
		}
		else {
			document.write ('<img border="0" alt="" id="LeftPhoto" height="166" width="501" src="/images/index/Photos/' + i + '.jpg">');
		}

		if (document.all && document.all.LeftFlashObject) {
			document.all.LeftFlashObject.style.display = "none";
		}
		else if (!document.all && document.getElementById ("ColumnOneMedia")) {
			document.getElementById ("ColumnOneMedia").style.display = "none";
		}
		document.write ('<a href="http://www.realtor.org/educsess.nsf/pageslu/tlcmainpage" target="NewWindow"><img border="0" alt="" id="LeftPhoto" height="166" width="501" src="images/index/06-2067NARbannerAd.gif"></a>');
	}
	else {
		*/
		if (document.all && document.all.LeftFlashObject) {
			document.all.LeftFlashObject.style.display = "none";
		}
		else if (!document.all && document.getElementById ("LeftFlashEmbed")) {
			document.getElementById ("LeftFlashEmbed").style.display = "none";
		}
		if (thisCookie == null) {
			SetCookie ("FirstVisit", today, null);
			thisCookie = GetCookie ("FirstVisit");
			/*
			document.write ('<a href="http://http.dvlabs.com/chaffee/eClosing_mpeg_4.mov" target="Ext" style="display: block; position: relative; z-index: 999999;">');
			document.write ('<img border="0" alt="" id="LeftPhoto" height="166" width="501" src="/images/index/Photos/8.jpg">');
			document.write ('</a>');
			*/
			document.write ('<img border="0" alt="" id="LeftPhoto" height="166" width="501" src="/images/index/LimitedRunPhotos/commercial.jpg">');
		}
		else if (secondCookie == null) {
			SetCookie ("SecondVisit", today, null);
			thisCookie = GetCookie ("SecondVisit");
			document.write ('<img border="0" alt="" id="LeftPhoto" height="166" width="501" src="/images/index/LimitedRunPhotos/residential.jpg">');
		}
		else {
			document.write ('<img border="0" alt="" id="LeftPhoto" height="166" width="501" src="/images/index/Photos/' + i + '.jpg">');
		}
	//}
}
function showHideFlashObject (a){ 
  var g,h=(a==1)?"hidden":"visible";
  if(document.getElementsByTagName){
  	g=document.getElementsByTagName("embed");
  	if(g){
		for(var i=0;i<g.length;i++){
  			g[i].style.visibility=h;
		}}
	}
}  

