// JavaScript Document $(document).ready(function() { Shops.Init(); Contact.Init(); }); var Contact = { Init : function() { $("#customer-service").find("a").click(function() { $("#customer-service").find("a").removeClass("current"); $(this).addClass("current"); $("#customer-service").find("a").each(function() { $("#content_"+$(this).attr("data")).hide(); }); $("#content_"+$(this).attr("data")).show(); $("#this_content").scrollTop(0); }); $("#customer-service").find("a:first").click(); }, CS_Submit : function ( form ) { var valid = true; if ( valid ) valid = validation.checkbox ( $(form).find("input[name=salutation]:checked"), "Please select your salutation." ); if ( valid ) valid = validation.field ( $(form).find("input[name='txt_name']"), "", "Please enter your name." ); if ( valid ) valid = validation.field ( $(form).find("input[name='txt_surname']"), "", "Please enter your surname." ); if ( valid ) valid = validation.email ( $(form).find("input[name='txt_email']"), "", "Please enter a valid email address." ); if ( valid ) valid = validation.field ( $(form).find("input[name='txt_phone']"), "", "Please enter your phone." ); if ( valid ) { if ( !$(form).find("input[name='agree']").is(":checked") ) { valid = false; alert ( "Please accept our privacy policy." ); } } if ( valid ) $(form).submit(); }, CV_Submit : function ( form ) { var valid = true; if ( valid ) valid = validation.field ( $(form).find("input[name='txt_name']"), "", "Please enter your name." ); if ( valid ) { if ( !$(form).find("input[name='agree']").is(":checked") ) { valid = false; alert ( "Please accept our privacy policy." ); } } if ( valid ) $(form).submit(); } } var Shops = { Init : function() { $("#location-menu").find("a") .click(function() { $("#location-menu").find("a").removeClass("current"); $(this).addClass("current"); switch ( $(this).attr("data-type") ) { case "all" : $(".head_office").show(); $(".hong_kong").show(); $(".kowloon").show(); $(".nt").show(); break; default : $(".head_office").hide(); $(".hong_kong").hide(); $(".kowloon").hide(); $(".nt").hide(); $("."+$(this).attr("data-type")).show(); break; } $("#location-container").scrollTop(0); }); } } var Popup = { P : null, Show : function ( index ) { var list = $("#collection-list"); var image = ""; $(list).find(".items").each(function() { if ( $(this).attr("index") == index ) image = $(this).attr("large"); }); this.P = window.parent.$("#popup"); $(this.P).empty(); /* $(this.P).click(function() { window.parent.ParentPopup.Close(); }); */ $(this.P).html ( '
' ).show(); $(this.P).find("img").draggable(); $(this.P).find(".btn-prev").click(function() { var i = ( index - 1 >= 0 ) ? index - 1 : Collection.Total - 1; Popup.Show ( i ); }); $(this.P).find(".btn-next").click(function() { var i = ( index + 1 < Collection.Total ) ? index + 1 : 0; Popup.Show ( i ); }); window.parent.ParentPopup.Init(); } } var Popup2 = { P : null, Show : function ( image ) { this.P = window.parent.$("#popup"); $(this.P).empty(); $(this.P).html ( '
' ).show(); $(this.P).find("img").draggable(); } } var Effect = { data : null, index : 0, init : function( data, limit ) { if ( limit != undefined ) this.photoLimit = limit; this.data = data; this.preload(); }, speed : 300, duration : 5000, countLoaded : 0, photoLimit : 3, preload : function() { var _this = this; this.countLoaded = 0; var imgArray = new Array(); for ( var i = 1; i <= this.photoLimit; i++ ) { imgArray.push( new Image() ); var img = imgArray[ imgArray.length - 1 ]; img.index = i; img.src = this.data [ this.index ].photo; img.onload = function() { _this.countLoaded ++; if ( _this.countLoaded >= _this.photoLimit ) { _this.render ( imgArray ); } } this.index = ( this.index + 1 < this.data.length ) ? this.index + 1 : 0; } }, render : function ( data ) { this.isInit = false; for ( var j = 0; j < data.length; j++ ) { var id = "#photo"+ (j+1); $(id).attr( { index:j }); var proc = function( obj ) { var index = $(obj).attr("index"); var src = data%5bindex%5d.html $(obj).html ( '' ); $(obj).css({ opacity:0 }); $(obj).stop().animate({ opacity:1 }, 1000 ); } if ( $(id).html() != "" ) { $(id).oneTime ( j * this.speed, null, function() { $(this).stop().animate({ opacity:0 }, 1000, null, function() { proc ( this ); }); }); } else { proc(id); } } this.queue(); }, queue : function() { var _this = this; $("#home-display").oneTime ( this.duration, null, function() { _this.preload(); }); } } var Collection = { Total : 0, Interval : null, IsMobile : false, Init : function() { var _this = this; /* if ( !this.IsMobile ) { $(".btn-prev").mousedown(function() { _this.Interval = setInterval ( _this.Prev, 10 ); }); $(".btn-prev").mouseup(function() { clearInterval ( _this.Interval ); }); $(".btn-next").mousedown(function() { _this.Interval = setInterval ( _this.Next, 10 ); }); $(".btn-next").mouseup(function() { clearInterval ( _this.Interval ); }); } else { */ $(".btn-prev").click(function() { var l = $("#content").scrollLeft() $("#content").animate({ "scrollLeft":l - 500 }); }); $(".btn-next").click(function() { var l = $("#content").scrollLeft() $("#content").animate({ "scrollLeft":l + 500 }); //$("#content").scrollLeft ( l + 300 ); }); //} }, Prev : function() { var l = $("#content").scrollLeft() $("#content").scrollLeft ( l - 10 ); }, Next : function() { var l = $("#content").scrollLeft() $("#content").scrollLeft ( l + 10 ); } }