// flash embed

function create(FO) {
	document.write ('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="'
					+ FO.width + '" height="' + FO.height + '" wmode="transparent">'+'<PARAM NAME=movie VALUE="' + FO.movie + '">'+
					'<PARAM NAME="quality" value="high"><param name="wmode" value="transparent">'+'<EMBED src="' + FO.movie + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'
					+ FO.width +'" height="' + FO.height + '" swliveconnect="true" wmode="transparent">'+'</embed></object>');
};

// some standard dreamweaver scripts

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

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,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){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function currentdate() {
	var d=new Date()
	var year=d.getFullYear()
	document.write(year)
}

function MM_showHideLayers() { //v9.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

// clear address field

function onprodClear() {
	if (document.getElementById("saddr").value == "Enter Starting Address") {
		document.getElementById("saddr").value = "";
	} else if (document.getElementById("saddr").value == "") {
		document.getElementById("saddr").value = "Enter Starting Address";
	}
};
function setbg(id, color) {
	document.getElementById(id).style.background=color;
}

function disclaimer() { //v1.0
  alert("In a continuing effort to improve our homes, The Islands at Riverlake-Sacramento, LLC reserves the right to make changes and modifications to plans, elevations, specifications, features, colors and prices without prior notice. Renderings, landscaping and maps are artists' conception and are not to scale. All dimensions and square footages are approximate.");
}

// contact form

function MM_validateForm() { //v4.0
    
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { fn=val.alt; nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+fn+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');

}

/* background stretch */

(function(a){a.backstretch=function(k,i,l){function m(c){try{f={left:0,top:0};d=e.width();b=d/j;if(b>=e.height()){g=(b-e.height())/2;h.centeredY&&a.extend(f,{top:"-"+g+"px"})}else{b=e.height();d=b*j;g=(d-e.width())/2;h.centeredX&&a.extend(f,{left:"-"+g+"px"})}a("#backstretch img").width(d).height(b).css(f)}catch(n){}typeof c=="function"&&c()}var h={centeredX:true,centeredY:true,speed:0},e="onorientationchange"in window?a(document):a(window),j,d,b,g,f;i&&typeof i=="object"&&a.extend(h,i);a(document).ready(function(){if(k){var c= a("<div />").attr("id","backstretch").css({left:0,top:0,position:"fixed",overflow:"hidden",zIndex:-9999}),n=a("<img />").css({position:"relative",display:"none"}).bind("load",function(o){var p=a(this);j=a(o.target).width()/a(o.target).height();m(function(){p.fadeIn(h.speed,function(){typeof l=="function"&&l()})})}).appendTo(c);a("body").prepend(c);n.attr("src",k);a(window).resize(m)}});return this}})(jQuery);

/* load news */

String.prototype.truncate = function(){
    var re = this.match(/^.{0,110}[\S]*/);
    var l = re[0].length;
    var re = re[0].replace(/\s$/,'');
    if(l < this.length)
        re = re + "...";
    return re;
}

$(document).ready(function(){
	var date = new Date();
	$.getJSON("http://www.regishomessacramento.com/islandsatriverlake/news/feed/?feed=json&jsonp=?",
		 function(data){
				entry = data[0];

				var monthNames = [ "January", "February", "March", "April", "May", "June",
													 "July", "August", "September", "October", "November", "December" ];
				var d = new Date(entry.date);
				var date = monthNames[d.getMonth()] + " " + d.getDate() + ", " + d.getFullYear();
				$("#newsContainerDate").html(date);                
				var title = entry.title;
				$("#newsContainerTitle").html(title);

				var content = entry.excerpt;
				
				content = content.truncate();
				
				content = content + " <a href=\"http://www.regishomessacramento.com/islandsatriverlake/news/\">More &gt;</a>";
				$("#newsContainerContent").html(content);

	 });
});
