// global javascript

$(function() {
	
	$('#inputBox').hide();
	
    $("img[ref=over]")  
        .mouseover(function () {  
            this.src = this.src.replace(/^(.+)(\.[a-z]+)$/, "$1_over$2");  
        })  
        .mouseout(function () {  
            this.src = this.src.replace(/^(.+)_over(\.[a-z]+)$/, "$1$2");  
        })  
        .each(function () {  
            this.preloaded = new Image;  
            this.preloaded.src = this.src.replace(/^(.+)(\.[a-z]+)$/, "$1_over$2");  
    });
    
  $('a.pagetop').click(function() {
     $(this).blur();
     $('html,body').animate({scrollTop: 0}, 1000, 'quad');
     return false;
  });
  
  $('#mainMenu').scrollFollow({
    container: 'menu-holder-td',
    offset: 80
  });

	/*
	$('#productLi').toggle(
		function() {$('#productSub').show('slow')},
		function() {$('#productSub').hide('slow')}
	);
	*/
});

jQuery.easing.quad = function (x, t, b, c, d) {
    return -c * ((t=t/d-1)*t*t*t - 1) + b;
};

function loginCh(url) {
	$('#login_hs').val(hex_sha1($('#login_id').val() + $('#login_pwd').val() + $('#login_hs').val()));
	$('#login_pwd').val('');
	
	$('#loginForm').submit();
}

function loadForm(formID, url) {
	$(formID).load(url);
	$(formID+":hidden").show("normal");
}

function hideForm(formID) {
	$(formID).fadeOut("normal");
}

function hideFormInput() {
	$("#inputBox").fadeOut("normal");
}

function postForm(formID, url, paramID) {
	var param = {};
	$('input',$(paramID)).each(function() {
		param[$(this).attr('name')] = ($(this).val())? $(this).val() : '';
	});
	$('select',$(paramID)).each(function() {
		param[$(this).attr('name')] = ($(this).val())? $(this).val() : '';
	});
	$('textarea',$(paramID)).each(function() {
		param[$(this).attr('name')] = ($(this).val())? $(this).val() : '';
	});
	$(formID).load(url, param);
}
