// JavaScript Document for Mr. Steam by AtlantaWebDesignGA.com

jQuery(document).ready(function() {
  // switch template layout if home page, subpage with/without floating image 
  jQuery(function() {
	 var path = location.pathname.substring(1);
	 var hash = location.hash.substring(1);
	 if ( path != "" ) {
		jQuery('#arrow-container').hide();
		jQuery('#header-photo-home').hide();
		jQuery('#site-description').hide();
		jQuery('.book-button-home').hide();
		jQuery('#book-online-home').hide();
		jQuery('#book-online-subpage').show();
		if ( hash != "" ) {
			jQuery('.hentry').addClass('move-hentry');
			}
        if ( jQuery('.entry-content img').width() >= 670) {
                  jQuery('.entry-content img').addClass('move-img');
                  jQuery('#content').addClass('move-content');
                  jQuery('#footer-container').addClass('move-footer');
                  jQuery('.addtoany_share_save_container').addClass('move-addtoany');
                  if (parseInt(jQuery.browser.version) == 7) {
                     jQuery('.entry-content img').addClass('move-img-ie7');
                     jQuery('#content').addClass('move-content-ie7');
                  }
              }
         }
         else {
		jQuery('#arrow-container').show();
		jQuery('#header-photo-home').show();
		jQuery('#site-description').show();
        jQuery('.book-button-home').show();
		jQuery('#book-online-home').show();
		jQuery('#book-online-subpage').hide();
		jQuery('#primary-menu').addClass('home-menu');
		jQuery('#container').addClass('home-container');
           }
  });
  // replace title on payment page
  jQuery('#product_776 label').text('Amount');
  jQuery('#product_776_submit_button').attr("value","Pay Now");
  // all following code is for the Book Online quote form
  // set total box screen position from right 
  var fromRight = (document.body.clientWidth-960)/2 +"px";
  jQuery('#field_31_2').css('right',fromRight);
  // call the quote form calculations sub if any room cleaning quantity field changes
  jQuery('#gform_fields_31 .room select').live('change', function() {
  var rooms = parseInt(document.getElementById('input_31_4').value) + parseInt(document.getElementById('input_31_7').value) + parseInt(document.getElementById('input_31_10').value) + parseInt(document.getElementById('input_31_13').value) + parseInt(document.getElementById('input_31_16').value) + parseInt(document.getElementById('input_31_19').value) + parseInt(document.getElementById('input_31_31').value) +  parseInt(document.getElementById('input_31_37').value) + parseInt(document.getElementById('input_31_40').value);
  // set Room Areas drop down to total rooms to get price
  var myValue =  jQuery("#input_31_43 option:contains('" + rooms + "')").val();
  jQuery("#input_31_43").val(myValue);
  //Forcing Gravity Forms to recalculate its Total field
  gformCalculateTotalPrice(31);
 });
 jQuery('select').live('change', function() {
   // copy total into my hidden field that has validation to check if order total is $59 or more
   var howmuch = parseInt(document.getElementById('input_31_2').value);
   jQuery("#input_31_116").val(howmuch);
 });
});
// reveal for popup windows
(function(c){c("a[data-reveal-id]").live("click",function(a){a.preventDefault();a=c(this).attr("data-reveal-id");c("#"+a).reveal(c(this).data())});c.fn.reveal=function(a){a=c.extend({},{animation:"fadeAndPop",animationspeed:300,closeonbackgroundclick:!0,dismissmodalclass:"close-reveal-modal"},a);return this.each(function(){function f(){g=!1}var b=c(this),e=parseInt(b.css("top")),h=b.height()+e,g=!1,d=c(".reveal-modal-bg");0==d.length&&(d=c('<div class="reveal-modal-bg" />').insertAfter(b));b.bind("reveal:open",
function(){d.unbind("click.modalEvent");c("."+a.dismissmodalclass).unbind("click.modalEvent");g||(g=!0,"fadeAndPop"==a.animation&&(b.css({top:c(document).scrollTop()-h,opacity:0,visibility:"visible"}),d.fadeIn(a.animationspeed/2),b.delay(a.animationspeed/2).animate({top:c(document).scrollTop()+e+"px",opacity:1},a.animationspeed,f())),"fade"==a.animation&&(b.css({opacity:0,visibility:"visible",top:c(document).scrollTop()+e}),d.fadeIn(a.animationspeed/2),b.delay(a.animationspeed/2).animate({opacity:1},
a.animationspeed,f())),"none"==a.animation&&(b.css({visibility:"visible",top:c(document).scrollTop()+e}),d.css({display:"block"}),f()));b.unbind("reveal:open")});b.bind("reveal:close",function(){g||(g=!0,"fadeAndPop"==a.animation&&(d.delay(a.animationspeed).fadeOut(a.animationspeed),b.animate({top:c(document).scrollTop()-h+"px",opacity:0},a.animationspeed/2,function(){b.css({top:e,opacity:1,visibility:"hidden"});f()})),"fade"==a.animation&&(d.delay(a.animationspeed).fadeOut(a.animationspeed),b.animate({opacity:0},
a.animationspeed,function(){b.css({opacity:1,visibility:"hidden",top:e});f()})),"none"==a.animation&&(b.css({visibility:"hidden",top:e}),d.css({display:"none"})));b.unbind("reveal:close")});b.trigger("reveal:open");c("."+a.dismissmodalclass).bind("click.modalEvent",function(){b.trigger("reveal:close")});a.closeonbackgroundclick&&(d.css({cursor:"pointer"}),d.bind("click.modalEvent",function(){b.trigger("reveal:close")}));c("body").keyup(function(a){27===a.which&&b.trigger("reveal:close")})})}})(jQuery);
// cookies
function writeCookie(name,value,days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
    }
    else var expires = "";
    document.cookie = name+"="+value+expires+"; path=/";
}
 
function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}
