;
/* AGGREGATED JS FILE: misc/drupal.js */
// $Id: drupal.js,v 1.29.2.1 2007/07/15 23:07:06 drumm Exp $

var Drupal = Drupal || {};

/**
 * Set the variable that indicates if JavaScript behaviors should be applied
 */
Drupal.jsEnabled = document.getElementsByTagName && document.createElement && document.createTextNode && document.documentElement && document.getElementById;

/**
 * Extends the current object with the parameter. Works recursively.
 */
Drupal.extend = function(obj) {
  for (var i in obj) {
    if (this[i]) {
      Drupal.extend.apply(this[i], [obj[i]]);
    }
    else {
      this[i] = obj[i];
    }
  }
};

/**
 * Redirects a button's form submission to a hidden iframe and displays the result
 * in a given wrapper. The iframe should contain a call to
 * window.parent.iframeHandler() after submission.
 */
Drupal.redirectFormButton = function (uri, button, handler) {
  // Trap the button
  button.onmouseover = button.onfocus = function() {
    button.onclick = function() {
      // Create target iframe
      Drupal.createIframe();

      // Prepare variables for use in anonymous function.
      var button = this;
      var action = button.form.action;
      var target = button.form.target;

      // Redirect form submission to iframe
      this.form.action = uri;
      this.form.target = 'redirect-target';

      handler.onsubmit();

      // Set iframe handler for later
      window.iframeHandler = function () {
        var iframe = $('#redirect-target').get(0);
        // Restore form submission
        button.form.action = action;
        button.form.target = target;

        // Get response from iframe body
        try {
          response = (iframe.contentWindow || iframe.contentDocument || iframe).document.body.innerHTML;
          // Firefox 1.0.x hack: Remove (corrupted) control characters
          response = response.replace(/[\f\n\r\t]/g, ' ');
          if (window.opera) {
            // Opera-hack: it returns innerHTML sanitized.
            response = response.replace(/&quot;/g, '"');
          }
        }
        catch (e) {
          response = null;
        }

        response = Drupal.parseJson(response);
        // Check response code
        if (response.status == 0) {
          handler.onerror(response.data);
          return;
        }
        handler.oncomplete(response.data);

        return true;
      }

      return true;
    }
  }
  button.onmouseout = button.onblur = function() {
    button.onclick = null;
  }
};

/**
 * Retrieves the absolute position of an element on the screen
 */
Drupal.absolutePosition = function (el) {
  var sLeft = 0, sTop = 0;
  var isDiv = /^div$/i.test(el.tagName);
  if (isDiv && el.scrollLeft) {
    sLeft = el.scrollLeft;
  }
  if (isDiv && el.scrollTop) {
    sTop = el.scrollTop;
  }
  var r = { x: el.offsetLeft - sLeft, y: el.offsetTop - sTop };
  if (el.offsetParent) {
    var tmp = Drupal.absolutePosition(el.offsetParent);
    r.x += tmp.x;
    r.y += tmp.y;
  }
  return r;
};

/**
 * Return the dimensions of an element on the screen
 */
Drupal.dimensions = function (el) {
  return { width: el.offsetWidth, height: el.offsetHeight };
};

/**
 *  Returns the position of the mouse cursor based on the event object passed
 */
Drupal.mousePosition = function(e) {
  return { x: e.clientX + document.documentElement.scrollLeft, y: e.clientY + document.documentElement.scrollTop };
};

/**
 * Parse a JSON response.
 *
 * The result is either the JSON object, or an object with 'status' 0 and 'data' an error message.
 */
Drupal.parseJson = function (data) {
  if ((data.substring(0, 1) != '{') && (data.substring(0, 1) != '[')) {
    return { status: 0, data: data.length ? data : 'Unspecified error' };
  }
  return eval('(' + data + ');');
};

/**
 * Create an invisible iframe for form submissions.
 */
Drupal.createIframe = function () {
  if ($('#redirect-holder').size()) {
    return;
  }
  // Note: some browsers require the literal name/id attributes on the tag,
  // some want them set through JS. We do both.
  window.iframeHandler = function () {};
  var div = document.createElement('div');
  div.id = 'redirect-holder';
  $(div).html('<iframe name="redirect-target" id="redirect-target" class="redirect" onload="window.iframeHandler();"></iframe>');
  var iframe = div.firstChild;
  $(iframe)
    .attr({
      name: 'redirect-target',
      id: 'redirect-target'
    })
    .css({
      position: 'absolute',
      height: '1px',
      width: '1px',
      visibility: 'hidden'
    });
  $('body').append(div);
};

/**
 * Delete the invisible iframe
 */
Drupal.deleteIframe = function () {
  $('#redirect-holder').remove();
};

/**
 * Freeze the current body height (as minimum height). Used to prevent
 * unnecessary upwards scrolling when doing DOM manipulations.
 */
Drupal.freezeHeight = function () {
  Drupal.unfreezeHeight();
  var div = document.createElement('div');
  $(div).css({
    position: 'absolute',
    top: '0px',
    left: '0px',
    width: '1px',
    height: $('body').css('height')
  }).attr('id', 'freeze-height');
  $('body').append(div);
};

/**
 * Unfreeze the body height
 */
Drupal.unfreezeHeight = function () {
  $('#freeze-height').remove();
};

/**
 * Wrapper to address the mod_rewrite url encoding bug
 * (equivalent of drupal_urlencode() in PHP).
 */
Drupal.encodeURIComponent = function (item, uri) {
  uri = uri || location.href;
  item = encodeURIComponent(item).replace(/%2F/g, '/');
  return (uri.indexOf('?q=') != -1) ? item : item.replace(/%26/g, '%2526').replace(/%23/g, '%2523').replace(/\/\//g, '/%252F');
};

// Global Killswitch on the <html> element
if (Drupal.jsEnabled) {
  document.documentElement.className = 'js';
}

;
/* AGGREGATED JS FILE: sites/hanuman.ru/modules/jquery_update/compat.js */
// $Id: compat.js,v 1.1.2.1 2008/05/02 21:05:06 stevemckenzie Exp $
// UPGRADE: The following attribute helpers should now be used as:
// .attr("title") or .attr("title","new title")
jQuery.each(["id","title","name","href","src","rel"], function(i,n){
  jQuery.fn[ n ] = function(h) {
    return h == undefined ?
      this.length ? this[0][n] : null :
      this.attr( n, h );
  };
});

// UPGRADE: The following css helpers should now be used as:
// .css("top") or .css("top","30px")
jQuery.each("top,left,position,float,overflow,color,background".split(","), function(i,n){
  jQuery.fn[ n ] = function(h) {
    return h == undefined ?
      ( this.length ? jQuery.css( this[0], n ) : null ) :
      this.css( n, h );
  };
});

// UPGRADE: The following event helpers should now be used as such:
// .oneblur(fn) -> .one("blur",fn)
// .unblur(fn) -> .unbind("blur",fn)
var e = ("blur,focus,load,resize,scroll,unload,click,dblclick," +
  "mousedown,mouseup,mousemove,mouseover,mouseout,change,reset,select," + 
  "submit,keydown,keypress,keyup,error").split(",");

// Go through all the event names, but make sure that
// it is enclosed properly
for ( var i = 0; i < e.length; i++ ) new function(){
      
  var o = e[i];
    
  // Handle event unbinding
  jQuery.fn["un"+o] = function(f){ return this.unbind(o, f); };
    
  // Finally, handle events that only fire once
  jQuery.fn["one"+o] = function(f){
    // save cloned reference to this
    var element = jQuery(this);
    var handler = function() {
      // unbind itself when executed
      element.unbind(o, handler);
      element = null;
      // apply original handler with the same arguments
      return f.apply(this, arguments);
    };
    return this.bind(o, handler);
  };
      
};

// UPGRADE: .ancestors() was removed in favor of .parents()
jQuery.fn.ancestors = jQuery.fn.parents;

// UPGRADE: The CSS selector :nth-child() now starts at 1, instead of 0
jQuery.expr[":"]["nth-child"] = "jQuery.nth(a.parentNode.firstChild,parseInt(m[3])+1,'nextSibling')==a";

// UPGRADE: .filter(["div", "span"]) now becomes .filter("div, span")
jQuery.fn._filter = jQuery.fn.filter;
jQuery.fn.filter = function(arr){
  return this._filter( arr.constructor == Array ? arr.join(",") : arr );
};

/*
 * Compatibility Plugin for jQuery 1.1 (on top of jQuery 1.2)
 * By John Resig
 * Dual licensed under MIT and GPL.
 *
 * For XPath compatibility with 1.1, you should also include the XPath
 * compatability plugin.
 */
(function(jQuery){

	// You should now use .slice() instead of eq/lt/gt
	// And you should use .filter(":contains(text)") instead of .contains()
	jQuery.each( [ "eq", "lt", "gt", "contains" ], function(i,n){
		jQuery.fn[ n ] = function(num,fn) {
			return this.filter( ":" + n + "(" + num + ")", fn );
		};
	});

	// This is no longer necessary in 1.2
	jQuery.fn.evalScripts = function(){};

	// You should now be using $.ajax() instead
	jQuery.fn.loadIfModified = function() {
		var old = jQuery.ajaxSettings.ifModified;
		jQuery.ajaxSettings.ifModified = true;
	
		var ret = jQuery.fn.load.apply( this, arguments );
	
		jQuery.ajaxSettings.ifModified = old;

		return ret;
	};

	// You should now be using $.ajax() instead
	jQuery.getIfModified = function() {
		var old = jQuery.ajaxSettings.ifModified;
		jQuery.ajaxSettings.ifModified = true;
	
		var ret = jQuery.get.apply( jQuery, arguments );
	
		jQuery.ajaxSettings.ifModified = old;

		return ret;
	};

	jQuery.ajaxTimeout = function( timeout ) {
		jQuery.ajaxSettings.timeout = timeout;
	};

})(jQuery);

;
/* AGGREGATED JS FILE: sites/hanuman.ru/modules/hanuman/hanuman.js */
$(document).ready(function() 
{	
	hideGoods();
	$(".selectselect select").change(function()
	{
		hideGoods($(this).val());
	});

	if($(".priceplace").length && price_adjust.length)
	{
		var price, newprice, price_, last_price2;
		var used=[];
		price_ = 0;
		last_price = 0;

		price=parseInt($(".priceplace").html());
		newprice=price;

		$(".selectselect select").each(function()
		{
			if(!in_array($(this).val(), used))
			{
				newprice+=parseInt(price_adjust[$(this).val()]);
				used.push($(this).val());
			}
		});
		$(".selectselect input[checked='checked']").each(function()
		{
			if(!in_array($(this).val(), used))
			{
				newprice+=parseInt(price_adjust[$(this).val()]);
				used.push($(this).val());
			}
		});

		$(".selectselect select, .selectselect input").each(function()
		{
			$(this).change(function()
			{
				$(this).val($(this).val());
				price_ = parseInt(price_adjust[$(this).val()]);
				$(".priceplace").html(price+parseInt(price_adjust[$(this).val()])).colorBlend([{colorList:["#FFEB95", "white"], param:"background", duration:3000, isFade:false, cycles:1}]);
				$("h2 strong").html(price+parseInt(price_adjust[$(this).val()])).colorBlend([{colorList:["#FFEB95", "white"], param:"background", duration:3000, isFade:false, cycles:1}]);
			});
		});

		$(".selectselect2 select, .radioselect input, .selectselect2 input").each(function()
		{
			$(this).change(function()
			{
				if (last_price != price+parseInt(price_adjust[$(this).val()])+price_){
					last_price = price+parseInt(price_adjust[$(this).val()])+price_;
					$(".priceplace").html(price+parseInt(price_adjust[$(this).val()])+price_).colorBlend([{colorList:["#FFEB95", "white"], param:"background", duration:3000, isFade:false, cycles:1}]);
					$("h2 strong").html(price+parseInt(price_adjust[$(this).val()])+price_).colorBlend([{colorList:["#FFEB95", "white"], param:"background", duration:3000, isFade:false, cycles:1}]);
				}
			});
		});

		$(".column-wrapper .selectselect input[type='hidden']").each(function()
		{
				newprice+=parseInt(price_adjust[$(this).val()]);
		});

		$(".priceplace").html(newprice);
		$("h2 strong").html(newprice);
	}

	$(".add_to_cart form").submit(function()
	{
//		var color=0, size=0;

		var json_object={};
		json_object.nid=$(this).find("#edit-nid").val();
		json_object.qty=$(this).find("#edit-qty").val();
//		json_object.attributes=[];	

		$(this).find(".radioselect input").each(function()
		{					
			if($(this).attr("checked"))
			{
//				alert($(this).attr("aid"));
				json_object[$(this).attr("aid")]=$(this).val();
			}
		});

		if($(this).find(".selectselect select, .selectselect2 select").length)
		{
			$(this).find(".selectselect select, .selectselect2 select").each(function()
			{		
				json_object[$(this).attr("aid")]=$(this).val();
			});
		}
		//else
		//{
			if($(this).find(".selectselect input").length)
			{
				json_object[$(this).find(".selectselect input").attr("aid")]=$(this).find(".selectselect input").val();
			}
			if($(this).find(".selectselect input, .selectselect2 input").length)
			{
				json_object[$(this).find(".selectselect2 input").attr("aid")]=$(this).find(".selectselect2 input").val();
			}
		//}

		var button=$(this).find("input[type=image]");
//		url(../i/btn-adding2cart.gif)
		button.attr('src', '/themes/hm/i/btn-adding2cart.gif');
	
		$.post("/hanuman/addtocart", json_object, function(data)
		{	
			if($("#cart_container").html()=='')
			{
				$("#cart_container").html(data.html);
				$("#cart_container .block").hide;
				$("#cart_container .block").show("slide", { direction: "up" }, 1000);
			}
			else
			{
				$("#cart_container").html(data.html);
			}
			
			button.effect("transfer", { to: "div#cart_container .content a" }, 500);
			button.attr('src', '/themes/hm/i/btn-added.png');
			pageTracker._trackPageview("/cart/ajax-add-to-cart");
			if(data.messages)
			{
				$("#messages_container").html(data.messages);
			}
		}, "json");

		return false;
	});	
	HideButtonText();
});

function HideButtonText()
{
	$("form").each(function()
	{
		$("input.button-image").each(function()
		{
			var oldval=$(this).val();
			$(this).val('');
			$(this).click(function()
			{
				$(this).val(oldval);
			});
		});
	});
}

function company_apply_address(address_str)
{
	eval('var address = ' + address_str + ';');
	
	$("#edit-panes-delivery-company-name").val(address.company_name).trigger('change');
	$("#edit-panes-delivery-company-inn").val(address.company_inn).trigger('change');
	$("#edit-panes-delivery-company-kpp").val(address.company_kpp).trigger('change');
	$("#edit-panes-delivery-company-address").val(address.company_address).trigger('change');
	$("#edit-panes-delivery-company-factaddress").val(address.company_factaddress).trigger('change');
	$("#edit-panes-delivery-company-rs").val(address.company_rs).trigger('change');
	$("#edit-panes-delivery-company-bank").val(address.company_bank).trigger('change');
	$("#edit-panes-delivery-company-bik").val(address.company_bik).trigger('change');
	$("#edit-panes-delivery-company-ks").val(address.company_address).trigger('ks');
	$("#edit-panes-delivery-delivery-last-name").val(address.delivery_last_name).trigger('change');
	$("#edit-panes-delivery-delivery-first-name").val(address.delivery_first_name).trigger('change');
	$("#edit-panes-delivery-delivery-middle-name").val(address.middle_name).trigger('change');
	$("#edit-panes-delivery-delivery-phone").val(address.delivery_phone).trigger('change');
}

function hideGoods(sid)
{
	var size;
	var activate=0;
	if(sid)
		size=sid;
	else
	{
		if($(".selectselect select").length)
			size=$(".selectselect select").val();
		else
			size=$(".selectselect input").val();
	}
	if(size)
	{
		$(".radioselect input").each(function()
		{		
			//alert($(this).attr("checked"));
			if(attr_statuses[size][$(this).val()])
			{
				
				if(activate && activate!=$(this).val())
				{
					$(this).parent().parent().parent().removeClass("active").show();
					$(this).parent().parent().parent().show();
				}
				else
				{
					//alert("as");
					$(this).attr("checked", true);
					$(this).parent().parent().parent().addClass("active").show();
					activate=$(this).val();
				}
			}
			else
			{
				$(this).parent().parent().parent().removeClass("active").hide();
			}
		});
		$(".selectselect2 select").each(function()
		{		
			$(this).empty();
			var oSelect = this;
			for(var i=0; i < tind.length; i++){
			if(attr_statuses[size][tind[i]]){
				var oOption = document.createElement('OPTION');
				oSelect.options.add(oOption);
				oOption.innerHTML = tname[i];
				oOption.value = tind[i];
			}

			}
		});
		$(".selectselect2 input").each(function()
		{		
			//alert($(this).attr("checked"));
			if(attr_statuses[size][$(this).val()])
			{
				
				if(activate && activate!=$(this).val())
				{
					$(this).parent().parent().removeClass("active").show();
					$(this).parent().parent().show();
				}
				else
				{
					//alert("a");
					$(this).attr("checked", true);
					$(this).parent().parent().addClass("active").show();
					activate=$(this).val();
				}
			}
			else
			{
				$(this).parent().parent().removeClass("active").hide();
			}
		});
	}
}

function in_array(needle, haystack, strict) {    // Checks if a value exists in an array
    // 
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
 
    var found = false, key, strict = !!strict;
 
    for (key in haystack) {
        if ((strict && haystack[key] === needle) || (!strict && haystack[key] == needle)) {
            found = true;
            break;
        }
    }
 
    return found;
}

;
/* AGGREGATED JS FILE: sites/hanuman.ru/modules/google_analytics/googleanalytics.js */
// $Id: googleanalytics.js,v 1.1.2.2 2008/05/03 22:18:03 hass Exp $

if (Drupal.jsEnabled) {
  $(document).ready(function() {

    $('a').click( function() {
      var ga = Drupal.settings.googleanalytics;
      // Extract the domain from the location (the domain is in domain[2]).
      // http://docs.jquery.com/Plugins/Validation/Methods/url
      var domain = /^(https?|ftp|news|nntp|telnet|irc|ssh|sftp|webcal):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)*(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.exec(window.location);
      // Expression for check external links.
      var isInternal = new RegExp("^(https?|ftp|news|nntp|telnet|irc|ssh|sftp|webcal):\/\/" + domain[2], "i");
      // Expression for special links like gotwo.module /go/* links.
      var isInternalSpecial = new RegExp("(\/go\/.*)$", "i");
      // Expression for check download links.
      var isDownload = new RegExp("\\.(" + ga.trackDownloadExtensions + ")$", "i");

      // Is the clicked URL internal?
      if (isInternal.test(this.href)) {
        // Is download tracking activated and the file extension configured for download tracking?
        if ((ga.trackDownload && isDownload.test(this.href)) || isInternalSpecial.test(this.href)) {
          // Keep the internal URL for Google Analytics website overlay intact.
          if (ga.LegacyVersion) {
            urchinTracker(this.href.replace(isInternal, ''));
          }
          else {
            pageTracker._trackPageview(this.href.replace(isInternal, ''));
          }
        }
      }
      else {
        if (ga.trackMailto && this.href.indexOf('mailto:') == 0) {
          // Mailto link clicked.
          if (ga.LegacyVersion) {
            urchinTracker('/mailto/' + this.href.substring(7));
          }
          else {
            pageTracker._trackPageview('/mailto/' + this.href.substring(7));
          }
        }
        else if (ga.trackOutgoing) {
          // External link clicked. Clean and track the URL.
          if (ga.LegacyVersion) {
            urchinTracker('/outgoing/' + this.href.replace(/^(https?|ftp|news|nntp|telnet|irc|ssh|sftp|webcal):\/\//i, '').split('/').join('--'));
          }
          else {
            pageTracker._trackPageview('/outgoing/' + this.href.replace(/^(https?|ftp|news|nntp|telnet|irc|ssh|sftp|webcal):\/\//i, '').split('/').join('--'));
          }
        }
      }
    });
  });
}

