﻿
function Browser_Check_CheckPage()
{
	var result = true;
	try{
		//if(result){if(!Popup_Check()){result=false;}}
		//if(result){if(!OS_Check()){alert("Vista用戶請以管理員權限登入");}}
		if(result){if(!IE_Check()){result=false;}}
		//if(result){if(!IE_version()){result=false;}}
		if(result){if(!Viewer_Check()){result=false;}}
		if(result){if(!CreateTEObjFunctionBrowser_Indexhtm()){result=false;}}
	}catch(e)
	{
		return false;
	}
	return result;
}
//
//Create TE OBJ
function CreateTEObjFunctionBrowser_Indexhtm()
{
	var result;
		try{			
			var TE3DWindowNode=createTEObj("TE3DWindow","100%","100%");
			var TENode=createTEObj("TE");		

			var containerNode=document.getElementById("TEContainer");				
			containerNode.appendChild(TE3DWindowNode);
			containerNode.appendChild(TENode);
			result=true;			
		}catch(e){
			//$("TEContainer").innerHTML="<a href='http://www.skylineglobe.com/SkylineGlobe/TerraExplorer/install/SkylineGlobeSetup.exe'>下載TE 3D Plugin</a>"
			result=false;
			return result;			
		}
		return result;
}
// Popup window
function Popup_Check(){
	newwindow =window.open('checkPoput.htm','checkPoput','top=9999,left=9999,height=0,width=0,status=yes,toolbar=no,menubar=no,location=no,scrollbars=no');
	if(newwindow  != null) {
		newwindow.close();
		return true;
	}else{
		return false;
	}
}

// Os Check
	function OS_Check(){
		var result;
		version = navigator.userAgent.substring(navigator.userAgent.indexOf("Windows NT") + 11, navigator.userAgent.indexOf("Windows NT") + 14);
		//if (version=="5.0" ) {alert("Windows-2000");}//2000
		//if (version=="5.1" ) {alert("Windows-XP");}	//xp
		//if (version=="5.2" ) {alert("Windows-2003");}//2003
		//if (version=="6.0" ) {alert("Vista");}		//Vista
		//if (version=="6.1" ) {alert("Windows-7");}	//win 7
		if (version=="6.0" ) {//vista
			result = false;
		}else{
			result =true;
		}	
		return result;
	}
	
	// IE Check
    function IE_Check() {//是不是IE
        var result;
        if (navigator.appName.indexOf('Microsoft') == -1) {
            result = false;
        } else {
            result = true;
        }
        return result;

    }
    
    // IE ver Check
	function IE_version() {//ie 版本確認
        var result;
        version = navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE") + 5, navigator.userAgent.indexOf("MSIE") + 8);
        if (version > 6) {
            result = true; //IE & 7 OK
        } else {
            result = false; //請升級成IE7，才會得到更好的支援。
        }
        return result;
    }
    //IE下有沒有裝Viewer
    function Viewer_Check() {//IE下有沒有裝Viewer
        var result;
        try {
            new ActiveXObject("TerraExplorer2.TEInformationWindow");
            result = true;
        } catch (e) {
            result = false;
			return result;
        }
        return result;
    }
    //
	//Viewer 版本
    function Viewer_Ver_number(){
        var result;
		var _tmpID=setInterval(function(){		
		try{
			if(globe == null){
				globe = new SGWorld();
			}
			if (globe.version < "5.1.2"){
				result = false;
			}else{
				result = true;
			}
			clearInterval(_tmpID);
		        return result;
        } catch (e) {
            return false;
        	}
		},100)
    }
