
	if ("https:" == document.location.protocol) {
		var base_url = '';
	} else {
		var base_url = '';
	}

	var glv_products = {};
	glv_products['bh-01']     = '1';
	glv_products['bh-02']     = '2';
	glv_products['bh-03']     = '3';
	glv_products['bh-try']    = '4';
	glv_products['nla-first'] = '5';
	glv_products['nla-nml']   = '6';
	glv_products['bh-reg']    = '7';
	glv_products['nla-reg']   = '8';
	glv_products['se-body']   = '9';
	glv_products['se-mat']    = '10';
	glv_products['se-arm']    = '11';

	var login_check = base_url + '/login.php';
	var login_id_text = 'agent_id';
	var login_pw_text = 'agent_pw';


	$(function(){

		// AJAXのキャッシュOFF
		$.ajaxSetup({ cache: false });

		// リンクの点線除去
		$('a').focus( function(){ if(this.blur)this.blur(); });

		if ($.browser.msie) {
			$(':header:has(a), li:has(a), dt:has(a), dd:has(a)').each(function(){
				font_color = $(this).css('color');
				$('a', this).css('color', font_color);
			});
		}

		// 画像ロールオーバー
		$('img.imgover').rollover('_on');
		// 画像ロールオーバー(点滅)
		$('img.imgfade, a img, input[type="image"]').live('mouseover', function () {
			$(this).animate({opacity:'0.6'}, {duration: 500} );
			$(this).animate({opacity:'1.0'}, {duration: "normal"});
		});

		// コメント内のリンク
		$('div.content a[href^="http"]').addClass('blank');
		$('a[href$=".pdf"]').addClass('blank');
		// 別窓
		$('a.blank').live('click', function(){ this.target = "_blank"; });

		// メールスパム対策
		$('span.mail').each(function(){
			var mailadd = $(this).text();
			mailadd = mailadd.replace('atmark', '@');
			$(this).html('<a href="mailto:' + mailadd + '">' + mailadd + '</a>');
		});

		// ポップアップ
		SexyLightbox.initialize({color:'white', dir: base_url + '/img', imagesdir:base_url + '/img'});

		$('select.number[max]').each(function(){
			var min = $(this).attr('min') == undefined ? 0 : $(this).attr('min');
			var max = $(this).attr('max');
			var option = "";
			for (i=min; i<=max; i++) {
				option += '<option value="' + i + '">' + i + '</option>';
			}
			$(this).html(option);
		});

		$('img[pdtcd]').click(set_cart);
		load_cart();

		$('#login').click(argent_login);

	});

	function chgImg () {  }

	function load_cart () {
		$('#cart_price').load(base_url + '/cart/ #cartarea',function (){
			$('a:has(#button_cartin)').click(function(){
				jQuery.cookie('backurl', location.href, { expires: 7, path: base_url + '/' });
			});
		});
	}

	function set_cart () {
		quantity = 1;
		thisForm = $(this).closest('form');
		if ($(thisForm).size() == 1 && $('.number', thisForm).size() == 1) {
			quantity = $('.number', thisForm).val();
		}

		var url = base_url + '/cart/products/detail.php?product_id=' + glv_products[$(this).attr('pdtcd')];
		var data = {
			'mode':'cart',
			'quantity':quantity,
			'product_id':glv_products[$(this).attr('pdtcd')]
		};
		jQuery.post(url, data, function() {
			load_cart();
			alert('商品を買い物カゴに追加しました');
		});
	}

	function argent_login () {
		var data = {};
		data['agent_id'] = $('input[name="' + login_id_text + '"]').val();
		data['agent_pw'] = $('input[name="' + login_pw_text + '"]').val();
		jQuery.postJSON(login_check, data, function (data) {
			if (data.state == 'err') {
				alert('IDかPASSの入力に誤りがあります');
			} else if (data.state == 'ok') {
				location.href = data.agent_page;
			}
		});
	}

	function to_object (json_str) {
		return eval('(' + json_str + ')');
	}

	jQuery.postJSON = function(url, data, callback) {
		jQuery.post(url, data, callback, "json");
	};
	
