<!-- 

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-1821463-5']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

function fullScreen() {
var offset = 4; //needs to change accordingly with browsers
    window.moveTo(-offset, -offset);
    window.resizeTo(screen.availWidth + (2 * offset), 
    screen.availHeight + (2 * offset));
}

    $(function(){ 
        $("#sidemenu li a").mouseenter(function(){
            var _this = $(this), 
                _width = _this.width() * -1; 
           		_this.stop().animate({ 
                backgroundPosition: "(0 0)"}, 250); 
        		return false;
		 })
		.mouseleave(function(){
            $(this).stop().animate({
                backgroundPosition: "(-192px 0)"}, 250); 
        		return false;
		 }) 
    }); 
	$(function(){ 
        $("#brand-btn").mouseenter(function(){
				$("#brand-overlay").css('display', 'block');
           		$("#brand-overlay").stop().animate({ 
                bottom: 25}, 500); 
        		return false;
		 })
		 $("#brand-overlay").mouseleave(function(){
           		$(this).stop().animate({ 
                bottom: -109}, 500);
        		return false;
		 })
		 $("#brand-close").click(function(){
           		$("#brand-overlay").stop().animate({ 
                bottom: -109}, 500); 
        		return false;
		 })
    }); 
//--> 

$(document).ready(function() {   
	// Add the class 'button' just like in CSS with a dot in front of it   
       $('#sidemenu li.sub').append('<span class="hover"></span>').each(function () {   
            var $span = $('> span.hover', this).css('opacity', 0);   
            $(this).hover(function () {   
                $span.stop().fadeTo(500, 1); //Change the number 500 to change the speed of the Fade In   
            }, function () {   
        $span.stop().fadeTo(500, 0); //Change the number 500 to change the speed of the Fade Out   
            });   
        });   
    });  /**/

$(document).ready(function() {   
	// Add the class 'button' just like in CSS with a dot in front of it   
       $('#control li#ulferts, #control li#ulfenbo, #control li#home, #control li#special, #control li#udesign, #control li#elegance').append('<span class="hover"></span>').each(function () {   
            var $span = $('> span.hover', this).css('opacity', 0);   
            $(this).hover(function () {   
                $span.stop().fadeTo(500, 1); //Change the number 500 to change the speed of the Fade In   
            }, function () {   
       		 $span.stop().fadeTo(500, 0); //Change the number 500 to change the speed of the Fade Out   
            });   
        });   
});

function addtoCard(pid)
{
	$.get("/Connections/ecart.php?action=add&pid=" + pid, function(data){

   		if (data == 1)
		{
			$('#add_msg').slideDown();	
		}
 });
}

function deltoCard(pid)
{
	$.get("/Connections/ecart.php?action=delete&pid=" + pid, function(data){

   		if (data == 1)
		{
			window.location.reload( false );
		}
 });
}

function changetoCard()
{
	$.post("/Connections/ecart.php?action=update", $("#cartForm").serialize(), function(data)
	{
		window.location.reload( false );
	});
}

function changePhoto(img)
{
	$('#detail_large_pic').fadeOut('fast', function () {
		$('#detail_large_pic').html('<img src="/images/cms/' + img +'" height="300" />');
	});
	
	$('#detail_large_pic').fadeIn();
}
	 
function submitSeach()
{
	var field = document.getElementsByTagName("input");
	
	var strings = "";
	var strings2 = "";
	for (i = 0; i < field.length; i++)
	{
		if (field[i].checked == true && field[i].name.indexOf('search_key_') != -1)
		{
			if (strings == "")
				strings =	field[i].value;
			else
				strings +=	"," + field[i].value ;
		}
		
		if (field[i].checked == true && field[i].name.indexOf('search_group_') != -1)
		{
			if (strings2 == "")
				strings2 =	field[i].value;
			else
				strings2 +=	"," + field[i].value ;
		}
		
		
	}
	document.searchForm.searchGroup.value = strings2;
	document.searchForm.searchString.value = strings;
	document.searchForm.submit();
}

function selectGroup(obj, subID)
{
	var field = document.getElementsByName("search_key_" + subID) ;
	
	for (i = 0; i < field.length; i++)
	{
		if (obj.checked == true)
			field[i].checked = true ;
		else
			field[i].checked = false ;
	}
}

function checkGroup(obj, subID)
{
	if (obj.checked == false)
	{
		document.getElementById("search_group_" + subID).checked = false;
	}
}
	
$(document).ready(function() {

	//When page loads...
	$(".tab-content").hide(); //Hide all content
	$("#panel-tab li:first a").addClass("active").show(); //Activate first tab
	$(".tab-content:first").show(); //Show first tab content

	//On Click Event
	$("#panel-tab li a").click(function() {
		$("#panel-tab li a").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab-content").hide(); //Hide all tab content

		var activeTab = $(this).attr("href"); //Find the href attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active ID content
		return false;
	});/**/
	
	$("#full-sized-area").width($(window).width()-244);
	$("#price-list-area").height($(window).height()-90);
	$("#full-sized-area").height($(window).height()-150);
	$(".v-scroll-pane").height($(document).height()-250);
	$("#news-thumbnail-wrapper").width($(document).width()-400);
	$("#press-scroll-pane").width($(document).width()-450);
	
	function ColumnResize() {
 		$("#bottom-col").css('width',($(window).width()-460));
		$(".press-scroll-pane").css('width',($(window).width()-460));
 	}

	ColumnResize();//Triggers when document first loads&nbsp;&nbsp; &nbsp;

	$(window).bind("resize", function(){//Adjusts image when browser resized
 		ColumnResize();
	});
	//alert($(window).height());
});

$(function()
{
	$('#full-sized-area').jScrollPane();
	$('#price-list-area').jScrollPane();
	$('.v-scroll-pane').jScrollPane();
	$('.press-scroll-pane').jScrollPane();
	$('.cart-scroll-pane').jScrollPane();
	
});

$(function()
{
	var $detailsThumbnail = $('#details-thumbnail-wrapper');    
	var detailsThumbnailWidth = 120;
	var slides = $('#details-thumbnail-wrapper .product-details-thumbnail');
	var numberOfSlides = slides.length;
	$detailsThumbnail.css('width', detailsThumbnailWidth * numberOfSlides);
	$('.h-scroll-pane').jScrollPane();
});

$(function()
{
	var $relatedThumbnail = $('#related-thumbnail-wrapper');    
	var relatedThumbnailWidth = 120;
	var slides = $('#related-thumbnail-wrapper .product-details-thumbnail');
	var numberOfSlides = slides.length;
	$relatedThumbnail.css('width', relatedThumbnailWidth * numberOfSlides);
	$('.h2-scroll-pane').jScrollPane();
});

$(function()
{
	var $newsThumbnail = $('#news-thumbnail-wrapper');    
	var newsThumbnailWidth = 120;
	var slides = $('#news-thumbnail-wrapper .news-thumbnail');
	var numberOfSlides = slides.length;
	$newsThumbnail.css('width', newsThumbnailWidth * numberOfSlides);
	$('.news-scroll-pane').jScrollPane();
});

//on page load 
$(document).ready(function() { 


                //insert scrollbars 
                var $scroller = $('.scroll-pane'); 
                $scroller.jScrollPane({showArrows:false,scrollbarWidth:12,arrowSize: 13,animateTo:true}); 
                $('a.scrollto').click(function() { 
                        var targetElementSelectorString = $(this).attr('rel'); 
                        $scroller[0].scrollTo(targetElementSelectorString); 
                        return false; 
                }); 


        }); 
/*$(function()
{
	$('.scroll-pane').jScrollPane();
});*/


$(document).ready(function() {
	//Code goes here
//Set default open/close settings
$('.acc_container').hide(); //Hide/close all containers
$('.acc_trigger:first').addClass('active').next().show(); //Add "active" class to first trigger, then show/open the immediate next container

//On Click
$('.acc_trigger').click(function(){
	if( $(this).next().is(':hidden') ) { //If immediate next container is closed...
		$('.acc_trigger').removeClass('active').next().slideUp(); //Remove all "active" state and slide up the immediate next container
		$(this).toggleClass('active').next().slideDown(); //Add "active" state to clicked trigger and slide down the immediate next container
	}
	return false; //Prevent the browser jump to the link anchor
});

});/**/
/*
$(function() {    
var $fullArea = $('#full-sized-area');    
var $fullContent = $('#full-sized-content', $fullArea);    
var slideWidth = $(document).width()-244;
var slides = $('.product-lot');
var numberOfSlides = slides.length;

$fullContent.css('width', slideWidth * numberOfSlides);

// find what portion of the content is displayed    
var contentRatio = $fullArea.width() / $fullContent.width();    
// scale the controls box    
var $controlsArea = $('#drag-controls-area');   
var $controls = $('#drag-controls', $controlsArea);    
$controls.css('width', $controlsArea.width() * contentRatio);    
// determine the scale difference between the controls and content    
var scaleRatio = $controlsArea.width() / $fullContent.width();    
$fullBackground = $('#full-sized-background');    
// attach the draggable behavior    
$controls.draggable({        
axis : 'x', // confine dragging to the x-axis        
containment : 'parent',       
drag : function(ev, ui) {            
// move the full sized content            
var newContentPosition = -1 * ui.position.left / scaleRatio;            
$fullContent.css('left', newContentPosition);            
// move the background            
$fullBackground.css('left', newContentPosition * .4);        
}    
});
});
*/
$(document).ready(function() {
			$(".iframe").fancybox({
				'width'				: 980,
				'height'			: 600,
				'autoScale'			: false,
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'type'				: 'iframe',
				'padding'			: 0,
				'margin'			: 0
			});

	$("a[rel=promotion]").fancybox({
				'padding'			: 0,
				'margin'			: 0,
				'overlayOpacity'	: 0.8,
				'transitionIn'		: 'none',
				'autoScale'			: true,
				'autoDimensions'	: true,
				'transitionOut'		: 'none',
				'titlePosition' 	: 'outside',
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
					return '<span class="fancybox-title-outside">' + (title.length ? ' &nbsp; ' + title : '') + '</span>';
				}
			});
			$(".video_link").fancybox({
				'padding'			: 0,
				'margin'			: 0,
				'width'				: 480,
				'height'			: 400,
				'autoDimensions'	: false,
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'type'				: 'iframe'
			});
			$(".popup").fancybox({
				'padding'			: 0,
				'margin'			: 0
			});
			$("#ie6").fancybox({
				'modal' : true,
				'titlePosition'		: 'inside',
				'transitionIn'		: 'none',
				'transitionOut'		: 'none'
			});
		});
		
function changeLanguage(language)
{
	var currentLanguage = getLanguage();
	var canChange = true;
	var linkd = location.href;

	var last_char = linkd.substr(linkd.length-1, 1);
	var goLink = "";
	
	if (last_char == "#")
		goLink = linkd.substr(0, linkd.length-1);
	else
		goLink = linkd;
		
	if (canChange == true)
	{
		if (currentLanguage == 1)
		{
			if (language == "en")
			{
				location.href= goLink.replace('/eng/','/eng/');
			}
			else if (language == "tc")
			{
				location.href= goLink.replace('/eng/','/tch/');
			}
			else if (language == "sc")
			{
				location.href= goLink.replace('/eng/','/sch/');
			}
		}
		else if (currentLanguage == 2)
		{
			if (language == "en")
			{
				location.href= goLink.replace('/tch/','/eng/');
			}
			else if (language == "tc")
			{
				location.href= goLink.replace('/tch/','/tch/');
			}
			else if (language == "sc")
			{
				location.href= goLink.replace('/tch/','/sch/');
			}
		}
		else if (currentLanguage == 3)
		{
			if (language == "en")
			{
				location.href= goLink.replace('/sch/','/eng/');
			}
			else if (language == "tc")
			{
				location.href= goLink.replace('/sch/','/tch/');
			}
			else if (language == "sc")
			{
				location.href= goLink.replace('/sch/','/sch/');
			}
		}
	}

}

function getLanguage()
{
	var linkd = location.href;
		
	if (linkd.search("/eng/") != -1)
	{
		return 1;
	}
	else if (linkd.search("/tch/") != -1)
	{
		return 2;
	}
	else if (linkd.search("/sch/") != -1)
	{
		return 3;
	}
}		

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

		function submitForm()
		{
			var lang = getLanguage();
			var error = false;
			var msg = "";
			
			if (document.cartForm.NAME.value == "")
			{
				error = true;
				
				if (lang == 1)
				{
					msg += "Name\n";	
				}
				else if (lang == 2)
				{
					msg += "姓名\n";	
				}
			}
			
			if (document.cartForm.PHONE.value == "")
			{
				error = true;
				if (lang == 1)
				{
					msg += "Contact number\n";	
				}
				else if (lang == 2)
				{
					msg += "聯絡電話\n";	
				}	
			}
			
			if (document.cartForm.EMAIL.value == "")
			{
				error = true;
				if (lang == 1)
				{
					msg += "Email Address\n";	
				}
				else if (lang == 2)
				{
					msg += "電郵地址\n";	
				}
			}
			
			if (error == false)
			{
				//document.cartForm.action = "/Connections/submit.php";
				//document.cartForm.submit();
				
				$.post("/Connections/submit.php", $("#cartForm").serialize(), function(data)
				{
					location.href = "shopping-cart.php?oid=" + data;
				});
				
			}
			else
			{
				if (lang == 1)
				{
					alert("Please fill in following fields:\t\t\n\n" + msg);	
				}
				else if (lang == 2)
				{
					alert("請輸入以下資料:\t\t\n\n" + msg);	
				}
			}
		}
		
		function resetForm()
		{
			document.cartForm.reset();
		}

		
		function Maximize() 
		{
			window.innerWidth = screen.width;
			window.innerHeight = screen.height;
			window.screenX = 0;
			window.screenY = 0;
			alwaysLowered = false;
		}
		
		if (window.screenX != 0 || window.screenY != 0 || window.innerWidth != screen.width || window.innerHeight != screen.height)
		{
			Maximize();
		}
