/* sni-hgtv - Tue, 07 Jun 2011 10:18:35 -0400 */

if( typeof(SNI.HGTV) == "undefined" ) {
	SNI.HGTV = {};
}

;(function(d){var k=d.scrollTo=function(a,i,e){d(window).scrollTo(a,i,e)};k.defaults={axis:'xy',duration:parseFloat(d.fn.jquery)>=1.3?0:1};k.window=function(a){return d(window)._scrollable()};d.fn._scrollable=function(){return this.map(function(){var a=this,i=!a.nodeName||d.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!i)return a;var e=(a.contentWindow||a).document||a.ownerDocument||a;return d.browser.safari||e.compatMode=='BackCompat'?e.body:e.documentElement})};d.fn.scrollTo=function(n,j,b){if(typeof j=='object'){b=j;j=0}if(typeof b=='function')b={onAfter:b};if(n=='max')n=9e9;b=d.extend({},k.defaults,b);j=j||b.speed||b.duration;b.queue=b.queue&&b.axis.length>1;if(b.queue)j/=2;b.offset=p(b.offset);b.over=p(b.over);return this._scrollable().each(function(){var q=this,r=d(q),f=n,s,g={},u=r.is('html,body');switch(typeof f){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)){f=p(f);break}f=d(f,this);case'object':if(f.is||f.style)s=(f=d(f)).offset()}d.each(b.axis.split(''),function(a,i){var e=i=='x'?'Left':'Top',h=e.toLowerCase(),c='scroll'+e,l=q[c],m=k.max(q,i);if(s){g[c]=s[h]+(u?0:l-r.offset()[h]);if(b.margin){g[c]-=parseInt(f.css('margin'+e))||0;g[c]-=parseInt(f.css('border'+e+'Width'))||0}g[c]+=b.offset[h]||0;if(b.over[h])g[c]+=f[i=='x'?'width':'height']()*b.over[h]}else{var o=f[h];g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o}if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],m);if(!a&&b.queue){if(l!=g[c])t(b.onAfterFirst);delete g[c]}});t(b.onAfter);function t(a){r.animate(g,j,b.easing,a&&function(){a.call(this,n,b)})}}).end()};k.max=function(a,i){var e=i=='x'?'Width':'Height',h='scroll'+e;if(!d(a).is('html,body'))return a[h]-d(a)[e.toLowerCase()]();var c='client'+e,l=a.ownerDocument.documentElement,m=a.ownerDocument.body;return Math.max(l[h],m[h])-Math.min(l[c],m[c])};function p(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);
SNI.HGTV.TakeOverHeader={init:function(){var $nav=$("#takeover-nav");SNI.HGTV.TakeOverHeader.setTakeoverTab($nav,SNI.HGTV.GlobalHeader.globalNav.getTabsToSelect(mdManager));SNI.HGTV.TakeOverHeader.globalSearch();},globalSearch:function(){var $search=$("#hd-search-input");if($search.val()!==""){$search.parent().find("label span").hide();}
$(function(){if($search.val()!==""){$search.parent().find("label span").hide();}});$search.focus(function(){$search.parents("#takeover-search").addClass("longbox");$search.parent().find("label span").addClass("focus");this.onkeydown=function(){$search.parent().find("label span").hide();};}).blur(function(){if($search.val()===""){$search.parent().find("label span").show().removeClass("focus");}
$search.parents("#takeover-search").removeClass("longbox");});$("#hgSearchForm").submit(function(){if($search.val()===""){$search.focus();return false;}else{return true;}});},setTakeoverTab:function($nav,oTabs){var $tTabs,$tTab;$tTabs=$nav.children("li");$tTabs.removeClass("sel");$tTab=$tTabs.filter("li.tab-"+oTabs.tTab);if($tTab.length>0){$tTab.addClass("sel");}
return;},setTentpoleTab:function(){var hook=$("#body-hook").attr('rel'),pagetype;if(typeof(hook)!=='undefined'&&hook!==null){pagetype=hook.slice(4);$("#tentpole-menu").find("li.tab-"+pagetype).addClass("sel");}else if(mdManager.getParameter("Type")=="SECTION"){$("#tentpole-menu").children("li").eq(0).addClass("sel");}}};
(function($){$.fn.countDown=function(options){var options=$.extend({date:'January 1, 2099 00:00:00',updateInterval:1,wraps:null,onExpire:function(){}},options);return this.each(function(i){var obj=this;var today=new Date();var endDate=new Date(options.date);var ms=Math.floor(endDate.getTime()-today.getTime())
function two(x){return((x>9)?"":"0")+x}
function three(x){return((x>99)?"":"0")+((x>9)?"":"0")+x}
function MS2DHMSMS(ms){var nt={};var sec=Math.floor(ms/1000);ms=ms%1000;nt.ms=three(ms).toString();var min=Math.floor(sec/60);sec=sec%60;nt.ss=two(sec).toString();var hr=Math.floor(min/60);min=min%60;nt.mm=two(min).toString();var day=Math.floor(hr/24);hr=hr%24;nt.hh=two(hr).toString();nt.dd=day.toString();return nt;}
function getTimeLeft(){var today=new Date();var ms=Math.floor(endDate.getTime()-today.getTime())
sLeft=MS2DHMSMS(ms).ss;mLeft=MS2DHMSMS(ms).mm;hLeft=MS2DHMSMS(ms).hh;dLeft=MS2DHMSMS(ms).dd;if(options.wraps==null)
$(obj).html('<span class="jcdDays">'+dLeft+'</span>&nbsp;<span class="jcdDaysText">day'+s+'</span>&nbsp;<span class="jcdHours">'+hLeft+'</span>:<span class="jcdMinutes">'+mLeft+'</span>:<span class="jcdSeconds">'+sLeft+'</span>');else{for(x in options.wraps){if(x=='days')$(options.wraps[x]).html(dLeft);if(x=='hours')$(options.wraps[x]).html(hLeft);if(x=='minutes')$(options.wraps[x]).html(mLeft);if(x=='seconds')$(options.wraps[x]).html(sLeft);}}};if(parseInt(MS2DHMSMS(ms).dd)<0)
options.onExpire.call(this,obj);else
if(options.updateInterval)setInterval(function(){getTimeLeft();},options.updateInterval*500);else getTimeLeft();});};})(jQuery);SNI.HGTV.timer={init:function(timer_data){for(var i=0;i<timer_data.length;i++){var now=new Date();now=now.getTime();var then=new Date(timer_data[i].date);then=then.getTime();if(then>now){var date=timer_data[i].date;var message=timer_data[i].message;SNI.HGTV.timer.countdown(date,now,then);SNI.HGTV.timer.message(message);break;}else{if(i==timer_data.length-1){$(".countdown").hide();}}};},countdown:function(date,now,then){var diff=Math.floor(then-now);var sec=Math.floor(diff/1000);var mn=Math.floor(sec/60);sec=sec%60;sec=SNI.HGTV.timer.two(sec);var hr=Math.floor(mn/60);mn=mn%60;mn=SNI.HGTV.timer.two(mn);var day=Math.floor(hr/24);hr=hr%24;hr=SNI.HGTV.timer.two(hr);document.getElementById('cdDays').innerHTML=day;document.getElementById('cdHours').innerHTML=hr;document.getElementById('cd_minutes').innerHTML=mn;document.getElementById('cd_seconds').innerHTML=sec;t=setTimeout('SNI.HGTV.timer.init(timer_data)',500);},two:function(x){return((x>9)?"":"0")+x;},message:function(message){document.getElementById('cd_additional_text').innerHTML=message;}}
if(typeof(SNI.HGTV.SweepsInvite)=="undefined"){SNI.HGTV.SweepsInvite={};}
SNI.HGTV.SweepsInvite={invite:"#sweeps-invite",revealModule:function(trigger,module){$(SNI.HGTV.SweepsInvite.invite).find(trigger).click(function(){module.fadeIn(SNI.HGTV.ANIMATION_SPEED);$(this).addClass("active");return false;})},closeModule:function(trigger,module,speed){if(speed==null){speed=SNI.HGTV.ANIMATION_SPEED;};module.fadeOut(speed);if($(trigger).hasClass("active")){$(trigger).removeClass("active");};},inviteAFriend:function(){var module=$("#invite-a-friend");var form=module.find("form");var null_value="";SNI.HGTV.Omniture.ClickTrackSingleCustom("#invite-button","GH09:InviteFriends","prop2","")
SNI.HGTV.SweepsInvite.revealModule(".email",module);$(".close").click(function(){SNI.HGTV.SweepsInvite.closeModule(".email",module);});$(".form-submit a").click(function(){SNI.HGTV.SweepsInvite.closeModule(".email",module);return false;});form.validate({errorLabelContainer:false,rules:{from_name:{required:true},from_email:{required:true,email:true},to_emails:{required:true,multipleEmails:true}},messages:{from_name:{required:"Whoops. Please enter your name."},from_email:{required:"Whoops. Please enter your e-mail address.",email:"Whoops. Please check the format of your e-mail address and re-enter (i.e. joe@hgtv.com)."},to_emails:{required:"Whoops. Please enter at least one friend e-mail address.",multipleEmails:"Whoops. One or more of your friend e-mail addresses is not formatted correctly. Please check the format and re-enter (i.e. joe@hgtv.com)."}},showErrors:function(errorMap,errorList){if(errorList.length){module.find('.message').addClass('alert').html(errorList[0].message);element=$(errorList[0].element);if(element.hasClass('isemail')){element.select();}
this.errorList=[this.errorList[0]];this.defaultShowErrors();}},submitHandler:function(){var txtarea=form.find('textarea[name="body"]');msg_body_full=form.find('input[name="from_name"]').val()+msg_body;txtarea.val(msg_body_full);module.find('.message').hide().removeClass("alert");form.find('fieldset').hide();form.find("label").removeClass("error");form.find('button').addClass('disabled').attr('disabled','disabled');form.find('.cancel').addClass("disabled");form.find('.loading').show();var form_data="";form.find(":input:not('button')").each(function(){var input_name=$(this).attr("name");var input_value=$(this).val();form_data+=input_name+"="+input_value+"&";});$.ajax({type:"POST",url:form.attr("action"),data:form_data.slice(0,-1),cache:false,success:function(data){form.find('.loading').hide();var response=$(data);var emailSent=response.eq(7).text();if(emailSent=="false"){form.find('fieldset').show();form.find('button').removeClass('disabled').removeAttr('disabled');form.find('.cancel').removeClass("disabled");form.find("label[for='friends-email']").addClass("error");$("#friends-email").select();module.find('.message').addClass("alert").text("Whoops. The e-mail could not be sent to one or more of your friends. Please check the format of their e-mail address and re-enter (i.e. joe@HGTV.com).").show();}else{var success=module.find('.success');form.hide();success.show();var timeout=setTimeout(function(){SNI.HGTV.SweepsInvite.closeModule(".email",module,300);module.hide();success.hide();module.find('.message').text("All fields are required.").show();form.find("input:text").each(function(){$(this).val("");});form.find('button').removeClass('disabled').removeAttr('disabled');form.find('.cancel').removeClass("disabled");form.find('fieldset').show();form.show();},3000);$(".close").click(function(){clearTimeout(timeout);SNI.HGTV.SweepsInvite.closeModule(".email",module);module.hide();success.hide();module.find('.message').text("All fields are required.").show();form.find("input:text").each(function(){$(this).val("");});form.find('button').removeClass('disabled').removeAttr('disabled');form.find('.cancel').removeClass("disabled");form.find('fieldset').show();form.show();});}},error:function(){form.find('.loading').hide();form.find('fieldset').show();form.find('button').removeClass('disabled').removeAttr('disabled');form.find('.cancel').removeClass("disabled");module.find('.message').addClass("alert").text("Whoops. We encountered an error when trying to e-mail this page. Please wait a few moments and try again.").show();}});}});}};
if(typeof(SNI.HGTV.Sweepstakes)==="undefined"){SNI.HGTV.Sweepstakes={};}
SNI.HGTV.Sweepstakes={premier:{init:function(){SNI.HGTV.Sweepstakes.checkAll($(".hgtv-nl"));SNI.HGTV.Sweepstakes.closeErrors();var form=$("#sweepsEntryForm");var _ckVals=SNI.Util.Cookie.get('sniPremSweepsVals');_xemail='';if(_ckVals!==null){var _aryCkVals=_ckVals.split('|');_xemail=_aryCkVals[0];if(_aryCkVals[1]!==undefined){_xfn=_aryCkVals[1];}else{_xfn='';}
if(_aryCkVals[2]!==undefined){_xln=_aryCkVals[2];}else{_xln='';}
if(_aryCkVals[3]!==undefined){_xaddy=_aryCkVals[3];}else{_xaddy='';}
if(_aryCkVals[4]!==undefined){_xcity=_aryCkVals[4];}else{_xcity='';}
if(_aryCkVals[5]!==undefined){_xstate=_aryCkVals[5];}else{_xstate=0;}
if(_aryCkVals[6]!==undefined){_xzip=_aryCkVals[6];}else{_xzip='';}
if(_aryCkVals[7]!=undefined){_xphone=_aryCkVals[7];}else{_xphone='';}
if(_aryCkVals[8]!=undefined){_xgender=_aryCkVals[8];}else{_xgender=null;}}
$("#fvEmail").blur(function(){SNI.HGTV.Sweepstakes.premier.checkCkVals($("#fvEmail").val(),form);});var validator=form.validate({errorContainer:'#sweepsEntryForm div.form-errors',errorLabelContainer:'#sweepsEntryForm div.form-errors ul',wrapper:"li",rules:{fvFirstName:"required",fvLastName:"required",fvAddress1:"required",fvCity:"required",fvState:"required",fvZip:{required:true,zipUS:true},fvEvePhone:{required:true,phoneUS:true},fvEmail:{required:true,email:true},fvConfirmEmail:{required:true,equalTo:"#fvEmail"},fvGender:"required"},messages:{fvFirstName:"Please enter your first name",fvLastName:"Please enter your last name",fvAddress1:"Please enter your address",fvCity:"Please enter your city",fvState:"Please select your state",fvZip:"Please enter a valid ZIP code",fvEvePhone:"Please enter a valid phone number with area code",fvEmail:"Please enter an e-mail address",fvConfirmEmail:"Please make sure your e-mails match",fvGender:"Please select your gender"},showErrors:function(errorMap,errorList){if(errorList.length){this.defaultShowErrors();SNI.HGTV.Sweepstakes.scrollTop();}},submitHandler:function(form){if(window.onbeforeunload!="undefined"){window.onbeforeunload=null;}
SNI.HGTV.Sweepstakes.premier.phoneSplit();SNI.HGTV.Sweepstakes.premier.ckInit();form.submit();}});},phoneSplit:function(){var fvEvePhone=$("#fvEvePhone").val();var fvAreaCode=fvEvePhone.match(/\([2-9]\d{2}\)|[2-9]\d{2}/);var fvPhone=fvEvePhone.match(/[2-9]\d{2}-?\s?\d{4}/);$("#fvAreaCode").val(fvAreaCode);$("#fvPhone").val(fvPhone);},ckInit:function(){var _email=$("#fvEmail").val();var _fn=$("#fvFirstName").val();var _ln=$("#fvLastName").val();var _addy=$("#fvAddress1").val();var _city=$("#fvCity").val();var _state=$("#fvState").val();var _zip=$("#fvZip").val();var _phone=$("#fvEvePhone").val();if($('#sweepsEntryForm input[name="fvGender"]').eq(0).attr("checked")===true){var _gender='m';}else{_gender='f';}
var _ckVals=_email+'|'+_fn+'|'+_ln+'|'+_addy+'|'+_city+'|'+_state+'|'+_zip+'|'+_phone+'|'+_gender;SNI.Util.Cookie.set('sniPremSweepsVals',_ckVals,365);},checkCkVals:function(userEmail,form){if(userEmail!=""&&userEmail==_xemail){$("#fvConfirmEmail").val($("#fvEmail").val());if($("#fvFirstName").val()===''){$("#fvFirstName").val(_xfn);}
if($("#fvLastName").val()===''){$("#fvLastName").val(_xln);}
if($("#fvAddress1").val()===''){$("#fvAddress1").val(_xaddy);}
if($("#fvCity").val()===''){$("#fvCity").val(_xcity);}
if($("#fvState").val()===''){$("#fvState").val(_xstate);}
if(form.find('dt a').html()==='Select<em></em>'||form.find('dt a').html()==='Select<EM></EM>'){form.find('dt a').html(_xstate+'<em></em>');}
if($("#fvZip").val()===''){$("#fvZip").val(_xzip);}
if($("#fvEvePhone").val()===''){$("#fvEvePhone").val(_xphone);}
if(form.find('input[name="fvGender"]').eq(0).attr("checked")===false&&form.find('input[name="fvGender"]').eq(1).attr("checked")===false){if(_xgender!==null){if(_xgender=='m'){form.find('input[name="fvGender"]').eq(0).attr({checked:"true"});}else{form.find('input[name="fvGender"]').eq(1).attr({checked:"true"});}}}}}},init:function(){SNI.HGTV.Sweepstakes.checkAll($(".hgtv-nl"));SNI.HGTV.Sweepstakes.closeErrors();var form=$("#sweepsEntryForm");var _ckVals=SNI.Util.Cookie.get('sniSweepsVals');_xemail='';if(_ckVals!==null){var _aryCkVals=_ckVals.split('|');_xemail=_aryCkVals[0];if(_aryCkVals[1]!==undefined){_xfn=_aryCkVals[1];}else{_xfn='';}
if(_aryCkVals[2]!==undefined){_xln=_aryCkVals[2];}else{_xln='';}
if(_aryCkVals[3]!==undefined){_xaddy=_aryCkVals[3];}else{_xaddy='';}
if(_aryCkVals[4]!==undefined){_xcity=_aryCkVals[4];}else{_xcity='';}
if(_aryCkVals[5]!==undefined){_xstate=_aryCkVals[5];}else{_xstate=0;}
if(_aryCkVals[6]!==undefined){_xzip=_aryCkVals[6];}else{_xzip='';}
if(_aryCkVals[7]!=undefined){_xphone=_aryCkVals[7];}else{_xphone='';}
if(_aryCkVals[8]!=undefined){_xgender=_aryCkVals[8];}else{_xgender=null;}}
$("#fvEmail").blur(function(){SNI.HGTV.Sweepstakes.checkCkVals($("#fvEmail").val(),form);});var validator=form.validate({debug:false,rules:{fvFirst:"required",fvLast:"required",fvAddress1:"required",fvCity:"required",fvState:"required",fvZip:{required:true,digits:true},fvEvePhone:{required:true,phoneUS:true},fvEmail:"email",fvEmail:{required:true,email:true},fvEmailConfirm:{required:true,equalTo:"#fvEmail"},fvGender:"required"},messages:{fvFirst:"Please enter your first name",fvLast:"Please enter your last name",fvAddress1:"Please enter your address",fvCity:"Please enter your city",fvState:"Please select your state",fvZip:"Please enter your 5 digit ZIP code",fvEvePhone:"Please enter a valid phone number",fvEmail:"Please enter an e-mail address",fvEmailConfirm:"Please make sure your e-mails match",fvGender:"Please select your gender"},errorContainer:".form-errors",errorLabelContainer:$(".list-alt",".form-errors"),wrapper:"li",showErrors:function(errorMap,errorList){if(errorList.length){this.defaultShowErrors();SNI.HGTV.Sweepstakes.scrollTop();}else{if(window.onbeforeunload!="undefined"){window.onbeforeunload=null;}
SNI.HGTV.Sweepstakes.ckInit();}}});},ckInit:function(){var _email=$("#fvEmail").val();var _fn=$("#fvFirstName").val();var _ln=$("#fvLastName").val();var _addy=$("#fvAddress1").val();var _city=$("#fvCity").val();var _state=$("#fvState").val();var _zip=$("#fvZip").val();var _phone=$("#fvEvePhone").val();if($('#sweepsEntryForm input[name="fvGender"]').eq(0).attr("checked")===true){var _gender='m';}else{_gender='f';}
var _ckVals=_email+'|'+_fn+'|'+_ln+'|'+_addy+'|'+_city+'|'+_state+'|'+_zip+'|'+_phone+'|'+_gender;SNI.Util.Cookie.set('sniSweepsVals',_ckVals,365);},checkCkVals:function(userEmail,form){if(userEmail!=""&&userEmail==_xemail){$("#fvConfirmEmail").val($("#fvEmail").val());if($("#fvFirstName").val()===''){$("#fvFirstName").val(_xfn);}
if($("#fvLastName").val()===''){$("#fvLastName").val(_xln);}
if($("#fvAddress1").val()===''){$("#fvAddress1").val(_xaddy);}
if($("#fvCity").val()===''){$("#fvCity").val(_xcity);}
if($("#fvState").val()===''){$("#fvState").val(_xstate);}
if(form.find('dt a').html()==='Select<em></em>'||form.find('dt a').html()==='Select<EM></EM>'){form.find('dt a').html(_xstate+'<em></em>');}
if($("#fvZip").val()===''){$("#fvZip").val(_xzip);}
if($("#fvEvePhone").val()===''){$("#fvEvePhone").val(_xphone);}
if(form.find('input[name="fvGender"]').eq(0).attr("checked")===false&&form.find('input[name="fvGender"]').eq(1).attr("checked")===false){if(_xgender!==null){if(_xgender=='m'){form.find('input[name="fvGender"]').eq(0).attr({checked:"true"});}else{form.find('input[name="fvGender"]').eq(1).attr({checked:"true"});}}}}},closeErrors:function(){var errors=$("#sweepsEntryForm div.form-errors");errors.find('.close').click(function(){errors.slideUp();return false;});},revealModule:function(parent,trigger,module){$(parent).find(trigger).click(function(){module.fadeIn(SNI.HGTV.ANIMATION_SPEED);$(this).addClass("active");return false;})},closeModule:function(trigger,module,speed){if(speed==null){speed=SNI.HGTV.ANIMATION_SPEED;};module.fadeOut(speed);if($(trigger).hasClass("active")){$(trigger).removeClass("active");};},checkAll:function(container){container.find("#optionalall").click(function(){var $this=$(this);var checkValue=$this.find('span').html();if(container.hasClass("hgtv-nl")){var optins=$(".hgtv-nl input[@type=checkbox],.sponsor-offer input[@type=checkbox]");}else if(container.hasClass("acco-content")){var optins=$(".acco-content input[@type=checkbox]");}
if(checkValue==='Check All'){optins.each(function(){optins.attr('checked',true);});$this.find('span').html('Uncheck All');}else{optins.each(function(){optins.attr('checked',false);});$this.find('span').html('Check All');}
return false;});},scrollTop:function(){var winOffset=70;var win=$(window);var winTop=win.scrollTop()+winOffset;var errorTop=$('#sweepsEntryForm div.form-errors').offset().top;if(errorTop<winTop){win.scrollTop(errorTop-winOffset);}},confirmExit:function(e){if(!e)e=window.event;e.cancelBubble=true;return"It appears you have not entered the sweepstakes.\nDon't miss a chance to win the Green Home Sweepstakes.";if(e.stopPropagation){e.stopPropagation();e.preventDefault();}},inviteAFriend:function(){var parent=$("#sweeps-thanks");var module=$("#invite-a-friend");var form=module.find("form");var null_value="";SNI.HGTV.Sweepstakes.revealModule(parent,".email",module);$(".close").click(function(){SNI.HGTV.Sweepstakes.closeModule(".email",module);});$(".form-submit a").click(function(){SNI.HGTV.Sweepstakes.closeModule(".email",module);return false;});form.validate({errorLabelContainer:module.find('.message'),rules:{from_name:{required:true},from_email:{required:true,email:true},to_emails:{required:true,multipleEmails:true}},messages:{from_name:{required:"Whoops. Please enter your name."},from_email:{required:"Whoops. Please enter your e-mail address.",email:"Whoops. Please check the format of your e-mail address and re-enter (i.e. joe@hgtv.com)."},to_emails:{required:"Whoops. Please enter at least one friend e-mail address.",multipleEmails:"Whoops. One or more of your friend e-mail addresses is not formatted correctly. Please check the format and re-enter (i.e. joe@hgtv.com)."}},showErrors:function(errorMap,errorList){if(errorList.length){module.find('.message').addClass('alert').html(errorList[0].message);element=$(errorList[0].element);if(element.hasClass('isemail')){element.select();}
this.errorList=[this.errorList[0]];this.defaultShowErrors();}},submitHandler:function(){var txtarea=form.find('input[name="body"]');var txtarea_comment=txtarea.val();var msg_body=form.find('input[name="from_name"]').val()+" thought you might like this.\n\n";msg_body+=txtarea.val()+"\n\n";msg_body+=form.find('input[name="url"]').val();module.find('.message').hide().removeClass("alert");form.find('fieldset').hide();form.find("label").removeClass("error");form.find('button').addClass('disabled').attr('disabled','disabled');form.find('.cancel').addClass("disabled");form.find('.loading').show();txtarea.val(msg_body);var form_data=form.serialize();$.ajax({type:"POST",url:form.attr("action"),data:form_data,cache:false,success:function(data){form.find('.loading').hide();var response=$(data);var emailSent=response.eq(7).text();if(emailSent=="false"){form.find('fieldset').show();form.find('button').removeClass('disabled').removeAttr('disabled');form.find('.cancel').removeClass("disabled");form.find("label[for='friends-email']").addClass("error");$("#friends-email").select();module.find('.message').addClass("alert").text("Whoops. The e-mail could not be sent to one or more of your friends. Please check the format of their e-mail address and re-enter (i.e. joe@HGTV.com).").show();}else{var success=module.find('.success');form.hide();success.show();var timeout=setTimeout(function(){SNI.HGTV.Sweepstakes.closeModule(".email",module,300);module.hide();success.hide();txtarea.val(txtarea_comment);module.find('.message').text("All fields are required.").show();form.find("input:text").each(function(){$(this).val("");});form.find('button').removeClass('disabled').removeAttr('disabled');form.find('.cancel').removeClass("disabled");form.find('fieldset').show();form.show();},3000);$(".close").click(function(){clearTimeout(timeout);SNI.HGTV.Sweepstakes.closeModule(".email",module);module.hide();success.hide();txtarea.val(txtarea_comment);module.find('.message').text("All fields are required.").show();form.find("input:text").each(function(){$(this).val("");});form.find('button').removeClass('disabled').removeAttr('disabled');form.find('.cancel').removeClass("disabled");form.find('fieldset').show();form.show();});}},error:function(){form.find('.loading').hide();txtarea.val(txtarea_comment);form.find('fieldset').show();form.find('button').removeClass('disabled').removeAttr('disabled');form.find('.cancel').removeClass("disabled");module.find('.message').addClass("alert").text("Whoops. We encountered an error when trying to e-mail this page. Please wait a few moments and try again.").show();}});}});},reminder:function(){$("#sweepsReminder").validate({debug:false,rules:{email:"email",email:{required:true,email:true},email_confirm:{required:true,equalTo:"#email"},POSTAL_CODE_:{required:true,minlength:5}},messages:{email:"Please enter an e-mail address",email_confirm:"Please make sure your e-mails match",POSTAL_CODE_:"Please enter your 5 digit ZIP code"},errorContainer:".form-errors",errorLabelContainer:$(".list-alt",".form-errors"),wrapper:"li",showErrors:function(errorMap,errorList){if(errorList.length){$('#sweepsReminder').fadeIn().animate({scrollTop:0},'slow');this.defaultShowErrors();}else{if(window.onbeforeunload!="undefined"){window.onbeforeunload=null;}}}});},thanks_reminder:{remind:"#sweeps-thanks",signUp:function(){var parent=$("#sweeps-thanks");var module=$("#reminder-signup");var form=module.find("form");var null_value="";SNI.HGTV.Sweepstakes.revealModule(parent,".reminder",module);$(".close").click(function(){SNI.HGTV.Sweepstakes.closeModule(".reminder",module);});$(".form-submit a").click(function(){SNI.HGTV.Sweepstakes.closeModule(".reminder",module);return false;});form.validate({debug:false,rules:{email:"email",email:{required:true,email:true},email_confirm:{required:true,equalTo:"#email"},POSTAL_CODE_:{required:true,minlength:5}},messages:{email:"Please enter an e-mail address",email_confirm:"Please make sure your e-mails match",POSTAL_CODE_:"Please enter your 5 digit ZIP code"},showErrors:function(errorMap,errorList){if(errorList.length){module.find('.message').addClass('alert').html(errorList[0].message);element=$(errorList[0].element);if(element.hasClass('isemail')){element.select();}
this.errorList=[this.errorList[0]];}}});}}};$.validator.addMethod("phoneUS",function(phone_number,element){phone_number=phone_number.replace(/\s+/g,"");return this.optional(element)||phone_number.length>9&&phone_number.match(/^(1-?)?(\([2-9]\d{2}\)|[2-9]\d{2})-?[2-9]\d{2}-?\d{4}$/);},"Please specify a valid phone number");$.validator.addMethod("zipUS",function(zip_code,element){zip_code=zip_code.replace(/\s+/g,"");return this.optional(element)||zip_code.length>4&&zip_code.match(/^\d{5}(-\d{4})?$/);},"Please specify a valid zip code");
if(typeof(SNI.HGTV.newflashtour)=='undefined'){SNI.HGTV.newflashtour={};}
SNI.HGTV.newflashtour=function(){var pageId=mdManager.getParameter('DetailId');var pageIds=[{tour:'5946059',photoGallery:'6023377',video:'29860',name:"Front"},{tour:'5946070',photoGallery:'6023399',video:'29855',name:"Entry Hall"},{tour:'5946077',photoGallery:'6023411',video:'29843',name:"Great Room"},{tour:'5946076',photoGallery:'6023409',video:'29865',name:"Kitchen"},{tour:'5946078',photoGallery:'6023413',video:'29859',name:"Walk-through Pantry"},{tour:'5946079',photoGallery:'6023415',video:'29861',name:"Dining Room"},{tour:'5946064',photoGallery:'6023387',video:'29851',name:"Home Theater"},{tour:'5946060',photoGallery:'6023379',video:'29864',name:"Master Suite"},{tour:'5946062',photoGallery:'6023383',video:'29857',name:"Master Bathroom"},{tour:'5946061',photoGallery:'6023381',video:'29848',name:"Master Closet"},{tour:'5946063',photoGallery:'6023385',video:'29850',name:"Sunrise Room"},{tour:'5946065',photoGallery:'6023389',video:'29844',name:"Laundry Room"},{tour:'5946066',photoGallery:'6023391',video:'29858',name:"Kids Bedroom"},{tour:'5946068',photoGallery:'6023395',video:'29847',name:"Jack & Jill Bathroom"},{tour:'5946067',photoGallery:'6023393',video:'29845',name:"Guest Bedroom"},{tour:'5946081',photoGallery:'6023419',video:'29846',name:"Home Office"},{tour:'5946073',photoGallery:'6023405',video:'29862',name:"Motor Court"},{tour:'5946074',photoGallery:'6023407',video:'29863',name:"Casita"},{tour:'5946080',photoGallery:'6023417',video:'29849',name:"Casita Patio"},{tour:'5946069',photoGallery:'6023397',video:'29856',name:"Three Car Garage"},{tour:'5946072',photoGallery:'6023403',video:'29854',name:"Back Patio"},{tour:'5946071',photoGallery:'6023401',video:'29852',name:"Recycling Room"}];var flashvars={};var idFound=false;flashvars.startHereRoomId='5946059';for(var i=0;i<pageIds.length;i++){for(pageType in pageIds[i]){if(pageIds[i][pageType]==pageId){flashvars.selectedRoomId=pageIds[i].tour;flashvars.startHereRoomId=null;idFound=true;break;}}
if(idFound==true){break;}};var params={allowscriptaccess:'always'};swfobject.embedSWF('http://web.hgtv.com/webhgtv/hg20/pkgs/2010/dh/swf/floorplan.swf','floorplan-container','323','280','9.0.0',null,flashvars,params);};
if(typeof(SNI.HGTV.DesignStar)=='undefined'){SNI.HGTV.DesignStar={};}
SNI.HGTV.DesignStar.dsTabs=function(jsel){$('.ds-tabs .ui-tabs-nav li').each(function(i){$(this).addClass("tab-num-"+i);});$('.ds-tabs .tab-well').each(function(i){$(this).addClass("tab-num-"+i);});$('.ds-tabs .tab-well').not(".tab-num-0").hide();$('.ds-tabs .ui-tabs-nav li').click(function(){if($(this).hasClass('ui-tabs-selected')){return false;}else{$(this).siblings().removeClass('ui-tabs-selected');var selectedClass=$(this).attr("class");$('.ds-tabs .tab-well').each(function(){if($(this).hasClass(selectedClass)){$(this).show();$(this).siblings().hide();}});$(this).addClass('ui-tabs-selected');return false;}});};SNI.HGTV.DesignStar.bodyHook=function(){var bodyClass=$('#body-hook').attr('rel');$('body').addClass(bodyClass);};SNI.HGTV.DesignStar.Medialibrary=function(element,config){togglelist=$(element).find('li.switch');carouselCount=0;togglelist.each(function(){var $this=$(this);var target=$this.find("h4");if(carouselCount<4){$this.addClass("selected");}
if(!$this.hasClass("selected")){$this.find(".channel-bd").hide();}
target.click(function(){if($this.hasClass("selected")){$this.removeClass("selected");$this.find(".channel-bd").hide();}else{$this.addClass("selected");$this.find(".channel-bd").show();}
carouselCount++;});});};SNI.HGTV.DesignStar.ThankYouToggle=function(element,config){var submitStatus='';if($.query.has('fvEmail')){submitStatus=$.query.get('fvEmail');}
if(submitStatus!=''){$("#thank-you-message").show();}
$("#ty-close").click(function(){$("#thank-you-message").hide();});};SNI.HGTV.DesignStar.ReminderSignUp={remind:"#reminders",revealModule:function(trigger,module){$(SNI.HGTV.DesignStar.ReminderSignUp.remind).find(trigger).click(function(){module.fadeIn(SNI.HGTV.ANIMATION_SPEED);$(this).addClass("active");return false;});},closeModule:function(trigger,module,speed){if(speed===null){speed=SNI.HGTV.ANIMATION_SPEED;};module.fadeOut(speed);if($(trigger).hasClass("active")){$(trigger).removeClass("active");}},signUp:function(){var module=$("#reminder-signup");var form=module.find("form");var null_value="";SNI.HGTV.DesignStar.ReminderSignUp.revealModule(".reminder",module);$(".close").click(function(){SNI.HGTV.DesignStar.ReminderSignUp.closeModule(".reminder",module);});$(".form-submit a").click(function(){SNI.HGTV.DesignStar.ReminderSignUp.closeModule(".reminder",module);return false;});form.validate({debug:false,rules:{FIRST_NAME_:"required",LAST_NAME_:"required",email:"email",email:{required:true,email:true},email_confirm:{required:true,equalTo:"#email"}},messages:{FIRST_NAME_:"Please enter your first name",LAST_NAME_:"Please enter your last name",email:"Please enter an e-mail address",email_confirm:"Please make sure your e-mails match"},showErrors:function(errorMap,errorList){if(errorList.length){module.find('.message').addClass('alert').html(errorList[0].message);element=$(errorList[0].element);if(element.hasClass('isemail')){element.select();}
this.errorList=[this.errorList[0]];}}});}};(function($){$.fn.countDown2=function(options){var options=$.extend({container:null,date:'January 1, 2099 00:00:00',updateInterval:.5,wraps:null,onExpire:function(){}},options);return this.each(function(i){var obj=this;var today=new Date();var endDate=new Date(options.date);var ms=Math.floor(endDate.getTime()-today.getTime());function two(x){return((x>9)?"":"0")+x};function three(x){return((x>99)?"":"0")+((x>9)?"":"0")+x};function MS2DHMSMS(ms){var nt={};var sec=Math.floor(ms/1000);ms=ms%1000;nt.ms=three(ms).toString();var min=Math.floor(sec/60);sec=sec%60;nt.ss=two(sec).toString();var hr=Math.floor(min/60);min=min%60;nt.mm=two(min).toString();var day=Math.floor(hr/24);hr=hr%24;nt.hh=two(hr).toString();nt.dd=day.toString();return nt;}
function getTimeLeft(){var today=new Date();var ms=Math.floor(endDate.getTime()-today.getTime());sLeft=MS2DHMSMS(ms).ss;mLeft=MS2DHMSMS(ms).mm;hLeft=MS2DHMSMS(ms).hh;dLeft=MS2DHMSMS(ms).dd;if(dLeft<=0){if(hLeft<=0){if(mLeft<=0){if(sLeft<=0){options.onExpire.call(this,obj);}}}}
if(options.wraps==null){$(obj).html('<span class="jcdDays">'+dLeft+'</span>&nbsp;<span class="jcdDaysText">day'+s+'</span>&nbsp;<span class="jcdHours">'+hLeft+'</span>:<span class="jcdMinutes">'+mLeft+'</span>:<span class="jcdSeconds">'+sLeft+'</span>');}else{for(x in options.wraps){if(x=='days'){$(options.wraps[x]).html(dLeft);}
if(x=='hours'){$(options.wraps[x]).html(hLeft);}
if(x=='minutes'){$(options.wraps[x]).html(mLeft);}
if(x=='seconds'){$(options.wraps[x]).html(sLeft);}}}};if(options.container){$(options.container).css('display','block');obj.container=options.container;}
if(parseInt(MS2DHMSMS(ms).dd)<0){options.onExpire.call(this,obj);}else{if(options.updateInterval){setInterval(function(){getTimeLeft();},options.updateInterval*1000);}else{getTimeLeft();}}});};})(jQuery);
if(typeof(SNI.HGTV.DreamHome)=='undefined'){SNI.HGTV.DreamHome={};}
SNI.HGTV.DreamHome.Medialibrary=function(element,config){togglelist=$(element).find('li.switch');carouselCount=0;togglelist.each(function(){var $this=$(this);var target=$this.find("h4");if(!$this.hasClass("selected")){$this.find(".channel-bd").hide();}
target.click(function(){if($this.hasClass("selected")){$this.removeClass("selected");$this.find(".channel-bd").hide();}else{$this.addClass("selected");$this.find(".channel-bd").show();}
carouselCount++;});});};SNI.HGTV.DreamHome.flashtour=function(){var pageId=mdManager.getParameter('DetailId');var pageIds=[{tour:'5946059',photoGallery:'6023377',video:'29860',name:"Front"},{tour:'5946070',photoGallery:'6023399',video:'29855',name:"Entry Hall"},{tour:'5946077',photoGallery:'6023411',video:'29843',name:"Great Room"},{tour:'5946076',photoGallery:'6023409',video:'29865',name:"Kitchen"},{tour:'5946078',photoGallery:'6023413',video:'29859',name:"Walk-through Pantry"},{tour:'5946079',photoGallery:'6023415',video:'29861',name:"Dining Room"},{tour:'5946064',photoGallery:'6023387',video:'29851',name:"Home Theater"},{tour:'5946060',photoGallery:'6023379',video:'29864',name:"Master Suite"},{tour:'5946062',photoGallery:'6023383',video:'29857',name:"Master Bathroom"},{tour:'5946061',photoGallery:'6023381',video:'29848',name:"Master Closet"},{tour:'5946063',photoGallery:'6023385',video:'29850',name:"Sunrise Room"},{tour:'5946065',photoGallery:'6023389',video:'29844',name:"Laundry Room"},{tour:'5946066',photoGallery:'6023391',video:'29858',name:"Kids Bedroom"},{tour:'5946068',photoGallery:'6023395',video:'29847',name:"Jack & Jill Bathroom"},{tour:'5946067',photoGallery:'6023393',video:'29845',name:"Guest Bedroom"},{tour:'5946081',photoGallery:'6023419',video:'29846',name:"Home Office"},{tour:'5946073',photoGallery:'6023405',video:'29862',name:"Motor Court"},{tour:'5946074',photoGallery:'6023407',video:'29863',name:"Casita"},{tour:'5946080',photoGallery:'6023417',video:'29849',name:"Casita Patio"},{tour:'5946069',photoGallery:'6023397',video:'29856',name:"Three Car Garage"},{tour:'5946072',photoGallery:'6023403',video:'29854',name:"Back Patio"},{tour:'5946071',photoGallery:'6023401',video:'29852',name:"Recycling Room"}];var flashvars={};var idFound=false;flashvars.startHereRoomId='5946059';for(var i=0;i<pageIds.length;i++){for(pageType in pageIds[i]){if(pageIds[i][pageType]==pageId){flashvars.selectedRoomId=pageIds[i].tour;flashvars.startHereRoomId=null;idFound=true;break;}}
if(idFound==true){break;}};var params={allowscriptaccess:'always'};swfobject.embedSWF('http://web.hgtv.com/webhgtv/hg20/pkgs/2010/dh/swf/floorplan.swf','floorplan-container','323','280','9.0.0',null,flashvars,params);};(function($){SNI.HGTV.photogalleryTracking=function(){var rendered_images_manager={},$gallery_element;$(document).bind("load-photo-complete",function(e,params){$gallery_element=params.element||$(".photo-gallery4");if($gallery_element){$gallery_element.find(".pg-viewport .pg-photo-description .pg-show-caption").click(function(){SNI.Omniture.dynamicSingleVar({section:"HGTV",module:"Photo Gallery",linkText:params.gallery.title+" : Caption - More",element:$(this)});});if(!rendered_images_manager[params.photo.iid]){$gallery_element.find(".pg-viewport .pg-you-might-like ul li a").click(function(){if($(this).is("a")){SNI.Omniture.dynamicSingleVar({section:"HGTV",module:"Photo Gallery",linkText:params.gallery.title+" : "+$(this).text().trim(),element:$(this)});}});}
rendered_images_manager[params.photo.iid]=params.photo;}});$(document).bind("show-thumbnails",function(e,params){SNI.Omniture.dynamicSingleVar({section:"HGTV",module:"Photo Gallery",linkText:params.gallery.title+" : Thumbnails",element:params.element});});$(document).bind("endframe-render-complete",function(e,params){$gallery_element=params.element||$(".photo-gallery4");if($gallery_element){$gallery_element.find(".pg-viewport .pg-endframe a").click(function(){var title_text=$(this).text().trim();title_text=(title_text.length>0)?title_text:$(this).attr("title");SNI.Omniture.dynamicSingleVar({section:"HGTV",module:"Photo Gallery : End Frame",linkText:params.gallery.title+" : "+title_text,element:$(this)});});}});}})(jQuery);
if(typeof(SNI.HGTV.GreenHome)=='undefined'){SNI.HGTV.GreenHome={};}
SNI.HGTV.GreenHome.flashtour=function(){var pageId=mdManager.getParameter('DetailId');var pageIds=[{tour:'6024752',photoGallery:'6024750',video:'33703',name:"Living Room"},{tour:'6024792',photoGallery:'6024756',video:'33504',name:"Kitchen"},{tour:'6024794',photoGallery:'6024758',video:'33516',name:"Dining Room"},{tour:'6024798',photoGallery:'6024762',video:'33510',name:"Hall"},{tour:'6024796',photoGallery:'6024760',video:'33515',name:"Laundry Room"},{tour:'6024800',photoGallery:'6024764',video:'33702',name:"Sitting Room"},{tour:'6024806',photoGallery:'6024772',video:'33507',name:"Master Bedroom"},{tour:'6024808',photoGallery:'6024774',video:'33506',name:"Master Bathroom"},{tour:'6024810',photoGallery:'6024776',video:'33512',name:"Master Closet"},{tour:'6024802',photoGallery:'6024766',video:'33513',name:"Kid's Bedroom"},{tour:'6024804',photoGallery:'6024770',video:'33514',name:"Kid's Bathroom"},{tour:'6024812',photoGallery:'6024778',video:'33509',name:"Tower"},{tour:'6024814',photoGallery:'6024780',video:'33503',name:"Exterior Front"},{tour:'6024816',photoGallery:'6024782',video:'33505',name:"Covered Porch"},{tour:'6024820',photoGallery:'6024786',video:'33521',name:"Garage Exterior"},{tour:'6024828',photoGallery:'6024830',video:'33501',name:"GMC Terrain"},{tour:'6024818',photoGallery:'6024784',video:'33511',name:"Outdoor Kitchen"}];var flashvars={};var idFound=false;for(var i=0;i<pageIds.length;i++){for(pageType in pageIds[i]){if(pageIds[i][pageType]==pageId){flashvars.selectedRoomId=pageIds[i].tour;idFound=true;break;}}
if(idFound==true){break;}};if(flashvars.selectedRoomId==""||typeof(flashvars.selectedRoomId)=='undefined'){flashvars.startHereRoomId='6024752';}
var params={allowscriptaccess:'always'};swfobject.embedSWF("http://web.hgtv.com/webhgtv/hg20/pkgs/2010/gh/swf/floorplan.swf","floorplan-container","323","468","9.0.0",null,flashvars,params);};
SNI.HGTV.flashtour=function(pageIds,startHereRoomId,swfPath,swfHeight){var pageId=mdManager.getParameter('DetailId'),flashvars={},idFound=false,pageType;for(var i=0;i<pageIds.length;i++){for(pageType in pageIds[i]){if(pageIds[i][pageType]==pageId){flashvars.selectedRoomId=pageIds[i].tour;idFound=true;break;}}
if(idFound===true){break;}}
if(flashvars.selectedRoomId===""||typeof(flashvars.selectedRoomId)=='undefined'){flashvars.startHereRoomId=startHereRoomId;}
var params={allowscriptaccess:'always'};swfobject.embedSWF(swfPath,"floorplan-container","322",swfHeight,"9.0.0",null,flashvars,params);};
SNI.HGTV.ViewSliderTP=(function(){function ViewSlider(){this.updateImageList=function(){this.images=this.images.not('[src]');return this.images;};this.monitorScroll=function(){var sliding_window=this;var slider=sliding_window.slider;sliding_window.images=slider.find('img').not('[src]');if(sliding_window.images.length>0){slider.scroll(function(e){sliding_window.images.each(function(i){var $this=jQuery(this);if(($this.offset().left-slider.offset().left)<=slider.width()){SNI.HGTV.LazyImage.load($this);sliding_window.updateImageList();}});});}};this.calculateBodyWidth=function(slider_body){slider_body=slider_body||sliding_window.slider.children('ul');var total_body_width=0;slider_body.children('li').each(function(i){var $this=$(this);var list_item_width=$this.outerWidth()+parseInt($this.css('margin-left'),10)+parseInt($this.css('margin-right'),10);total_body_width=total_body_width+list_item_width;});return total_body_width;};this.init=function(element,addWidth){var sliding_window=this;var slider=element||jQuery('.view-slider');if(!addWidth){addWidth=0;}
sliding_window.slider=slider;slider.addClass("view-slider-setup");sliding_window.images=slider.find('img').not('[src]');var slider_body=slider.children('ul');var slider_body_width=sliding_window.calculateBodyWidth(slider_body);if(slider_body.width()!==slider_body_width){slider_body.width(slider_body_width+addWidth);}
sliding_window.images.each(function(i){var $this=jQuery(this);if($this.position().left<=sliding_window.slider.width()){SNI.HGTV.LazyImage.load($this);}});sliding_window.updateImageList();sliding_window.monitorScroll();};}
return{init:function(element,addWidth){var view_slider=new ViewSlider();view_slider.init(element,addWidth);return view_slider;}};})();SNI.HGTV.ActiveScroll=(function(){var rootElement;var featuredItems;var itemList;var currentActiveElement;var _getInitialActiveItem=function(){var activeItem;if((typeof(featuredItems)==="object")&&(featuredItems.length>0)){activeItem=$(featuredItems[Math.floor(Math.random()*(featuredItems.length))]);}
else{activeItem=itemList.eq(0);}
return activeItem;};var _onItemPodClick=function(evt){var allowDefaultBehavior=true;var clicked=$(evt.target);if(!clicked.hasClass("item")){clicked=clicked.parents(".item").eq(0);}
if(!clicked.hasClass("active")){var activeItem=rootElement.find(".active");activeItem.removeClass('active');clicked.addClass('active');rootElement.scrollTo(clicked,{duration:150,offset:-153});allowDefaultBehavior=false;}
return allowDefaultBehavior;};var initActiveScrollBehavior=function(){var activeItem=_getInitialActiveItem();currentActiveElement=activeItem;activeItem.addClass("active");rootElement.scrollTo(activeItem,350,{offset:-153});itemList.parent().click(_onItemPodClick);};return{init:function(jqueryRootElement,addWidth){rootElement=jqueryRootElement;itemList=rootElement.find('.item');featuredItems=rootElement.find(".featured");SNI.HGTV.ViewSliderTP.init(rootElement,addWidth);initActiveScrollBehavior();}};})();
