$(window).load(function() {

        var theWindow        = $(window),
            $bg              = $("#bg"),
            aspectRatio      = $bg.width() / $bg.height();

        function resizeBg() {

                if ( (theWindow.width() / theWindow.height()) < aspectRatio ) {
                    $bg
                        .removeClass()
                        .addClass('bgheight');
                } else {
                    $bg
                        .removeClass()
                        .addClass('bgwidth');
                }

        }

        theWindow.resize(function() {
                resizeBg();
        }).trigger("resize");

});
$(document).ready(function(){

       $('.item_pic').hover(function(){
            $(this).next('.store_popup_container').show();
       },function(){
            $(this).next('.store_popup_container').hide();
       });
       
});


// A class of utility functions
SC = new Object();
SC.util = {
	// Turns the passed argument into an array
	toArray: (function () {
		var slice = Array.prototype.slice;
		return function (array, index) {
			var ret;
			if(!SC.IE || SC.is.array(array)) {
				ret = slice.call(array, index || 0);
			}
			else {
				ret = [];
				for(var i = 0, elem; elem = array[i]; i++) {
					ret[i] = elem;
				}
			}
			return ret;
		};
	})(),

	// Clones an object (the second object will always have the properties of the first)
	clone: function (obj) {
		var fn = new Function;
		fn.prototype = obj;
		return new fn();
	},

	// No Operation
	noop: function () {
		return new Function;
	},

	// Run the function only one time
	runOnce: function (fn) {
		var run = typeof fn !== 'function', undf;
		return function () {
			return run === (run = true) ? undf : fn.apply(this, arguments);
		};
	},

	// Curry a function for later use
	curry: function (fn) {
		var self = this;
		var args = SC.util.toArray(arguments, 1);
		return function () {
			fn.apply(self, args.concat(SC.util.toArray(arguments)));
		};
	},

	// Call only after called
	debounce: function (fn, to) {
		var timer;
		return function () {
			clearTimeout(timer);
			timer = setTimeout(SC.util.curry.apply(this, [fn].concat(SC.util.toArray(arguments))), to);
		};
	},

	frameDoc: function (iframe) {
		return iframe.contentDocument || iframe.contentWindow && iframe.contentWindow.document || iframe.document || iframe.id && window.frames[iframe.id].document;
	},

	frameWin: function (iframe) {
		return iframe.contentWindow || iframe.window ||iframe.id && window.frames[iframe.id].window;
	},

	frameBody: function (iframe) {
		var doc = SC.util.frameDoc(iframe);
		return doc && doc.body;
	},

	frameHTML: function (iframe) {
		var body = SC.util.frameBody(iframe);
		return body && body.innerHTML;
	},

	// Remove tags from HTML
	striptags: (function () {
		var rStrip = /<[^>]+>/;
		return function (html) {
			return SC.is.str(html) && html.split(rStrip).join('');
		}
	})(),

	// Minimizes the number of spaces
	minSpaces: (function () {
		var rHead = /^\s+/,
			rOne = /\s{2,}/,
			rTail = /\s+$/;
		return function (text) {
			return SC.is.str(text) && text
				.replace(rHead, '')
				.replace(rTail, '')
				.replace(rOne, '');
		}
	})(),

	// Replaces whitespace with string
	noWS: (function () {
		var rWS = /\W+/g;
		return function (str, replace) {
			return str.replace(rWS, replace || '');
		};
	})(),

	// returns the max object based on property
	maxProp: function (prop, a, b) {
		return a[prop] < b[prop] ? b : a;
	},

	// Returns the min object based on property
	minProp: function (prop, a, b) {
		return a[prop] > b[prop] ? b : a;
	},

	// Checks if function is valid before running
	run: function (fn) {
		if(SC.is.fn(fn)) {
			return fn.apply(this, SC.util.toArray(arguments, 1));
		}
	},

	// Adds a trailing slash to path (if not string, returns empty string)
	tailSlash: function (path) {
		return SC.is.str(path) ? path.replace(/(.)\/?$/, '$1/') : '';
	},

	// Returns default if val is undefined (if just obj is passed, then returns default function
	defaultValue: function (obj, val) {
		return SC.is.undf(obj) ? val
			: !SC.is.undf(val) ? obj
			: function (key, val) {
				return !SC.is.undf(obj[key]) ? obj[key] : val;
			};
	},

	// Round number to accurcy level (1 = int, .1 = tenths, .001 = hundreths, 10 = tens)
	round: function (num, accr) {
		accr = 1 / (accr || 1);
		return Math.round(num * accr) / accr;
	},

	addParam: (function () {
		var rMark = /\?/;
		return function (src, key, val) {
			return src+(rMark.test(src)?'&':'?')+key+(val?'='+val:'');
		};
	})()
};
