//=====================================================//
var LoadReadyLocal = {

    /*registerForm: function(exPar){
        $(function() {
            var options = {
                url: exPar['formAction'],
                success: Validate.validateFormData,
                beforeSubmit: function() {},
                dataType: 'json'

            };
            $('#registerForm').ajaxForm(options);
        });
    },*/

    registerForm: function(){
        $(function() {
            Member.setupRegisterForm();
        });
    },
    newsLetterForm: function(){
        $(function() {
            Content.setupNewsletterForm();
        });
    },
    enquiryForm: function(){
        $(function() {
            Content.setupEnquiryForm();
        });
    }
};

LoadReady = $.extend(LoadReady, LoadReadyLocal);


$(function() {

    $('#list li:nth-child(even)').css({'background-color': '#eff3ef'});

    // set the border right of last item to 0 //
    $('#list li:nth-child(even)').css({'background-color': '#eff3ef'});
    $('table.generic tr:nth-child(even)').css({'background-color': '#f3f3f3'});
    $('#keyword').focus(function(){
        var value = $(this).val();
        if ($(this).val() == 'keyword search'){
            $(this).val("");
        }
    });

    $('#fld_email').focus(function(){
        var value = $(this).val();
        if ($(this).val() == 'Email Address'){
            $(this).val("");
        }
    });

    $('#fld_pass_word').focus(function(){
        var value = $(this).val();
        if ($(this).val() == 'password'){
            $(this).val("");
        }
    });
    
    catLang = 'chi';
    
    $('#catLangSwitch').click(function(e){
        e.preventDefault();
        url = $(this).attr('href') + catLang;
        $.get(url, function(data){
            $('#vlistOuter').html(data);
            langText = (catLang == 'chi') ? 'ENG' : '中文';
            $('#catLangSwitch').text(langText);
            catLang = (catLang == 'chi') ? 'eng' : 'chi';
        });
    
    });


	var offsetX = 10;
	var offsetY = -125;
    $('.row td a img').hover(function(e) {
    	var src = $(this).attr('src');
        var filePathArr = src.split("/");
        var fileName = filePathArr[filePathArr.length - 1];
        var href = "/media/product/normal/" + fileName;
        
        imgObj = new Image(); 
        imgObj.src = href;
        
        imgObj.onload = function(){
	        $('<img id="hoverLargeImage" src="' + href + '" alt="" />')
	        .css('top', e.pageY + offsetY)
	        .css('left', e.pageX + offsetX)
	        .appendTo('body')
	        .hide()
	        .fadeIn(1000)
	        ;
	    }

    }, function() {
        $('#hoverLargeImage').remove();
    });

    $('.row td a img').mousemove(function(e) {
        $("#hoverLargeImage").css('top', e.pageY + offsetY).css('left', e.pageX + offsetX);
    });

    $(".productList tr:even").css("background-color", "#EFFFCE");
    $(".productList tr:odd").css("background-color", "#EFF1F1");

    $('.loginBtn').livequery('click', function(e) {
        Member.loginForm.call(this, e);
    });

    $('.floatBoxLContent .floatBoxLrow').hover(
        function () {
            $(this).css('border-bottom', '3px solid #99cc33');
        },
        function () {
            $(this).css('border-bottom', '3px solid #dddddd');
        }
    );

});

