﻿function LTrim( value ) 
{
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
}

function RTrim( value ) 
{
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
}


function trim( value ) 
{
	return LTrim(RTrim(value));
}

function validate(email) 
{
   
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   return reg.test(email); 
}

	function myGetWindowWidth() {
		var windowWidth = 0;
		if (typeof(window.innerWidth) == 'number') {
			windowWidth = window.innerWidth;
		}
		else {
			if (document.documentElement && document.documentElement.clientWidth) {
				windowWidth = document.documentElement.clientWidth;
			}
			else {
				if (document.body && document.body.clientWidth) {
					windowWidth = document.body.clientWidth;
				}
			}
		}
		return windowWidth;
	}
	
	
function  KeepPostion()
{
        var wW = myGetWindowWidth()/2;
      	$('#footertxtname').css("left",(wW - 400) + "px");
      	$('#footertxtemail').css("left",(wW - 218) + "px");
      	$('#footerbtnsubmit').css("left",(wW - 43) + "px");
      	$('#footerfacebook').css("left",(wW + 260) + "px");
      	$('#footersharefacebook').css("left",(wW + 311) + "px");
      	$('#footersharetwitter').css("left",(wW + 342) + "px");
      	$('#footershareemail').css("left",(wW + 373) + "px");
      	$('#msgName').css("left",(wW - 400) + "px");
      	$('#msgEmail').css("left",(wW - 218) + "px");
      	$('#divThankYou').css("left",(wW + 50) + "px");
      	
}	
var map;

 function gmapinitialize() {
        if (GBrowserIsCompatible()) {
            // initialize
            map = new GMap2(document.getElementById("content-location-map-google"));
            map.setCenter(new GLatLng(22.357061, 114.10469), 10);
            map.addControl(new GSmallZoomControl());
            displayMarkersUne();
        }
    }
 // Custom icon for the markers
    var customIcon;
    // Function to add an marker to the map 
    function createMarker(latlng, message) {
        markerOptions = { icon: customIcon };
        var marker = new GMarker(latlng, markerOptions);
        GEvent.addListener(marker, "click", function() {
            var myHtml = message;
            map.openInfoWindowHtml(latlng, myHtml);
        });
        return marker;
    }
     function displayMarkersUne() {
        // Hong Kong
        
        map.addOverlay(createMarker(new GLatLng(22.286778, 114.217386), "<font class=\"mapText\"><strong>太古城中心 - 太古</strong><br />香港太古城太古城道18號太古城中心302A號鋪<br />Shop 302A, Cityplaza, 18 Tai Koo Shing Rd., Tai Koo Shing, HK<br/>Tel: 2513 6910</font>"));

        // Kowloon

        map.addOverlay(createMarker(new GLatLng(22.318225, 114.168613), "<font class=\"mapText\"><strong>朗豪坊 - 旺角</strong><br />旺角亞皆老街8號朗豪坊L3-33號舖<br />Shop 33, L3 Langham Place, 8 Argyle Street, Mongkok, Kln<br/>Tel: 3514 4329</font>"));

        map.addOverlay(createMarker(new GLatLng(22.297897, 114.167916), "<font class=\"mapText\"><strong>港威商場 - 海港城</strong><br />九龍海港城港威商場2/F 2120B號舖<br />Shop 2120B, Level Two, Gateway Arcade, Harbour City, TST, Kln<br/>Tel: 2314 2909</font>"));

        //map.addOverlay(createMarker(new GLatLng(22.337205, 114.174643), "<font class=\"mapText\"><strong>又一城 - 九龍塘</strong><br />九龍塘達之路80號又一城UG 01號舖 (LOG ON)<br />LOG ON - Unit 01, UG Festival Walk, 80 Tat Chi Road, Kowloon Tong, Kln<br/>Tel: 3104 1198</font>"));

        // N.T.

        map.addOverlay(createMarker(new GLatLng(22.371334, 114.118831), "<font class=\"mapText\"><strong>千色百貨 - 荃灣</strong><br />荃灣城市中心2期1/F, 1-04千色Citistore<br />1-04, 1/F., Tsuen Wan Citistore, Tsuen Wan, N.T.<br/>Tel: 2151 0882</font>"));

        map.addOverlay(createMarker(new GLatLng(22.381190, 114.188139), "<font class=\"mapText\"><strong>一田百貨 - 沙田</strong><br />新界沙田新城市中心3期2/F一田百貨<br />2/F., Phase 3, New Town Plaza, 3 - 9 Shatin Centre St., Shatin, N.T.<br/>Tel: 2603 0680</font>"));

        map.addOverlay(createMarker(new GLatLng(22.444926, 114.024020), "<font class=\"mapText\"><strong>元朗廣場 - 元朗</strong><br />新界元朗青山公路元朗廣場1/F 128號舖<br />Shop 128 Yuen Long Plaza, Castle Peak Road, Yuen Long, N.T.<br/>Tel: 2443 2562</font>"));

        map.addOverlay(createMarker(new GLatLng(22.393110, 113.975671), "<font class=\"mapText\"><strong>時代廣場 - 屯門</strong><br />屯門時代廣場北翼3/F Id:c<br />id:c - Level 3, North Wing, Trend Plaza, Tuen Mun, N.T.<br/>Tel: 2441 9498</font>"));
		
		map.addOverlay(createMarker(new GLatLng(22.35762, 114.12720), "<font class=\"mapText\"><strong>新都會廣場 - 葵芳</strong><br />葵芳興芳路223號新都會廣場L2 240 - 241號舖<br />Shop 240-241, Level 2, Metro Plaza, Kwai Fong, N.T.<br/>Tel: 2410 1588</font>"));

        // Macau

        //map.addOverlay(createMarker(new GLatLng(22.19351, 113.539726), "<font class=\"mapText\"><strong>中央廣場 - 新馬路</strong><br />澳門新馬路39號中央廣場G/F<br />Tel: (853) 2835 5269</font>"));

    }
    
$(document).ready(function()
{
	    var selected = "bra";
	    var braPage = 1;
	    var pantyPage = 1;
	    var vestPage = 1;
	    
	    var maxBraPage = 3;
	    var maxPantyPage = 4;
	    var maxVestPage = 1;
	    
	   var selectedNews = "1";
	  var selectedView = "m";
	
	$('.gifBtn').mouseover(function() {
  	    var src = $(this).attr('src');
   	    $(this).attr('src', src.replace(".gif","_d.gif"));
    });
        
    $('.gifBtn').mouseout(function() {
        var src = $(this).attr('src');
   	    $(this).attr('src', src.replace("_d.gif",".gif"));
    });
    
    $('#name').click(function() {
  	    $('#divThankYou').hide();
  	    var name = $(this).val();
  	    if (name == "--Your Name--")
  	        $(this).val("");
    });
     $('#email').click(function() {
  	    $('#divThankYou').hide();
  	    var name = $(this).val();
  	    if (name == "--Your Email--")
  	        $(this).val("");
    });
    
       $('#btnSubmit').click(function() {
  	         $('#divThankYou').hide();
  	        var ok = true;
  	        var name = trim($('#name').val());
  	        var email = trim($('#email').val());
  	        if (name == "" || name == "--Your Name--")
  	        {
  	              $('#msgName').show();
  	              ok = false;
  	        }
  	        else
  	        {
  	            $('#msgName').hide();
  	        }
  	        if (email == "" || email == "--Your Email--" || validate(email) == false)
  	        {
  	              $('#msgEmail').show();
  	              ok = false;
  	        }
  	        else
  	        {
  	            $('#msgEmail').hide();
  	        }
  	        
  	        if (ok)
  	        {
  	            //$('#divThankYou').show('slow');
  	            loadByAjax('divThankYou', "sub.aspx", name , email);
  	        }
    });
    
    

    
     $('#bra').mouseover(function() {
  	     if (selected != "bra")
        {
  	        var src = $(this).attr('src');
   	        $(this).attr('src', src.replace(".gif","_d.gif"));
   	    }    
    });
    
       $('#bra').mouseout(function() {
        if (selected != "bra")
        {
            var src = $(this).attr('src');
   	        $(this).attr('src', src.replace("_d.gif",".gif"));
   	    }    
    });
    
    $('#bra').click(function() {
        if (selected != "bra")
        {
            selected = "bra";
            $('#bra').attr('src', 'images/btn_bra_s.gif');
            $('#panty').attr('src', 'images/btn_panty.gif');
            $('#vest').attr('src', 'images/btn_vest.gif');
            $('#divPanty').hide();
            $('#divVest').hide();
            $('#divBra').show('slow');
   	    }    
    });
    
    $('#panty').mouseover(function() {
        if (selected != "panty")
        {
            var src = $(this).attr('src');
            $(this).attr('src', src.replace(".gif","_d.gif"));
   	    }
    });
    
    $('#panty').mouseout(function() {
        if (selected != "panty")
        {
            var src = $(this).attr('src');
   	        $(this).attr('src', src.replace("_d.gif",".gif"));
   	    }    
    });
    
    $('#panty').click(function() {
        if (selected != "panty")
        {
            selected = "panty";
            $('#panty').attr('src', 'images/btn_panty_s.gif');
            $('#bra').attr('src', 'images/btn_bra.gif');
            $('#vest').attr('src', 'images/btn_vest.gif');
            $('#divVest').hide();
            $('#divBra').hide();
            $('#divPanty').show('slow');
   	    }
    });
    
      $('#vest').mouseover(function() {
  	      if (selected != "vest")
            {
  	        var src = $(this).attr('src');
   	        $(this).attr('src', src.replace(".gif","_d.gif"));
   	    }
    });
    
    $('#vest').mouseout(function() {
        if (selected != "vest")
        {
            var src = $(this).attr('src');
            $(this).attr('src', src.replace("_d.gif",".gif"));
        }    
    });
    
    $('#vest').click(function() {
        if (selected != "vest")
        {
  	         selected = "vest";
  	         $('#vest').attr('src', 'images/btn_vest_s.gif');
  	         $('#bra').attr('src', 'images/btn_bra.gif');
  	         $('#panty').attr('src', 'images/btn_panty.gif');
  	         $('#divBra').hide();
  	         $('#divPanty').hide();
  	         $('#divVest').show('slow');
   	    }    
    });
     
    $('#prevBra').click(function() {
  	   braPage--;
  	   if (braPage == 1)
  	        $('#divBra .prev').hide();
  	   if (braPage != maxBraPage)
  	        $('#divBra .next').show();
  	   $('#scrollAreaBra').animate({ left: "+=750px" }, 1000);
    });
    
    $('#nextBra').click(function() {  	   
       braPage++;
       $('#divBra .prev').show();
       if (braPage == maxBraPage)
            $('#divBra .next').hide();
       $('#scrollAreaBra').animate({ left: "-=750px" }, 1000);
    });
    
    $('#prevPanty').click(function() {
  	    pantyPage--;
  	    if (pantyPage == 1)
  	        $('#divPanty .prev').hide();
  	      if (pantyPage != maxPantyPage)
  	        $('#divPanty .next').show();    
  	    $('#scrollAreaPanty').animate({ left: "+=750px" }, 1000);    
    });
    
    $('#nextPanty').click(function() {
        pantyPage++;
  	    $('#divPanty .prev').show();
        if (pantyPage == maxPantyPage)
            $('#divPanty .next').hide();
  	    $('#scrollAreaPanty').animate({ left: "-=750px" }, 1000);
    });
    
    $('#prevVest').click(function() {
        vestPage--;
  	    if (vestPage == 1)
  	        $('#divVest .prev').hide();
        if (vestPage != maxVestPage)
  	        $('#divVest .next').show();    
  	    $('#scrollAreaVest').animate({ left: "+=750px" }, 1000);    
    });
    
    $('#nextVest').click(function() {
        vestPage++;
        $('#divVest .prev').show();
        if (vestPage == maxVestPage)
            $('#divVest .next').hide();
        $('#scrollAreaVest').animate({ left: "-=750px" }, 1000);
  	});
    
    $("#scrollAreaBra a").fancybox({
        'transitionIn': 'none',
        'transitionOut': 'none',
        'type': 'ajax',
        'titleShow': false
    });
        
    $("#scrollAreaPanty a").fancybox({
        'transitionIn': 'none',
        'transitionOut': 'none',
        'type': 'ajax',
        'titleShow': false
    });
        
    $("#scrollAreaVest a").fancybox({
        'transitionIn': 'none',
        'transitionOut': 'none',
        'type': 'ajax',
        'titleShow': false
    });
        
    $('.newsGifBtn').click(function() {
        var sel = $(this).attr('id').replace('news','');
        if (sel != selectedNews)
        {
            //$('#news1').attr('src',  'images/news/btn_news1.gif');
            //$('#news2').attr('src',  'images/news/btn_news2.gif');
            // $('#news3').attr('src',  'images/news/btn_news3.gif');
            
            var i = 1;
            while($('#news'+i).attr('src') != null)
            {
                $('#news'+i).attr('src',  'images/news/btn_news'+i+'.gif');      	                
                i++;
            }
            
            selectedNews = sel;
            $('#imgNewsContent').attr('src', 'images/news/news'+sel+'.gif');
            $(this).attr('src', 'images/news/btn_news'+sel+'_d.gif');
         }
    });
    
  	$('.newsGifBtn').mouseover(function() {
        var sel = $(this).attr('id').replace('news','');
        if (sel != selectedNews)
        {
            var src = $(this).attr('src');
            $(this).attr('src', src.replace(".gif","_d.gif"));
        }
    });
        
    $('.newsGifBtn').mouseout(function() {
        var sel = $(this).attr('id').replace('news','');
        if (sel != selectedNews)
        {
            var src = $(this).attr('src');
            $(this).attr('src', src.replace("_d.gif",".gif"));
        }    
    });
        
    $('.mapBtn').click(function() {        
        var sel = $(this).attr('id');
        if (sel != selectedView)
        {
            if (sel == "m")
            {
                $('#m').attr('src', 'images/btn_mapView_s.gif');
                $('#l').attr('src', 'images/btn_listView.gif');
                $('#content-location-list').hide('slow');
                $('#content-location-map').show('slow');
            }
            else
            {
                $('#m').attr('src', 'images/btn_mapView.gif');
                $('#l').attr('src', 'images/btn_listView_s.gif');
                $('#content-location-map').hide('slow');
                $('#content-location-list').show('slow');
            }
            selectedView = sel;
         }
    });
          
  	$('.mapBtn').mouseover(function() {
        var sel = $(this).attr('id');
        if (sel != selectedView)
        {
            var src = $(this).attr('src');
            $(this).attr('src', src.replace(".gif","_d.gif"));
        }
    });
        
    $('.mapBtn').mouseout(function() {
        var sel = $(this).attr('id');
        if (sel != selectedView)
        {
            var src = $(this).attr('src');
            $(this).attr('src', src.replace("_d.gif",".gif"));
        }
    });
    
    customIcon = new GIcon(G_DEFAULT_ICON);
    customIcon.image = "images/marker.png";
    customIcon.shadow = "images/markerShadow.png";
    customIcon.iconSize = new GSize(18, 29);
    customIcon.shadowSize = new GSize(30, 43);
    customIcon.iconAnchor = new GPoint(1, 26);
    customIcon.infoWindowAnchor = new GPoint(9, 2);
    gmapinitialize();
});
