/* sni-hgtv - Wed, 01 Sep 2010 13:44:09 -0400 */

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


SNI.HGTV.TakeOverHeader={init:function(){$("#hd-search-input").val("");SNI.HGTV.TakeOverHeader.loginDrop();},loginDrop:function(){var navTimer=null;var initializeMenu="#hd-logo";hideAll();initMenu(initializeMenu);function initMenu(initializeMenu){var menu=initializeMenu;$(menu).find('h3:first span').click(function(){hideAll();});$(menu).each(function(i){menuItem=$(this);var leftOffset=menuItem.offset().left;var dropdownWidth=345;if(menuItem.hasClass("nav-e")){offsetVal=leftOffset-dropdownWidth+menuItem.outerWidth()+3;}else{offsetVal=leftOffset-1;}
menuItem.find('div.drop').css({left:offsetVal});menuItem.hover(function(e){hideAll();var $this=$(this);$this.addClass("dd-on");$this.find('div.drop').show();},function(e){clearTimeout(navTimer);navTimer=null;var closeDiv=$(this);navTimer=setTimeout(function(){closeDiv.removeClass("dd-on");closeDiv.find('div.drop').hide();navTimer=null;},100);});});if($.browser.msie&&(parseInt($.browser.version)<7)){var win=$(window);win.resize(function(){$('#hg-hd').width(($(this).width()<1002?1002:'auto'));});$('#hg-hd').width((win.width()<1002?1002:'auto'));}}
function hideAll(){clearTimeout(navTimer);navTimer=null;$("#hd-logo .drop").hide();}},bodyHook:function(){var bodyClass=$('#body-hook').attr('rel');$('body').addClass(bodyClass);}};
(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);};
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){var pageId=mdManager.getParameter('DetailId');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=startHereRoomId;}
var params={allowscriptaccess:'always'};swfobject.embedSWF(swfPath,"floorplan-container","322",swfHeight,"9.0.0",null,flashvars,params);};