$.extend({
	getUrlVars:function() {
		var vars = [], hash;
		var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
		for(var i = 0; i < hashes.length; i++) {
			hash = hashes[i].split('=');
			vars.push(hash[0]);
			vars[hash[0]] = hash[1];
		}
		return vars;
	},
	getUrlVar:function(name) {
		return $.getUrlVars()[name];
	}
});
$.fn.extend({
	openFuncybox:function(mode) {
		code = $.getUrlVar('itemCd');
		if(code == undefined) {
			return;
		}
		
		if(mode == 'mens_new_arrival') {
			url = '/collection/mens/new_arrival/data.js';
			width = 380;
			height = 730;
		} else if(mode == 'ladies_new_arrival') {
			url = '/collection/ladys/new_arrival/data.js';
			width = 380;
			height = 730;
		} else if(mode == 'mens_styling') {
			url = '/collection/mens/styling/data.js';
			width = 625;
			height = 525;
		} else if(mode == 'ladies_styling') {
			url = '/collection/ladys/styling/data.js';
			width = 625;
			height = 525;
		} else {
			return;
		}
		
		$.ajax({
			url:url,
			dataType:'jsonp',
			jsonpCallback:'callback_fancybox',
			success:function(data, status) {
				$('body').after('<a href="' + data[code].path + '" class="iframe" style="display:none;" id="openFuncyboxElement">&nbsp;</a>');
				$("#openFuncyboxElement").fancybox({
					width:width,
					height:height,
					showNavArrows:false
				});
				$('#openFuncyboxElement').click();
			}
		});
	}
});
$(function() {
	$('#globalNav li').hover(
		function() {
			$('ul', this).animate(
				{height: "toggle"},
				'fast'
			);
		},
		function() {
			$('ul', this).animate(
				{height: "toggle"},
				'fast'
			); 
		}
	); 
});
