$(function()
	{
	var timer;
	var img = -1;
	//輪播停留時間
	var speed = 6000;
 
	//淡入淡出時間　
	var fOut = 500, fIn = 1000;
	var myImages = $(".list a");	
	$("#TopAD").slideDown();
	
	 $(".link").append("<ul />");
	for(var i=1;i<=myImages.length;i++)
	{
		var addd = $('.list a img').eq(i-1).attr('alt');
		$(".link ul").append("<li>"+i+"</li>"+"&nbsp;&nbsp;"+addd+"&nbsp;&nbsp;");
		
	}
 
	//滑鼠點選頁籤切換
	$(".link li").click(function(){
		var idx = $(this).text() - 1;
		img = idx;
		//抓索引值
		var _link = myImages.eq(idx);
		//取得連結、標題、內文、日期...
		var adlink=_link.attr("href");
		var adtitle=_link.find("img").attr("title");
		var addate=_link.find("img").attr("rel");
		var adbody=_link.find("img").attr("alt");
		var adsrc=_link.find("img").attr("src");
		var adlink=_link.attr("href");
		var adtarget=_link.attr("target");
 
		/*淡入淡出效果*/
		$(".TopAdleft > *:not(.link)").fadeOut(fOut, function(){
			$(".TopAdleft h2").find("a").attr({
				href: adlink,
				target: adtarget
			});
			$(".TopAdleft h2 a").html(adtitle);
			$(".TopAdleft .Adbody a").html(adbody);
			$(".TopAdleft .Adbody").find("a").attr({
				href: adlink,
				target: adtarget
			});
		}).fadeIn(fIn);
		$(".TopAdright").fadeOut(fOut, function(){
			$(".TopAdright").find("a").attr({
				href: adlink,
				target: adtarget
			});
			$(".TopAdright").find("img").attr("src",adsrc);
		}).fadeIn(fIn);	
 
		$(this).removeClass("off").addClass("on")
			.siblings().removeClass("on").addClass("off");		
	});
 
	//當滑鼠滑入區塊停止自動播放
	$("#TopAD").hover(function(){
		clearTimeout(timer);
	}, function(){
		timer = setTimeout(autoShow, speed);
	});
 
	//自動輪播
	function autoShow(){
		img = (img+1<myImages.length) ? img+1 : 0;
		$(".link li").eq(img).click();
		timer = setTimeout(autoShow, speed);
	}
 
	//啟動自動輪播
	autoShow();	
});


/*
function MM_openBrWindow(theURL,winName,features) { 
  window.open(theURL,winName,features);
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}*/




$(function(){
	// 先取得 div#news ul
	// 接著把 ul 中的 li 項目再重覆加入 ul 中(等於有兩組內容)
	// 再來取得 div#news 的高來決定每次跑馬燈移動的距離
	// 設定跑馬燈移動的速度及輪播的速度
	var $marqueeUl = $('div#news ul'),
		$marqueeli = $marqueeUl.append($marqueeUl.html()).children(),
		_height = $('div#news').height() * -1,
		scrollSpeed = 600,
		timer,
		speed = 3000 + scrollSpeed,
		direction = 0,	// 0 表示往上, 1 表示往下
		_lock = false;
 
	// 先把 $marqueeli 移動到第二組
	$marqueeUl.css('top', $marqueeli.length / 2 * _height);
 
	// 幫左邊 $marqueeli 加上 hover 事件
	// 當滑鼠移入時停止計時器；反之則啟動
	$marqueeli.hover(function(){
		clearTimeout(timer);
	}, function(){
		timer = setTimeout(showad, speed);
	});
 
	// 判斷要往上還是往下
	$('div#news .news_btn').click(function(){
		if(_lock) return;
		clearTimeout(timer);
		direction = $(this).attr('id') == 'news_next_btn' ? 0 : 1;
		showad();
	});
 
	// 控制跑馬燈上下移動的處理函式
	function showad(){
		_lock = !_lock;
		var _now = $marqueeUl.position().top / _height;
		_now = (direction ? _now - 1 + $marqueeli.length : _now + 1)  % $marqueeli.length;
 
		// $marqueeUl 移動
		$marqueeUl.animate({
			top: _now * _height
		}, scrollSpeed, function(){
			// 如果已經移動到第二組時...則馬上把 top 設回到第一組的最後一筆
			// 藉此產生不間斷的輪播
			if(_now == $marqueeli.length - 1){
				$marqueeUl.css('top', $marqueeli.length / 2 * _height - _height);
			}else if(_now == 0){
				$marqueeUl.css('top', $marqueeli.length / 2 * _height);
			}
			_lock = !_lock;
		});
 
		// 再啟動計時器
		timer = setTimeout(showad, speed);
	}
 
	// 啟動計時器
	timer = setTimeout(showad, speed);
 
	$('a').focus(function(){
		this.blur();
	});
});




			$(function(){

				
				// Tabs
				$('#tabs').tabs();
	

				//hover states on the static widgets
				$('#dialog_link, ul#icons li').hover(
					function() { $(this).addClass('ui-state-hover'); }, 
					function() { $(this).removeClass('ui-state-hover'); }
				);
				
			});
			
			
			
			
		
		function about_show()
  		{

		var timer;
		timer=setTimeout("$('#about_menu').slideDown(100)",300);
		$('#menu_2').mouseout(function(){clearTimeout(timer);})
		$('#about_menu ul li').eq(5).addClass('selected1');
		
		}		
		function app_show()
  		{
		var timer;
		timer=setTimeout("$('#app_menu').slideDown(100)",300);
		$('#menu_2').mouseout(function(){clearTimeout(timer);})
		$('#app_menu ul li').eq(7).addClass('selected1');
		}
		function support_show()
  		{
		var timer;
		timer=setTimeout("$('#support_menu').slideDown(100)",300);
		$('#menu_2').mouseout(function(){clearTimeout(timer);})
		$('#support_menu ul li').eq(6).addClass('selected1');
		}
		function contact_show()
  		{
		var timer;
		timer=setTimeout("$('#contact_menu').slideDown(100)",300);
		$('#menu_2').mouseout(function(){clearTimeout(timer);})
		$('#contact_menu ul li').eq(8).addClass('selected1');
		}
		function embedded_show()
  		{
		var timer;
		timer=setTimeout("$('#embedded_menu').slideDown(100)",300);
		$('#menu_2').mouseout(function(){clearTimeout(timer);})
		$('#embedded_menu ul li').eq(0).addClass('selected1');
		}
		function boxpc_show()
  		{
		var timer;
		timer=setTimeout("$('#boxpc_menu').slideDown(100)",300);
		$('#menu_2').mouseout(function(){clearTimeout(timer);})
		$('#boxpc_menu ul li').eq(3).addClass('selected1');
		}
		function ehealth_show()
  		{
		var timer;
		timer=setTimeout("$('#ehealth_menu').slideDown(100)",300);
		$('#menu_2').mouseout(function(){clearTimeout(timer);})
		$('#ehealth_menu ul li').eq(2).addClass('selected1');
		}
		function mobile_show()
  		{
		var timer;
		timer=setTimeout("$('#mobile_menu').slideDown(100)",300);
		$('#menu_2').mouseout(function(){clearTimeout(timer);})
		$('#mobile_menu ul li').eq(1).addClass('selected1');
		}
		function panelpc_show()
  		{
		var timer;
		timer=setTimeout("$('#panelpc_menu').slideDown(100)",300);
		$('#menu_2').mouseout(function(){clearTimeout(timer);})
		$('#panelpc_menu ul li').eq(4).addClass('selected1');
		}

		function lan_show()
  		{
	    $('#lan').css("display","")
	    $('#lan').show("slide",{direction:"up"},400);
		}
		
		function inquiry_form()
  		{

								
			i++;
			if(i%2==0)
			{
			$('#inquiry_form').css("z-index","8")
		    $('#inquiry_form').css("display","")
	 	    $('#inquiry_form').show("slide",{direction:"right"},500);
			
		 	}
			else
			{
		    $('#inquiry_form').hide("slide",{direction:"right"},500);
			setTimeout("$('#inquiry_form').css('display','none')",501);
			$('#inquiry_form').css("z-index","0")
			
			}
			
			
			
			}
		
		function hideall()
		{
		var timer;
		timer=setTimeout("hidealll()",200);
		$('.menu_content').mouseover(function(){clearTimeout(timer);})
		}
		
		
		
		function hidealll()
		{

		
		$('#app_menu').fadeOut(1);
 		 $('#contact_menu').fadeOut(1);
		 $('#support_menu').fadeOut(1);
		$('#about_menu').fadeOut(1);
		$('#embedded_menu').fadeOut(1);
		$('#boxpc_menu').fadeOut(1);
		$('#ehealth_menu').fadeOut(1);
		$('#mobile_menu').fadeOut(1);
		$('#panelpc_menu').fadeOut(1);
		$('#lan').fadeOut(50);
		$('#menu_1').css("z-index","1");
		$('#menu_2').css("z-index","1")
		
		}
		
			function startt()
			{
/*			  	  
 $('#product_menu').mouseleave(function() {$('#product_menu').slideUp(200);setTimeout("$('#menu_area').css('z-index','0')",201);});
  $('#support_menu').mouseleave(function() {$('#support_menu').slideUp(200);setTimeout("$('#menu_area').css('z-index','0')",201);});
   $('#app_menu').mouseleave(function() {$('#app_menu').slideUp(200);setTimeout("$('#menu_area').css('z-index','0')",201);});
    $('#contact_menu').mouseleave(function() {$('#contact_menu').slideUp(200);setTimeout("$('#menu_area').css('z-index','0')",201);});
	 $('#about_menu').mouseleave(function() {$('#about_menu').slideUp(200);setTimeout("$('#menu_1').css('z-index','0')",201);});*/
	/*  $('#lan').mouseleave(function() {$('#lan').hide("slide",{direction:"up"},400);});*/
	$('#lan').mouseleave(function() {$('#lan').hide("slide",{direction:"up"},400);});
	 $('#menu_2').mouseleave(function() {hideall();});

		 $('ul').filter('[class*=menu_2_btn]').children('li:lt(5)').addClass('selected2');
		$('#embedded_menu ul').children('li:lt(5)').addClass('selected2');
	 	$('#boxpc_menu ul').children('li:lt(5)').addClass('selected2');
		$('#ehealth_menu ul').children('li:lt(5)').addClass('selected2');
		$('#mobile_menu ul').children('li:lt(5)').addClass('selected2');
		$('#panelpc_menu ul').children('li:lt(5)').addClass('selected2');
		$('#about_menu ul').children('li:lt(5)').addClass('selected2');
		$('#support_menu ul').children('li:lt(5)').addClass('selected2');
		$('#app_menu ul').children('li:lt(5)').addClass('selected2');
		$('#contact_menu ul').children('li:lt(5)').addClass('selected2');
        
		$('.frameani').each(function()
		{
			if(this.className.indexOf('current_page') ==-1)
			{
				$('.frameani').css("top",'108px');
			}
		});
		
		$('.frameani').hover(function()
		{
			$('.frameani').animate({top:"30px"},'fast');
		},function()
		{
			$('.frameani').animate({top:"108px"},'fast');
		}
		);
		
		$('.frameani1').each(function()
		{
			if(this.className.indexOf('current_page') ==-1)
			{
				$('.frameani1').css("top",'108px');
			}
		});
		
		$('.frameani1').hover(function()
		{
			$('.frameani1').animate({top:"30px"},'fast');
		},function()
		{
			$('.frameani1').animate({top:"108px"},'fast');
		}
		);
			
		$('.frameani2').each(function()
		{
			if(this.className.indexOf('current_page') ==-1)
			{
				$('.frameani2').css("top",'108px');
			}
		});
		
		$('.frameani2').hover(function()
		{
			$('.frameani2').animate({top:"30px"},'fast');
		},function()
		{
			$('.frameani2').animate({top:"108px"},'fast');
		}
		);
			
			$('.tabsselected').click(function() { $( ".selector" ).tabs({ selected: 11 });});

    $("#tabs").tabs({
        select:function(event, ui) {
            window.location.hash = ui.tab.hash ;
        }
    });
			
	  	 	 }
			 
function mailpage()
{
mail_str = "mailto:?subject= " + document.title;
mail_str += "&body= You can find ARBOR Here:" + location.href;
location.href = mail_str;
}
			 
			 


var fmxSpeed_1 = 15;
var fmxSpace_1 = 8; 
var fmxPageWidth_1 = 209; 
var fmxfill_1 = 0; 
var fmxMoveLock_1 = false;
var fmxMoveTimeObj_1;
var fmxComp_1 = 0;
var fmxAutoPlayObj_1=null;
/*NTES("#List2_1").innerHTML=NTES("#List1_1").innerHTML;
NTES("#ISL_Cont_1").scrollLeft=fmxfill_1>=0?fmxfill_1:NTES("#List1_1").scrollWidth-Math.abs(fmxfill_1);
NTES("#ISL_Cont_1").onmouseover=function(){clearInterval(fmxAutoPlayObj_1)}
NTES("#ISL_Cont_1").onmouseout=function(){FmxAutoPlay_1()}*/
FmxAutoPlay_1();
function FmxAutoPlay_1(){
	clearInterval(fmxAutoPlayObj_1);
	//fmxAutoPlayObj_1=setInterval('FmxISL_GoDown_1();FmxISL_StopDown_1();',5000);
}
function FmxISL_GoUp_1(){
	if(fmxMoveLock_1)return;
	clearInterval(fmxAutoPlayObj_1);
	fmxMoveLock_1=true;
	fmxMoveTimeObj_1=setInterval('FmxISL_ScrUp_1();',fmxSpeed_1)
}
function FmxISL_StopUp_1(){
	clearInterval(fmxMoveTimeObj_1);
	if((NTES("#ISL_Cont_1").scrollLeft-fmxfill_1)%fmxPageWidth_1!=0){
		fmxComp_1=fmxfill_1-(NTES("#ISL_Cont_1").scrollLeft%fmxPageWidth_1);
		FmxCompScr_1();
	}else{
		fmxMoveLock_1=false;
	}
	FmxAutoPlay_1()
}
function FmxISL_ScrUp_1(){
	if(NTES("#ISL_Cont_1").scrollLeft<=0){
		NTES("#ISL_Cont_1").scrollLeft=NTES("#ISL_Cont_1").scrollLeft+NTES("#List1_1").offsetWidth;
	}
	NTES("#ISL_Cont_1").scrollLeft-=fmxSpace_1;
}
function FmxISL_GoDown_1(){
	clearInterval(fmxMoveTimeObj_1);
	if(fmxMoveLock_1)return;
	clearInterval(fmxAutoPlayObj_1);
	fmxMoveLock_1=true;FmxISL_ScrDown_1();
	fmxMoveTimeObj_1=setInterval('FmxISL_ScrDown_1()',fmxSpeed_1);
}
function FmxISL_StopDown_1(){
	clearInterval(fmxMoveTimeObj_1);
	if(NTES("#ISL_Cont_1").scrollLeft%fmxPageWidth_1-(fmxfill_1>=0?fmxfill_1:fmxfill_1+1)!=0){
		fmxComp_1=fmxPageWidth_1-NTES("#ISL_Cont_1").scrollLeft%fmxPageWidth_1+fmxfill_1;
		FmxCompScr_1();
	}else{
		fmxMoveLock_1=false;
	}
	FmxAutoPlay_1();
}
function FmxISL_ScrDown_1(){
	if(NTES("#ISL_Cont_1").scrollLeft>=NTES("#List1_1").scrollWidth){
		NTES("#ISL_Cont_1").scrollLeft=NTES("#ISL_Cont_1").scrollLeft-NTES("#List1_1").scrollWidth;
	}
	NTES("#ISL_Cont_1").scrollLeft+=fmxSpace_1;
}
function FmxCompScr_1(){
	if(fmxComp_1==0){
		fmxMoveLock_1=false;
		return;
	}
	var num,TempSpeed=fmxSpeed_1,TempSpace=fmxSpace_1;
	if(Math.abs(fmxComp_1)<fmxPageWidth_1/2){
		TempSpace=Math.round(Math.abs(fmxComp_1/fmxSpace_1));
		if(TempSpace<1){
		TempSpace=1;
		}
	}
	if(fmxComp_1<0){
		if(fmxComp_1<-TempSpace){
			fmxComp_1+=TempSpace;
			num=TempSpace;
		}else{
			num=-fmxComp_1;
			fmxComp_1=0;
		}
		NTES("#ISL_Cont_1").scrollLeft-=num;
		setTimeout('FmxCompScr_1()',TempSpeed);
	}else{
		if(fmxComp_1>TempSpace){
			fmxComp_1-=TempSpace;num=TempSpace;
		}else{
			num=fmxComp_1;
			fmxComp_1=0;
		}
		NTES("#ISL_Cont_1").scrollLeft+=num;setTimeout('FmxCompScr_1()',TempSpeed);
	}
}


//product_pic swap
function MM_openBrWindow(theURL,winName,features) { 
  window.open(theURL,winName,features);
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//product_pic swap
function sendit(){if(confirm("Thank you for your inquiry, we will contact you soon..."))return true;else return false;}

function rad(){
var maxNum = 9999;  
var minNum = 0;  
var nn = Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum;
document.getElementById('vano').value=nn;

}

function formenter(){    
	if (event.keyCode == 13) 
	{        
		event.cancelBubble = true;
		event.returnValue = false;
         }
    }  
function formbutton(){
	$('#sendbutton').attr('disabled',false);
	}
function formbuttondisable(){
	$('#sendbutton').attr('disabled',true);
	}
