﻿// -----------------------------------------------------------------------------
// Globals
// Major version of Flash required
var requiredMajorVersion = 8;
// Minor version of Flash required
var requiredMinorVersion = 0;
// Minor version of Flash required
var requiredRevision = 0;
// -----------------------------------------------------------------------------

$(document).ready(function() {
    //先將我要推薦隱藏(用於javascript關掉時)
    $("#pRecommend").css("display", "none");

    // Version check for the Flash Player that has the ability to start Player Product Install (6.0r65)
    var hasProductInstall = DetectFlashVer(6, 0, 65);

    // Version check based upon the values defined in globals
    var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);

    if (hasProductInstall && !hasReqestedVersion) {
        $(".flashAlt").css("display", "none");
    } else if (hasReqestedVersion) {
        $(".flashAlt").css("display", "none");
    } else {

    }

    

});

if (typeof(km_scripts) == 'undefined') var km_scripts = new Object();
km_myclass_import('../Common/js/flashobject.js');
km_myclass_import('../Common/ui/jqGalView.js');


function km_myclass_import(jsFile) {
  if (km_scripts[jsFile] != null) return;
  var scriptElt = document.createElement('script');
  scriptElt.type = 'text/javascript';
  scriptElt.src = jsFile;
  document.getElementsByTagName('head')[0].appendChild(scriptElt);
  km_scripts[jsFile] = jsFile; // or whatever value your prefer
}


function createCookie(name,value,days){
	if (days){
		var date = new Date();
		date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
		var expires = "; expires=" + date.toGMTString();
	} else {
			var expires = "";
	}
	document.cookie = name + "=" + value + expires + "; path=/";
}

function get_text_cookie ( cookie_name ){
	  var results = document.cookie.match ( cookie_name + '=(.*?)(;|$)' );

	  if ( results ) {
		return (unescape ( results[1]));
	  }
	  else { return null; }
}

//設定字級
function ResetFontSize(size){
    
    //將字級說明隱藏(用於javascript關掉時)
    $("#FontZoomBlock").css("display","none");
     
	var docs = document.getElementById('fixPagination');	
	if(docs){
		var imgArr = ["100","120", "130"];
		var currentTextSize = 100;
		var currentLineHeight = null;
		if(size==""){	//預設載入時判斷
			if(get_text_cookie("RangeSize")) {
					size = get_text_cookie("RangeSize");
			}else{
				size = "100";
				createCookie("RangeSize","100", 1000);
			}
		}else{
			createCookie("RangeSize",size, 1000);
		}
		
		currentTextSize = parseInt(size);
		currentLineHeight = parseInt((currentTextSize/10) * 2.4);
		
		docs.style.fontSize = currentTextSize + '%';
		//docs.style.lineHeight = currentLineHeight +'px';

		if(document.getElementById("imgpt0")){
			for( var ix=0; ix<imgArr.length; ix++){
				if(imgArr[ix]==size){				
					document.getElementById("imgpt" + ix).src="../images/ico_pt"+ ix +"_2.gif";
				}else{
					document.getElementById("imgpt" + ix).src="../images/ico_pt"+ ix +".gif";	
				}
			}
		}
	}	
}

//頁籤
function initTagElement(iPos, iLang, iName, iPath){
    if(iPath.indexOf("style")>0){
        iPath = iPath + iPos +"_"+ iLang;
    }else{
        iPath = iPath + iPos;
    };
    $("#pan"+ iName +"1").css("background-image","url(" + iPath +".gif)");
    $("#pan"+ iName +"1 > .sence0").css("display","none");
    $("#pan"+ iName +"1 > .sence1").css("display","none");
    $("#ifax"+ iName + iPos).fadeIn("slow");
}

//首頁推薦景點換圖
function initSceneImg(iPath, iHead, iImg){
    $("#" + iImg).attr("src", iPath);
    $("#" + iImg).attr("alt", iHead);
    
}

function initRecommend(iSNo, iLang){   //景點推廌
    
    $("#ifaxRecommend").load("../user/ajaxExec.aspx", { jDo:"P", jSNo:iSNo, jLang:iLang });
    $("#ifaxTop").load("../user/ajaxExec.aspx", { jDo:"T", jSNo:iSNo, jLang:iLang });    
    $("#btnRecommend").fadeOut("slow"); 
}


function init_flash(w){	
	var fw = 0;
	var pos = "M";
	var docs = document.getElementById('dFlayer');	
	if(docs){	
		if(pos=="M"){	//置中
			fw = (screen.width-w)/2;
		}else{
			fw = 0;
		}
		docs.style.position = "absolute";
		docs.style.left = fw + "px";
		docs.style.top = "0px";
	}
}

function changeTour(obj1, obj2){
    //$('#'+obj1).children(.toggleClass("diy_ioc_0"))
    $("#days1"+ obj1+ " span").removeClass("diy_ico_1").addClass("diy_ico_0");
    $("#link"+ obj2).addClass("diy_ico_1");
    $("#days2"+ obj1+ " > div").hide();
    $("#item"+ obj2).fadeIn("slow");   
}

function changeMap(objs){
    $('#map' + objs).toggleClass("diy_map1","diy_map0");    
	$('#map' + objs).next('div').slideToggle('slow');//.siblings('div:visible').slideUp('fast');
  
}


function InitYouTube(url, iid){
	var str1 = "";
	str1 = "<object height=\"122\" width=\"151\">"
	str1 += "<param name=\"movie\" value=\""+ url +"\">"
    str1 += "<param name=\"allowFullScreen\" value=\"true\">"
    str1 += "<embed height=\"122\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" allowFullScreen=\"true\" "
	str1 += "src=\""+ url +"\" type=\"application/x-shockwave-flash\" width=\"151\"></embed></object>"
	$(".r_funtion_video1").html(str1);
	$(".in").removeClass("in").addClass("out");
	$("#" + iid).toggleClass("in");
}



//以下是上方選單捲動
function lib_bwcheck(){ //Browsercheck (needed)
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent
	this.dom=document.getElementById?1:0
	this.opera5=this.agent.indexOf("Opera 5")>-1
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0; 
	this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
	this.ie7=(this.ver.indexOf("MSIE 7")>-1 && this.dom && !this.opera5)?1:0;
	this.ie8=(this.ver.indexOf("MSIE 8")>-1 && this.dom && !this.opera5)?1:0;
	this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
	this.ie=this.ie4||this.ie5||this.ie6||this.ie7||this.ie8
	this.mac=this.agent.indexOf("Mac")>-1
	this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie8 || this.ie7 || this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5)
	return this
}
var bw=new lib_bwcheck()

// A unit of measure that will be added when setting the position of a layer.
var px = bw.ns4||window.opera?"":"px";

if(document.layers){ //NS4 resize fix...
	scrX= innerWidth; scrY= innerHeight;
	onresize= function(){if(scrX!= innerWidth || scrY!= innerHeight){history.go(0)} }
}

//object constructor...
function scrollerobj(obj,nest){
	nest = (!nest)?"":'document.'+nest+'.'
	this.elm = bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):document.getElementById(obj)
	this.css = bw.ns4?this.elm:this.elm.style
	this.doc = bw.ns4?this.elm.document:document
	this.obj = obj+'scrollerobj'; eval(this.obj+'=this')
	this.x = (bw.ns4||bw.opera5)?this.css.left:this.elm.offsetLeft
	this.y = (bw.ns4||bw.opera5)?this.css.top:this.elm.offsetTop
	this.w = (bw.ie4||bw.ie5||bw.ie6||bw.ie7||bw.ie8||bw.ns6)?this.elm.offsetWidth:bw.ns4?this.elm.clip.width:bw.opera5?this.css.pixelWidth:0
	this.h = (bw.ie4||bw.ie5||bw.ie6||bw.ie7||bw.ie8||bw.ns6)?this.elm.offsetHeight:bw.ns4?this.elm.clip.height:bw.opera5?this.css.pixelHeight:0
}

//object methods...
scrollerobj.prototype.moveTo = function(x,y){
	if(x!=null){this.x=x; this.css.left=x+px}
	if(y!=null){this.y=y; this.css.top=y+px}
}
scrollerobj.prototype.moveBy = function(x,y){this.moveTo(this.x+x,this.y+y)}

var scrollTimer = null;
var busy = 0;
var scroller1 = null;
var activePage = null;
function scroll(step){
	clearTimeout(scrollTimer);	
		
	if ( !busy && (step<0&&activePage.x+activePage.w>scroller1.w || step>0&&activePage.x<0) ){
		activePage.moveBy(step,0);
		scrollTimer = setTimeout('scroll('+step+')',40);
	}
}
function stopScroll(){
	clearTimeout(scrollTimer);
}

function initPageSlide() {
   
    $(".minor_box").css({ margin: "5px 2px 0px 2px", height: "20px" });
    $("#minor_item").css({ position: "absolute", whiteSpace: "nowrap" });
    scroller1 = new scrollerobj('minor_box');
    activePage = new scrollerobj('minor_item', 'minor_box');
    activePage.moveTo(0,0);
}






